blob: 1434156ec66c563237ae9b1d4c28fd92fa774e7c [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é-Gonnard179c2272020-02-03 15:37:47 +010040G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12u.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
Manuel Pégourié-Gonnard45575512020-01-02 11:58:00 +0100750requires_config_enabled MBEDTLS_ZLIB_SUPPORT
751run_test "Default (compression enabled)" \
752 "$P_SRV debug_level=3" \
753 "$P_CLI debug_level=3" \
754 0 \
755 -s "Allocating compression buffer" \
756 -c "Allocating compression buffer" \
757 -s "Record expansion is unknown (compression)" \
758 -c "Record expansion is unknown (compression)" \
759 -S "error" \
760 -C "error"
761
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100762# Test current time in ServerHello
763requires_config_enabled MBEDTLS_HAVE_TIME
764run_test "Default, ServerHello contains gmt_unix_time" \
765 "$P_SRV debug_level=3" \
766 "$P_CLI debug_level=3" \
767 0 \
768 -s "Protocol is TLSv1.2" \
769 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
770 -s "client hello v3, signature_algorithm ext: 6" \
771 -s "ECDHE curve: secp521r1" \
772 -S "error" \
773 -C "error" \
774 -f "check_server_hello_time" \
775 -F "check_server_hello_time"
776
Simon Butcher8e004102016-10-14 00:48:33 +0100777# Test for uniqueness of IVs in AEAD ciphersuites
778run_test "Unique IV in GCM" \
779 "$P_SRV exchanges=20 debug_level=4" \
780 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
781 0 \
782 -u "IV used" \
783 -U "IV used"
784
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100785# Tests for rc4 option
786
Simon Butchera410af52016-05-19 22:12:18 +0100787requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100788run_test "RC4: server disabled, client enabled" \
789 "$P_SRV" \
790 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
791 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100792 -s "SSL - The server has no ciphersuites in common"
793
Simon Butchera410af52016-05-19 22:12:18 +0100794requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100795run_test "RC4: server half, client enabled" \
796 "$P_SRV arc4=1" \
797 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
798 1 \
799 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100800
801run_test "RC4: server enabled, client disabled" \
802 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
803 "$P_CLI" \
804 1 \
805 -s "SSL - The server has no ciphersuites in common"
806
807run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100808 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100809 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
810 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100811 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100812 -S "SSL - The server has no ciphersuites in common"
813
Hanno Becker3a333a52018-08-17 09:54:10 +0100814# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
815
816requires_gnutls
817requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
818run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
819 "$G_SRV"\
820 "$P_CLI force_version=tls1_1" \
821 0
822
823requires_gnutls
824requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
825run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
826 "$G_SRV"\
827 "$P_CLI force_version=tls1" \
828 0
829
Gilles Peskinebc70a182017-05-09 15:59:24 +0200830# Tests for SHA-1 support
831
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200832requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200833run_test "SHA-1 forbidden by default in server certificate" \
834 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
835 "$P_CLI debug_level=2 allow_sha1=0" \
836 1 \
837 -c "The certificate is signed with an unacceptable hash"
838
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200839requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
840run_test "SHA-1 forbidden by default in server certificate" \
841 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
842 "$P_CLI debug_level=2 allow_sha1=0" \
843 0
844
Gilles Peskinebc70a182017-05-09 15:59:24 +0200845run_test "SHA-1 explicitly allowed in server certificate" \
846 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
847 "$P_CLI allow_sha1=1" \
848 0
849
850run_test "SHA-256 allowed by default in server certificate" \
851 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
852 "$P_CLI allow_sha1=0" \
853 0
854
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200855requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200856run_test "SHA-1 forbidden by default in client certificate" \
857 "$P_SRV auth_mode=required allow_sha1=0" \
858 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
859 1 \
860 -s "The certificate is signed with an unacceptable hash"
861
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200862requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
863run_test "SHA-1 forbidden by default in client certificate" \
864 "$P_SRV auth_mode=required allow_sha1=0" \
865 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
866 0
867
Gilles Peskinebc70a182017-05-09 15:59:24 +0200868run_test "SHA-1 explicitly allowed in client certificate" \
869 "$P_SRV auth_mode=required allow_sha1=1" \
870 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
871 0
872
873run_test "SHA-256 allowed by default in client certificate" \
874 "$P_SRV auth_mode=required allow_sha1=0" \
875 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
876 0
877
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100878# Tests for Truncated HMAC extension
879
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100880run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200881 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100882 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100883 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000884 -s "dumping 'expected mac' (20 bytes)" \
885 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100886
Hanno Becker32c55012017-11-10 08:42:54 +0000887requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100888run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200889 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000890 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100891 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000892 -s "dumping 'expected mac' (20 bytes)" \
893 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100894
Hanno Becker32c55012017-11-10 08:42:54 +0000895requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100896run_test "Truncated HMAC: client enabled, server default" \
897 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000898 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100899 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000900 -s "dumping 'expected mac' (20 bytes)" \
901 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100902
Hanno Becker32c55012017-11-10 08:42:54 +0000903requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100904run_test "Truncated HMAC: client enabled, server disabled" \
905 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000906 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100907 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000908 -s "dumping 'expected mac' (20 bytes)" \
909 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100910
Hanno Becker32c55012017-11-10 08:42:54 +0000911requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000912run_test "Truncated HMAC: client disabled, server enabled" \
913 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000914 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +0000915 0 \
916 -s "dumping 'expected mac' (20 bytes)" \
917 -S "dumping 'expected mac' (10 bytes)"
918
919requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100920run_test "Truncated HMAC: client enabled, server enabled" \
921 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000922 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100923 0 \
Hanno Becker992b6872017-11-09 18:57:39 +0000924 -S "dumping 'expected mac' (20 bytes)" \
925 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100926
Hanno Becker4c4f4102017-11-10 09:16:05 +0000927run_test "Truncated HMAC, DTLS: client default, server default" \
928 "$P_SRV dtls=1 debug_level=4" \
929 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
930 0 \
931 -s "dumping 'expected mac' (20 bytes)" \
932 -S "dumping 'expected mac' (10 bytes)"
933
934requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
935run_test "Truncated HMAC, DTLS: client disabled, server default" \
936 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000937 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000938 0 \
939 -s "dumping 'expected mac' (20 bytes)" \
940 -S "dumping 'expected mac' (10 bytes)"
941
942requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
943run_test "Truncated HMAC, DTLS: client enabled, server default" \
944 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000945 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000946 0 \
947 -s "dumping 'expected mac' (20 bytes)" \
948 -S "dumping 'expected mac' (10 bytes)"
949
950requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
951run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
952 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000953 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000954 0 \
955 -s "dumping 'expected mac' (20 bytes)" \
956 -S "dumping 'expected mac' (10 bytes)"
957
958requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
959run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
960 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000961 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +0000962 0 \
963 -s "dumping 'expected mac' (20 bytes)" \
964 -S "dumping 'expected mac' (10 bytes)"
965
966requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
967run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
968 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +0000969 "$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 +0100970 0 \
971 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100972 -s "dumping 'expected mac' (10 bytes)"
973
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100974# Tests for Encrypt-then-MAC extension
975
976run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100977 "$P_SRV debug_level=3 \
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" \
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
988run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100989 "$P_SRV debug_level=3 etm=0 \
990 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100991 "$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
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001000run_test "Encrypt then MAC: client enabled, aead cipher" \
1001 "$P_SRV debug_level=3 etm=1 \
1002 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1003 "$P_CLI debug_level=3 etm=1" \
1004 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
1012run_test "Encrypt then MAC: client enabled, stream cipher" \
1013 "$P_SRV debug_level=3 etm=1 \
1014 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001015 "$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 +01001016 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
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001024run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001025 "$P_SRV debug_level=3 etm=1 \
1026 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001027 "$P_CLI debug_level=3 etm=0" \
1028 0 \
1029 -C "client hello, adding encrypt_then_mac extension" \
1030 -S "found encrypt then mac extension" \
1031 -S "server hello, adding encrypt then mac extension" \
1032 -C "found encrypt_then_mac extension" \
1033 -C "using encrypt then mac" \
1034 -S "using encrypt then mac"
1035
Janos Follathe2681a42016-03-07 15:57:05 +00001036requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001037run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001038 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001039 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001040 "$P_CLI debug_level=3 force_version=ssl3" \
1041 0 \
1042 -C "client hello, adding encrypt_then_mac extension" \
1043 -S "found encrypt then mac extension" \
1044 -S "server hello, adding encrypt then mac extension" \
1045 -C "found encrypt_then_mac extension" \
1046 -C "using encrypt then mac" \
1047 -S "using encrypt then mac"
1048
Janos Follathe2681a42016-03-07 15:57:05 +00001049requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001050run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001051 "$P_SRV debug_level=3 force_version=ssl3 \
1052 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001053 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001054 0 \
1055 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001056 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001057 -S "server hello, adding encrypt then mac extension" \
1058 -C "found encrypt_then_mac extension" \
1059 -C "using encrypt then mac" \
1060 -S "using encrypt then mac"
1061
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001062# Tests for Extended Master Secret extension
1063
1064run_test "Extended Master Secret: default" \
1065 "$P_SRV debug_level=3" \
1066 "$P_CLI debug_level=3" \
1067 0 \
1068 -c "client hello, adding extended_master_secret extension" \
1069 -s "found extended master secret extension" \
1070 -s "server hello, adding extended master secret extension" \
1071 -c "found extended_master_secret extension" \
1072 -c "using extended master secret" \
1073 -s "using extended master secret"
1074
1075run_test "Extended Master Secret: client enabled, server disabled" \
1076 "$P_SRV debug_level=3 extended_ms=0" \
1077 "$P_CLI debug_level=3 extended_ms=1" \
1078 0 \
1079 -c "client hello, adding extended_master_secret extension" \
1080 -s "found extended master secret extension" \
1081 -S "server hello, adding extended master secret extension" \
1082 -C "found extended_master_secret extension" \
1083 -C "using extended master secret" \
1084 -S "using extended master secret"
1085
1086run_test "Extended Master Secret: client disabled, server enabled" \
1087 "$P_SRV debug_level=3 extended_ms=1" \
1088 "$P_CLI debug_level=3 extended_ms=0" \
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 SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001099 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001100 "$P_CLI debug_level=3 force_version=ssl3" \
1101 0 \
1102 -C "client hello, adding extended_master_secret extension" \
1103 -S "found extended master secret extension" \
1104 -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
Janos Follathe2681a42016-03-07 15:57:05 +00001109requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001110run_test "Extended Master Secret: client enabled, server SSLv3" \
1111 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001112 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001113 0 \
1114 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001115 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001116 -S "server hello, adding extended master secret extension" \
1117 -C "found extended_master_secret extension" \
1118 -C "using extended master secret" \
1119 -S "using extended master secret"
1120
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001121# Tests for FALLBACK_SCSV
1122
1123run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001124 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001125 "$P_CLI debug_level=3 force_version=tls1_1" \
1126 0 \
1127 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001128 -S "received FALLBACK_SCSV" \
1129 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001130 -C "is a fatal alert message (msg 86)"
1131
1132run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001133 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001134 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1135 0 \
1136 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001137 -S "received FALLBACK_SCSV" \
1138 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001139 -C "is a fatal alert message (msg 86)"
1140
1141run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001142 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001143 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001144 1 \
1145 -c "adding FALLBACK_SCSV" \
1146 -s "received FALLBACK_SCSV" \
1147 -s "inapropriate fallback" \
1148 -c "is a fatal alert message (msg 86)"
1149
1150run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001151 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001152 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001153 0 \
1154 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001155 -s "received FALLBACK_SCSV" \
1156 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001157 -C "is a fatal alert message (msg 86)"
1158
1159requires_openssl_with_fallback_scsv
1160run_test "Fallback SCSV: default, openssl server" \
1161 "$O_SRV" \
1162 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1163 0 \
1164 -C "adding FALLBACK_SCSV" \
1165 -C "is a fatal alert message (msg 86)"
1166
1167requires_openssl_with_fallback_scsv
1168run_test "Fallback SCSV: enabled, openssl server" \
1169 "$O_SRV" \
1170 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1171 1 \
1172 -c "adding FALLBACK_SCSV" \
1173 -c "is a fatal alert message (msg 86)"
1174
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001175requires_openssl_with_fallback_scsv
1176run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001177 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001178 "$O_CLI -tls1_1" \
1179 0 \
1180 -S "received FALLBACK_SCSV" \
1181 -S "inapropriate fallback"
1182
1183requires_openssl_with_fallback_scsv
1184run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001185 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001186 "$O_CLI -tls1_1 -fallback_scsv" \
1187 1 \
1188 -s "received FALLBACK_SCSV" \
1189 -s "inapropriate fallback"
1190
1191requires_openssl_with_fallback_scsv
1192run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001193 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001194 "$O_CLI -fallback_scsv" \
1195 0 \
1196 -s "received FALLBACK_SCSV" \
1197 -S "inapropriate fallback"
1198
Andres Amaya Garcia14783c42018-07-10 20:08:04 +01001199# Test sending and receiving empty application data records
1200
1201run_test "Encrypt then MAC: empty application data record" \
1202 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1203 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1204 0 \
1205 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1206 -s "dumping 'input payload after decrypt' (0 bytes)" \
1207 -c "0 bytes written in 1 fragments"
1208
Manuel Pégourié-Gonnardd6e44542020-03-24 10:53:39 +01001209run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia14783c42018-07-10 20:08:04 +01001210 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1211 "$P_CLI auth_mode=none etm=0 request_size=0" \
1212 0 \
1213 -s "dumping 'input payload after decrypt' (0 bytes)" \
1214 -c "0 bytes written in 1 fragments"
1215
1216run_test "Encrypt then MAC, DTLS: empty application data record" \
1217 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1218 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1219 0 \
1220 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1221 -s "dumping 'input payload after decrypt' (0 bytes)" \
1222 -c "0 bytes written in 1 fragments"
1223
Manuel Pégourié-Gonnardd6e44542020-03-24 10:53:39 +01001224run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia14783c42018-07-10 20:08:04 +01001225 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1226 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1227 0 \
1228 -s "dumping 'input payload after decrypt' (0 bytes)" \
1229 -c "0 bytes written in 1 fragments"
1230
Gilles Peskined50177f2017-05-16 17:53:03 +02001231## ClientHello generated with
1232## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1233## then manually twiddling the ciphersuite list.
1234## The ClientHello content is spelled out below as a hex string as
1235## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1236## The expected response is an inappropriate_fallback alert.
1237requires_openssl_with_fallback_scsv
1238run_test "Fallback SCSV: beginning of list" \
1239 "$P_SRV debug_level=2" \
1240 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1241 0 \
1242 -s "received FALLBACK_SCSV" \
1243 -s "inapropriate fallback"
1244
1245requires_openssl_with_fallback_scsv
1246run_test "Fallback SCSV: end of list" \
1247 "$P_SRV debug_level=2" \
1248 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1249 0 \
1250 -s "received FALLBACK_SCSV" \
1251 -s "inapropriate fallback"
1252
1253## Here the expected response is a valid ServerHello prefix, up to the random.
1254requires_openssl_with_fallback_scsv
1255run_test "Fallback SCSV: not in list" \
1256 "$P_SRV debug_level=2" \
1257 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1258 0 \
1259 -S "received FALLBACK_SCSV" \
1260 -S "inapropriate fallback"
1261
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001262# Tests for CBC 1/n-1 record splitting
1263
1264run_test "CBC Record splitting: TLS 1.2, no splitting" \
1265 "$P_SRV" \
1266 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1267 request_size=123 force_version=tls1_2" \
1268 0 \
1269 -s "Read from client: 123 bytes read" \
1270 -S "Read from client: 1 bytes read" \
1271 -S "122 bytes read"
1272
1273run_test "CBC Record splitting: TLS 1.1, no splitting" \
1274 "$P_SRV" \
1275 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1276 request_size=123 force_version=tls1_1" \
1277 0 \
1278 -s "Read from client: 123 bytes read" \
1279 -S "Read from client: 1 bytes read" \
1280 -S "122 bytes read"
1281
1282run_test "CBC Record splitting: TLS 1.0, splitting" \
1283 "$P_SRV" \
1284 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1285 request_size=123 force_version=tls1" \
1286 0 \
1287 -S "Read from client: 123 bytes read" \
1288 -s "Read from client: 1 bytes read" \
1289 -s "122 bytes read"
1290
Janos Follathe2681a42016-03-07 15:57:05 +00001291requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001292run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001293 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001294 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1295 request_size=123 force_version=ssl3" \
1296 0 \
1297 -S "Read from client: 123 bytes read" \
1298 -s "Read from client: 1 bytes read" \
1299 -s "122 bytes read"
1300
1301run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001302 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001303 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1304 request_size=123 force_version=tls1" \
1305 0 \
1306 -s "Read from client: 123 bytes read" \
1307 -S "Read from client: 1 bytes read" \
1308 -S "122 bytes read"
1309
1310run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1311 "$P_SRV" \
1312 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1313 request_size=123 force_version=tls1 recsplit=0" \
1314 0 \
1315 -s "Read from client: 123 bytes read" \
1316 -S "Read from client: 1 bytes read" \
1317 -S "122 bytes read"
1318
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001319run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1320 "$P_SRV nbio=2" \
1321 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1322 request_size=123 force_version=tls1" \
1323 0 \
1324 -S "Read from client: 123 bytes read" \
1325 -s "Read from client: 1 bytes read" \
1326 -s "122 bytes read"
1327
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001328# Tests for Session Tickets
1329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001330run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001331 "$P_SRV debug_level=3 tickets=1" \
1332 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001333 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001334 -c "client hello, adding session ticket extension" \
1335 -s "found session ticket extension" \
1336 -s "server hello, adding session ticket extension" \
1337 -c "found session_ticket extension" \
1338 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001339 -S "session successfully restored from cache" \
1340 -s "session successfully restored from ticket" \
1341 -s "a session has been resumed" \
1342 -c "a session has been resumed"
1343
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001344run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001345 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1346 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001347 0 \
1348 -c "client hello, adding session ticket extension" \
1349 -s "found session ticket extension" \
1350 -s "server hello, adding session ticket extension" \
1351 -c "found session_ticket extension" \
1352 -c "parse new session ticket" \
1353 -S "session successfully restored from cache" \
1354 -s "session successfully restored from ticket" \
1355 -s "a session has been resumed" \
1356 -c "a session has been resumed"
1357
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001358run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001359 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1360 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001361 0 \
1362 -c "client hello, adding session ticket extension" \
1363 -s "found session ticket extension" \
1364 -s "server hello, adding session ticket extension" \
1365 -c "found session_ticket extension" \
1366 -c "parse new session ticket" \
1367 -S "session successfully restored from cache" \
1368 -S "session successfully restored from ticket" \
1369 -S "a session has been resumed" \
1370 -C "a session has been resumed"
1371
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001372run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001373 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001374 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001375 0 \
1376 -c "client hello, adding session ticket extension" \
1377 -c "found session_ticket extension" \
1378 -c "parse new session ticket" \
1379 -c "a session has been resumed"
1380
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001381run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001382 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001383 "( $O_CLI -sess_out $SESSION; \
1384 $O_CLI -sess_in $SESSION; \
1385 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001386 0 \
1387 -s "found session ticket extension" \
1388 -s "server hello, adding session ticket extension" \
1389 -S "session successfully restored from cache" \
1390 -s "session successfully restored from ticket" \
1391 -s "a session has been resumed"
1392
Hanno Beckerb5546362018-08-21 13:55:22 +01001393# Tests for Session Tickets with DTLS
1394
1395run_test "Session resume using tickets, DTLS: basic" \
1396 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001397 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001398 0 \
1399 -c "client hello, adding session ticket extension" \
1400 -s "found session ticket extension" \
1401 -s "server hello, adding session ticket extension" \
1402 -c "found session_ticket extension" \
1403 -c "parse new session ticket" \
1404 -S "session successfully restored from cache" \
1405 -s "session successfully restored from ticket" \
1406 -s "a session has been resumed" \
1407 -c "a session has been resumed"
1408
1409run_test "Session resume using tickets, DTLS: cache disabled" \
1410 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001411 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001412 0 \
1413 -c "client hello, adding session ticket extension" \
1414 -s "found session ticket extension" \
1415 -s "server hello, adding session ticket extension" \
1416 -c "found session_ticket extension" \
1417 -c "parse new session ticket" \
1418 -S "session successfully restored from cache" \
1419 -s "session successfully restored from ticket" \
1420 -s "a session has been resumed" \
1421 -c "a session has been resumed"
1422
1423run_test "Session resume using tickets, DTLS: timeout" \
1424 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001425 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001426 0 \
1427 -c "client hello, adding session ticket extension" \
1428 -s "found session ticket extension" \
1429 -s "server hello, adding session ticket extension" \
1430 -c "found session_ticket extension" \
1431 -c "parse new session ticket" \
1432 -S "session successfully restored from cache" \
1433 -S "session successfully restored from ticket" \
1434 -S "a session has been resumed" \
1435 -C "a session has been resumed"
1436
1437run_test "Session resume using tickets, DTLS: openssl server" \
1438 "$O_SRV -dtls1" \
1439 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1440 0 \
1441 -c "client hello, adding session ticket extension" \
1442 -c "found session_ticket extension" \
1443 -c "parse new session ticket" \
1444 -c "a session has been resumed"
1445
1446run_test "Session resume using tickets, DTLS: openssl client" \
1447 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1448 "( $O_CLI -dtls1 -sess_out $SESSION; \
1449 $O_CLI -dtls1 -sess_in $SESSION; \
1450 rm -f $SESSION )" \
1451 0 \
1452 -s "found session ticket extension" \
1453 -s "server hello, adding session ticket extension" \
1454 -S "session successfully restored from cache" \
1455 -s "session successfully restored from ticket" \
1456 -s "a session has been resumed"
1457
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001458# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001459
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001460run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001461 "$P_SRV debug_level=3 tickets=0" \
1462 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001463 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001464 -c "client hello, adding session ticket extension" \
1465 -s "found session ticket extension" \
1466 -S "server hello, adding session ticket extension" \
1467 -C "found session_ticket extension" \
1468 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001469 -s "session successfully restored from cache" \
1470 -S "session successfully restored from ticket" \
1471 -s "a session has been resumed" \
1472 -c "a session has been resumed"
1473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001474run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001475 "$P_SRV debug_level=3 tickets=1" \
1476 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001477 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001478 -C "client hello, adding session ticket extension" \
1479 -S "found session ticket extension" \
1480 -S "server hello, adding session ticket extension" \
1481 -C "found session_ticket extension" \
1482 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001483 -s "session successfully restored from cache" \
1484 -S "session successfully restored from ticket" \
1485 -s "a session has been resumed" \
1486 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001488run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001489 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1490 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001491 0 \
1492 -S "session successfully restored from cache" \
1493 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001494 -S "a session has been resumed" \
1495 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001496
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001497run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001498 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1499 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001500 0 \
1501 -s "session successfully restored from cache" \
1502 -S "session successfully restored from ticket" \
1503 -s "a session has been resumed" \
1504 -c "a session has been resumed"
1505
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001506run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001507 "$P_SRV debug_level=3 tickets=0" \
1508 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001509 0 \
1510 -s "session successfully restored from cache" \
1511 -S "session successfully restored from ticket" \
1512 -s "a session has been resumed" \
1513 -c "a session has been resumed"
1514
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001515run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001516 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1517 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001518 0 \
1519 -S "session successfully restored from cache" \
1520 -S "session successfully restored from ticket" \
1521 -S "a session has been resumed" \
1522 -C "a session has been resumed"
1523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001524run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001525 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1526 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001527 0 \
1528 -s "session successfully restored from cache" \
1529 -S "session successfully restored from ticket" \
1530 -s "a session has been resumed" \
1531 -c "a session has been resumed"
1532
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001533run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001534 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001535 "( $O_CLI -sess_out $SESSION; \
1536 $O_CLI -sess_in $SESSION; \
1537 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001538 0 \
1539 -s "found session ticket extension" \
1540 -S "server hello, adding session ticket extension" \
1541 -s "session successfully restored from cache" \
1542 -S "session successfully restored from ticket" \
1543 -s "a session has been resumed"
1544
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001545run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001546 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001547 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001548 0 \
1549 -C "found session_ticket extension" \
1550 -C "parse new session ticket" \
1551 -c "a session has been resumed"
1552
Hanno Beckerb5546362018-08-21 13:55:22 +01001553# Tests for Session Resume based on session-ID and cache, DTLS
1554
1555run_test "Session resume using cache, DTLS: tickets enabled on client" \
1556 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001557 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001558 0 \
1559 -c "client hello, adding session ticket extension" \
1560 -s "found session ticket extension" \
1561 -S "server hello, adding session ticket extension" \
1562 -C "found session_ticket extension" \
1563 -C "parse new session ticket" \
1564 -s "session successfully restored from cache" \
1565 -S "session successfully restored from ticket" \
1566 -s "a session has been resumed" \
1567 -c "a session has been resumed"
1568
1569run_test "Session resume using cache, DTLS: tickets enabled on server" \
1570 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001571 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001572 0 \
1573 -C "client hello, adding session ticket extension" \
1574 -S "found session ticket extension" \
1575 -S "server hello, adding session ticket extension" \
1576 -C "found session_ticket extension" \
1577 -C "parse new session ticket" \
1578 -s "session successfully restored from cache" \
1579 -S "session successfully restored from ticket" \
1580 -s "a session has been resumed" \
1581 -c "a session has been resumed"
1582
1583run_test "Session resume using cache, DTLS: cache_max=0" \
1584 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001585 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001586 0 \
1587 -S "session successfully restored from cache" \
1588 -S "session successfully restored from ticket" \
1589 -S "a session has been resumed" \
1590 -C "a session has been resumed"
1591
1592run_test "Session resume using cache, DTLS: cache_max=1" \
1593 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001594 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001595 0 \
1596 -s "session successfully restored from cache" \
1597 -S "session successfully restored from ticket" \
1598 -s "a session has been resumed" \
1599 -c "a session has been resumed"
1600
1601run_test "Session resume using cache, DTLS: timeout > delay" \
1602 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001603 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=0" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001604 0 \
1605 -s "session successfully restored from cache" \
1606 -S "session successfully restored from ticket" \
1607 -s "a session has been resumed" \
1608 -c "a session has been resumed"
1609
1610run_test "Session resume using cache, DTLS: timeout < delay" \
1611 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001612 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001613 0 \
1614 -S "session successfully restored from cache" \
1615 -S "session successfully restored from ticket" \
1616 -S "a session has been resumed" \
1617 -C "a session has been resumed"
1618
1619run_test "Session resume using cache, DTLS: no timeout" \
1620 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01001621 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Beckerb5546362018-08-21 13:55:22 +01001622 0 \
1623 -s "session successfully restored from cache" \
1624 -S "session successfully restored from ticket" \
1625 -s "a session has been resumed" \
1626 -c "a session has been resumed"
1627
1628run_test "Session resume using cache, DTLS: openssl client" \
1629 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1630 "( $O_CLI -dtls1 -sess_out $SESSION; \
1631 $O_CLI -dtls1 -sess_in $SESSION; \
1632 rm -f $SESSION )" \
1633 0 \
1634 -s "found session ticket extension" \
1635 -S "server hello, adding session ticket extension" \
1636 -s "session successfully restored from cache" \
1637 -S "session successfully restored from ticket" \
1638 -s "a session has been resumed"
1639
1640run_test "Session resume using cache, DTLS: openssl server" \
1641 "$O_SRV -dtls1" \
1642 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1643 0 \
1644 -C "found session_ticket extension" \
1645 -C "parse new session ticket" \
1646 -c "a session has been resumed"
1647
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001648# Tests for Max Fragment Length extension
1649
Hanno Becker6428f8d2017-09-22 16:58:50 +01001650MAX_CONTENT_LEN_EXPECT='16384'
1651MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1652
1653if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1654 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1655 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1656 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1657 printf "\n"
1658 printf "The tests assume this value and if it changes, the tests in this\n"
1659 printf "script should also be adjusted.\n"
1660 printf "\n"
1661
1662 exit 1
1663fi
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" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001667 "$P_SRV debug_level=3" \
1668 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001669 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001670 -c "Maximum fragment length is 16384" \
1671 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001672 -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"
1676
Hanno Becker4aed27e2017-09-18 15:00:34 +01001677requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001678run_test "Max fragment length: enabled, default, larger message" \
1679 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001680 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001681 0 \
1682 -c "Maximum fragment length is 16384" \
1683 -s "Maximum fragment length is 16384" \
1684 -C "client hello, adding max_fragment_length extension" \
1685 -S "found max fragment length extension" \
1686 -S "server hello, max_fragment_length extension" \
1687 -C "found max_fragment_length extension" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001688 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001689 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001690 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001691
1692requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1693run_test "Max fragment length, DTLS: enabled, default, larger message" \
1694 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001695 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001696 1 \
1697 -c "Maximum fragment length is 16384" \
1698 -s "Maximum fragment length is 16384" \
1699 -C "client hello, adding max_fragment_length extension" \
1700 -S "found max fragment length extension" \
1701 -S "server hello, max_fragment_length extension" \
1702 -C "found max_fragment_length extension" \
1703 -c "fragment larger than.*maximum "
1704
1705requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1706run_test "Max fragment length: disabled, larger message" \
1707 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001708 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001709 0 \
1710 -C "Maximum fragment length is 16384" \
1711 -S "Maximum fragment length is 16384" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001712 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001713 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001714 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001715
1716requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1717run_test "Max fragment length DTLS: disabled, larger message" \
1718 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001719 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001720 1 \
1721 -C "Maximum fragment length is 16384" \
1722 -S "Maximum fragment length is 16384" \
1723 -c "fragment larger than.*maximum "
1724
1725requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001726run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001727 "$P_SRV debug_level=3" \
1728 "$P_CLI debug_level=3 max_frag_len=4096" \
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 4096" \
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"
1736
Hanno Becker4aed27e2017-09-18 15:00:34 +01001737requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001738run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001739 "$P_SRV debug_level=3 max_frag_len=4096" \
1740 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001741 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001742 -c "Maximum fragment length is 16384" \
1743 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001744 -C "client hello, adding max_fragment_length extension" \
1745 -S "found max fragment length extension" \
1746 -S "server hello, max_fragment_length extension" \
1747 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001748
Hanno Becker4aed27e2017-09-18 15:00:34 +01001749requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001750requires_gnutls
1751run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001752 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001753 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001754 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001755 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001756 -c "client hello, adding max_fragment_length extension" \
1757 -c "found max_fragment_length extension"
1758
Hanno Becker4aed27e2017-09-18 15:00:34 +01001759requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001760run_test "Max fragment length: client, message just fits" \
1761 "$P_SRV debug_level=3" \
1762 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1763 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001764 -c "Maximum fragment length is 2048" \
1765 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001766 -c "client hello, adding max_fragment_length extension" \
1767 -s "found max fragment length extension" \
1768 -s "server hello, max_fragment_length extension" \
1769 -c "found max_fragment_length extension" \
1770 -c "2048 bytes written in 1 fragments" \
1771 -s "2048 bytes read"
1772
Hanno Becker4aed27e2017-09-18 15:00:34 +01001773requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001774run_test "Max fragment length: client, larger message" \
1775 "$P_SRV debug_level=3" \
1776 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1777 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001778 -c "Maximum fragment length is 2048" \
1779 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001780 -c "client hello, adding max_fragment_length extension" \
1781 -s "found max fragment length extension" \
1782 -s "server hello, max_fragment_length extension" \
1783 -c "found max_fragment_length extension" \
1784 -c "2345 bytes written in 2 fragments" \
1785 -s "2048 bytes read" \
1786 -s "297 bytes read"
1787
Hanno Becker4aed27e2017-09-18 15:00:34 +01001788requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001789run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001790 "$P_SRV debug_level=3 dtls=1" \
1791 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1792 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001793 -c "Maximum fragment length is 2048" \
1794 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001795 -c "client hello, adding max_fragment_length extension" \
1796 -s "found max fragment length extension" \
1797 -s "server hello, max_fragment_length extension" \
1798 -c "found max_fragment_length extension" \
1799 -c "fragment larger than.*maximum"
1800
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001801# Tests for renegotiation
1802
Hanno Becker6a243642017-10-12 15:18:45 +01001803# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001804run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001805 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001806 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001807 0 \
1808 -C "client hello, adding renegotiation extension" \
1809 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1810 -S "found renegotiation extension" \
1811 -s "server hello, secure renegotiation extension" \
1812 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001813 -C "=> renegotiate" \
1814 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001815 -S "write hello request"
1816
Hanno Becker6a243642017-10-12 15:18:45 +01001817requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001818run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001819 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001820 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001821 0 \
1822 -c "client hello, adding renegotiation extension" \
1823 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1824 -s "found renegotiation extension" \
1825 -s "server hello, secure renegotiation extension" \
1826 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001827 -c "=> renegotiate" \
1828 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001829 -S "write hello request"
1830
Hanno Becker6a243642017-10-12 15:18:45 +01001831requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001832run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001833 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001834 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001835 0 \
1836 -c "client hello, adding renegotiation extension" \
1837 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1838 -s "found renegotiation extension" \
1839 -s "server hello, secure renegotiation extension" \
1840 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001841 -c "=> renegotiate" \
1842 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001843 -s "write hello request"
1844
Janos Follathb0f148c2017-10-05 12:29:42 +01001845# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1846# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1847# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001848requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001849run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1850 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1851 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1852 0 \
1853 -c "client hello, adding renegotiation extension" \
1854 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1855 -s "found renegotiation extension" \
1856 -s "server hello, secure renegotiation extension" \
1857 -c "found renegotiation extension" \
1858 -c "=> renegotiate" \
1859 -s "=> renegotiate" \
1860 -S "write hello request" \
1861 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1862
1863# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1864# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1865# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001866requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001867run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1868 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1869 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1870 0 \
1871 -c "client hello, adding renegotiation extension" \
1872 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1873 -s "found renegotiation extension" \
1874 -s "server hello, secure renegotiation extension" \
1875 -c "found renegotiation extension" \
1876 -c "=> renegotiate" \
1877 -s "=> renegotiate" \
1878 -s "write hello request" \
1879 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1880
Hanno Becker6a243642017-10-12 15:18:45 +01001881requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001882run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001883 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001884 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001885 0 \
1886 -c "client hello, adding renegotiation extension" \
1887 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1888 -s "found renegotiation extension" \
1889 -s "server hello, secure renegotiation extension" \
1890 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001891 -c "=> renegotiate" \
1892 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001893 -s "write hello request"
1894
Hanno Becker6a243642017-10-12 15:18:45 +01001895requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001896run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001897 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001898 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001899 1 \
1900 -c "client hello, adding renegotiation extension" \
1901 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1902 -S "found renegotiation extension" \
1903 -s "server hello, secure renegotiation extension" \
1904 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001905 -c "=> renegotiate" \
1906 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001907 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001908 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001909 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001910
Hanno Becker6a243642017-10-12 15:18:45 +01001911requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001912run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001913 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001914 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001915 0 \
1916 -C "client hello, adding renegotiation extension" \
1917 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1918 -S "found renegotiation extension" \
1919 -s "server hello, secure renegotiation extension" \
1920 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001921 -C "=> renegotiate" \
1922 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001923 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001924 -S "SSL - An unexpected message was received from our peer" \
1925 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001926
Hanno Becker6a243642017-10-12 15:18:45 +01001927requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001928run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001929 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001930 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001931 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001932 0 \
1933 -C "client hello, adding renegotiation extension" \
1934 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1935 -S "found renegotiation extension" \
1936 -s "server hello, secure renegotiation extension" \
1937 -c "found renegotiation extension" \
1938 -C "=> renegotiate" \
1939 -S "=> renegotiate" \
1940 -s "write hello request" \
1941 -S "SSL - An unexpected message was received from our peer" \
1942 -S "failed"
1943
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001944# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001945requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001946run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001947 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001948 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001949 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001950 0 \
1951 -C "client hello, adding renegotiation extension" \
1952 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1953 -S "found renegotiation extension" \
1954 -s "server hello, secure renegotiation extension" \
1955 -c "found renegotiation extension" \
1956 -C "=> renegotiate" \
1957 -S "=> renegotiate" \
1958 -s "write hello request" \
1959 -S "SSL - An unexpected message was received from our peer" \
1960 -S "failed"
1961
Hanno Becker6a243642017-10-12 15:18:45 +01001962requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001963run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001964 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001965 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001966 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001967 0 \
1968 -C "client hello, adding renegotiation extension" \
1969 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1970 -S "found renegotiation extension" \
1971 -s "server hello, secure renegotiation extension" \
1972 -c "found renegotiation extension" \
1973 -C "=> renegotiate" \
1974 -S "=> renegotiate" \
1975 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001976 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001977
Hanno Becker6a243642017-10-12 15:18:45 +01001978requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001979run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001980 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001981 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001982 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001983 0 \
1984 -c "client hello, adding renegotiation extension" \
1985 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1986 -s "found renegotiation extension" \
1987 -s "server hello, secure renegotiation extension" \
1988 -c "found renegotiation extension" \
1989 -c "=> renegotiate" \
1990 -s "=> renegotiate" \
1991 -s "write hello request" \
1992 -S "SSL - An unexpected message was received from our peer" \
1993 -S "failed"
1994
Hanno Becker6a243642017-10-12 15:18:45 +01001995requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001996run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001997 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001998 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1999 0 \
2000 -C "client hello, adding renegotiation extension" \
2001 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2002 -S "found renegotiation extension" \
2003 -s "server hello, secure renegotiation extension" \
2004 -c "found renegotiation extension" \
2005 -S "record counter limit reached: renegotiate" \
2006 -C "=> renegotiate" \
2007 -S "=> renegotiate" \
2008 -S "write hello request" \
2009 -S "SSL - An unexpected message was received from our peer" \
2010 -S "failed"
2011
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002012# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002013requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002014run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002015 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002016 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002017 0 \
2018 -c "client hello, adding renegotiation extension" \
2019 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2020 -s "found renegotiation extension" \
2021 -s "server hello, secure renegotiation extension" \
2022 -c "found renegotiation extension" \
2023 -s "record counter limit reached: renegotiate" \
2024 -c "=> renegotiate" \
2025 -s "=> renegotiate" \
2026 -s "write hello request" \
2027 -S "SSL - An unexpected message was received from our peer" \
2028 -S "failed"
2029
Hanno Becker6a243642017-10-12 15:18:45 +01002030requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002031run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002032 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002033 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002034 0 \
2035 -c "client hello, adding renegotiation extension" \
2036 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2037 -s "found renegotiation extension" \
2038 -s "server hello, secure renegotiation extension" \
2039 -c "found renegotiation extension" \
2040 -s "record counter limit reached: renegotiate" \
2041 -c "=> renegotiate" \
2042 -s "=> renegotiate" \
2043 -s "write hello request" \
2044 -S "SSL - An unexpected message was received from our peer" \
2045 -S "failed"
2046
Hanno Becker6a243642017-10-12 15:18:45 +01002047requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002048run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002049 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002050 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2051 0 \
2052 -C "client hello, adding renegotiation extension" \
2053 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2054 -S "found renegotiation extension" \
2055 -s "server hello, secure renegotiation extension" \
2056 -c "found renegotiation extension" \
2057 -S "record counter limit reached: renegotiate" \
2058 -C "=> renegotiate" \
2059 -S "=> renegotiate" \
2060 -S "write hello request" \
2061 -S "SSL - An unexpected message was received from our peer" \
2062 -S "failed"
2063
Hanno Becker6a243642017-10-12 15:18:45 +01002064requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002065run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002066 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002067 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002068 0 \
2069 -c "client hello, adding renegotiation extension" \
2070 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2071 -s "found renegotiation extension" \
2072 -s "server hello, secure renegotiation extension" \
2073 -c "found renegotiation extension" \
2074 -c "=> renegotiate" \
2075 -s "=> renegotiate" \
2076 -S "write hello request"
2077
Hanno Becker6a243642017-10-12 15:18:45 +01002078requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002079run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002080 "$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 +02002081 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002082 0 \
2083 -c "client hello, adding renegotiation extension" \
2084 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2085 -s "found renegotiation extension" \
2086 -s "server hello, secure renegotiation extension" \
2087 -c "found renegotiation extension" \
2088 -c "=> renegotiate" \
2089 -s "=> renegotiate" \
2090 -s "write hello request"
2091
Hanno Becker6a243642017-10-12 15:18:45 +01002092requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002093run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002094 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002095 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002096 0 \
2097 -c "client hello, adding renegotiation extension" \
2098 -c "found renegotiation extension" \
2099 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002100 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002101 -C "error" \
2102 -c "HTTP/1.0 200 [Oo][Kk]"
2103
Paul Bakker539d9722015-02-08 16:18:35 +01002104requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002105requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002106run_test "Renegotiation: gnutls server strict, client-initiated" \
2107 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002108 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002109 0 \
2110 -c "client hello, adding renegotiation extension" \
2111 -c "found renegotiation extension" \
2112 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002113 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002114 -C "error" \
2115 -c "HTTP/1.0 200 [Oo][Kk]"
2116
Paul Bakker539d9722015-02-08 16:18:35 +01002117requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002118requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002119run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2120 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2121 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2122 1 \
2123 -c "client hello, adding renegotiation extension" \
2124 -C "found renegotiation extension" \
2125 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002126 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002127 -c "error" \
2128 -C "HTTP/1.0 200 [Oo][Kk]"
2129
Paul Bakker539d9722015-02-08 16:18:35 +01002130requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002131requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002132run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2133 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2134 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2135 allow_legacy=0" \
2136 1 \
2137 -c "client hello, adding renegotiation extension" \
2138 -C "found renegotiation extension" \
2139 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002140 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002141 -c "error" \
2142 -C "HTTP/1.0 200 [Oo][Kk]"
2143
Paul Bakker539d9722015-02-08 16:18:35 +01002144requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002145requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002146run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2147 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2148 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2149 allow_legacy=1" \
2150 0 \
2151 -c "client hello, adding renegotiation extension" \
2152 -C "found renegotiation extension" \
2153 -c "=> renegotiate" \
2154 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002155 -C "error" \
2156 -c "HTTP/1.0 200 [Oo][Kk]"
2157
Hanno Becker6a243642017-10-12 15:18:45 +01002158requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002159run_test "Renegotiation: DTLS, client-initiated" \
2160 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2161 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2162 0 \
2163 -c "client hello, adding renegotiation extension" \
2164 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2165 -s "found renegotiation extension" \
2166 -s "server hello, secure renegotiation extension" \
2167 -c "found renegotiation extension" \
2168 -c "=> renegotiate" \
2169 -s "=> renegotiate" \
2170 -S "write hello request"
2171
Hanno Becker6a243642017-10-12 15:18:45 +01002172requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002173run_test "Renegotiation: DTLS, server-initiated" \
2174 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002175 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2176 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002177 0 \
2178 -c "client hello, adding renegotiation extension" \
2179 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2180 -s "found renegotiation extension" \
2181 -s "server hello, secure renegotiation extension" \
2182 -c "found renegotiation extension" \
2183 -c "=> renegotiate" \
2184 -s "=> renegotiate" \
2185 -s "write hello request"
2186
Hanno Becker6a243642017-10-12 15:18:45 +01002187requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002188run_test "Renegotiation: DTLS, renego_period overflow" \
2189 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2190 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2191 0 \
2192 -c "client hello, adding renegotiation extension" \
2193 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2194 -s "found renegotiation extension" \
2195 -s "server hello, secure renegotiation extension" \
2196 -s "record counter limit reached: renegotiate" \
2197 -c "=> renegotiate" \
2198 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002199 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002200
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002201requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002202requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002203run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2204 "$G_SRV -u --mtu 4096" \
2205 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2206 0 \
2207 -c "client hello, adding renegotiation extension" \
2208 -c "found renegotiation extension" \
2209 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002210 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002211 -C "error" \
2212 -s "Extra-header:"
2213
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002214# Test for the "secure renegotation" extension only (no actual renegotiation)
2215
Paul Bakker539d9722015-02-08 16:18:35 +01002216requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002217run_test "Renego ext: gnutls server strict, client default" \
2218 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2219 "$P_CLI debug_level=3" \
2220 0 \
2221 -c "found renegotiation extension" \
2222 -C "error" \
2223 -c "HTTP/1.0 200 [Oo][Kk]"
2224
Paul Bakker539d9722015-02-08 16:18:35 +01002225requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002226run_test "Renego ext: gnutls server unsafe, client default" \
2227 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2228 "$P_CLI debug_level=3" \
2229 0 \
2230 -C "found renegotiation extension" \
2231 -C "error" \
2232 -c "HTTP/1.0 200 [Oo][Kk]"
2233
Paul Bakker539d9722015-02-08 16:18:35 +01002234requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002235run_test "Renego ext: gnutls server unsafe, client break legacy" \
2236 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2237 "$P_CLI debug_level=3 allow_legacy=-1" \
2238 1 \
2239 -C "found renegotiation extension" \
2240 -c "error" \
2241 -C "HTTP/1.0 200 [Oo][Kk]"
2242
Paul Bakker539d9722015-02-08 16:18:35 +01002243requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002244run_test "Renego ext: gnutls client strict, server default" \
2245 "$P_SRV debug_level=3" \
2246 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
2247 0 \
2248 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2249 -s "server hello, secure renegotiation extension"
2250
Paul Bakker539d9722015-02-08 16:18:35 +01002251requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002252run_test "Renego ext: gnutls client unsafe, server default" \
2253 "$P_SRV debug_level=3" \
2254 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2255 0 \
2256 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2257 -S "server hello, secure renegotiation extension"
2258
Paul Bakker539d9722015-02-08 16:18:35 +01002259requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002260run_test "Renego ext: gnutls client unsafe, server break legacy" \
2261 "$P_SRV debug_level=3 allow_legacy=-1" \
2262 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2263 1 \
2264 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2265 -S "server hello, secure renegotiation extension"
2266
Janos Follath0b242342016-02-17 10:11:21 +00002267# Tests for silently dropping trailing extra bytes in .der certificates
2268
2269requires_gnutls
2270run_test "DER format: no trailing bytes" \
2271 "$P_SRV crt_file=data_files/server5-der0.crt \
2272 key_file=data_files/server5.key" \
2273 "$G_CLI " \
2274 0 \
2275 -c "Handshake was completed" \
2276
2277requires_gnutls
2278run_test "DER format: with a trailing zero byte" \
2279 "$P_SRV crt_file=data_files/server5-der1a.crt \
2280 key_file=data_files/server5.key" \
2281 "$G_CLI " \
2282 0 \
2283 -c "Handshake was completed" \
2284
2285requires_gnutls
2286run_test "DER format: with a trailing random byte" \
2287 "$P_SRV crt_file=data_files/server5-der1b.crt \
2288 key_file=data_files/server5.key" \
2289 "$G_CLI " \
2290 0 \
2291 -c "Handshake was completed" \
2292
2293requires_gnutls
2294run_test "DER format: with 2 trailing random bytes" \
2295 "$P_SRV crt_file=data_files/server5-der2.crt \
2296 key_file=data_files/server5.key" \
2297 "$G_CLI " \
2298 0 \
2299 -c "Handshake was completed" \
2300
2301requires_gnutls
2302run_test "DER format: with 4 trailing random bytes" \
2303 "$P_SRV crt_file=data_files/server5-der4.crt \
2304 key_file=data_files/server5.key" \
2305 "$G_CLI " \
2306 0 \
2307 -c "Handshake was completed" \
2308
2309requires_gnutls
2310run_test "DER format: with 8 trailing random bytes" \
2311 "$P_SRV crt_file=data_files/server5-der8.crt \
2312 key_file=data_files/server5.key" \
2313 "$G_CLI " \
2314 0 \
2315 -c "Handshake was completed" \
2316
2317requires_gnutls
2318run_test "DER format: with 9 trailing random bytes" \
2319 "$P_SRV crt_file=data_files/server5-der9.crt \
2320 key_file=data_files/server5.key" \
2321 "$G_CLI " \
2322 0 \
2323 -c "Handshake was completed" \
2324
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002325# Tests for auth_mode
2326
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002327run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002328 "$P_SRV crt_file=data_files/server5-badsign.crt \
2329 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002330 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002331 1 \
2332 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002333 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002334 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002335 -c "X509 - Certificate verification failed"
2336
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002337run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002338 "$P_SRV crt_file=data_files/server5-badsign.crt \
2339 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002340 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002341 0 \
2342 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002343 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002344 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002345 -C "X509 - Certificate verification failed"
2346
Hanno Beckere6706e62017-05-15 16:05:15 +01002347run_test "Authentication: server goodcert, client optional, no trusted CA" \
2348 "$P_SRV" \
2349 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2350 0 \
2351 -c "x509_verify_cert() returned" \
2352 -c "! The certificate is not correctly signed by the trusted CA" \
2353 -c "! Certificate verification flags"\
2354 -C "! mbedtls_ssl_handshake returned" \
2355 -C "X509 - Certificate verification failed" \
2356 -C "SSL - No CA Chain is set, but required to operate"
2357
2358run_test "Authentication: server goodcert, client required, no trusted CA" \
2359 "$P_SRV" \
2360 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2361 1 \
2362 -c "x509_verify_cert() returned" \
2363 -c "! The certificate is not correctly signed by the trusted CA" \
2364 -c "! Certificate verification flags"\
2365 -c "! mbedtls_ssl_handshake returned" \
2366 -c "SSL - No CA Chain is set, but required to operate"
2367
2368# The purpose of the next two tests is to test the client's behaviour when receiving a server
2369# certificate with an unsupported elliptic curve. This should usually not happen because
2370# the client informs the server about the supported curves - it does, though, in the
2371# corner case of a static ECDH suite, because the server doesn't check the curve on that
2372# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2373# different means to have the server ignoring the client's supported curve list.
2374
2375requires_config_enabled MBEDTLS_ECP_C
2376run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2377 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2378 crt_file=data_files/server5.ku-ka.crt" \
2379 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2380 1 \
2381 -c "bad certificate (EC key curve)"\
2382 -c "! Certificate verification flags"\
2383 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2384
2385requires_config_enabled MBEDTLS_ECP_C
2386run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2387 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2388 crt_file=data_files/server5.ku-ka.crt" \
2389 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2390 1 \
2391 -c "bad certificate (EC key curve)"\
2392 -c "! Certificate verification flags"\
2393 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2394
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002395run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002396 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002397 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002398 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002399 0 \
2400 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002401 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002402 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002403 -C "X509 - Certificate verification failed"
2404
Simon Butcher99000142016-10-13 17:21:01 +01002405run_test "Authentication: client SHA256, server required" \
2406 "$P_SRV auth_mode=required" \
2407 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2408 key_file=data_files/server6.key \
2409 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2410 0 \
2411 -c "Supported Signature Algorithm found: 4," \
2412 -c "Supported Signature Algorithm found: 5,"
2413
2414run_test "Authentication: client SHA384, server required" \
2415 "$P_SRV auth_mode=required" \
2416 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2417 key_file=data_files/server6.key \
2418 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2419 0 \
2420 -c "Supported Signature Algorithm found: 4," \
2421 -c "Supported Signature Algorithm found: 5,"
2422
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002423requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2424run_test "Authentication: client has no cert, server required (SSLv3)" \
2425 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2426 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2427 key_file=data_files/server5.key" \
2428 1 \
2429 -S "skip write certificate request" \
2430 -C "skip parse certificate request" \
2431 -c "got a certificate request" \
2432 -c "got no certificate to send" \
2433 -S "x509_verify_cert() returned" \
2434 -s "client has no certificate" \
2435 -s "! mbedtls_ssl_handshake returned" \
2436 -c "! mbedtls_ssl_handshake returned" \
2437 -s "No client certification received from the client, but required by the authentication mode"
2438
2439run_test "Authentication: client has no cert, server required (TLS)" \
2440 "$P_SRV debug_level=3 auth_mode=required" \
2441 "$P_CLI debug_level=3 crt_file=none \
2442 key_file=data_files/server5.key" \
2443 1 \
2444 -S "skip write certificate request" \
2445 -C "skip parse certificate request" \
2446 -c "got a certificate request" \
2447 -c "= write certificate$" \
2448 -C "skip write certificate$" \
2449 -S "x509_verify_cert() returned" \
2450 -s "client has no certificate" \
2451 -s "! mbedtls_ssl_handshake returned" \
2452 -c "! mbedtls_ssl_handshake returned" \
2453 -s "No client certification received from the client, but required by the authentication mode"
2454
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002455run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002456 "$P_SRV debug_level=3 auth_mode=required" \
2457 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002458 key_file=data_files/server5.key" \
2459 1 \
2460 -S "skip write certificate request" \
2461 -C "skip parse certificate request" \
2462 -c "got a certificate request" \
2463 -C "skip write certificate" \
2464 -C "skip write certificate verify" \
2465 -S "skip parse certificate verify" \
2466 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002467 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002468 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002469 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002470 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002471 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002472# We don't check that the client receives the alert because it might
2473# detect that its write end of the connection is closed and abort
2474# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002475
Janos Follath89baba22017-04-10 14:34:35 +01002476run_test "Authentication: client cert not trusted, server required" \
2477 "$P_SRV debug_level=3 auth_mode=required" \
2478 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2479 key_file=data_files/server5.key" \
2480 1 \
2481 -S "skip write certificate request" \
2482 -C "skip parse certificate request" \
2483 -c "got a certificate request" \
2484 -C "skip write certificate" \
2485 -C "skip write certificate verify" \
2486 -S "skip parse certificate verify" \
2487 -s "x509_verify_cert() returned" \
2488 -s "! The certificate is not correctly signed by the trusted CA" \
2489 -s "! mbedtls_ssl_handshake returned" \
2490 -c "! mbedtls_ssl_handshake returned" \
2491 -s "X509 - Certificate verification failed"
2492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002493run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002494 "$P_SRV debug_level=3 auth_mode=optional" \
2495 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002496 key_file=data_files/server5.key" \
2497 0 \
2498 -S "skip write certificate request" \
2499 -C "skip parse certificate request" \
2500 -c "got a certificate request" \
2501 -C "skip write certificate" \
2502 -C "skip write certificate verify" \
2503 -S "skip parse certificate verify" \
2504 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002505 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002506 -S "! mbedtls_ssl_handshake returned" \
2507 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002508 -S "X509 - Certificate verification failed"
2509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002510run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002511 "$P_SRV debug_level=3 auth_mode=none" \
2512 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002513 key_file=data_files/server5.key" \
2514 0 \
2515 -s "skip write certificate request" \
2516 -C "skip parse certificate request" \
2517 -c "got no certificate request" \
2518 -c "skip write certificate" \
2519 -c "skip write certificate verify" \
2520 -s "skip parse certificate verify" \
2521 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002522 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002523 -S "! mbedtls_ssl_handshake returned" \
2524 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002525 -S "X509 - Certificate verification failed"
2526
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002527run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002528 "$P_SRV debug_level=3 auth_mode=optional" \
2529 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002530 0 \
2531 -S "skip write certificate request" \
2532 -C "skip parse certificate request" \
2533 -c "got a certificate request" \
2534 -C "skip write certificate$" \
2535 -C "got no certificate to send" \
2536 -S "SSLv3 client has no certificate" \
2537 -c "skip write certificate verify" \
2538 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002539 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002540 -S "! mbedtls_ssl_handshake returned" \
2541 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002542 -S "X509 - Certificate verification failed"
2543
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002544run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002545 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002546 "$O_CLI" \
2547 0 \
2548 -S "skip write certificate request" \
2549 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002550 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002551 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002552 -S "X509 - Certificate verification failed"
2553
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002554run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002555 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002556 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002557 0 \
2558 -C "skip parse certificate request" \
2559 -c "got a certificate request" \
2560 -C "skip write certificate$" \
2561 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002562 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002563
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002564run_test "Authentication: client no cert, openssl server required" \
2565 "$O_SRV -Verify 10" \
2566 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2567 1 \
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 "! mbedtls_ssl_handshake returned"
2573
Janos Follathe2681a42016-03-07 15:57:05 +00002574requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002575run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002576 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002577 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002578 0 \
2579 -S "skip write certificate request" \
2580 -C "skip parse certificate request" \
2581 -c "got a certificate request" \
2582 -C "skip write certificate$" \
2583 -c "skip write certificate verify" \
2584 -c "got no certificate to send" \
2585 -s "SSLv3 client has no certificate" \
2586 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002587 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002588 -S "! mbedtls_ssl_handshake returned" \
2589 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002590 -S "X509 - Certificate verification failed"
2591
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002592# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2593# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002594
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002595MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002596MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002597
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002598if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002599 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002600 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002601 printf "test value of ${MAX_IM_CA}. \n"
2602 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002603 printf "The tests assume this value and if it changes, the tests in this\n"
2604 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002605 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002606
2607 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002608fi
2609
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002610run_test "Authentication: server max_int chain, client default" \
2611 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2612 key_file=data_files/dir-maxpath/09.key" \
2613 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2614 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002615 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002616
2617run_test "Authentication: server max_int+1 chain, client default" \
2618 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2619 key_file=data_files/dir-maxpath/10.key" \
2620 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2621 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002622 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002623
2624run_test "Authentication: server max_int+1 chain, client optional" \
2625 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2626 key_file=data_files/dir-maxpath/10.key" \
2627 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2628 auth_mode=optional" \
2629 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002630 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002631
2632run_test "Authentication: server max_int+1 chain, client none" \
2633 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2634 key_file=data_files/dir-maxpath/10.key" \
2635 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2636 auth_mode=none" \
2637 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002638 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002639
2640run_test "Authentication: client max_int+1 chain, server default" \
2641 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2642 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2643 key_file=data_files/dir-maxpath/10.key" \
2644 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002645 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002646
2647run_test "Authentication: client max_int+1 chain, server optional" \
2648 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2649 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2650 key_file=data_files/dir-maxpath/10.key" \
2651 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002652 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002653
2654run_test "Authentication: client max_int+1 chain, server required" \
2655 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2656 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2657 key_file=data_files/dir-maxpath/10.key" \
2658 1 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002659 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002660
2661run_test "Authentication: client max_int chain, server required" \
2662 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2663 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2664 key_file=data_files/dir-maxpath/09.key" \
2665 0 \
Antonin Décimo8fd91562019-01-23 15:24:37 +01002666 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002667
Janos Follath89baba22017-04-10 14:34:35 +01002668# Tests for CA list in CertificateRequest messages
2669
2670run_test "Authentication: send CA list in CertificateRequest (default)" \
2671 "$P_SRV debug_level=3 auth_mode=required" \
2672 "$P_CLI crt_file=data_files/server6.crt \
2673 key_file=data_files/server6.key" \
2674 0 \
2675 -s "requested DN"
2676
2677run_test "Authentication: do not send CA list in CertificateRequest" \
2678 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2679 "$P_CLI crt_file=data_files/server6.crt \
2680 key_file=data_files/server6.key" \
2681 0 \
2682 -S "requested DN"
2683
2684run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2685 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2686 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2687 key_file=data_files/server5.key" \
2688 1 \
2689 -S "requested DN" \
2690 -s "x509_verify_cert() returned" \
2691 -s "! The certificate is not correctly signed by the trusted CA" \
2692 -s "! mbedtls_ssl_handshake returned" \
2693 -c "! mbedtls_ssl_handshake returned" \
2694 -s "X509 - Certificate verification failed"
2695
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002696# Tests for certificate selection based on SHA verson
2697
2698run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2699 "$P_SRV crt_file=data_files/server5.crt \
2700 key_file=data_files/server5.key \
2701 crt_file2=data_files/server5-sha1.crt \
2702 key_file2=data_files/server5.key" \
2703 "$P_CLI force_version=tls1_2" \
2704 0 \
2705 -c "signed using.*ECDSA with SHA256" \
2706 -C "signed using.*ECDSA with SHA1"
2707
2708run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2709 "$P_SRV crt_file=data_files/server5.crt \
2710 key_file=data_files/server5.key \
2711 crt_file2=data_files/server5-sha1.crt \
2712 key_file2=data_files/server5.key" \
2713 "$P_CLI force_version=tls1_1" \
2714 0 \
2715 -C "signed using.*ECDSA with SHA256" \
2716 -c "signed using.*ECDSA with SHA1"
2717
2718run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2719 "$P_SRV crt_file=data_files/server5.crt \
2720 key_file=data_files/server5.key \
2721 crt_file2=data_files/server5-sha1.crt \
2722 key_file2=data_files/server5.key" \
2723 "$P_CLI force_version=tls1" \
2724 0 \
2725 -C "signed using.*ECDSA with SHA256" \
2726 -c "signed using.*ECDSA with SHA1"
2727
2728run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2729 "$P_SRV crt_file=data_files/server5.crt \
2730 key_file=data_files/server5.key \
2731 crt_file2=data_files/server6.crt \
2732 key_file2=data_files/server6.key" \
2733 "$P_CLI force_version=tls1_1" \
2734 0 \
2735 -c "serial number.*09" \
2736 -c "signed using.*ECDSA with SHA256" \
2737 -C "signed using.*ECDSA with SHA1"
2738
2739run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2740 "$P_SRV crt_file=data_files/server6.crt \
2741 key_file=data_files/server6.key \
2742 crt_file2=data_files/server5.crt \
2743 key_file2=data_files/server5.key" \
2744 "$P_CLI force_version=tls1_1" \
2745 0 \
2746 -c "serial number.*0A" \
2747 -c "signed using.*ECDSA with SHA256" \
2748 -C "signed using.*ECDSA with SHA1"
2749
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002750# tests for SNI
2751
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002752run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002753 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002754 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002755 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002756 0 \
2757 -S "parse ServerName extension" \
2758 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2759 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002760
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002761run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002762 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002763 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002764 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 +02002765 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002766 0 \
2767 -s "parse ServerName extension" \
2768 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2769 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002770
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002771run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002772 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002773 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002774 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 +02002775 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002776 0 \
2777 -s "parse ServerName extension" \
2778 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2779 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002780
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002781run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002782 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002783 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002784 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 +02002785 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002786 1 \
2787 -s "parse ServerName extension" \
2788 -s "ssl_sni_wrapper() returned" \
2789 -s "mbedtls_ssl_handshake returned" \
2790 -c "mbedtls_ssl_handshake returned" \
2791 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002792
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002793run_test "SNI: client auth no override: optional" \
2794 "$P_SRV debug_level=3 auth_mode=optional \
2795 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2796 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2797 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002798 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002799 -S "skip write certificate request" \
2800 -C "skip parse certificate request" \
2801 -c "got a certificate request" \
2802 -C "skip write certificate" \
2803 -C "skip write certificate verify" \
2804 -S "skip parse certificate verify"
2805
2806run_test "SNI: client auth override: none -> optional" \
2807 "$P_SRV debug_level=3 auth_mode=none \
2808 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2809 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2810 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002811 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002812 -S "skip write certificate request" \
2813 -C "skip parse certificate request" \
2814 -c "got a certificate request" \
2815 -C "skip write certificate" \
2816 -C "skip write certificate verify" \
2817 -S "skip parse certificate verify"
2818
2819run_test "SNI: client auth override: optional -> none" \
2820 "$P_SRV debug_level=3 auth_mode=optional \
2821 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2822 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2823 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002824 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002825 -s "skip write certificate request" \
2826 -C "skip parse certificate request" \
2827 -c "got no certificate request" \
2828 -c "skip write certificate" \
2829 -c "skip write certificate verify" \
2830 -s "skip parse certificate verify"
2831
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002832run_test "SNI: CA no override" \
2833 "$P_SRV debug_level=3 auth_mode=optional \
2834 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2835 ca_file=data_files/test-ca.crt \
2836 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2837 "$P_CLI debug_level=3 server_name=localhost \
2838 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2839 1 \
2840 -S "skip write certificate request" \
2841 -C "skip parse certificate request" \
2842 -c "got a certificate request" \
2843 -C "skip write certificate" \
2844 -C "skip write certificate verify" \
2845 -S "skip parse certificate verify" \
2846 -s "x509_verify_cert() returned" \
2847 -s "! The certificate is not correctly signed by the trusted CA" \
2848 -S "The certificate has been revoked (is on a CRL)"
2849
2850run_test "SNI: CA override" \
2851 "$P_SRV debug_level=3 auth_mode=optional \
2852 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2853 ca_file=data_files/test-ca.crt \
2854 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2855 "$P_CLI debug_level=3 server_name=localhost \
2856 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2857 0 \
2858 -S "skip write certificate request" \
2859 -C "skip parse certificate request" \
2860 -c "got a certificate request" \
2861 -C "skip write certificate" \
2862 -C "skip write certificate verify" \
2863 -S "skip parse certificate verify" \
2864 -S "x509_verify_cert() returned" \
2865 -S "! The certificate is not correctly signed by the trusted CA" \
2866 -S "The certificate has been revoked (is on a CRL)"
2867
2868run_test "SNI: CA override with CRL" \
2869 "$P_SRV debug_level=3 auth_mode=optional \
2870 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2871 ca_file=data_files/test-ca.crt \
2872 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2873 "$P_CLI debug_level=3 server_name=localhost \
2874 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2875 1 \
2876 -S "skip write certificate request" \
2877 -C "skip parse certificate request" \
2878 -c "got a certificate request" \
2879 -C "skip write certificate" \
2880 -C "skip write certificate verify" \
2881 -S "skip parse certificate verify" \
2882 -s "x509_verify_cert() returned" \
2883 -S "! The certificate is not correctly signed by the trusted CA" \
2884 -s "The certificate has been revoked (is on a CRL)"
2885
Andres AGe8b07742016-12-07 10:01:30 +00002886# Tests for SNI and DTLS
2887
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002888run_test "SNI: DTLS, no SNI callback" \
2889 "$P_SRV debug_level=3 dtls=1 \
2890 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2891 "$P_CLI server_name=localhost dtls=1" \
2892 0 \
2893 -S "parse ServerName extension" \
2894 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2895 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2896
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002897run_test "SNI: DTLS, matching cert 1" \
Andres AGe8b07742016-12-07 10:01:30 +00002898 "$P_SRV debug_level=3 dtls=1 \
2899 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2900 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2901 "$P_CLI server_name=localhost dtls=1" \
2902 0 \
2903 -s "parse ServerName extension" \
2904 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2905 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2906
Andres Amaya Garciaf9519bf2018-05-01 20:27:37 +01002907run_test "SNI: DTLS, matching cert 2" \
2908 "$P_SRV debug_level=3 dtls=1 \
2909 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2910 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2911 "$P_CLI server_name=polarssl.example dtls=1" \
2912 0 \
2913 -s "parse ServerName extension" \
2914 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2915 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2916
2917run_test "SNI: DTLS, no matching cert" \
2918 "$P_SRV debug_level=3 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,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2921 "$P_CLI server_name=nonesuch.example dtls=1" \
2922 1 \
2923 -s "parse ServerName extension" \
2924 -s "ssl_sni_wrapper() returned" \
2925 -s "mbedtls_ssl_handshake returned" \
2926 -c "mbedtls_ssl_handshake returned" \
2927 -c "SSL - A fatal alert message was received from our peer"
2928
2929run_test "SNI: DTLS, client auth no override: optional" \
2930 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2931 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2932 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2933 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2934 0 \
2935 -S "skip write certificate request" \
2936 -C "skip parse certificate request" \
2937 -c "got a certificate request" \
2938 -C "skip write certificate" \
2939 -C "skip write certificate verify" \
2940 -S "skip parse certificate verify"
2941
2942run_test "SNI: DTLS, client auth override: none -> optional" \
2943 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2944 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2945 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2946 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2947 0 \
2948 -S "skip write certificate request" \
2949 -C "skip parse certificate request" \
2950 -c "got a certificate request" \
2951 -C "skip write certificate" \
2952 -C "skip write certificate verify" \
2953 -S "skip parse certificate verify"
2954
2955run_test "SNI: DTLS, client auth override: optional -> none" \
2956 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2957 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2958 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2959 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2960 0 \
2961 -s "skip write certificate request" \
2962 -C "skip parse certificate request" \
2963 -c "got no certificate request" \
2964 -c "skip write certificate" \
2965 -c "skip write certificate verify" \
2966 -s "skip parse certificate verify"
2967
2968run_test "SNI: DTLS, CA no override" \
2969 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2970 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2971 ca_file=data_files/test-ca.crt \
2972 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2973 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2974 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2975 1 \
2976 -S "skip write certificate request" \
2977 -C "skip parse certificate request" \
2978 -c "got a certificate request" \
2979 -C "skip write certificate" \
2980 -C "skip write certificate verify" \
2981 -S "skip parse certificate verify" \
2982 -s "x509_verify_cert() returned" \
2983 -s "! The certificate is not correctly signed by the trusted CA" \
2984 -S "The certificate has been revoked (is on a CRL)"
2985
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01002986run_test "SNI: DTLS, CA override" \
Andres AGe8b07742016-12-07 10:01:30 +00002987 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2988 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2989 ca_file=data_files/test-ca.crt \
2990 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2991 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2992 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2993 0 \
2994 -S "skip write certificate request" \
2995 -C "skip parse certificate request" \
2996 -c "got a certificate request" \
2997 -C "skip write certificate" \
2998 -C "skip write certificate verify" \
2999 -S "skip parse certificate verify" \
3000 -S "x509_verify_cert() returned" \
3001 -S "! The certificate is not correctly signed by the trusted CA" \
3002 -S "The certificate has been revoked (is on a CRL)"
3003
Andres Amaya Garcia914eea42018-05-01 20:26:47 +01003004run_test "SNI: DTLS, CA override with CRL" \
Andres AGe8b07742016-12-07 10:01:30 +00003005 "$P_SRV debug_level=3 auth_mode=optional \
3006 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3007 ca_file=data_files/test-ca.crt \
3008 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3009 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3010 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3011 1 \
3012 -S "skip write certificate request" \
3013 -C "skip parse certificate request" \
3014 -c "got a certificate request" \
3015 -C "skip write certificate" \
3016 -C "skip write certificate verify" \
3017 -S "skip parse certificate verify" \
3018 -s "x509_verify_cert() returned" \
3019 -S "! The certificate is not correctly signed by the trusted CA" \
3020 -s "The certificate has been revoked (is on a CRL)"
3021
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003022# Tests for non-blocking I/O: exercise a variety of handshake flows
3023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003024run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003025 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3026 "$P_CLI nbio=2 tickets=0" \
3027 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003028 -S "mbedtls_ssl_handshake returned" \
3029 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003030 -c "Read from server: .* bytes read"
3031
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003032run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003033 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3034 "$P_CLI nbio=2 tickets=0" \
3035 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003036 -S "mbedtls_ssl_handshake returned" \
3037 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003038 -c "Read from server: .* bytes read"
3039
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003040run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003041 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3042 "$P_CLI nbio=2 tickets=1" \
3043 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003044 -S "mbedtls_ssl_handshake returned" \
3045 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003046 -c "Read from server: .* bytes read"
3047
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003048run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003049 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3050 "$P_CLI nbio=2 tickets=1" \
3051 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003052 -S "mbedtls_ssl_handshake returned" \
3053 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003054 -c "Read from server: .* bytes read"
3055
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003056run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003057 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3058 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3059 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003060 -S "mbedtls_ssl_handshake returned" \
3061 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003062 -c "Read from server: .* bytes read"
3063
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003064run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003065 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3066 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3067 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003068 -S "mbedtls_ssl_handshake returned" \
3069 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003070 -c "Read from server: .* bytes read"
3071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003072run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003073 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3074 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3075 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003076 -S "mbedtls_ssl_handshake returned" \
3077 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003078 -c "Read from server: .* bytes read"
3079
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003080# Tests for version negotiation
3081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003082run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003083 "$P_SRV" \
3084 "$P_CLI" \
3085 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003086 -S "mbedtls_ssl_handshake returned" \
3087 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003088 -s "Protocol is TLSv1.2" \
3089 -c "Protocol is TLSv1.2"
3090
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003091run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003092 "$P_SRV" \
3093 "$P_CLI max_version=tls1_1" \
3094 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003095 -S "mbedtls_ssl_handshake returned" \
3096 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003097 -s "Protocol is TLSv1.1" \
3098 -c "Protocol is TLSv1.1"
3099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003100run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003101 "$P_SRV max_version=tls1_1" \
3102 "$P_CLI" \
3103 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003104 -S "mbedtls_ssl_handshake returned" \
3105 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003106 -s "Protocol is TLSv1.1" \
3107 -c "Protocol is TLSv1.1"
3108
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003109run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003110 "$P_SRV max_version=tls1_1" \
3111 "$P_CLI max_version=tls1_1" \
3112 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003113 -S "mbedtls_ssl_handshake returned" \
3114 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003115 -s "Protocol is TLSv1.1" \
3116 -c "Protocol is TLSv1.1"
3117
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003118run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003119 "$P_SRV min_version=tls1_1" \
3120 "$P_CLI max_version=tls1_1" \
3121 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003122 -S "mbedtls_ssl_handshake returned" \
3123 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003124 -s "Protocol is TLSv1.1" \
3125 -c "Protocol is TLSv1.1"
3126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003127run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003128 "$P_SRV max_version=tls1_1" \
3129 "$P_CLI min_version=tls1_1" \
3130 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003131 -S "mbedtls_ssl_handshake returned" \
3132 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003133 -s "Protocol is TLSv1.1" \
3134 -c "Protocol is TLSv1.1"
3135
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003136run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003137 "$P_SRV max_version=tls1_1" \
3138 "$P_CLI min_version=tls1_2" \
3139 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003140 -s "mbedtls_ssl_handshake returned" \
3141 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003142 -c "SSL - Handshake protocol not within min/max boundaries"
3143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003144run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003145 "$P_SRV min_version=tls1_2" \
3146 "$P_CLI max_version=tls1_1" \
3147 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003148 -s "mbedtls_ssl_handshake returned" \
3149 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003150 -s "SSL - Handshake protocol not within min/max boundaries"
3151
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003152# Tests for ALPN extension
3153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003154run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003155 "$P_SRV debug_level=3" \
3156 "$P_CLI debug_level=3" \
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" \
3164 -S "Application Layer Protocol is"
3165
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003166run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003167 "$P_SRV debug_level=3" \
3168 "$P_CLI debug_level=3 alpn=abc,1234" \
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 (none)" \
3176 -S "Application Layer Protocol is"
3177
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003178run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003179 "$P_SRV debug_level=3 alpn=abc,1234" \
3180 "$P_CLI debug_level=3" \
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" \
3188 -s "Application Layer Protocol is (none)"
3189
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003190run_test "ALPN: both, common cli1-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=abc,1234" \
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 cli2-srv1" \
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,abc" \
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 abc" \
3212 -s "Application Layer Protocol is abc"
3213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003214run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003215 "$P_SRV debug_level=3 alpn=abc,1234" \
3216 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003217 0 \
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é-Gonnard8e03c712014-08-30 21:42:40 +02003226run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003227 "$P_SRV debug_level=3 alpn=abc,123" \
3228 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003229 1 \
3230 -c "client hello, adding alpn extension" \
3231 -s "found alpn extension" \
3232 -c "got an alert message, type: \\[2:120]" \
3233 -S "server hello, adding alpn extension" \
3234 -C "found alpn extension" \
3235 -C "Application Layer Protocol is 1234" \
3236 -S "Application Layer Protocol is 1234"
3237
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003238
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003239# Tests for keyUsage in leaf certificates, part 1:
3240# server-side certificate/suite selection
3241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003242run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003243 "$P_SRV key_file=data_files/server2.key \
3244 crt_file=data_files/server2.ku-ds.crt" \
3245 "$P_CLI" \
3246 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003247 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003248
3249
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003250run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003251 "$P_SRV key_file=data_files/server2.key \
3252 crt_file=data_files/server2.ku-ke.crt" \
3253 "$P_CLI" \
3254 0 \
3255 -c "Ciphersuite is TLS-RSA-WITH-"
3256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003257run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003258 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003259 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003260 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003261 1 \
3262 -C "Ciphersuite is "
3263
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003264run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003265 "$P_SRV key_file=data_files/server5.key \
3266 crt_file=data_files/server5.ku-ds.crt" \
3267 "$P_CLI" \
3268 0 \
3269 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3270
3271
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003272run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003273 "$P_SRV key_file=data_files/server5.key \
3274 crt_file=data_files/server5.ku-ka.crt" \
3275 "$P_CLI" \
3276 0 \
3277 -c "Ciphersuite is TLS-ECDH-"
3278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003279run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003280 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003281 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003282 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003283 1 \
3284 -C "Ciphersuite is "
3285
3286# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003287# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003288
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003289run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003290 "$O_SRV -key data_files/server2.key \
3291 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003292 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003293 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3294 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003295 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003296 -C "Processing of the Certificate handshake message failed" \
3297 -c "Ciphersuite is TLS-"
3298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003299run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003300 "$O_SRV -key data_files/server2.key \
3301 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003302 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003303 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3304 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003305 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003306 -C "Processing of the Certificate handshake message failed" \
3307 -c "Ciphersuite is TLS-"
3308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003309run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003310 "$O_SRV -key data_files/server2.key \
3311 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003312 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003313 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3314 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003315 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003316 -C "Processing of the Certificate handshake message failed" \
3317 -c "Ciphersuite is TLS-"
3318
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003319run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003320 "$O_SRV -key data_files/server2.key \
3321 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003322 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003323 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3324 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003325 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003326 -c "Processing of the Certificate handshake message failed" \
3327 -C "Ciphersuite is TLS-"
3328
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003329run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3330 "$O_SRV -key data_files/server2.key \
3331 -cert data_files/server2.ku-ke.crt" \
3332 "$P_CLI debug_level=1 auth_mode=optional \
3333 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3334 0 \
3335 -c "bad certificate (usage extensions)" \
3336 -C "Processing of the Certificate handshake message failed" \
3337 -c "Ciphersuite is TLS-" \
3338 -c "! Usage does not match the keyUsage extension"
3339
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003340run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003341 "$O_SRV -key data_files/server2.key \
3342 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003343 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003344 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3345 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003346 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003347 -C "Processing of the Certificate handshake message failed" \
3348 -c "Ciphersuite is TLS-"
3349
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003350run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003351 "$O_SRV -key data_files/server2.key \
3352 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003353 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003354 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3355 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003356 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003357 -c "Processing of the Certificate handshake message failed" \
3358 -C "Ciphersuite is TLS-"
3359
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003360run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3361 "$O_SRV -key data_files/server2.key \
3362 -cert data_files/server2.ku-ds.crt" \
3363 "$P_CLI debug_level=1 auth_mode=optional \
3364 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3365 0 \
3366 -c "bad certificate (usage extensions)" \
3367 -C "Processing of the Certificate handshake message failed" \
3368 -c "Ciphersuite is TLS-" \
3369 -c "! Usage does not match the keyUsage extension"
3370
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003371# Tests for keyUsage in leaf certificates, part 3:
3372# server-side checking of client cert
3373
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003374run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003375 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003376 "$O_CLI -key data_files/server2.key \
3377 -cert data_files/server2.ku-ds.crt" \
3378 0 \
3379 -S "bad certificate (usage extensions)" \
3380 -S "Processing of the Certificate handshake message failed"
3381
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003382run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003383 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003384 "$O_CLI -key data_files/server2.key \
3385 -cert data_files/server2.ku-ke.crt" \
3386 0 \
3387 -s "bad certificate (usage extensions)" \
3388 -S "Processing of the Certificate handshake message failed"
3389
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003390run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003391 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003392 "$O_CLI -key data_files/server2.key \
3393 -cert data_files/server2.ku-ke.crt" \
3394 1 \
3395 -s "bad certificate (usage extensions)" \
3396 -s "Processing of the Certificate handshake message failed"
3397
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003398run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003399 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003400 "$O_CLI -key data_files/server5.key \
3401 -cert data_files/server5.ku-ds.crt" \
3402 0 \
3403 -S "bad certificate (usage extensions)" \
3404 -S "Processing of the Certificate handshake message failed"
3405
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003406run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003407 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003408 "$O_CLI -key data_files/server5.key \
3409 -cert data_files/server5.ku-ka.crt" \
3410 0 \
3411 -s "bad certificate (usage extensions)" \
3412 -S "Processing of the Certificate handshake message failed"
3413
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003414# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003416run_test "extKeyUsage srv: serverAuth -> 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-srv.crt" \
3419 "$P_CLI" \
3420 0
3421
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003422run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003423 "$P_SRV key_file=data_files/server5.key \
3424 crt_file=data_files/server5.eku-srv.crt" \
3425 "$P_CLI" \
3426 0
3427
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003428run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003429 "$P_SRV key_file=data_files/server5.key \
3430 crt_file=data_files/server5.eku-cs_any.crt" \
3431 "$P_CLI" \
3432 0
3433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003434run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003435 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003436 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003437 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003438 1
3439
3440# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3441
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003442run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003443 "$O_SRV -key data_files/server5.key \
3444 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003445 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003446 0 \
3447 -C "bad certificate (usage extensions)" \
3448 -C "Processing of the Certificate handshake message failed" \
3449 -c "Ciphersuite is TLS-"
3450
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003451run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003452 "$O_SRV -key data_files/server5.key \
3453 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003454 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003455 0 \
3456 -C "bad certificate (usage extensions)" \
3457 -C "Processing of the Certificate handshake message failed" \
3458 -c "Ciphersuite is TLS-"
3459
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003460run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003461 "$O_SRV -key data_files/server5.key \
3462 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003463 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003464 0 \
3465 -C "bad certificate (usage extensions)" \
3466 -C "Processing of the Certificate handshake message failed" \
3467 -c "Ciphersuite is TLS-"
3468
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003469run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003470 "$O_SRV -key data_files/server5.key \
3471 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003472 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003473 1 \
3474 -c "bad certificate (usage extensions)" \
3475 -c "Processing of the Certificate handshake message failed" \
3476 -C "Ciphersuite is TLS-"
3477
3478# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3479
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003480run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003481 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003482 "$O_CLI -key data_files/server5.key \
3483 -cert data_files/server5.eku-cli.crt" \
3484 0 \
3485 -S "bad certificate (usage extensions)" \
3486 -S "Processing of the Certificate handshake message failed"
3487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003488run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003489 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003490 "$O_CLI -key data_files/server5.key \
3491 -cert data_files/server5.eku-srv_cli.crt" \
3492 0 \
3493 -S "bad certificate (usage extensions)" \
3494 -S "Processing of the Certificate handshake message failed"
3495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003496run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003497 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003498 "$O_CLI -key data_files/server5.key \
3499 -cert data_files/server5.eku-cs_any.crt" \
3500 0 \
3501 -S "bad certificate (usage extensions)" \
3502 -S "Processing of the Certificate handshake message failed"
3503
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003504run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003505 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003506 "$O_CLI -key data_files/server5.key \
3507 -cert data_files/server5.eku-cs.crt" \
3508 0 \
3509 -s "bad certificate (usage extensions)" \
3510 -S "Processing of the Certificate handshake message failed"
3511
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003512run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003513 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003514 "$O_CLI -key data_files/server5.key \
3515 -cert data_files/server5.eku-cs.crt" \
3516 1 \
3517 -s "bad certificate (usage extensions)" \
3518 -s "Processing of the Certificate handshake message failed"
3519
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003520# Tests for DHM parameters loading
3521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003522run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003523 "$P_SRV" \
3524 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3525 debug_level=3" \
3526 0 \
3527 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003528 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003530run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003531 "$P_SRV dhm_file=data_files/dhparams.pem" \
3532 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3533 debug_level=3" \
3534 0 \
3535 -c "value of 'DHM: P ' (1024 bits)" \
3536 -c "value of 'DHM: G ' (2 bits)"
3537
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003538# Tests for DHM client-side size checking
3539
3540run_test "DHM size: server default, client default, OK" \
3541 "$P_SRV" \
3542 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3543 debug_level=1" \
3544 0 \
3545 -C "DHM prime too short:"
3546
3547run_test "DHM size: server default, client 2048, OK" \
3548 "$P_SRV" \
3549 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3550 debug_level=1 dhmlen=2048" \
3551 0 \
3552 -C "DHM prime too short:"
3553
3554run_test "DHM size: server 1024, client default, OK" \
3555 "$P_SRV dhm_file=data_files/dhparams.pem" \
3556 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3557 debug_level=1" \
3558 0 \
3559 -C "DHM prime too short:"
3560
3561run_test "DHM size: server 1000, client default, rejected" \
3562 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3563 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3564 debug_level=1" \
3565 1 \
3566 -c "DHM prime too short:"
3567
3568run_test "DHM size: server default, client 2049, rejected" \
3569 "$P_SRV" \
3570 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3571 debug_level=1 dhmlen=2049" \
3572 1 \
3573 -c "DHM prime too short:"
3574
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003575# Tests for PSK callback
3576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003577run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003578 "$P_SRV psk=abc123 psk_identity=foo" \
3579 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3580 psk_identity=foo psk=abc123" \
3581 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003582 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003583 -S "SSL - Unknown identity received" \
3584 -S "SSL - Verification of the message MAC failed"
3585
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003586run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003587 "$P_SRV" \
3588 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3589 psk_identity=foo psk=abc123" \
3590 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003591 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003592 -S "SSL - Unknown identity received" \
3593 -S "SSL - Verification of the message MAC failed"
3594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003595run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003596 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3597 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3598 psk_identity=foo psk=abc123" \
3599 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003600 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003601 -s "SSL - Unknown identity received" \
3602 -S "SSL - Verification of the message MAC failed"
3603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003604run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003605 "$P_SRV psk_list=abc,dead,def,beef" \
3606 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3607 psk_identity=abc psk=dead" \
3608 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003609 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003610 -S "SSL - Unknown identity received" \
3611 -S "SSL - Verification of the message MAC failed"
3612
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003613run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003614 "$P_SRV psk_list=abc,dead,def,beef" \
3615 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3616 psk_identity=def psk=beef" \
3617 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003618 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003619 -S "SSL - Unknown identity received" \
3620 -S "SSL - Verification of the message MAC failed"
3621
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003622run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003623 "$P_SRV psk_list=abc,dead,def,beef" \
3624 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3625 psk_identity=ghi psk=beef" \
3626 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003627 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003628 -s "SSL - Unknown identity received" \
3629 -S "SSL - Verification of the message MAC failed"
3630
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003631run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003632 "$P_SRV psk_list=abc,dead,def,beef" \
3633 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3634 psk_identity=abc psk=beef" \
3635 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003636 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003637 -S "SSL - Unknown identity received" \
3638 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003639
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003640# Tests for EC J-PAKE
3641
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003642requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003643run_test "ECJPAKE: client not configured" \
3644 "$P_SRV debug_level=3" \
3645 "$P_CLI debug_level=3" \
3646 0 \
3647 -C "add ciphersuite: c0ff" \
3648 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003649 -S "found ecjpake kkpp extension" \
3650 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003651 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003652 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003653 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003654 -S "None of the common ciphersuites is usable"
3655
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003656requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003657run_test "ECJPAKE: server not configured" \
3658 "$P_SRV debug_level=3" \
3659 "$P_CLI debug_level=3 ecjpake_pw=bla \
3660 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3661 1 \
3662 -c "add ciphersuite: c0ff" \
3663 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003664 -s "found ecjpake kkpp extension" \
3665 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003666 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003667 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003668 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003669 -s "None of the common ciphersuites is usable"
3670
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003671requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003672run_test "ECJPAKE: working, TLS" \
3673 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3674 "$P_CLI debug_level=3 ecjpake_pw=bla \
3675 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003676 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003677 -c "add ciphersuite: c0ff" \
3678 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003679 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003680 -s "found ecjpake kkpp extension" \
3681 -S "skip ecjpake kkpp extension" \
3682 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003683 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003684 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003685 -S "None of the common ciphersuites is usable" \
3686 -S "SSL - Verification of the message MAC failed"
3687
Janos Follath74537a62016-09-02 13:45:28 +01003688server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003689requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003690run_test "ECJPAKE: password mismatch, TLS" \
3691 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3692 "$P_CLI debug_level=3 ecjpake_pw=bad \
3693 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3694 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003695 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003696 -s "SSL - Verification of the message MAC failed"
3697
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003698requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003699run_test "ECJPAKE: working, DTLS" \
3700 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3701 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3702 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3703 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003704 -c "re-using cached ecjpake parameters" \
3705 -S "SSL - Verification of the message MAC failed"
3706
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003707requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003708run_test "ECJPAKE: working, DTLS, no cookie" \
3709 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3710 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3711 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3712 0 \
3713 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003714 -S "SSL - Verification of the message MAC failed"
3715
Janos Follath74537a62016-09-02 13:45:28 +01003716server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003717requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003718run_test "ECJPAKE: password mismatch, DTLS" \
3719 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3720 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3721 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3722 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003723 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003724 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003725
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003726# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003727requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003728run_test "ECJPAKE: working, DTLS, nolog" \
3729 "$P_SRV dtls=1 ecjpake_pw=bla" \
3730 "$P_CLI dtls=1 ecjpake_pw=bla \
3731 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3732 0
3733
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003734# Tests for ciphersuites per version
3735
Janos Follathe2681a42016-03-07 15:57:05 +00003736requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003737requires_config_enabled MBEDTLS_CAMELLIA_C
3738requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003739run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003740 "$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 +02003741 "$P_CLI force_version=ssl3" \
3742 0 \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003743 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003744
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003745requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
3746requires_config_enabled MBEDTLS_CAMELLIA_C
3747requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003748run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003749 "$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 +01003750 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003751 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003752 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003753
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003754requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
3755requires_config_enabled MBEDTLS_CAMELLIA_C
3756requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003757run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003758 "$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 +02003759 "$P_CLI force_version=tls1_1" \
3760 0 \
3761 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3762
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003763requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
3764requires_config_enabled MBEDTLS_CAMELLIA_C
3765requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003766run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnarda82d38d2019-03-01 10:14:58 +01003767 "$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 +02003768 "$P_CLI force_version=tls1_2" \
3769 0 \
3770 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3771
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003772# Test for ClientHello without extensions
3773
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003774requires_gnutls
Manuel Pégourié-Gonnard37abf122020-01-30 12:45:14 +01003775run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnarda92990a2020-01-30 11:19:45 +01003776 "$P_SRV debug_level=3" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003777 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3778 0 \
3779 -s "dumping 'client hello extensions' (0 bytes)"
3780
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003781# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003782
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003783run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003784 "$P_SRV" \
3785 "$P_CLI request_size=100" \
3786 0 \
3787 -s "Read from client: 100 bytes read$"
3788
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003789run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003790 "$P_SRV" \
3791 "$P_CLI request_size=500" \
3792 0 \
3793 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003794
Andrzej Kurekd731a632018-06-19 09:37:30 -04003795# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003796
Janos Follathe2681a42016-03-07 15:57:05 +00003797requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekd731a632018-06-19 09:37:30 -04003798run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003799 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003800 "$P_CLI request_size=1 force_version=ssl3 \
3801 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3802 0 \
3803 -s "Read from client: 1 bytes read"
3804
Janos Follathe2681a42016-03-07 15:57:05 +00003805requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekd731a632018-06-19 09:37:30 -04003806run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003807 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003808 "$P_CLI request_size=1 force_version=ssl3 \
3809 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3810 0 \
3811 -s "Read from client: 1 bytes read"
3812
Andrzej Kurekd731a632018-06-19 09:37:30 -04003813run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003814 "$P_SRV" \
3815 "$P_CLI request_size=1 force_version=tls1 \
3816 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3817 0 \
3818 -s "Read from client: 1 bytes read"
3819
Andrzej Kurekd731a632018-06-19 09:37:30 -04003820run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003821 "$P_SRV" \
3822 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3823 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3824 0 \
3825 -s "Read from client: 1 bytes read"
3826
Hanno Becker32c55012017-11-10 08:42:54 +00003827requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003828run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003829 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003830 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003831 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003832 0 \
3833 -s "Read from client: 1 bytes read"
3834
Hanno Becker32c55012017-11-10 08:42:54 +00003835requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003836run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003837 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003838 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003839 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003840 0 \
3841 -s "Read from client: 1 bytes read"
3842
Andrzej Kurekd731a632018-06-19 09:37:30 -04003843run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003844 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003845 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00003846 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3847 0 \
3848 -s "Read from client: 1 bytes read"
3849
Andrzej Kurekd731a632018-06-19 09:37:30 -04003850run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00003851 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3852 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003853 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003854 0 \
3855 -s "Read from client: 1 bytes read"
3856
3857requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003858run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003859 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003860 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003861 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003862 0 \
3863 -s "Read from client: 1 bytes read"
3864
Hanno Becker8501f982017-11-10 08:59:04 +00003865requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003866run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003867 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3868 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3869 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003870 0 \
3871 -s "Read from client: 1 bytes read"
3872
Andrzej Kurekd731a632018-06-19 09:37:30 -04003873run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003874 "$P_SRV" \
3875 "$P_CLI request_size=1 force_version=tls1_1 \
3876 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3877 0 \
3878 -s "Read from client: 1 bytes read"
3879
Andrzej Kurekd731a632018-06-19 09:37:30 -04003880run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003881 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003882 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003883 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003884 0 \
3885 -s "Read from client: 1 bytes read"
3886
3887requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003888run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003889 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003890 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003891 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003892 0 \
3893 -s "Read from client: 1 bytes read"
3894
3895requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003896run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003897 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003898 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003899 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003900 0 \
3901 -s "Read from client: 1 bytes read"
3902
Andrzej Kurekd731a632018-06-19 09:37:30 -04003903run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003904 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003905 "$P_CLI request_size=1 force_version=tls1_1 \
3906 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3907 0 \
3908 -s "Read from client: 1 bytes read"
3909
Andrzej Kurekd731a632018-06-19 09:37:30 -04003910run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00003911 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003912 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003913 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003914 0 \
3915 -s "Read from client: 1 bytes read"
3916
Hanno Becker8501f982017-11-10 08:59:04 +00003917requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003918run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003919 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003920 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003921 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003922 0 \
3923 -s "Read from client: 1 bytes read"
3924
Hanno Becker32c55012017-11-10 08:42:54 +00003925requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003926run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003927 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003928 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003929 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003930 0 \
3931 -s "Read from client: 1 bytes read"
3932
Andrzej Kurekd731a632018-06-19 09:37:30 -04003933run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003934 "$P_SRV" \
3935 "$P_CLI request_size=1 force_version=tls1_2 \
3936 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3937 0 \
3938 -s "Read from client: 1 bytes read"
3939
Andrzej Kurekd731a632018-06-19 09:37:30 -04003940run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003941 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00003942 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003943 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003944 0 \
3945 -s "Read from client: 1 bytes read"
3946
Andrzej Kurekd731a632018-06-19 09:37:30 -04003947run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003948 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003949 "$P_CLI request_size=1 force_version=tls1_2 \
3950 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003951 0 \
3952 -s "Read from client: 1 bytes read"
3953
Hanno Becker32c55012017-11-10 08:42:54 +00003954requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003955run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003956 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003957 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003958 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003959 0 \
3960 -s "Read from client: 1 bytes read"
3961
Hanno Becker8501f982017-11-10 08:59:04 +00003962requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003963run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003964 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003965 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003966 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003967 0 \
3968 -s "Read from client: 1 bytes read"
3969
Andrzej Kurekd731a632018-06-19 09:37:30 -04003970run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003971 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003972 "$P_CLI request_size=1 force_version=tls1_2 \
3973 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3974 0 \
3975 -s "Read from client: 1 bytes read"
3976
Andrzej Kurekd731a632018-06-19 09:37:30 -04003977run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003978 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003979 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003980 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00003981 0 \
3982 -s "Read from client: 1 bytes read"
3983
Hanno Becker32c55012017-11-10 08:42:54 +00003984requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003985run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003986 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003987 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003988 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003989 0 \
3990 -s "Read from client: 1 bytes read"
3991
Hanno Becker8501f982017-11-10 08:59:04 +00003992requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04003993run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00003994 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00003995 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00003996 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003997 0 \
3998 -s "Read from client: 1 bytes read"
3999
Andrzej Kurekd731a632018-06-19 09:37:30 -04004000run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004001 "$P_SRV" \
4002 "$P_CLI request_size=1 force_version=tls1_2 \
4003 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4004 0 \
4005 -s "Read from client: 1 bytes read"
4006
Andrzej Kurekd731a632018-06-19 09:37:30 -04004007run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004008 "$P_SRV" \
4009 "$P_CLI request_size=1 force_version=tls1_2 \
4010 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4011 0 \
4012 -s "Read from client: 1 bytes read"
4013
Andrzej Kurekd731a632018-06-19 09:37:30 -04004014# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004015
4016requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004017run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004018 "$P_SRV dtls=1 force_version=dtls1" \
4019 "$P_CLI dtls=1 request_size=1 \
4020 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4021 0 \
4022 -s "Read from client: 1 bytes read"
4023
4024requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004025run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004026 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4027 "$P_CLI dtls=1 request_size=1 \
4028 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4029 0 \
4030 -s "Read from client: 1 bytes read"
4031
4032requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4033requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004034run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004035 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4036 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004037 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4038 0 \
4039 -s "Read from client: 1 bytes read"
4040
4041requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4042requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004043run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004044 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004045 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004046 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004047 0 \
4048 -s "Read from client: 1 bytes read"
4049
4050requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004051run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004052 "$P_SRV dtls=1 force_version=dtls1_2" \
4053 "$P_CLI dtls=1 request_size=1 \
4054 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4055 0 \
4056 -s "Read from client: 1 bytes read"
4057
4058requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekd731a632018-06-19 09:37:30 -04004059run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004060 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004061 "$P_CLI dtls=1 request_size=1 \
4062 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4063 0 \
4064 -s "Read from client: 1 bytes read"
4065
4066requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4067requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004068run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004069 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004070 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004071 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004072 0 \
4073 -s "Read from client: 1 bytes read"
4074
4075requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4076requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004077run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004078 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004079 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004080 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004081 0 \
4082 -s "Read from client: 1 bytes read"
4083
Andrzej Kurekd731a632018-06-19 09:37:30 -04004084# Tests for small server packets
4085
4086requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4087run_test "Small server packet SSLv3 BlockCipher" \
4088 "$P_SRV response_size=1 min_version=ssl3" \
4089 "$P_CLI force_version=ssl3 \
4090 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4091 0 \
4092 -c "Read from server: 1 bytes read"
4093
4094requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4095run_test "Small server packet SSLv3 StreamCipher" \
4096 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4097 "$P_CLI force_version=ssl3 \
4098 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4099 0 \
4100 -c "Read from server: 1 bytes read"
4101
4102run_test "Small server packet TLS 1.0 BlockCipher" \
4103 "$P_SRV response_size=1" \
4104 "$P_CLI force_version=tls1 \
4105 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4106 0 \
4107 -c "Read from server: 1 bytes read"
4108
4109run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4110 "$P_SRV response_size=1" \
4111 "$P_CLI force_version=tls1 etm=0 \
4112 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4113 0 \
4114 -c "Read from server: 1 bytes read"
4115
4116requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4117run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4118 "$P_SRV response_size=1 trunc_hmac=1" \
4119 "$P_CLI force_version=tls1 \
4120 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4121 0 \
4122 -c "Read from server: 1 bytes read"
4123
4124requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4125run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4126 "$P_SRV response_size=1 trunc_hmac=1" \
4127 "$P_CLI force_version=tls1 \
4128 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4129 0 \
4130 -c "Read from server: 1 bytes read"
4131
4132run_test "Small server packet TLS 1.0 StreamCipher" \
4133 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4134 "$P_CLI force_version=tls1 \
4135 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4136 0 \
4137 -c "Read from server: 1 bytes read"
4138
4139run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4140 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4141 "$P_CLI force_version=tls1 \
4142 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4143 0 \
4144 -c "Read from server: 1 bytes read"
4145
4146requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4147run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4148 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4149 "$P_CLI force_version=tls1 \
4150 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4151 0 \
4152 -c "Read from server: 1 bytes read"
4153
4154requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4155run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4156 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4157 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4158 trunc_hmac=1 etm=0" \
4159 0 \
4160 -c "Read from server: 1 bytes read"
4161
4162run_test "Small server packet TLS 1.1 BlockCipher" \
4163 "$P_SRV response_size=1" \
4164 "$P_CLI force_version=tls1_1 \
4165 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4166 0 \
4167 -c "Read from server: 1 bytes read"
4168
4169run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4170 "$P_SRV response_size=1" \
4171 "$P_CLI force_version=tls1_1 \
4172 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4173 0 \
4174 -c "Read from server: 1 bytes read"
4175
4176requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4177run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4178 "$P_SRV response_size=1 trunc_hmac=1" \
4179 "$P_CLI force_version=tls1_1 \
4180 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4181 0 \
4182 -c "Read from server: 1 bytes read"
4183
4184requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4185run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4186 "$P_SRV response_size=1 trunc_hmac=1" \
4187 "$P_CLI force_version=tls1_1 \
4188 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4189 0 \
4190 -c "Read from server: 1 bytes read"
4191
4192run_test "Small server packet TLS 1.1 StreamCipher" \
4193 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4194 "$P_CLI force_version=tls1_1 \
4195 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4196 0 \
4197 -c "Read from server: 1 bytes read"
4198
4199run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4200 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4201 "$P_CLI force_version=tls1_1 \
4202 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4203 0 \
4204 -c "Read from server: 1 bytes read"
4205
4206requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4207run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4208 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4209 "$P_CLI force_version=tls1_1 \
4210 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4211 0 \
4212 -c "Read from server: 1 bytes read"
4213
4214requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4215run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4216 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4217 "$P_CLI force_version=tls1_1 \
4218 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4219 0 \
4220 -c "Read from server: 1 bytes read"
4221
4222run_test "Small server packet TLS 1.2 BlockCipher" \
4223 "$P_SRV response_size=1" \
4224 "$P_CLI force_version=tls1_2 \
4225 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4226 0 \
4227 -c "Read from server: 1 bytes read"
4228
4229run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4230 "$P_SRV response_size=1" \
4231 "$P_CLI force_version=tls1_2 \
4232 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4233 0 \
4234 -c "Read from server: 1 bytes read"
4235
4236run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4237 "$P_SRV response_size=1" \
4238 "$P_CLI force_version=tls1_2 \
4239 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4240 0 \
4241 -c "Read from server: 1 bytes read"
4242
4243requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4244run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4245 "$P_SRV response_size=1 trunc_hmac=1" \
4246 "$P_CLI force_version=tls1_2 \
4247 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4248 0 \
4249 -c "Read from server: 1 bytes read"
4250
4251requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4252run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4253 "$P_SRV response_size=1 trunc_hmac=1" \
4254 "$P_CLI force_version=tls1_2 \
4255 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4256 0 \
4257 -c "Read from server: 1 bytes read"
4258
4259run_test "Small server packet TLS 1.2 StreamCipher" \
4260 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4261 "$P_CLI force_version=tls1_2 \
4262 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4263 0 \
4264 -c "Read from server: 1 bytes read"
4265
4266run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4267 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4268 "$P_CLI force_version=tls1_2 \
4269 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4270 0 \
4271 -c "Read from server: 1 bytes read"
4272
4273requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4274run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4275 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4276 "$P_CLI force_version=tls1_2 \
4277 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4278 0 \
4279 -c "Read from server: 1 bytes read"
4280
4281requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4282run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4283 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4284 "$P_CLI force_version=tls1_2 \
4285 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4286 0 \
4287 -c "Read from server: 1 bytes read"
4288
4289run_test "Small server packet TLS 1.2 AEAD" \
4290 "$P_SRV response_size=1" \
4291 "$P_CLI force_version=tls1_2 \
4292 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4293 0 \
4294 -c "Read from server: 1 bytes read"
4295
4296run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4297 "$P_SRV response_size=1" \
4298 "$P_CLI force_version=tls1_2 \
4299 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4300 0 \
4301 -c "Read from server: 1 bytes read"
4302
4303# Tests for small server packets in DTLS
4304
4305requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4306run_test "Small server packet DTLS 1.0" \
4307 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4308 "$P_CLI dtls=1 \
4309 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4310 0 \
4311 -c "Read from server: 1 bytes read"
4312
4313requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4314run_test "Small server packet DTLS 1.0, without EtM" \
4315 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4316 "$P_CLI dtls=1 \
4317 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4318 0 \
4319 -c "Read from server: 1 bytes read"
4320
4321requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4322requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4323run_test "Small server packet DTLS 1.0, truncated hmac" \
4324 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4325 "$P_CLI dtls=1 trunc_hmac=1 \
4326 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4327 0 \
4328 -c "Read from server: 1 bytes read"
4329
4330requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4331requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4332run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4333 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4334 "$P_CLI dtls=1 \
4335 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4336 0 \
4337 -c "Read from server: 1 bytes read"
4338
4339requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4340run_test "Small server packet DTLS 1.2" \
4341 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4342 "$P_CLI dtls=1 \
4343 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4344 0 \
4345 -c "Read from server: 1 bytes read"
4346
4347requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4348run_test "Small server packet DTLS 1.2, without EtM" \
4349 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4350 "$P_CLI dtls=1 \
4351 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4352 0 \
4353 -c "Read from server: 1 bytes read"
4354
4355requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4356requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4357run_test "Small server packet DTLS 1.2, truncated hmac" \
4358 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4359 "$P_CLI dtls=1 \
4360 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4361 0 \
4362 -c "Read from server: 1 bytes read"
4363
4364requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4365requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4366run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4367 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4368 "$P_CLI dtls=1 \
4369 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4370 0 \
4371 -c "Read from server: 1 bytes read"
4372
Janos Follath00efff72016-05-06 13:48:23 +01004373# A test for extensions in SSLv3
4374
4375requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4376run_test "SSLv3 with extensions, server side" \
4377 "$P_SRV min_version=ssl3 debug_level=3" \
4378 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4379 0 \
4380 -S "dumping 'client hello extensions'" \
4381 -S "server hello, total extension length:"
4382
Andrzej Kurek557335e2018-06-28 04:03:10 -04004383# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004384
Janos Follathe2681a42016-03-07 15:57:05 +00004385requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek557335e2018-06-28 04:03:10 -04004386run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004387 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004388 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004389 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4390 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004391 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004392 -s "Read from client: 16384 bytes read"
4393
Janos Follathe2681a42016-03-07 15:57:05 +00004394requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek557335e2018-06-28 04:03:10 -04004395run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004396 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004397 "$P_CLI request_size=16384 force_version=ssl3 \
4398 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4399 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004400 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004401 -s "Read from client: 16384 bytes read"
4402
Andrzej Kurek557335e2018-06-28 04:03:10 -04004403run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004404 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004405 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004406 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4407 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004408 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004409 -s "Read from client: 16384 bytes read"
4410
Andrzej Kurek557335e2018-06-28 04:03:10 -04004411run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004412 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004413 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4414 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4415 0 \
4416 -s "Read from client: 16384 bytes read"
4417
Hanno Becker32c55012017-11-10 08:42:54 +00004418requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004419run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004420 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004421 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004422 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004423 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004424 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004425 -s "Read from client: 16384 bytes read"
4426
Hanno Becker32c55012017-11-10 08:42:54 +00004427requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004428run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004429 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004430 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004431 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004432 0 \
4433 -s "Read from client: 16384 bytes read"
4434
Andrzej Kurek557335e2018-06-28 04:03:10 -04004435run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004436 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004437 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004438 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4439 0 \
4440 -s "Read from client: 16384 bytes read"
4441
Andrzej Kurek557335e2018-06-28 04:03:10 -04004442run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004443 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4444 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004445 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004446 0 \
4447 -s "Read from client: 16384 bytes read"
4448
4449requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004450run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004451 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004452 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004453 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004454 0 \
4455 -s "Read from client: 16384 bytes read"
4456
Hanno Becker278fc7a2017-11-10 09:16:28 +00004457requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004458run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004459 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004460 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004461 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004462 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004463 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004464 -s "Read from client: 16384 bytes read"
4465
Andrzej Kurek557335e2018-06-28 04:03:10 -04004466run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004467 "$P_SRV" \
4468 "$P_CLI request_size=16384 force_version=tls1_1 \
4469 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4470 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004471 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004472 -s "Read from client: 16384 bytes read"
4473
Andrzej Kurek557335e2018-06-28 04:03:10 -04004474run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004475 "$P_SRV" \
4476 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4477 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004478 0 \
4479 -s "Read from client: 16384 bytes read"
4480
Hanno Becker32c55012017-11-10 08:42:54 +00004481requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004482run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004483 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004484 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004485 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004486 0 \
4487 -s "Read from client: 16384 bytes read"
4488
Hanno Becker32c55012017-11-10 08:42:54 +00004489requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004490run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004491 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004492 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004493 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004494 0 \
4495 -s "Read from client: 16384 bytes read"
4496
Andrzej Kurek557335e2018-06-28 04:03:10 -04004497run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004498 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4499 "$P_CLI request_size=16384 force_version=tls1_1 \
4500 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4501 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004502 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004503 -s "Read from client: 16384 bytes read"
4504
Andrzej Kurek557335e2018-06-28 04:03:10 -04004505run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004506 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004507 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004508 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004509 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004510 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004511 -s "Read from client: 16384 bytes read"
4512
Hanno Becker278fc7a2017-11-10 09:16:28 +00004513requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004514run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004515 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004516 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004517 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004518 0 \
4519 -s "Read from client: 16384 bytes read"
4520
Hanno Becker278fc7a2017-11-10 09:16:28 +00004521requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004522run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004523 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004524 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004525 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004526 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004527 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004528 -s "Read from client: 16384 bytes read"
4529
Andrzej Kurek557335e2018-06-28 04:03:10 -04004530run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004531 "$P_SRV" \
4532 "$P_CLI request_size=16384 force_version=tls1_2 \
4533 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4534 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004535 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004536 -s "Read from client: 16384 bytes read"
4537
Andrzej Kurek557335e2018-06-28 04:03:10 -04004538run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004539 "$P_SRV" \
4540 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4541 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4542 0 \
4543 -s "Read from client: 16384 bytes read"
4544
Andrzej Kurek557335e2018-06-28 04:03:10 -04004545run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004546 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004547 "$P_CLI request_size=16384 force_version=tls1_2 \
4548 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004549 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004550 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004551 -s "Read from client: 16384 bytes read"
4552
Hanno Becker32c55012017-11-10 08:42:54 +00004553requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004554run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004555 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004556 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004557 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004558 0 \
4559 -s "Read from client: 16384 bytes read"
4560
Hanno Becker278fc7a2017-11-10 09:16:28 +00004561requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004562run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004563 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004564 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004565 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004566 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004567 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004568 -s "Read from client: 16384 bytes read"
4569
Andrzej Kurek557335e2018-06-28 04:03:10 -04004570run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004571 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004572 "$P_CLI request_size=16384 force_version=tls1_2 \
4573 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4574 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004575 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004576 -s "Read from client: 16384 bytes read"
4577
Andrzej Kurek557335e2018-06-28 04:03:10 -04004578run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004579 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004580 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004581 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4582 0 \
4583 -s "Read from client: 16384 bytes read"
4584
Hanno Becker32c55012017-11-10 08:42:54 +00004585requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004586run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004587 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004588 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004589 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004590 0 \
4591 -s "Read from client: 16384 bytes read"
4592
Hanno Becker278fc7a2017-11-10 09:16:28 +00004593requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004594run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004595 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004596 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004597 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004598 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004599 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004600 -s "Read from client: 16384 bytes read"
4601
Andrzej Kurek557335e2018-06-28 04:03:10 -04004602run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004603 "$P_SRV" \
4604 "$P_CLI request_size=16384 force_version=tls1_2 \
4605 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4606 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004607 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004608 -s "Read from client: 16384 bytes read"
4609
Andrzej Kurek557335e2018-06-28 04:03:10 -04004610run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004611 "$P_SRV" \
4612 "$P_CLI request_size=16384 force_version=tls1_2 \
4613 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4614 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01004615 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004616 -s "Read from client: 16384 bytes read"
4617
Ron Eldorc7f15232018-06-28 13:22:05 +03004618# Tests for ECC extensions (rfc 4492)
4619
Ron Eldor94226d82018-06-28 16:17:00 +03004620requires_config_enabled MBEDTLS_AES_C
4621requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4622requires_config_enabled MBEDTLS_SHA256_C
4623requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004624run_test "Force a non ECC ciphersuite in the client side" \
4625 "$P_SRV debug_level=3" \
Ron Eldor94226d82018-06-28 16:17:00 +03004626 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004627 0 \
4628 -C "client hello, adding supported_elliptic_curves extension" \
4629 -C "client hello, adding supported_point_formats extension" \
4630 -S "found supported elliptic curves extension" \
4631 -S "found supported point formats extension"
4632
Ron Eldor94226d82018-06-28 16:17:00 +03004633requires_config_enabled MBEDTLS_AES_C
4634requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4635requires_config_enabled MBEDTLS_SHA256_C
4636requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004637run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor94226d82018-06-28 16:17:00 +03004638 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorc7f15232018-06-28 13:22:05 +03004639 "$P_CLI debug_level=3" \
4640 0 \
4641 -C "found supported_point_formats extension" \
4642 -S "server hello, supported_point_formats extension"
4643
Ron Eldor94226d82018-06-28 16:17:00 +03004644requires_config_enabled MBEDTLS_AES_C
4645requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4646requires_config_enabled MBEDTLS_SHA256_C
4647requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004648run_test "Force an ECC ciphersuite in the client side" \
4649 "$P_SRV debug_level=3" \
4650 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4651 0 \
4652 -c "client hello, adding supported_elliptic_curves extension" \
4653 -c "client hello, adding supported_point_formats extension" \
4654 -s "found supported elliptic curves extension" \
4655 -s "found supported point formats extension"
4656
Ron Eldor94226d82018-06-28 16:17:00 +03004657requires_config_enabled MBEDTLS_AES_C
4658requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
4659requires_config_enabled MBEDTLS_SHA256_C
4660requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorc7f15232018-06-28 13:22:05 +03004661run_test "Force an ECC ciphersuite in the server side" \
4662 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
4663 "$P_CLI debug_level=3" \
4664 0 \
4665 -c "found supported_point_formats extension" \
4666 -s "server hello, supported_point_formats extension"
4667
Andrzej Kurek557335e2018-06-28 04:03:10 -04004668# Test for large server packets
Andrzej Kurek557335e2018-06-28 04:03:10 -04004669requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4670run_test "Large server packet SSLv3 StreamCipher" \
4671 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4672 "$P_CLI force_version=ssl3 \
4673 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4674 0 \
4675 -c "Read from server: 16384 bytes read"
4676
Andrzej Kurekc8958212018-08-27 08:00:13 -04004677# Checking next 4 tests logs for 1n-1 split against BEAST too
4678requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4679run_test "Large server packet SSLv3 BlockCipher" \
4680 "$P_SRV response_size=16384 min_version=ssl3" \
4681 "$P_CLI force_version=ssl3 recsplit=0 \
4682 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4683 0 \
4684 -c "Read from server: 1 bytes read"\
4685 -c "16383 bytes read"\
4686 -C "Read from server: 16384 bytes read"
4687
Andrzej Kurek557335e2018-06-28 04:03:10 -04004688run_test "Large server packet TLS 1.0 BlockCipher" \
4689 "$P_SRV response_size=16384" \
4690 "$P_CLI force_version=tls1 recsplit=0 \
4691 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4692 0 \
4693 -c "Read from server: 1 bytes read"\
4694 -c "16383 bytes read"\
4695 -C "Read from server: 16384 bytes read"
4696
Andrzej Kurekd731a632018-06-19 09:37:30 -04004697run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
4698 "$P_SRV response_size=16384" \
4699 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
4700 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4701 0 \
4702 -c "Read from server: 1 bytes read"\
4703 -c "16383 bytes read"\
4704 -C "Read from server: 16384 bytes read"
4705
Andrzej Kurek557335e2018-06-28 04:03:10 -04004706requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4707run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
4708 "$P_SRV response_size=16384" \
4709 "$P_CLI force_version=tls1 recsplit=0 \
4710 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4711 trunc_hmac=1" \
4712 0 \
4713 -c "Read from server: 1 bytes read"\
4714 -c "16383 bytes read"\
4715 -C "Read from server: 16384 bytes read"
4716
4717requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4718run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
4719 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4720 "$P_CLI force_version=tls1 \
4721 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4722 trunc_hmac=1" \
4723 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004724 -s "16384 bytes written in 1 fragments" \
4725 -c "Read from server: 16384 bytes read"
4726
4727run_test "Large server packet TLS 1.0 StreamCipher" \
4728 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4729 "$P_CLI force_version=tls1 \
4730 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4731 0 \
4732 -s "16384 bytes written in 1 fragments" \
4733 -c "Read from server: 16384 bytes read"
4734
4735run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
4736 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4737 "$P_CLI force_version=tls1 \
4738 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4739 0 \
4740 -s "16384 bytes written in 1 fragments" \
4741 -c "Read from server: 16384 bytes read"
4742
4743requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4744run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
4745 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4746 "$P_CLI force_version=tls1 \
4747 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4748 0 \
4749 -s "16384 bytes written in 1 fragments" \
4750 -c "Read from server: 16384 bytes read"
4751
4752requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4753run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4754 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4755 "$P_CLI force_version=tls1 \
4756 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4757 0 \
4758 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004759 -c "Read from server: 16384 bytes read"
4760
4761run_test "Large server packet TLS 1.1 BlockCipher" \
4762 "$P_SRV response_size=16384" \
4763 "$P_CLI force_version=tls1_1 \
4764 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4765 0 \
4766 -c "Read from server: 16384 bytes read"
4767
Andrzej Kurekd731a632018-06-19 09:37:30 -04004768run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
4769 "$P_SRV response_size=16384" \
4770 "$P_CLI force_version=tls1_1 etm=0 \
4771 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004772 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004773 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004774 -c "Read from server: 16384 bytes read"
4775
4776requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4777run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
4778 "$P_SRV response_size=16384" \
4779 "$P_CLI force_version=tls1_1 \
4780 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4781 trunc_hmac=1" \
4782 0 \
4783 -c "Read from server: 16384 bytes read"
4784
4785requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekd731a632018-06-19 09:37:30 -04004786run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4787 "$P_SRV response_size=16384 trunc_hmac=1" \
4788 "$P_CLI force_version=tls1_1 \
4789 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4790 0 \
4791 -s "16384 bytes written in 1 fragments" \
4792 -c "Read from server: 16384 bytes read"
4793
4794run_test "Large server packet TLS 1.1 StreamCipher" \
4795 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4796 "$P_CLI force_version=tls1_1 \
4797 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4798 0 \
4799 -c "Read from server: 16384 bytes read"
4800
4801run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
4802 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4803 "$P_CLI force_version=tls1_1 \
4804 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4805 0 \
4806 -s "16384 bytes written in 1 fragments" \
4807 -c "Read from server: 16384 bytes read"
4808
4809requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek557335e2018-06-28 04:03:10 -04004810run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
4811 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4812 "$P_CLI force_version=tls1_1 \
4813 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4814 trunc_hmac=1" \
4815 0 \
4816 -c "Read from server: 16384 bytes read"
4817
Andrzej Kurekd731a632018-06-19 09:37:30 -04004818run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4819 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4820 "$P_CLI force_version=tls1_1 \
4821 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4822 0 \
4823 -s "16384 bytes written in 1 fragments" \
4824 -c "Read from server: 16384 bytes read"
4825
Andrzej Kurek557335e2018-06-28 04:03:10 -04004826run_test "Large server packet TLS 1.2 BlockCipher" \
4827 "$P_SRV response_size=16384" \
4828 "$P_CLI force_version=tls1_2 \
4829 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4830 0 \
4831 -c "Read from server: 16384 bytes read"
4832
Andrzej Kurekd731a632018-06-19 09:37:30 -04004833run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
4834 "$P_SRV response_size=16384" \
4835 "$P_CLI force_version=tls1_2 etm=0 \
4836 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4837 0 \
4838 -s "16384 bytes written in 1 fragments" \
4839 -c "Read from server: 16384 bytes read"
4840
Andrzej Kurek557335e2018-06-28 04:03:10 -04004841run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
4842 "$P_SRV response_size=16384" \
4843 "$P_CLI force_version=tls1_2 \
4844 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4845 0 \
4846 -c "Read from server: 16384 bytes read"
4847
4848requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4849run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
4850 "$P_SRV response_size=16384" \
4851 "$P_CLI force_version=tls1_2 \
4852 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
4853 trunc_hmac=1" \
4854 0 \
4855 -c "Read from server: 16384 bytes read"
4856
Andrzej Kurekd731a632018-06-19 09:37:30 -04004857run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4858 "$P_SRV response_size=16384 trunc_hmac=1" \
4859 "$P_CLI force_version=tls1_2 \
4860 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4861 0 \
4862 -s "16384 bytes written in 1 fragments" \
4863 -c "Read from server: 16384 bytes read"
4864
Andrzej Kurek557335e2018-06-28 04:03:10 -04004865run_test "Large server packet TLS 1.2 StreamCipher" \
4866 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4867 "$P_CLI force_version=tls1_2 \
4868 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4869 0 \
Andrzej Kurekd731a632018-06-19 09:37:30 -04004870 -s "16384 bytes written in 1 fragments" \
4871 -c "Read from server: 16384 bytes read"
4872
4873run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
4874 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4875 "$P_CLI force_version=tls1_2 \
4876 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4877 0 \
4878 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek557335e2018-06-28 04:03:10 -04004879 -c "Read from server: 16384 bytes read"
4880
4881requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4882run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
4883 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4884 "$P_CLI force_version=tls1_2 \
4885 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4886 trunc_hmac=1" \
4887 0 \
4888 -c "Read from server: 16384 bytes read"
4889
Andrzej Kurekd731a632018-06-19 09:37:30 -04004890requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4891run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4892 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4893 "$P_CLI force_version=tls1_2 \
4894 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4895 0 \
4896 -s "16384 bytes written in 1 fragments" \
4897 -c "Read from server: 16384 bytes read"
4898
Andrzej Kurek557335e2018-06-28 04:03:10 -04004899run_test "Large server packet TLS 1.2 AEAD" \
4900 "$P_SRV response_size=16384" \
4901 "$P_CLI force_version=tls1_2 \
4902 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4903 0 \
4904 -c "Read from server: 16384 bytes read"
4905
4906run_test "Large server packet TLS 1.2 AEAD shorter tag" \
4907 "$P_SRV response_size=16384" \
4908 "$P_CLI force_version=tls1_2 \
4909 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4910 0 \
4911 -c "Read from server: 16384 bytes read"
4912
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004913# Tests for DTLS HelloVerifyRequest
4914
4915run_test "DTLS cookie: enabled" \
4916 "$P_SRV dtls=1 debug_level=2" \
4917 "$P_CLI dtls=1 debug_level=2" \
4918 0 \
4919 -s "cookie verification failed" \
4920 -s "cookie verification passed" \
4921 -S "cookie verification skipped" \
4922 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004923 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004924 -S "SSL - The requested feature is not available"
4925
4926run_test "DTLS cookie: disabled" \
4927 "$P_SRV dtls=1 debug_level=2 cookies=0" \
4928 "$P_CLI dtls=1 debug_level=2" \
4929 0 \
4930 -S "cookie verification failed" \
4931 -S "cookie verification passed" \
4932 -s "cookie verification skipped" \
4933 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004934 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004935 -S "SSL - The requested feature is not available"
4936
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004937run_test "DTLS cookie: default (failing)" \
4938 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
4939 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
4940 1 \
4941 -s "cookie verification failed" \
4942 -S "cookie verification passed" \
4943 -S "cookie verification skipped" \
4944 -C "received hello verify request" \
4945 -S "hello verification requested" \
4946 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004947
4948requires_ipv6
4949run_test "DTLS cookie: enabled, IPv6" \
4950 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
4951 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
4952 0 \
4953 -s "cookie verification failed" \
4954 -s "cookie verification passed" \
4955 -S "cookie verification skipped" \
4956 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004957 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004958 -S "SSL - The requested feature is not available"
4959
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004960run_test "DTLS cookie: enabled, nbio" \
4961 "$P_SRV dtls=1 nbio=2 debug_level=2" \
4962 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4963 0 \
4964 -s "cookie verification failed" \
4965 -s "cookie verification passed" \
4966 -S "cookie verification skipped" \
4967 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02004968 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02004969 -S "SSL - The requested feature is not available"
4970
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004971# Tests for client reconnecting from the same port with DTLS
4972
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004973not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004974run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004975 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4976 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004977 0 \
4978 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004979 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004980 -S "Client initiated reconnection from same port"
4981
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004982not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004983run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004984 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
4985 "$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 +02004986 0 \
4987 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004988 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004989 -s "Client initiated reconnection from same port"
4990
Paul Bakker362689d2016-05-13 10:33:25 +01004991not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
4992run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004993 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
4994 "$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 +02004995 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02004996 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02004997 -s "Client initiated reconnection from same port"
4998
Paul Bakker362689d2016-05-13 10:33:25 +01004999only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5000run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5001 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5002 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5003 0 \
5004 -S "The operation timed out" \
5005 -s "Client initiated reconnection from same port"
5006
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005007run_test "DTLS client reconnect from same port: no cookies" \
5008 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005009 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5010 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005011 -s "The operation timed out" \
5012 -S "Client initiated reconnection from same port"
5013
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005014# Tests for various cases of client authentication with DTLS
5015# (focused on handshake flows and message parsing)
5016
5017run_test "DTLS client auth: required" \
5018 "$P_SRV dtls=1 auth_mode=required" \
5019 "$P_CLI dtls=1" \
5020 0 \
5021 -s "Verifying peer X.509 certificate... ok"
5022
5023run_test "DTLS client auth: optional, client has no cert" \
5024 "$P_SRV dtls=1 auth_mode=optional" \
5025 "$P_CLI dtls=1 crt_file=none key_file=none" \
5026 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005027 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005028
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005029run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005030 "$P_SRV dtls=1 auth_mode=none" \
5031 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5032 0 \
5033 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005034 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005035
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005036run_test "DTLS wrong PSK: badmac alert" \
5037 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5038 "$P_CLI dtls=1 psk=abc124" \
5039 1 \
5040 -s "SSL - Verification of the message MAC failed" \
5041 -c "SSL - A fatal alert message was received from our peer"
5042
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005043# Tests for receiving fragmented handshake messages with DTLS
5044
5045requires_gnutls
5046run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5047 "$G_SRV -u --mtu 2048 -a" \
5048 "$P_CLI dtls=1 debug_level=2" \
5049 0 \
5050 -C "found fragmented DTLS handshake message" \
5051 -C "error"
5052
5053requires_gnutls
5054run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5055 "$G_SRV -u --mtu 512" \
5056 "$P_CLI dtls=1 debug_level=2" \
5057 0 \
5058 -c "found fragmented DTLS handshake message" \
5059 -C "error"
5060
5061requires_gnutls
5062run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5063 "$G_SRV -u --mtu 128" \
5064 "$P_CLI dtls=1 debug_level=2" \
5065 0 \
5066 -c "found fragmented DTLS handshake message" \
5067 -C "error"
5068
5069requires_gnutls
5070run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
5071 "$G_SRV -u --mtu 128" \
5072 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5073 0 \
5074 -c "found fragmented DTLS handshake message" \
5075 -C "error"
5076
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005077requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005078requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005079run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
5080 "$G_SRV -u --mtu 256" \
5081 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
5082 0 \
5083 -c "found fragmented DTLS handshake message" \
5084 -c "client hello, adding renegotiation extension" \
5085 -c "found renegotiation extension" \
5086 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005087 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005088 -C "error" \
5089 -s "Extra-header:"
5090
5091requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005092requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005093run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
5094 "$G_SRV -u --mtu 256" \
5095 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
5096 0 \
5097 -c "found fragmented DTLS handshake message" \
5098 -c "client hello, adding renegotiation extension" \
5099 -c "found renegotiation extension" \
5100 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005101 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005102 -C "error" \
5103 -s "Extra-header:"
5104
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005105run_test "DTLS reassembly: no fragmentation (openssl server)" \
5106 "$O_SRV -dtls1 -mtu 2048" \
5107 "$P_CLI dtls=1 debug_level=2" \
5108 0 \
5109 -C "found fragmented DTLS handshake message" \
5110 -C "error"
5111
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005112run_test "DTLS reassembly: some fragmentation (openssl server)" \
5113 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005114 "$P_CLI dtls=1 debug_level=2" \
5115 0 \
5116 -c "found fragmented DTLS handshake message" \
5117 -C "error"
5118
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005119run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005120 "$O_SRV -dtls1 -mtu 256" \
5121 "$P_CLI dtls=1 debug_level=2" \
5122 0 \
5123 -c "found fragmented DTLS handshake message" \
5124 -C "error"
5125
5126run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
5127 "$O_SRV -dtls1 -mtu 256" \
5128 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5129 0 \
5130 -c "found fragmented DTLS handshake message" \
5131 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005132
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02005133# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02005134
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005135not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005136run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02005137 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005138 "$P_SRV dtls=1 debug_level=2" \
5139 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005140 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005141 -C "replayed record" \
5142 -S "replayed record" \
5143 -C "record from another epoch" \
5144 -S "record from another epoch" \
5145 -C "discarding invalid record" \
5146 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005147 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005148 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005149 -c "HTTP/1.0 200 OK"
5150
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005151not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02005152run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005153 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005154 "$P_SRV dtls=1 debug_level=2" \
5155 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02005156 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02005157 -c "replayed record" \
5158 -s "replayed record" \
Hanno Beckera34cc6b2017-05-26 16:07:36 +01005159 -c "record from another epoch" \
5160 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005161 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005162 -s "Extra-header:" \
5163 -c "HTTP/1.0 200 OK"
5164
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005165run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
5166 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005167 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
5168 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005169 0 \
5170 -c "replayed record" \
5171 -S "replayed record" \
Hanno Beckera34cc6b2017-05-26 16:07:36 +01005172 -c "record from another epoch" \
5173 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02005174 -c "resend" \
5175 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02005176 -s "Extra-header:" \
5177 -c "HTTP/1.0 200 OK"
5178
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005179run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02005180 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005181 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005182 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005183 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005184 -c "discarding invalid record (mac)" \
5185 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005186 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005187 -c "HTTP/1.0 200 OK" \
5188 -S "too many records with bad MAC" \
5189 -S "Verification of the message MAC failed"
5190
5191run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
5192 -p "$P_PXY bad_ad=1" \
5193 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
5194 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
5195 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005196 -C "discarding invalid record (mac)" \
5197 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005198 -S "Extra-header:" \
5199 -C "HTTP/1.0 200 OK" \
5200 -s "too many records with bad MAC" \
5201 -s "Verification of the message MAC failed"
5202
5203run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
5204 -p "$P_PXY bad_ad=1" \
5205 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
5206 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
5207 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005208 -c "discarding invalid record (mac)" \
5209 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005210 -s "Extra-header:" \
5211 -c "HTTP/1.0 200 OK" \
5212 -S "too many records with bad MAC" \
5213 -S "Verification of the message MAC failed"
5214
5215run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
5216 -p "$P_PXY bad_ad=1" \
5217 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
5218 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
5219 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02005220 -c "discarding invalid record (mac)" \
5221 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02005222 -s "Extra-header:" \
5223 -c "HTTP/1.0 200 OK" \
5224 -s "too many records with bad MAC" \
5225 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005226
5227run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005228 -p "$P_PXY delay_ccs=1" \
5229 "$P_SRV dtls=1 debug_level=1" \
5230 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005231 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02005232 -c "record from another epoch" \
5233 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005234 -s "Extra-header:" \
5235 -c "HTTP/1.0 200 OK"
5236
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02005237# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005238
Janos Follath74537a62016-09-02 13:45:28 +01005239client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005240run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005241 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005242 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005243 psk=abc123" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005244 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005245 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5246 0 \
5247 -s "Extra-header:" \
5248 -c "HTTP/1.0 200 OK"
5249
Janos Follath74537a62016-09-02 13:45:28 +01005250client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005251run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
5252 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005253 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none" \
5254 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005255 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5256 0 \
5257 -s "Extra-header:" \
5258 -c "HTTP/1.0 200 OK"
5259
Janos Follath74537a62016-09-02 13:45:28 +01005260client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005261run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
5262 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005263 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none" \
5264 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005265 0 \
5266 -s "Extra-header:" \
5267 -c "HTTP/1.0 200 OK"
5268
Janos Follath74537a62016-09-02 13:45:28 +01005269client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005270run_test "DTLS proxy: 3d, FS, client auth" \
5271 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005272 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=required" \
5273 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005274 0 \
5275 -s "Extra-header:" \
5276 -c "HTTP/1.0 200 OK"
5277
Janos Follath74537a62016-09-02 13:45:28 +01005278client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005279run_test "DTLS proxy: 3d, FS, ticket" \
5280 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005281 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=1 auth_mode=none" \
5282 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005283 0 \
5284 -s "Extra-header:" \
5285 -c "HTTP/1.0 200 OK"
5286
Janos Follath74537a62016-09-02 13:45:28 +01005287client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02005288run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
5289 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005290 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=1 auth_mode=required" \
5291 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005292 0 \
5293 -s "Extra-header:" \
5294 -c "HTTP/1.0 200 OK"
5295
Janos Follath74537a62016-09-02 13:45:28 +01005296client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005297run_test "DTLS proxy: 3d, max handshake, nbio" \
5298 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005299 "$P_SRV dtls=1 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005300 auth_mode=required" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005301 "$P_CLI dtls=1 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005302 0 \
5303 -s "Extra-header:" \
5304 -c "HTTP/1.0 200 OK"
5305
Janos Follath74537a62016-09-02 13:45:28 +01005306client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02005307run_test "DTLS proxy: 3d, min handshake, resumption" \
5308 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005309 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02005310 psk=abc123 debug_level=3" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005311 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01005312 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02005313 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5314 0 \
5315 -s "a session has been resumed" \
5316 -c "a session has been resumed" \
5317 -s "Extra-header:" \
5318 -c "HTTP/1.0 200 OK"
5319
Janos Follath74537a62016-09-02 13:45:28 +01005320client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005321run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
5322 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005323 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005324 psk=abc123 debug_level=3 nbio=2" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005325 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard5e261e92020-02-17 11:04:33 +01005326 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02005327 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
5328 0 \
5329 -s "a session has been resumed" \
5330 -c "a session has been resumed" \
5331 -s "Extra-header:" \
5332 -c "HTTP/1.0 200 OK"
5333
Janos Follath74537a62016-09-02 13:45:28 +01005334client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005335requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005336run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005337 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005338 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005339 psk=abc123 renegotiation=1 debug_level=2" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005340 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005341 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02005342 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5343 0 \
5344 -c "=> renegotiate" \
5345 -s "=> renegotiate" \
5346 -s "Extra-header:" \
5347 -c "HTTP/1.0 200 OK"
5348
Janos Follath74537a62016-09-02 13:45:28 +01005349client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005350requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005351run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
5352 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005353 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005354 psk=abc123 renegotiation=1 debug_level=2" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005355 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02005356 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005357 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5358 0 \
5359 -c "=> renegotiate" \
5360 -s "=> renegotiate" \
5361 -s "Extra-header:" \
5362 -c "HTTP/1.0 200 OK"
5363
Janos Follath74537a62016-09-02 13:45:28 +01005364client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005365requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005366run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005367 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005368 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005369 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005370 debug_level=2" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005371 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005372 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005373 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5374 0 \
5375 -c "=> renegotiate" \
5376 -s "=> renegotiate" \
5377 -s "Extra-header:" \
5378 -c "HTTP/1.0 200 OK"
5379
Janos Follath74537a62016-09-02 13:45:28 +01005380client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01005381requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005382run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005383 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005384 "$P_SRV dtls=1 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005385 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005386 debug_level=2 nbio=2" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005387 "$P_CLI dtls=1 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02005388 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02005389 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
5390 0 \
5391 -c "=> renegotiate" \
5392 -s "=> renegotiate" \
5393 -s "Extra-header:" \
5394 -c "HTTP/1.0 200 OK"
5395
Janos Follath74537a62016-09-02 13:45:28 +01005396client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005397not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005398run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005399 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5400 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005401 "$P_CLI dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005402 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02005403 -c "HTTP/1.0 200 OK"
5404
Janos Follath74537a62016-09-02 13:45:28 +01005405client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005406not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005407run_test "DTLS proxy: 3d, openssl server, fragmentation" \
5408 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5409 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005410 "$P_CLI dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005411 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005412 -c "HTTP/1.0 200 OK"
5413
Janos Follath74537a62016-09-02 13:45:28 +01005414client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005415not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005416run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
5417 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
5418 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005419 "$P_CLI dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005420 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005421 -c "HTTP/1.0 200 OK"
5422
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005423requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005424client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005425not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005426run_test "DTLS proxy: 3d, gnutls server" \
5427 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5428 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005429 "$P_CLI dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005430 0 \
5431 -s "Extra-header:" \
5432 -c "Extra-header:"
5433
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005434requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005435client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005436not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005437run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
5438 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5439 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005440 "$P_CLI dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02005441 0 \
5442 -s "Extra-header:" \
5443 -c "Extra-header:"
5444
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00005445requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01005446client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02005447not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005448run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
5449 -p "$P_PXY drop=5 delay=5 duplicate=5" \
5450 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardaa719e72020-03-03 10:08:15 +01005451 "$P_CLI dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02005452 0 \
5453 -s "Extra-header:" \
5454 -c "Extra-header:"
5455
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01005456# Final report
5457
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005458echo "------------------------------------------------------------------------"
5459
5460if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005461 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005462else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01005463 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005464fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02005465PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02005466echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01005467
5468exit $FAILS