blob: d33cc0f573d181a2591d004bdfe9114011c0ef8a [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02009# Assumes a build with default options.
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010010
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020016: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010017: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020018: ${GNUTLS_CLI:=gnutls-cli}
19: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskine39e29812017-05-16 17:53:03 +020020: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020022O_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 +010023O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020024G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010025G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskine39e29812017-05-16 17:53:03 +020026TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010027
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028TESTS=0
29FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020030SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010031
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000032CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020033
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010035FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020036EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010037
38print_usage() {
39 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010040 printf " -h|--help\tPrint this help.\n"
41 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
42 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
43 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Gilles Peskinebb4aaf12017-11-30 15:56:20 +010044 printf " --seed\tInteger seed value to use for this test run (default: random)\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045}
46
47get_options() {
48 while [ $# -gt 0 ]; do
49 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010050 -f|--filter)
51 shift; FILTER=$1
52 ;;
53 -e|--exclude)
54 shift; EXCLUDE=$1
55 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010056 -m|--memcheck)
57 MEMCHECK=1
58 ;;
Gilles Peskinebb4aaf12017-11-30 15:56:20 +010059 --seed)
60 shift; SEED="$1"
61 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062 -h|--help)
63 print_usage
64 exit 0
65 ;;
66 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020067 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010068 print_usage
69 exit 1
70 ;;
71 esac
72 shift
73 done
74}
75
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010076# skip next test if the flag is not enabled in config.h
77requires_config_enabled() {
78 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +020083# skip next test if the flag is enabled in config.h
84requires_config_disabled() {
85 if grep "^#define $1" $CONFIG_H > /dev/null; then
86 SKIP_NEXT="YES"
87 fi
88}
89
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020090# skip next test if OpenSSL doesn't support FALLBACK_SCSV
91requires_openssl_with_fallback_scsv() {
92 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
93 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
94 then
95 OPENSSL_HAS_FBSCSV="YES"
96 else
97 OPENSSL_HAS_FBSCSV="NO"
98 fi
99 fi
100 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
101 SKIP_NEXT="YES"
102 fi
103}
104
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200105# skip next test if GnuTLS isn't available
106requires_gnutls() {
107 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200108 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200109 GNUTLS_AVAILABLE="YES"
110 else
111 GNUTLS_AVAILABLE="NO"
112 fi
113 fi
114 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
115 SKIP_NEXT="YES"
116 fi
117}
118
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200119# skip next test if IPv6 isn't available on this host
120requires_ipv6() {
121 if [ -z "${HAS_IPV6:-}" ]; then
122 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
123 SRV_PID=$!
124 sleep 1
125 kill $SRV_PID >/dev/null 2>&1
126 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
127 HAS_IPV6="NO"
128 else
129 HAS_IPV6="YES"
130 fi
131 rm -r $SRV_OUT
132 fi
133
134 if [ "$HAS_IPV6" = "NO" ]; then
135 SKIP_NEXT="YES"
136 fi
137}
138
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200139# skip the next test if valgrind is in use
140not_with_valgrind() {
141 if [ "$MEMCHECK" -gt 0 ]; then
142 SKIP_NEXT="YES"
143 fi
144}
145
Paul Bakker3b224ff2016-05-13 10:33:25 +0100146# skip the next test if valgrind is NOT in use
147only_with_valgrind() {
148 if [ "$MEMCHECK" -eq 0 ]; then
149 SKIP_NEXT="YES"
150 fi
151}
152
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200153# multiply the client timeout delay by the given factor for the next test
154needs_more_time() {
155 CLI_DELAY_FACTOR=$1
156}
157
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100158# print_name <name>
159print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100160 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200161 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100162 for i in `seq 1 $LEN`; do printf '.'; done
163 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100164
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200165 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100166}
167
168# fail <message>
169fail() {
170 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100171 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100172
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200173 mv $SRV_OUT o-srv-${TESTS}.log
174 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200175 if [ -n "$PXY_CMD" ]; then
176 mv $PXY_OUT o-pxy-${TESTS}.log
177 fi
178 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100179
Azim Khan341e3782018-03-29 11:04:20 +0100180 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 +0200181 echo " ! server output:"
182 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200183 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200184 echo " ! client output:"
185 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200186 if [ -n "$PXY_CMD" ]; then
187 echo " ! ========================================================"
188 echo " ! proxy output:"
189 cat o-pxy-${TESTS}.log
190 fi
191 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200192 fi
193
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200194 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100195}
196
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100197# is_polar <cmd_line>
198is_polar() {
199 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
200}
201
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200202# openssl s_server doesn't have -www with DTLS
203check_osrv_dtls() {
204 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
205 NEEDS_INPUT=1
206 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
207 else
208 NEEDS_INPUT=0
209 fi
210}
211
212# provide input to commands that need it
213provide_input() {
214 if [ $NEEDS_INPUT -eq 0 ]; then
215 return
216 fi
217
218 while true; do
219 echo "HTTP/1.0 200 OK"
220 sleep 1
221 done
222}
223
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100224# has_mem_err <log_file_name>
225has_mem_err() {
226 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
227 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
228 then
229 return 1 # false: does not have errors
230 else
231 return 0 # true: has errors
232 fi
233}
234
Gilles Peskine684a5172017-12-14 18:58:42 +0100235# Wait for process $2 to be listening on port $1
236if type lsof >/dev/null 2>/dev/null; then
237 wait_server_start() {
238 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200239 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine684a5172017-12-14 18:58:42 +0100240 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200241 else
Gilles Peskine684a5172017-12-14 18:58:42 +0100242 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200243 fi
Gilles Peskine684a5172017-12-14 18:58:42 +0100244 # Make a tight loop, server normally takes less than 1s to start.
245 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
246 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
247 echo "SERVERSTART TIMEOUT"
248 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
249 break
250 fi
251 # Linux and *BSD support decimal arguments to sleep. On other
252 # OSes this may be a tight loop.
253 sleep 0.1 2>/dev/null || true
254 done
255 }
256else
Gilles Peskine784f41c2018-01-08 12:38:15 +0100257 echo "Warning: lsof not available, wait_server_start = sleep $START_DELAY"
Gilles Peskine684a5172017-12-14 18:58:42 +0100258 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200259 sleep "$START_DELAY"
Gilles Peskine684a5172017-12-14 18:58:42 +0100260 }
261fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200262
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200263# wait for client to terminate and set CLI_EXIT
264# must be called right after starting the client
265wait_client_done() {
266 CLI_PID=$!
267
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200268 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
269 CLI_DELAY_FACTOR=1
270
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200271 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200272 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200273
274 wait $CLI_PID
275 CLI_EXIT=$?
276
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200277 kill $DOG_PID >/dev/null 2>&1
278 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200279
280 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
281}
282
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200283# check if the given command uses dtls and sets global variable DTLS
284detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200285 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200286 DTLS=1
287 else
288 DTLS=0
289 fi
290}
291
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200292# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100293# Options: -s pattern pattern that must be present in server output
294# -c pattern pattern that must be present in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100295# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100296# -S pattern pattern that must be absent in server output
297# -C pattern pattern that must be absent in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100298# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100299run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100300 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200301 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100302
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100303 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
304 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200305 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100306 return
307 fi
308
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100309 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100310
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200311 # should we skip?
312 if [ "X$SKIP_NEXT" = "XYES" ]; then
313 SKIP_NEXT="NO"
314 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200315 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200316 return
317 fi
318
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200319 # does this test use a proxy?
320 if [ "X$1" = "X-p" ]; then
321 PXY_CMD="$2"
322 shift 2
323 else
324 PXY_CMD=""
325 fi
326
327 # get commands and client output
328 SRV_CMD="$1"
329 CLI_CMD="$2"
330 CLI_EXPECT="$3"
331 shift 3
332
333 # fix client port
334 if [ -n "$PXY_CMD" ]; then
335 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
336 else
337 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
338 fi
339
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200340 # update DTLS variable
341 detect_dtls "$SRV_CMD"
342
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100343 # prepend valgrind to our commands if active
344 if [ "$MEMCHECK" -gt 0 ]; then
345 if is_polar "$SRV_CMD"; then
346 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
347 fi
348 if is_polar "$CLI_CMD"; then
349 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
350 fi
351 fi
352
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200353 TIMES_LEFT=2
354 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200355 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200356
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200357 # run the commands
358 if [ -n "$PXY_CMD" ]; then
359 echo "$PXY_CMD" > $PXY_OUT
360 $PXY_CMD >> $PXY_OUT 2>&1 &
361 PXY_PID=$!
362 # assume proxy starts faster than server
363 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200364
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200365 check_osrv_dtls
366 echo "$SRV_CMD" > $SRV_OUT
367 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
368 SRV_PID=$!
Gilles Peskine684a5172017-12-14 18:58:42 +0100369 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200370
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200371 echo "$CLI_CMD" > $CLI_OUT
372 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
373 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100374
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200375 # terminate the server (and the proxy)
376 kill $SRV_PID
377 wait $SRV_PID
378 if [ -n "$PXY_CMD" ]; then
379 kill $PXY_PID >/dev/null 2>&1
380 wait $PXY_PID
381 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100382
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200383 # retry only on timeouts
384 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
385 printf "RETRY "
386 else
387 TIMES_LEFT=0
388 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200389 done
390
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100391 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200392 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100393 # expected client exit to incorrectly succeed in case of catastrophic
394 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100395 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200396 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100397 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100398 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100399 return
400 fi
401 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100402 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200403 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100404 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100405 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100406 return
407 fi
408 fi
409
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100410 # check server exit code
411 if [ $? != 0 ]; then
412 fail "server fail"
413 return
414 fi
415
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100416 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100417 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
418 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100419 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200420 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100421 return
422 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100423
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100424 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200425 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100426 while [ $# -gt 0 ]
427 do
428 case $1 in
429 "-s")
Janos Follath6d3e3382016-09-07 15:48:48 +0100430 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
431 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100432 return
433 fi
434 ;;
435
436 "-c")
Janos Follath6d3e3382016-09-07 15:48:48 +0100437 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
438 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100439 return
440 fi
441 ;;
442
443 "-S")
Janos Follath6d3e3382016-09-07 15:48:48 +0100444 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
445 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100446 return
447 fi
448 ;;
449
450 "-C")
Janos Follath6d3e3382016-09-07 15:48:48 +0100451 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
452 fail "pattern '$2' MUST NOT be present in the Client output"
453 return
454 fi
455 ;;
456
457 # The filtering in the following two options (-u and -U) do the following
458 # - ignore valgrind output
459 # - filter out everything but lines right after the pattern occurances
460 # - keep one of each non-unique line
461 # - count how many lines remain
462 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
463 # if there were no duplicates.
464 "-U")
465 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
466 fail "lines following pattern '$2' must be unique in Server output"
467 return
468 fi
469 ;;
470
471 "-u")
472 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
473 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100474 return
475 fi
476 ;;
477
478 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200479 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100480 exit 1
481 esac
482 shift 2
483 done
484
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100485 # check valgrind's results
486 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200487 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100488 fail "Server has memory errors"
489 return
490 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200491 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100492 fail "Client has memory errors"
493 return
494 fi
495 fi
496
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100497 # if we're here, everything is ok
498 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200499 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100500}
501
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100502cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200503 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200504 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
505 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
506 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
507 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100508 exit 1
509}
510
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100511#
512# MAIN
513#
514
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000515if cd $( dirname $0 ); then :; else
516 echo "cd $( dirname $0 ) failed" >&2
517 exit 1
518fi
519
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100520get_options "$@"
521
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100522# sanity checks, avoid an avalanche of errors
523if [ ! -x "$P_SRV" ]; then
524 echo "Command '$P_SRV' is not an executable file"
525 exit 1
526fi
527if [ ! -x "$P_CLI" ]; then
528 echo "Command '$P_CLI' is not an executable file"
529 exit 1
530fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200531if [ ! -x "$P_PXY" ]; then
532 echo "Command '$P_PXY' is not an executable file"
533 exit 1
534fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100535if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
536 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100537 exit 1
538fi
539
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200540# used by watchdog
541MAIN_PID="$$"
542
Manuel Pégourié-Gonnard3f69e542018-01-22 10:22:09 +0100543# We use somewhat arbitrary delays for tests:
544# - how long do we wait for the server to start (when lsof not available)?
545# - how long do we allow for the client to finish?
546# (not to check performance, just to avoid waiting indefinitely)
547# Things are slower with valgrind, so give extra time here.
548#
549# Note: without lsof, there is a trade-off between the running time of this
550# script and the risk of spurious errors because we didn't wait long enough.
551# The watchdog delay on the other hand doesn't affect normal running time of
552# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200553if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard3f69e542018-01-22 10:22:09 +0100554 START_DELAY=6
555 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200556else
Manuel Pégourié-Gonnard3f69e542018-01-22 10:22:09 +0100557 START_DELAY=2
558 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200559fi
Manuel Pégourié-Gonnard3f69e542018-01-22 10:22:09 +0100560
561# some particular tests need more time:
562# - for the client, we multiply the usual watchdog limit by a factor
563# - for the server, we sleep for a number of seconds after the client exits
564# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200565CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200566
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200567# Pick a "unique" server port in the range 10000-19999, and a proxy port
568PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000569PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200570SRV_PORT="1$PORT_BASE"
571PXY_PORT="2$PORT_BASE"
572unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200573
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200574# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000575# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200576P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
577P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Gilles Peskinebb4aaf12017-11-30 15:56:20 +0100578P_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 +0200579O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200580O_CLI="$O_CLI -connect localhost:+SRV_PORT"
581G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000582G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200583
Gilles Peskine35db5ba2017-05-10 10:13:59 +0200584# Allow SHA-1, because many of our test certificates use it
585P_SRV="$P_SRV allow_sha1=1"
586P_CLI="$P_CLI allow_sha1=1"
587
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200588# Also pick a unique name for intermediate files
589SRV_OUT="srv_out.$$"
590CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200591PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200592SESSION="session.$$"
593
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200594SKIP_NEXT="NO"
595
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100596trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100597
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200598# Basic test
599
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200600# Checks that:
601# - things work with all ciphersuites active (used with config-full in all.sh)
602# - the expected (highest security) parameters are selected
603# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200604run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200605 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200606 "$P_CLI" \
607 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200608 -s "Protocol is TLSv1.2" \
609 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
610 -s "client hello v3, signature_algorithm ext: 6" \
611 -s "ECDHE curve: secp521r1" \
612 -S "error" \
613 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200614
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000615run_test "Default, DTLS" \
616 "$P_SRV dtls=1" \
617 "$P_CLI dtls=1" \
618 0 \
619 -s "Protocol is DTLSv1.2" \
620 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
621
Janos Follath6d3e3382016-09-07 15:48:48 +0100622# Test for uniqueness of IVs in AEAD ciphersuites
623run_test "Unique IV in GCM" \
624 "$P_SRV exchanges=20 debug_level=4" \
625 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
626 0 \
627 -u "IV used" \
628 -U "IV used"
629
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100630# Tests for rc4 option
631
Simon Butcher6eb066e2016-05-19 22:12:18 +0100632requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100633run_test "RC4: server disabled, client enabled" \
634 "$P_SRV" \
635 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
636 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100637 -s "SSL - The server has no ciphersuites in common"
638
Simon Butcher6eb066e2016-05-19 22:12:18 +0100639requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100640run_test "RC4: server half, client enabled" \
641 "$P_SRV arc4=1" \
642 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
643 1 \
644 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100645
646run_test "RC4: server enabled, client disabled" \
647 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
648 "$P_CLI" \
649 1 \
650 -s "SSL - The server has no ciphersuites in common"
651
652run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100653 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100654 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
655 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100656 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100657 -S "SSL - The server has no ciphersuites in common"
658
Gilles Peskineae765992017-05-09 15:59:24 +0200659# Tests for SHA-1 support
660
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200661requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200662run_test "SHA-1 forbidden by default in server certificate" \
663 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
664 "$P_CLI debug_level=2 allow_sha1=0" \
665 1 \
666 -c "The certificate is signed with an unacceptable hash"
667
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200668requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
669run_test "SHA-1 forbidden by default in server certificate" \
670 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
671 "$P_CLI debug_level=2 allow_sha1=0" \
672 0
673
Gilles Peskineae765992017-05-09 15:59:24 +0200674run_test "SHA-1 explicitly allowed in server certificate" \
675 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
676 "$P_CLI allow_sha1=1" \
677 0
678
679run_test "SHA-256 allowed by default in server certificate" \
680 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
681 "$P_CLI allow_sha1=0" \
682 0
683
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200684requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200685run_test "SHA-1 forbidden by default in client certificate" \
686 "$P_SRV auth_mode=required allow_sha1=0" \
687 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
688 1 \
689 -s "The certificate is signed with an unacceptable hash"
690
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200691requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
692run_test "SHA-1 forbidden by default in client certificate" \
693 "$P_SRV auth_mode=required allow_sha1=0" \
694 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
695 0
696
Gilles Peskineae765992017-05-09 15:59:24 +0200697run_test "SHA-1 explicitly allowed in client certificate" \
698 "$P_SRV auth_mode=required allow_sha1=1" \
699 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
700 0
701
702run_test "SHA-256 allowed by default in client certificate" \
703 "$P_SRV auth_mode=required allow_sha1=0" \
704 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
705 0
706
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100707# Tests for Truncated HMAC extension
708
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100709run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200710 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100711 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100712 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000713 -s "dumping 'expected mac' (20 bytes)" \
714 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100715
Hanno Beckera83fafa2017-11-10 08:42:54 +0000716requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100717run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200718 "$P_SRV debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000719 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100720 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000721 -s "dumping 'expected mac' (20 bytes)" \
722 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100723
Hanno Beckera83fafa2017-11-10 08:42:54 +0000724requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100725run_test "Truncated HMAC: client enabled, server default" \
726 "$P_SRV debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000727 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100728 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000729 -s "dumping 'expected mac' (20 bytes)" \
730 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100731
Hanno Beckera83fafa2017-11-10 08:42:54 +0000732requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100733run_test "Truncated HMAC: client enabled, server disabled" \
734 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000735 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100736 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000737 -s "dumping 'expected mac' (20 bytes)" \
738 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100739
Hanno Beckera83fafa2017-11-10 08:42:54 +0000740requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Beckerd51bec72017-11-17 15:46:24 +0000741run_test "Truncated HMAC: client disabled, server enabled" \
742 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000743 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Beckerd51bec72017-11-17 15:46:24 +0000744 0 \
745 -s "dumping 'expected mac' (20 bytes)" \
746 -S "dumping 'expected mac' (10 bytes)"
747
748requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100749run_test "Truncated HMAC: client enabled, server enabled" \
750 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000751 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100752 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000753 -S "dumping 'expected mac' (20 bytes)" \
754 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100755
Hanno Becker02f632e2017-11-10 09:16:05 +0000756run_test "Truncated HMAC, DTLS: client default, server default" \
757 "$P_SRV dtls=1 debug_level=4" \
758 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
759 0 \
760 -s "dumping 'expected mac' (20 bytes)" \
761 -S "dumping 'expected mac' (10 bytes)"
762
763requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
764run_test "Truncated HMAC, DTLS: client disabled, server default" \
765 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000766 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000767 0 \
768 -s "dumping 'expected mac' (20 bytes)" \
769 -S "dumping 'expected mac' (10 bytes)"
770
771requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
772run_test "Truncated HMAC, DTLS: client enabled, server default" \
773 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000774 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000775 0 \
776 -s "dumping 'expected mac' (20 bytes)" \
777 -S "dumping 'expected mac' (10 bytes)"
778
779requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
780run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
781 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000782 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000783 0 \
784 -s "dumping 'expected mac' (20 bytes)" \
785 -S "dumping 'expected mac' (10 bytes)"
786
787requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
788run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
789 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000790 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000791 0 \
792 -s "dumping 'expected mac' (20 bytes)" \
793 -S "dumping 'expected mac' (10 bytes)"
794
795requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
796run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
797 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000798 "$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 +0100799 0 \
800 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100801 -s "dumping 'expected mac' (10 bytes)"
802
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100803# Tests for Encrypt-then-MAC extension
804
805run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100806 "$P_SRV debug_level=3 \
807 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100808 "$P_CLI debug_level=3" \
809 0 \
810 -c "client hello, adding encrypt_then_mac extension" \
811 -s "found encrypt then mac extension" \
812 -s "server hello, adding encrypt then mac extension" \
813 -c "found encrypt_then_mac extension" \
814 -c "using encrypt then mac" \
815 -s "using encrypt then mac"
816
817run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100818 "$P_SRV debug_level=3 etm=0 \
819 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100820 "$P_CLI debug_level=3 etm=1" \
821 0 \
822 -c "client hello, adding encrypt_then_mac extension" \
823 -s "found encrypt then mac extension" \
824 -S "server hello, adding encrypt then mac extension" \
825 -C "found encrypt_then_mac extension" \
826 -C "using encrypt then mac" \
827 -S "using encrypt then mac"
828
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100829run_test "Encrypt then MAC: client enabled, aead cipher" \
830 "$P_SRV debug_level=3 etm=1 \
831 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
832 "$P_CLI debug_level=3 etm=1" \
833 0 \
834 -c "client hello, adding encrypt_then_mac extension" \
835 -s "found encrypt then mac extension" \
836 -S "server hello, adding encrypt then mac extension" \
837 -C "found encrypt_then_mac extension" \
838 -C "using encrypt then mac" \
839 -S "using encrypt then mac"
840
841run_test "Encrypt then MAC: client enabled, stream cipher" \
842 "$P_SRV debug_level=3 etm=1 \
843 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100844 "$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 +0100845 0 \
846 -c "client hello, adding encrypt_then_mac extension" \
847 -s "found encrypt then mac extension" \
848 -S "server hello, adding encrypt then mac extension" \
849 -C "found encrypt_then_mac extension" \
850 -C "using encrypt then mac" \
851 -S "using encrypt then mac"
852
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100853run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100854 "$P_SRV debug_level=3 etm=1 \
855 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100856 "$P_CLI debug_level=3 etm=0" \
857 0 \
858 -C "client hello, adding encrypt_then_mac extension" \
859 -S "found encrypt then mac extension" \
860 -S "server hello, adding encrypt then mac extension" \
861 -C "found encrypt_then_mac extension" \
862 -C "using encrypt then mac" \
863 -S "using encrypt then mac"
864
Janos Follath542ee5d2016-03-07 15:57:05 +0000865requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100866run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100867 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100868 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100869 "$P_CLI debug_level=3 force_version=ssl3" \
870 0 \
871 -C "client hello, adding encrypt_then_mac extension" \
872 -S "found encrypt then mac extension" \
873 -S "server hello, adding encrypt then mac extension" \
874 -C "found encrypt_then_mac extension" \
875 -C "using encrypt then mac" \
876 -S "using encrypt then mac"
877
Janos Follath542ee5d2016-03-07 15:57:05 +0000878requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100879run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100880 "$P_SRV debug_level=3 force_version=ssl3 \
881 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100882 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100883 0 \
884 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100885 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100886 -S "server hello, adding encrypt then mac extension" \
887 -C "found encrypt_then_mac extension" \
888 -C "using encrypt then mac" \
889 -S "using encrypt then mac"
890
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200891# Tests for Extended Master Secret extension
892
893run_test "Extended Master Secret: default" \
894 "$P_SRV debug_level=3" \
895 "$P_CLI debug_level=3" \
896 0 \
897 -c "client hello, adding extended_master_secret extension" \
898 -s "found extended master secret extension" \
899 -s "server hello, adding extended master secret extension" \
900 -c "found extended_master_secret extension" \
901 -c "using extended master secret" \
902 -s "using extended master secret"
903
904run_test "Extended Master Secret: client enabled, server disabled" \
905 "$P_SRV debug_level=3 extended_ms=0" \
906 "$P_CLI debug_level=3 extended_ms=1" \
907 0 \
908 -c "client hello, adding extended_master_secret extension" \
909 -s "found extended master secret extension" \
910 -S "server hello, adding extended master secret extension" \
911 -C "found extended_master_secret extension" \
912 -C "using extended master secret" \
913 -S "using extended master secret"
914
915run_test "Extended Master Secret: client disabled, server enabled" \
916 "$P_SRV debug_level=3 extended_ms=1" \
917 "$P_CLI debug_level=3 extended_ms=0" \
918 0 \
919 -C "client hello, adding extended_master_secret extension" \
920 -S "found extended master secret extension" \
921 -S "server hello, adding extended master secret extension" \
922 -C "found extended_master_secret extension" \
923 -C "using extended master secret" \
924 -S "using extended master secret"
925
Janos Follath542ee5d2016-03-07 15:57:05 +0000926requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200927run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100928 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200929 "$P_CLI debug_level=3 force_version=ssl3" \
930 0 \
931 -C "client hello, adding extended_master_secret extension" \
932 -S "found extended master secret extension" \
933 -S "server hello, adding extended master secret extension" \
934 -C "found extended_master_secret extension" \
935 -C "using extended master secret" \
936 -S "using extended master secret"
937
Janos Follath542ee5d2016-03-07 15:57:05 +0000938requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200939run_test "Extended Master Secret: client enabled, server SSLv3" \
940 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100941 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200942 0 \
943 -c "client hello, adding extended_master_secret extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100944 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200945 -S "server hello, adding extended master secret extension" \
946 -C "found extended_master_secret extension" \
947 -C "using extended master secret" \
948 -S "using extended master secret"
949
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200950# Tests for FALLBACK_SCSV
951
952run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200953 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200954 "$P_CLI debug_level=3 force_version=tls1_1" \
955 0 \
956 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200957 -S "received FALLBACK_SCSV" \
958 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200959 -C "is a fatal alert message (msg 86)"
960
961run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200962 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200963 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
964 0 \
965 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200966 -S "received FALLBACK_SCSV" \
967 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200968 -C "is a fatal alert message (msg 86)"
969
970run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200971 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200972 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200973 1 \
974 -c "adding FALLBACK_SCSV" \
975 -s "received FALLBACK_SCSV" \
976 -s "inapropriate fallback" \
977 -c "is a fatal alert message (msg 86)"
978
979run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200980 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200981 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200982 0 \
983 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200984 -s "received FALLBACK_SCSV" \
985 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200986 -C "is a fatal alert message (msg 86)"
987
988requires_openssl_with_fallback_scsv
989run_test "Fallback SCSV: default, openssl server" \
990 "$O_SRV" \
991 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
992 0 \
993 -C "adding FALLBACK_SCSV" \
994 -C "is a fatal alert message (msg 86)"
995
996requires_openssl_with_fallback_scsv
997run_test "Fallback SCSV: enabled, openssl server" \
998 "$O_SRV" \
999 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1000 1 \
1001 -c "adding FALLBACK_SCSV" \
1002 -c "is a fatal alert message (msg 86)"
1003
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001004requires_openssl_with_fallback_scsv
1005run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001006 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001007 "$O_CLI -tls1_1" \
1008 0 \
1009 -S "received FALLBACK_SCSV" \
1010 -S "inapropriate fallback"
1011
1012requires_openssl_with_fallback_scsv
1013run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001014 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001015 "$O_CLI -tls1_1 -fallback_scsv" \
1016 1 \
1017 -s "received FALLBACK_SCSV" \
1018 -s "inapropriate fallback"
1019
1020requires_openssl_with_fallback_scsv
1021run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001022 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001023 "$O_CLI -fallback_scsv" \
1024 0 \
1025 -s "received FALLBACK_SCSV" \
1026 -S "inapropriate fallback"
1027
Gilles Peskine39e29812017-05-16 17:53:03 +02001028## ClientHello generated with
1029## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1030## then manually twiddling the ciphersuite list.
1031## The ClientHello content is spelled out below as a hex string as
1032## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1033## The expected response is an inappropriate_fallback alert.
1034requires_openssl_with_fallback_scsv
1035run_test "Fallback SCSV: beginning of list" \
1036 "$P_SRV debug_level=2" \
1037 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1038 0 \
1039 -s "received FALLBACK_SCSV" \
1040 -s "inapropriate fallback"
1041
1042requires_openssl_with_fallback_scsv
1043run_test "Fallback SCSV: end of list" \
1044 "$P_SRV debug_level=2" \
1045 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1046 0 \
1047 -s "received FALLBACK_SCSV" \
1048 -s "inapropriate fallback"
1049
1050## Here the expected response is a valid ServerHello prefix, up to the random.
1051requires_openssl_with_fallback_scsv
1052run_test "Fallback SCSV: not in list" \
1053 "$P_SRV debug_level=2" \
1054 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1055 0 \
1056 -S "received FALLBACK_SCSV" \
1057 -S "inapropriate fallback"
1058
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001059# Tests for CBC 1/n-1 record splitting
1060
1061run_test "CBC Record splitting: TLS 1.2, no splitting" \
1062 "$P_SRV" \
1063 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1064 request_size=123 force_version=tls1_2" \
1065 0 \
1066 -s "Read from client: 123 bytes read" \
1067 -S "Read from client: 1 bytes read" \
1068 -S "122 bytes read"
1069
1070run_test "CBC Record splitting: TLS 1.1, no splitting" \
1071 "$P_SRV" \
1072 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1073 request_size=123 force_version=tls1_1" \
1074 0 \
1075 -s "Read from client: 123 bytes read" \
1076 -S "Read from client: 1 bytes read" \
1077 -S "122 bytes read"
1078
1079run_test "CBC Record splitting: TLS 1.0, splitting" \
1080 "$P_SRV" \
1081 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1082 request_size=123 force_version=tls1" \
1083 0 \
1084 -S "Read from client: 123 bytes read" \
1085 -s "Read from client: 1 bytes read" \
1086 -s "122 bytes read"
1087
Janos Follath542ee5d2016-03-07 15:57:05 +00001088requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001089run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001090 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001091 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1092 request_size=123 force_version=ssl3" \
1093 0 \
1094 -S "Read from client: 123 bytes read" \
1095 -s "Read from client: 1 bytes read" \
1096 -s "122 bytes read"
1097
1098run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001099 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001100 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1101 request_size=123 force_version=tls1" \
1102 0 \
1103 -s "Read from client: 123 bytes read" \
1104 -S "Read from client: 1 bytes read" \
1105 -S "122 bytes read"
1106
1107run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1108 "$P_SRV" \
1109 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1110 request_size=123 force_version=tls1 recsplit=0" \
1111 0 \
1112 -s "Read from client: 123 bytes read" \
1113 -S "Read from client: 1 bytes read" \
1114 -S "122 bytes read"
1115
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001116run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1117 "$P_SRV nbio=2" \
1118 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1119 request_size=123 force_version=tls1" \
1120 0 \
1121 -S "Read from client: 123 bytes read" \
1122 -s "Read from client: 1 bytes read" \
1123 -s "122 bytes read"
1124
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001125# Tests for Session Tickets
1126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001127run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001128 "$P_SRV debug_level=3 tickets=1" \
1129 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001130 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001131 -c "client hello, adding session ticket extension" \
1132 -s "found session ticket extension" \
1133 -s "server hello, adding session ticket extension" \
1134 -c "found session_ticket extension" \
1135 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001136 -S "session successfully restored from cache" \
1137 -s "session successfully restored from ticket" \
1138 -s "a session has been resumed" \
1139 -c "a session has been resumed"
1140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001141run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001142 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1143 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001144 0 \
1145 -c "client hello, adding session ticket extension" \
1146 -s "found session ticket extension" \
1147 -s "server hello, adding session ticket extension" \
1148 -c "found session_ticket extension" \
1149 -c "parse new session ticket" \
1150 -S "session successfully restored from cache" \
1151 -s "session successfully restored from ticket" \
1152 -s "a session has been resumed" \
1153 -c "a session has been resumed"
1154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001155run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001156 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1157 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001158 0 \
1159 -c "client hello, adding session ticket extension" \
1160 -s "found session ticket extension" \
1161 -s "server hello, adding session ticket extension" \
1162 -c "found session_ticket extension" \
1163 -c "parse new session ticket" \
1164 -S "session successfully restored from cache" \
1165 -S "session successfully restored from ticket" \
1166 -S "a session has been resumed" \
1167 -C "a session has been resumed"
1168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001169run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001170 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001171 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001172 0 \
1173 -c "client hello, adding session ticket extension" \
1174 -c "found session_ticket extension" \
1175 -c "parse new session ticket" \
1176 -c "a session has been resumed"
1177
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001178run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001179 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001180 "( $O_CLI -sess_out $SESSION; \
1181 $O_CLI -sess_in $SESSION; \
1182 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001183 0 \
1184 -s "found session ticket extension" \
1185 -s "server hello, adding session ticket extension" \
1186 -S "session successfully restored from cache" \
1187 -s "session successfully restored from ticket" \
1188 -s "a session has been resumed"
1189
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001190# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001192run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001193 "$P_SRV debug_level=3 tickets=0" \
1194 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001195 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001196 -c "client hello, adding session ticket extension" \
1197 -s "found session ticket extension" \
1198 -S "server hello, adding session ticket extension" \
1199 -C "found session_ticket extension" \
1200 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001201 -s "session successfully restored from cache" \
1202 -S "session successfully restored from ticket" \
1203 -s "a session has been resumed" \
1204 -c "a session has been resumed"
1205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001206run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001207 "$P_SRV debug_level=3 tickets=1" \
1208 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001209 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001210 -C "client hello, adding session ticket extension" \
1211 -S "found session ticket extension" \
1212 -S "server hello, adding session ticket extension" \
1213 -C "found session_ticket extension" \
1214 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001215 -s "session successfully restored from cache" \
1216 -S "session successfully restored from ticket" \
1217 -s "a session has been resumed" \
1218 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001220run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001221 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1222 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001223 0 \
1224 -S "session successfully restored from cache" \
1225 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001226 -S "a session has been resumed" \
1227 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001229run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001230 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1231 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001232 0 \
1233 -s "session successfully restored from cache" \
1234 -S "session successfully restored from ticket" \
1235 -s "a session has been resumed" \
1236 -c "a session has been resumed"
1237
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001238run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001239 "$P_SRV debug_level=3 tickets=0" \
1240 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001241 0 \
1242 -s "session successfully restored from cache" \
1243 -S "session successfully restored from ticket" \
1244 -s "a session has been resumed" \
1245 -c "a session has been resumed"
1246
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001247run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001248 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1249 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001250 0 \
1251 -S "session successfully restored from cache" \
1252 -S "session successfully restored from ticket" \
1253 -S "a session has been resumed" \
1254 -C "a session has been resumed"
1255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001256run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1258 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001259 0 \
1260 -s "session successfully restored from cache" \
1261 -S "session successfully restored from ticket" \
1262 -s "a session has been resumed" \
1263 -c "a session has been resumed"
1264
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001265run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001266 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001267 "( $O_CLI -sess_out $SESSION; \
1268 $O_CLI -sess_in $SESSION; \
1269 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001270 0 \
1271 -s "found session ticket extension" \
1272 -S "server hello, adding session ticket extension" \
1273 -s "session successfully restored from cache" \
1274 -S "session successfully restored from ticket" \
1275 -s "a session has been resumed"
1276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001277run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001278 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001279 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001280 0 \
1281 -C "found session_ticket extension" \
1282 -C "parse new session ticket" \
1283 -c "a session has been resumed"
1284
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001285# Tests for Max Fragment Length extension
1286
Hanno Becker64691dc2017-09-22 16:58:50 +01001287MAX_CONTENT_LEN_EXPECT='16384'
1288MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1289
1290if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1291 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1292 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1293 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1294 printf "\n"
1295 printf "The tests assume this value and if it changes, the tests in this\n"
1296 printf "script should also be adjusted.\n"
1297 printf "\n"
1298
1299 exit 1
1300fi
1301
Hanno Becker05607782017-09-18 15:00:34 +01001302requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001303run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001304 "$P_SRV debug_level=3" \
1305 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001306 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001307 -c "Maximum fragment length is 16384" \
1308 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001309 -C "client hello, adding max_fragment_length extension" \
1310 -S "found max fragment length extension" \
1311 -S "server hello, max_fragment_length extension" \
1312 -C "found max_fragment_length extension"
1313
Hanno Becker05607782017-09-18 15:00:34 +01001314requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001315run_test "Max fragment length: enabled, default, larger message" \
1316 "$P_SRV debug_level=3" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001317 "$P_CLI debug_level=3 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001318 0 \
1319 -c "Maximum fragment length is 16384" \
1320 -s "Maximum fragment length is 16384" \
1321 -C "client hello, adding max_fragment_length extension" \
1322 -S "found max fragment length extension" \
1323 -S "server hello, max_fragment_length extension" \
1324 -C "found max_fragment_length extension" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001325 -c "16385 bytes written in 2 fragments" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001326 -s "16384 bytes read" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001327 -s "1 bytes read"
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001328
1329requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1330run_test "Max fragment length, DTLS: enabled, default, larger message" \
1331 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001332 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001333 1 \
1334 -c "Maximum fragment length is 16384" \
1335 -s "Maximum fragment length is 16384" \
1336 -C "client hello, adding max_fragment_length extension" \
1337 -S "found max fragment length extension" \
1338 -S "server hello, max_fragment_length extension" \
1339 -C "found max_fragment_length extension" \
1340 -c "fragment larger than.*maximum "
1341
1342requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1343run_test "Max fragment length: disabled, larger message" \
1344 "$P_SRV debug_level=3" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001345 "$P_CLI debug_level=3 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001346 0 \
1347 -C "Maximum fragment length is 16384" \
1348 -S "Maximum fragment length is 16384" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001349 -c "16385 bytes written in 2 fragments" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001350 -s "16384 bytes read" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001351 -s "1 bytes read"
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001352
1353requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1354run_test "Max fragment length DTLS: disabled, larger message" \
1355 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001356 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001357 1 \
1358 -C "Maximum fragment length is 16384" \
1359 -S "Maximum fragment length is 16384" \
1360 -c "fragment larger than.*maximum "
1361
1362requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001363run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001364 "$P_SRV debug_level=3" \
1365 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001366 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001367 -c "Maximum fragment length is 4096" \
1368 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001369 -c "client hello, adding max_fragment_length extension" \
1370 -s "found max fragment length extension" \
1371 -s "server hello, max_fragment_length extension" \
1372 -c "found max_fragment_length extension"
1373
Hanno Becker05607782017-09-18 15:00:34 +01001374requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001375run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001376 "$P_SRV debug_level=3 max_frag_len=4096" \
1377 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001378 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001379 -c "Maximum fragment length is 16384" \
1380 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001381 -C "client hello, adding max_fragment_length extension" \
1382 -S "found max fragment length extension" \
1383 -S "server hello, max_fragment_length extension" \
1384 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001385
Hanno Becker05607782017-09-18 15:00:34 +01001386requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001387requires_gnutls
1388run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001389 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001390 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001391 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001392 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001393 -c "client hello, adding max_fragment_length extension" \
1394 -c "found max_fragment_length extension"
1395
Hanno Becker05607782017-09-18 15:00:34 +01001396requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001397run_test "Max fragment length: client, message just fits" \
1398 "$P_SRV debug_level=3" \
1399 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1400 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001401 -c "Maximum fragment length is 2048" \
1402 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001403 -c "client hello, adding max_fragment_length extension" \
1404 -s "found max fragment length extension" \
1405 -s "server hello, max_fragment_length extension" \
1406 -c "found max_fragment_length extension" \
1407 -c "2048 bytes written in 1 fragments" \
1408 -s "2048 bytes read"
1409
Hanno Becker05607782017-09-18 15:00:34 +01001410requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001411run_test "Max fragment length: client, larger message" \
1412 "$P_SRV debug_level=3" \
1413 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1414 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001415 -c "Maximum fragment length is 2048" \
1416 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001417 -c "client hello, adding max_fragment_length extension" \
1418 -s "found max fragment length extension" \
1419 -s "server hello, max_fragment_length extension" \
1420 -c "found max_fragment_length extension" \
1421 -c "2345 bytes written in 2 fragments" \
1422 -s "2048 bytes read" \
1423 -s "297 bytes read"
1424
Hanno Becker05607782017-09-18 15:00:34 +01001425requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001426run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001427 "$P_SRV debug_level=3 dtls=1" \
1428 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1429 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001430 -c "Maximum fragment length is 2048" \
1431 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001432 -c "client hello, adding max_fragment_length extension" \
1433 -s "found max fragment length extension" \
1434 -s "server hello, max_fragment_length extension" \
1435 -c "found max_fragment_length extension" \
1436 -c "fragment larger than.*maximum"
1437
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001438# Tests for renegotiation
1439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001440run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001441 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001442 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001443 0 \
1444 -C "client hello, adding renegotiation extension" \
1445 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1446 -S "found renegotiation extension" \
1447 -s "server hello, secure renegotiation extension" \
1448 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001449 -C "=> renegotiate" \
1450 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001451 -S "write hello request"
1452
Hanno Becker78891132017-10-24 11:54:55 +01001453requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001454run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001455 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001456 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001457 0 \
1458 -c "client hello, adding renegotiation extension" \
1459 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1460 -s "found renegotiation extension" \
1461 -s "server hello, secure renegotiation extension" \
1462 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001463 -c "=> renegotiate" \
1464 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001465 -S "write hello request"
1466
Hanno Becker78891132017-10-24 11:54:55 +01001467requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001468run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001469 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001470 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001471 0 \
1472 -c "client hello, adding renegotiation extension" \
1473 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1474 -s "found renegotiation extension" \
1475 -s "server hello, secure renegotiation extension" \
1476 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001477 -c "=> renegotiate" \
1478 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001479 -s "write hello request"
1480
Janos Follath5f1dd802017-10-05 12:29:42 +01001481# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1482# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1483# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker78891132017-10-24 11:54:55 +01001484requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follath5f1dd802017-10-05 12:29:42 +01001485run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1486 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1487 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1488 0 \
1489 -c "client hello, adding renegotiation extension" \
1490 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1491 -s "found renegotiation extension" \
1492 -s "server hello, secure renegotiation extension" \
1493 -c "found renegotiation extension" \
1494 -c "=> renegotiate" \
1495 -s "=> renegotiate" \
1496 -S "write hello request" \
1497 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1498
1499# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1500# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1501# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker78891132017-10-24 11:54:55 +01001502requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follath5f1dd802017-10-05 12:29:42 +01001503run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1504 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1505 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1506 0 \
1507 -c "client hello, adding renegotiation extension" \
1508 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1509 -s "found renegotiation extension" \
1510 -s "server hello, secure renegotiation extension" \
1511 -c "found renegotiation extension" \
1512 -c "=> renegotiate" \
1513 -s "=> renegotiate" \
1514 -s "write hello request" \
1515 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1516
Hanno Becker78891132017-10-24 11:54:55 +01001517requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001518run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001519 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001520 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001521 0 \
1522 -c "client hello, adding renegotiation extension" \
1523 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1524 -s "found renegotiation extension" \
1525 -s "server hello, secure renegotiation extension" \
1526 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001527 -c "=> renegotiate" \
1528 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001529 -s "write hello request"
1530
Hanno Becker78891132017-10-24 11:54:55 +01001531requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001532run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001533 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001534 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001535 1 \
1536 -c "client hello, adding renegotiation extension" \
1537 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1538 -S "found renegotiation extension" \
1539 -s "server hello, secure renegotiation extension" \
1540 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001541 -c "=> renegotiate" \
1542 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001543 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001544 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001545 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001546
Hanno Becker78891132017-10-24 11:54:55 +01001547requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001548run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001549 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001550 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001551 0 \
1552 -C "client hello, adding renegotiation extension" \
1553 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1554 -S "found renegotiation extension" \
1555 -s "server hello, secure renegotiation extension" \
1556 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001557 -C "=> renegotiate" \
1558 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001559 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001560 -S "SSL - An unexpected message was received from our peer" \
1561 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001562
Hanno Becker78891132017-10-24 11:54:55 +01001563requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001564run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001565 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001566 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001567 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001568 0 \
1569 -C "client hello, adding renegotiation extension" \
1570 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1571 -S "found renegotiation extension" \
1572 -s "server hello, secure renegotiation extension" \
1573 -c "found renegotiation extension" \
1574 -C "=> renegotiate" \
1575 -S "=> renegotiate" \
1576 -s "write hello request" \
1577 -S "SSL - An unexpected message was received from our peer" \
1578 -S "failed"
1579
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001580# delay 2 for 1 alert record + 1 application data record
Hanno Becker78891132017-10-24 11:54:55 +01001581requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001582run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001583 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001584 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001585 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001586 0 \
1587 -C "client hello, adding renegotiation extension" \
1588 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1589 -S "found renegotiation extension" \
1590 -s "server hello, secure renegotiation extension" \
1591 -c "found renegotiation extension" \
1592 -C "=> renegotiate" \
1593 -S "=> renegotiate" \
1594 -s "write hello request" \
1595 -S "SSL - An unexpected message was received from our peer" \
1596 -S "failed"
1597
Hanno Becker78891132017-10-24 11:54:55 +01001598requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001599run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001600 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001601 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001602 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001603 0 \
1604 -C "client hello, adding renegotiation extension" \
1605 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1606 -S "found renegotiation extension" \
1607 -s "server hello, secure renegotiation extension" \
1608 -c "found renegotiation extension" \
1609 -C "=> renegotiate" \
1610 -S "=> renegotiate" \
1611 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001612 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001613
Hanno Becker78891132017-10-24 11:54:55 +01001614requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001615run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001616 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001617 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001618 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001619 0 \
1620 -c "client hello, adding renegotiation extension" \
1621 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1622 -s "found renegotiation extension" \
1623 -s "server hello, secure renegotiation extension" \
1624 -c "found renegotiation extension" \
1625 -c "=> renegotiate" \
1626 -s "=> renegotiate" \
1627 -s "write hello request" \
1628 -S "SSL - An unexpected message was received from our peer" \
1629 -S "failed"
1630
Hanno Becker78891132017-10-24 11:54:55 +01001631requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001632run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001633 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001634 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1635 0 \
1636 -C "client hello, adding renegotiation extension" \
1637 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1638 -S "found renegotiation extension" \
1639 -s "server hello, secure renegotiation extension" \
1640 -c "found renegotiation extension" \
1641 -S "record counter limit reached: renegotiate" \
1642 -C "=> renegotiate" \
1643 -S "=> renegotiate" \
1644 -S "write hello request" \
1645 -S "SSL - An unexpected message was received from our peer" \
1646 -S "failed"
1647
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001648# one extra exchange to be able to complete renego
Hanno Becker78891132017-10-24 11:54:55 +01001649requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001650run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001651 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001652 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001653 0 \
1654 -c "client hello, adding renegotiation extension" \
1655 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1656 -s "found renegotiation extension" \
1657 -s "server hello, secure renegotiation extension" \
1658 -c "found renegotiation extension" \
1659 -s "record counter limit reached: renegotiate" \
1660 -c "=> renegotiate" \
1661 -s "=> renegotiate" \
1662 -s "write hello request" \
1663 -S "SSL - An unexpected message was received from our peer" \
1664 -S "failed"
1665
Hanno Becker78891132017-10-24 11:54:55 +01001666requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001667run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001668 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001669 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001670 0 \
1671 -c "client hello, adding renegotiation extension" \
1672 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1673 -s "found renegotiation extension" \
1674 -s "server hello, secure renegotiation extension" \
1675 -c "found renegotiation extension" \
1676 -s "record counter limit reached: renegotiate" \
1677 -c "=> renegotiate" \
1678 -s "=> renegotiate" \
1679 -s "write hello request" \
1680 -S "SSL - An unexpected message was received from our peer" \
1681 -S "failed"
1682
Hanno Becker78891132017-10-24 11:54:55 +01001683requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001684run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001685 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001686 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1687 0 \
1688 -C "client hello, adding renegotiation extension" \
1689 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1690 -S "found renegotiation extension" \
1691 -s "server hello, secure renegotiation extension" \
1692 -c "found renegotiation extension" \
1693 -S "record counter limit reached: renegotiate" \
1694 -C "=> renegotiate" \
1695 -S "=> renegotiate" \
1696 -S "write hello request" \
1697 -S "SSL - An unexpected message was received from our peer" \
1698 -S "failed"
1699
Hanno Becker78891132017-10-24 11:54:55 +01001700requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001701run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001702 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001703 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001704 0 \
1705 -c "client hello, adding renegotiation extension" \
1706 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1707 -s "found renegotiation extension" \
1708 -s "server hello, secure renegotiation extension" \
1709 -c "found renegotiation extension" \
1710 -c "=> renegotiate" \
1711 -s "=> renegotiate" \
1712 -S "write hello request"
1713
Hanno Becker78891132017-10-24 11:54:55 +01001714requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001715run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001716 "$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 +02001717 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001718 0 \
1719 -c "client hello, adding renegotiation extension" \
1720 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1721 -s "found renegotiation extension" \
1722 -s "server hello, secure renegotiation extension" \
1723 -c "found renegotiation extension" \
1724 -c "=> renegotiate" \
1725 -s "=> renegotiate" \
1726 -s "write hello request"
1727
Hanno Becker78891132017-10-24 11:54:55 +01001728requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001729run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001730 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001731 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001732 0 \
1733 -c "client hello, adding renegotiation extension" \
1734 -c "found renegotiation extension" \
1735 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001736 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001737 -C "error" \
1738 -c "HTTP/1.0 200 [Oo][Kk]"
1739
Paul Bakker539d9722015-02-08 16:18:35 +01001740requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001741requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001742run_test "Renegotiation: gnutls server strict, client-initiated" \
1743 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001744 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001745 0 \
1746 -c "client hello, adding renegotiation extension" \
1747 -c "found renegotiation extension" \
1748 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001749 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001750 -C "error" \
1751 -c "HTTP/1.0 200 [Oo][Kk]"
1752
Paul Bakker539d9722015-02-08 16:18:35 +01001753requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001754requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001755run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1756 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1757 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1758 1 \
1759 -c "client hello, adding renegotiation extension" \
1760 -C "found renegotiation extension" \
1761 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001762 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001763 -c "error" \
1764 -C "HTTP/1.0 200 [Oo][Kk]"
1765
Paul Bakker539d9722015-02-08 16:18:35 +01001766requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001767requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001768run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1769 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1770 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1771 allow_legacy=0" \
1772 1 \
1773 -c "client hello, adding renegotiation extension" \
1774 -C "found renegotiation extension" \
1775 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001776 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001777 -c "error" \
1778 -C "HTTP/1.0 200 [Oo][Kk]"
1779
Paul Bakker539d9722015-02-08 16:18:35 +01001780requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001781requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001782run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1783 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1784 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1785 allow_legacy=1" \
1786 0 \
1787 -c "client hello, adding renegotiation extension" \
1788 -C "found renegotiation extension" \
1789 -c "=> renegotiate" \
1790 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001791 -C "error" \
1792 -c "HTTP/1.0 200 [Oo][Kk]"
1793
Hanno Becker78891132017-10-24 11:54:55 +01001794requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001795run_test "Renegotiation: DTLS, client-initiated" \
1796 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1797 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1798 0 \
1799 -c "client hello, adding renegotiation extension" \
1800 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1801 -s "found renegotiation extension" \
1802 -s "server hello, secure renegotiation extension" \
1803 -c "found renegotiation extension" \
1804 -c "=> renegotiate" \
1805 -s "=> renegotiate" \
1806 -S "write hello request"
1807
Hanno Becker78891132017-10-24 11:54:55 +01001808requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001809run_test "Renegotiation: DTLS, server-initiated" \
1810 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001811 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1812 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001813 0 \
1814 -c "client hello, adding renegotiation extension" \
1815 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1816 -s "found renegotiation extension" \
1817 -s "server hello, secure renegotiation extension" \
1818 -c "found renegotiation extension" \
1819 -c "=> renegotiate" \
1820 -s "=> renegotiate" \
1821 -s "write hello request"
1822
Hanno Becker78891132017-10-24 11:54:55 +01001823requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG9b1927b2017-01-19 16:30:57 +00001824run_test "Renegotiation: DTLS, renego_period overflow" \
1825 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1826 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1827 0 \
1828 -c "client hello, adding renegotiation extension" \
1829 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1830 -s "found renegotiation extension" \
1831 -s "server hello, secure renegotiation extension" \
1832 -s "record counter limit reached: renegotiate" \
1833 -c "=> renegotiate" \
1834 -s "=> renegotiate" \
Hanno Becker78891132017-10-24 11:54:55 +01001835 -s "write hello request"
Andres AG9b1927b2017-01-19 16:30:57 +00001836
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001837requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001838requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001839run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1840 "$G_SRV -u --mtu 4096" \
1841 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1842 0 \
1843 -c "client hello, adding renegotiation extension" \
1844 -c "found renegotiation extension" \
1845 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001846 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001847 -C "error" \
1848 -s "Extra-header:"
1849
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001850# Test for the "secure renegotation" extension only (no actual renegotiation)
1851
Paul Bakker539d9722015-02-08 16:18:35 +01001852requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001853run_test "Renego ext: gnutls server strict, client default" \
1854 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1855 "$P_CLI debug_level=3" \
1856 0 \
1857 -c "found renegotiation extension" \
1858 -C "error" \
1859 -c "HTTP/1.0 200 [Oo][Kk]"
1860
Paul Bakker539d9722015-02-08 16:18:35 +01001861requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001862run_test "Renego ext: gnutls server unsafe, client default" \
1863 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1864 "$P_CLI debug_level=3" \
1865 0 \
1866 -C "found renegotiation extension" \
1867 -C "error" \
1868 -c "HTTP/1.0 200 [Oo][Kk]"
1869
Paul Bakker539d9722015-02-08 16:18:35 +01001870requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001871run_test "Renego ext: gnutls server unsafe, client break legacy" \
1872 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1873 "$P_CLI debug_level=3 allow_legacy=-1" \
1874 1 \
1875 -C "found renegotiation extension" \
1876 -c "error" \
1877 -C "HTTP/1.0 200 [Oo][Kk]"
1878
Paul Bakker539d9722015-02-08 16:18:35 +01001879requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001880run_test "Renego ext: gnutls client strict, server default" \
1881 "$P_SRV debug_level=3" \
1882 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1883 0 \
1884 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1885 -s "server hello, secure renegotiation extension"
1886
Paul Bakker539d9722015-02-08 16:18:35 +01001887requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001888run_test "Renego ext: gnutls client unsafe, server default" \
1889 "$P_SRV debug_level=3" \
1890 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1891 0 \
1892 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1893 -S "server hello, secure renegotiation extension"
1894
Paul Bakker539d9722015-02-08 16:18:35 +01001895requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001896run_test "Renego ext: gnutls client unsafe, server break legacy" \
1897 "$P_SRV debug_level=3 allow_legacy=-1" \
1898 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1899 1 \
1900 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1901 -S "server hello, secure renegotiation extension"
1902
Janos Follath365b2262016-02-17 10:11:21 +00001903# Tests for silently dropping trailing extra bytes in .der certificates
1904
1905requires_gnutls
1906run_test "DER format: no trailing bytes" \
1907 "$P_SRV crt_file=data_files/server5-der0.crt \
1908 key_file=data_files/server5.key" \
1909 "$G_CLI " \
1910 0 \
1911 -c "Handshake was completed" \
1912
1913requires_gnutls
1914run_test "DER format: with a trailing zero byte" \
1915 "$P_SRV crt_file=data_files/server5-der1a.crt \
1916 key_file=data_files/server5.key" \
1917 "$G_CLI " \
1918 0 \
1919 -c "Handshake was completed" \
1920
1921requires_gnutls
1922run_test "DER format: with a trailing random byte" \
1923 "$P_SRV crt_file=data_files/server5-der1b.crt \
1924 key_file=data_files/server5.key" \
1925 "$G_CLI " \
1926 0 \
1927 -c "Handshake was completed" \
1928
1929requires_gnutls
1930run_test "DER format: with 2 trailing random bytes" \
1931 "$P_SRV crt_file=data_files/server5-der2.crt \
1932 key_file=data_files/server5.key" \
1933 "$G_CLI " \
1934 0 \
1935 -c "Handshake was completed" \
1936
1937requires_gnutls
1938run_test "DER format: with 4 trailing random bytes" \
1939 "$P_SRV crt_file=data_files/server5-der4.crt \
1940 key_file=data_files/server5.key" \
1941 "$G_CLI " \
1942 0 \
1943 -c "Handshake was completed" \
1944
1945requires_gnutls
1946run_test "DER format: with 8 trailing random bytes" \
1947 "$P_SRV crt_file=data_files/server5-der8.crt \
1948 key_file=data_files/server5.key" \
1949 "$G_CLI " \
1950 0 \
1951 -c "Handshake was completed" \
1952
1953requires_gnutls
1954run_test "DER format: with 9 trailing random bytes" \
1955 "$P_SRV crt_file=data_files/server5-der9.crt \
1956 key_file=data_files/server5.key" \
1957 "$G_CLI " \
1958 0 \
1959 -c "Handshake was completed" \
1960
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001961# Tests for auth_mode
1962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001963run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001964 "$P_SRV crt_file=data_files/server5-badsign.crt \
1965 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001966 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001967 1 \
1968 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001969 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001970 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001971 -c "X509 - Certificate verification failed"
1972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001973run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001974 "$P_SRV crt_file=data_files/server5-badsign.crt \
1975 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001976 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001977 0 \
1978 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001979 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001980 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001981 -C "X509 - Certificate verification failed"
1982
Hanno Becker61c0c702017-05-15 16:05:15 +01001983run_test "Authentication: server goodcert, client optional, no trusted CA" \
1984 "$P_SRV" \
1985 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1986 0 \
1987 -c "x509_verify_cert() returned" \
1988 -c "! The certificate is not correctly signed by the trusted CA" \
1989 -c "! Certificate verification flags"\
1990 -C "! mbedtls_ssl_handshake returned" \
1991 -C "X509 - Certificate verification failed" \
1992 -C "SSL - No CA Chain is set, but required to operate"
1993
1994run_test "Authentication: server goodcert, client required, no trusted CA" \
1995 "$P_SRV" \
1996 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1997 1 \
1998 -c "x509_verify_cert() returned" \
1999 -c "! The certificate is not correctly signed by the trusted CA" \
2000 -c "! Certificate verification flags"\
2001 -c "! mbedtls_ssl_handshake returned" \
2002 -c "SSL - No CA Chain is set, but required to operate"
2003
2004# The purpose of the next two tests is to test the client's behaviour when receiving a server
2005# certificate with an unsupported elliptic curve. This should usually not happen because
2006# the client informs the server about the supported curves - it does, though, in the
2007# corner case of a static ECDH suite, because the server doesn't check the curve on that
2008# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2009# different means to have the server ignoring the client's supported curve list.
2010
2011requires_config_enabled MBEDTLS_ECP_C
2012run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2013 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2014 crt_file=data_files/server5.ku-ka.crt" \
2015 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2016 1 \
2017 -c "bad certificate (EC key curve)"\
2018 -c "! Certificate verification flags"\
2019 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2020
2021requires_config_enabled MBEDTLS_ECP_C
2022run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2023 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2024 crt_file=data_files/server5.ku-ka.crt" \
2025 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2026 1 \
2027 -c "bad certificate (EC key curve)"\
2028 -c "! Certificate verification flags"\
2029 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002031run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002032 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002033 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002034 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002035 0 \
2036 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002037 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002038 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002039 -C "X509 - Certificate verification failed"
2040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002041run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002042 "$P_SRV debug_level=3 auth_mode=required" \
2043 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002044 key_file=data_files/server5.key" \
2045 1 \
2046 -S "skip write certificate request" \
2047 -C "skip parse certificate request" \
2048 -c "got a certificate request" \
2049 -C "skip write certificate" \
2050 -C "skip write certificate verify" \
2051 -S "skip parse certificate verify" \
2052 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002053 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002054 -s "! mbedtls_ssl_handshake returned" \
2055 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002056 -s "X509 - Certificate verification failed"
2057
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002058run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002059 "$P_SRV debug_level=3 auth_mode=optional" \
2060 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002061 key_file=data_files/server5.key" \
2062 0 \
2063 -S "skip write certificate request" \
2064 -C "skip parse certificate request" \
2065 -c "got a certificate request" \
2066 -C "skip write certificate" \
2067 -C "skip write certificate verify" \
2068 -S "skip parse certificate verify" \
2069 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002070 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002071 -S "! mbedtls_ssl_handshake returned" \
2072 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002073 -S "X509 - Certificate verification failed"
2074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002075run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002076 "$P_SRV debug_level=3 auth_mode=none" \
2077 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002078 key_file=data_files/server5.key" \
2079 0 \
2080 -s "skip write certificate request" \
2081 -C "skip parse certificate request" \
2082 -c "got no certificate request" \
2083 -c "skip write certificate" \
2084 -c "skip write certificate verify" \
2085 -s "skip parse certificate verify" \
2086 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002087 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002088 -S "! mbedtls_ssl_handshake returned" \
2089 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002090 -S "X509 - Certificate verification failed"
2091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002092run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002093 "$P_SRV debug_level=3 auth_mode=optional" \
2094 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002095 0 \
2096 -S "skip write certificate request" \
2097 -C "skip parse certificate request" \
2098 -c "got a certificate request" \
2099 -C "skip write certificate$" \
2100 -C "got no certificate to send" \
2101 -S "SSLv3 client has no certificate" \
2102 -c "skip write certificate verify" \
2103 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002104 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002105 -S "! mbedtls_ssl_handshake returned" \
2106 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002107 -S "X509 - Certificate verification failed"
2108
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002109run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002110 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002111 "$O_CLI" \
2112 0 \
2113 -S "skip write certificate request" \
2114 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002115 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002116 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002117 -S "X509 - Certificate verification failed"
2118
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002119run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002120 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002121 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002122 0 \
2123 -C "skip parse certificate request" \
2124 -c "got a certificate request" \
2125 -C "skip write certificate$" \
2126 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002127 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002128
Janos Follath542ee5d2016-03-07 15:57:05 +00002129requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002130run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002131 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002132 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002133 0 \
2134 -S "skip write certificate request" \
2135 -C "skip parse certificate request" \
2136 -c "got a certificate request" \
2137 -C "skip write certificate$" \
2138 -c "skip write certificate verify" \
2139 -c "got no certificate to send" \
2140 -s "SSLv3 client has no certificate" \
2141 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002142 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002143 -S "! mbedtls_ssl_handshake returned" \
2144 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002145 -S "X509 - Certificate verification failed"
2146
Manuel Pégourié-Gonnard591035d2017-06-26 10:45:33 +02002147run_test "Authentication: server max_int chain, client default" \
2148 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2149 key_file=data_files/dir-maxpath/09.key" \
2150 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2151 0 \
2152 -C "X509 - A fatal error occured"
2153
2154run_test "Authentication: server max_int+1 chain, client default" \
2155 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2156 key_file=data_files/dir-maxpath/10.key" \
2157 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2158 1 \
2159 -c "X509 - A fatal error occured"
2160
2161run_test "Authentication: server max_int+1 chain, client optional" \
2162 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2163 key_file=data_files/dir-maxpath/10.key" \
2164 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2165 auth_mode=optional" \
2166 1 \
2167 -c "X509 - A fatal error occured"
2168
2169run_test "Authentication: server max_int+1 chain, client none" \
2170 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2171 key_file=data_files/dir-maxpath/10.key" \
2172 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2173 auth_mode=none" \
2174 0 \
2175 -C "X509 - A fatal error occured"
2176
2177run_test "Authentication: client max_int+1 chain, server default" \
2178 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2179 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2180 key_file=data_files/dir-maxpath/10.key" \
2181 0 \
2182 -S "X509 - A fatal error occured"
2183
2184run_test "Authentication: client max_int+1 chain, server optional" \
2185 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2186 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2187 key_file=data_files/dir-maxpath/10.key" \
2188 1 \
2189 -s "X509 - A fatal error occured"
2190
2191run_test "Authentication: client max_int+1 chain, server required" \
2192 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2193 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2194 key_file=data_files/dir-maxpath/10.key" \
2195 1 \
2196 -s "X509 - A fatal error occured"
2197
2198run_test "Authentication: client max_int chain, server required" \
2199 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2200 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2201 key_file=data_files/dir-maxpath/09.key" \
2202 0 \
2203 -S "X509 - A fatal error occured"
2204
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002205# Tests for certificate selection based on SHA verson
2206
2207run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2208 "$P_SRV crt_file=data_files/server5.crt \
2209 key_file=data_files/server5.key \
2210 crt_file2=data_files/server5-sha1.crt \
2211 key_file2=data_files/server5.key" \
2212 "$P_CLI force_version=tls1_2" \
2213 0 \
2214 -c "signed using.*ECDSA with SHA256" \
2215 -C "signed using.*ECDSA with SHA1"
2216
2217run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2218 "$P_SRV crt_file=data_files/server5.crt \
2219 key_file=data_files/server5.key \
2220 crt_file2=data_files/server5-sha1.crt \
2221 key_file2=data_files/server5.key" \
2222 "$P_CLI force_version=tls1_1" \
2223 0 \
2224 -C "signed using.*ECDSA with SHA256" \
2225 -c "signed using.*ECDSA with SHA1"
2226
2227run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2228 "$P_SRV crt_file=data_files/server5.crt \
2229 key_file=data_files/server5.key \
2230 crt_file2=data_files/server5-sha1.crt \
2231 key_file2=data_files/server5.key" \
2232 "$P_CLI force_version=tls1" \
2233 0 \
2234 -C "signed using.*ECDSA with SHA256" \
2235 -c "signed using.*ECDSA with SHA1"
2236
2237run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2238 "$P_SRV crt_file=data_files/server5.crt \
2239 key_file=data_files/server5.key \
2240 crt_file2=data_files/server6.crt \
2241 key_file2=data_files/server6.key" \
2242 "$P_CLI force_version=tls1_1" \
2243 0 \
2244 -c "serial number.*09" \
2245 -c "signed using.*ECDSA with SHA256" \
2246 -C "signed using.*ECDSA with SHA1"
2247
2248run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2249 "$P_SRV crt_file=data_files/server6.crt \
2250 key_file=data_files/server6.key \
2251 crt_file2=data_files/server5.crt \
2252 key_file2=data_files/server5.key" \
2253 "$P_CLI force_version=tls1_1" \
2254 0 \
2255 -c "serial number.*0A" \
2256 -c "signed using.*ECDSA with SHA256" \
2257 -C "signed using.*ECDSA with SHA1"
2258
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002259# tests for SNI
2260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002261run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002262 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002263 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002264 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002265 0 \
2266 -S "parse ServerName extension" \
2267 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2268 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002270run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002271 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002272 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002273 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 +02002274 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002275 0 \
2276 -s "parse ServerName extension" \
2277 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2278 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002279
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002280run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002281 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002282 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002283 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 +02002284 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002285 0 \
2286 -s "parse ServerName extension" \
2287 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2288 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002289
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002290run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002291 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002292 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002293 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 +02002294 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002295 1 \
2296 -s "parse ServerName extension" \
2297 -s "ssl_sni_wrapper() returned" \
2298 -s "mbedtls_ssl_handshake returned" \
2299 -c "mbedtls_ssl_handshake returned" \
2300 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002301
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002302run_test "SNI: client auth no override: optional" \
2303 "$P_SRV debug_level=3 auth_mode=optional \
2304 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2305 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2306 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002307 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002308 -S "skip write certificate request" \
2309 -C "skip parse certificate request" \
2310 -c "got a certificate request" \
2311 -C "skip write certificate" \
2312 -C "skip write certificate verify" \
2313 -S "skip parse certificate verify"
2314
2315run_test "SNI: client auth override: none -> optional" \
2316 "$P_SRV debug_level=3 auth_mode=none \
2317 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2318 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2319 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002320 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002321 -S "skip write certificate request" \
2322 -C "skip parse certificate request" \
2323 -c "got a certificate request" \
2324 -C "skip write certificate" \
2325 -C "skip write certificate verify" \
2326 -S "skip parse certificate verify"
2327
2328run_test "SNI: client auth override: optional -> none" \
2329 "$P_SRV debug_level=3 auth_mode=optional \
2330 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2331 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2332 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002333 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002334 -s "skip write certificate request" \
2335 -C "skip parse certificate request" \
2336 -c "got no certificate request" \
2337 -c "skip write certificate" \
2338 -c "skip write certificate verify" \
2339 -s "skip parse certificate verify"
2340
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002341run_test "SNI: CA no override" \
2342 "$P_SRV debug_level=3 auth_mode=optional \
2343 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2344 ca_file=data_files/test-ca.crt \
2345 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2346 "$P_CLI debug_level=3 server_name=localhost \
2347 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2348 1 \
2349 -S "skip write certificate request" \
2350 -C "skip parse certificate request" \
2351 -c "got a certificate request" \
2352 -C "skip write certificate" \
2353 -C "skip write certificate verify" \
2354 -S "skip parse certificate verify" \
2355 -s "x509_verify_cert() returned" \
2356 -s "! The certificate is not correctly signed by the trusted CA" \
2357 -S "The certificate has been revoked (is on a CRL)"
2358
2359run_test "SNI: CA override" \
2360 "$P_SRV debug_level=3 auth_mode=optional \
2361 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2362 ca_file=data_files/test-ca.crt \
2363 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2364 "$P_CLI debug_level=3 server_name=localhost \
2365 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2366 0 \
2367 -S "skip write certificate request" \
2368 -C "skip parse certificate request" \
2369 -c "got a certificate request" \
2370 -C "skip write certificate" \
2371 -C "skip write certificate verify" \
2372 -S "skip parse certificate verify" \
2373 -S "x509_verify_cert() returned" \
2374 -S "! The certificate is not correctly signed by the trusted CA" \
2375 -S "The certificate has been revoked (is on a CRL)"
2376
2377run_test "SNI: CA override with CRL" \
2378 "$P_SRV debug_level=3 auth_mode=optional \
2379 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2380 ca_file=data_files/test-ca.crt \
2381 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2382 "$P_CLI debug_level=3 server_name=localhost \
2383 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2384 1 \
2385 -S "skip write certificate request" \
2386 -C "skip parse certificate request" \
2387 -c "got a certificate request" \
2388 -C "skip write certificate" \
2389 -C "skip write certificate verify" \
2390 -S "skip parse certificate verify" \
2391 -s "x509_verify_cert() returned" \
2392 -S "! The certificate is not correctly signed by the trusted CA" \
2393 -s "The certificate has been revoked (is on a CRL)"
2394
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002395# Tests for non-blocking I/O: exercise a variety of handshake flows
2396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002397run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002398 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2399 "$P_CLI nbio=2 tickets=0" \
2400 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002401 -S "mbedtls_ssl_handshake returned" \
2402 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002403 -c "Read from server: .* bytes read"
2404
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002405run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002406 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2407 "$P_CLI nbio=2 tickets=0" \
2408 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002409 -S "mbedtls_ssl_handshake returned" \
2410 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002411 -c "Read from server: .* bytes read"
2412
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002413run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002414 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2415 "$P_CLI nbio=2 tickets=1" \
2416 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002417 -S "mbedtls_ssl_handshake returned" \
2418 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002419 -c "Read from server: .* bytes read"
2420
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002421run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002422 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2423 "$P_CLI nbio=2 tickets=1" \
2424 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002425 -S "mbedtls_ssl_handshake returned" \
2426 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002427 -c "Read from server: .* bytes read"
2428
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002429run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002430 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2431 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2432 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002433 -S "mbedtls_ssl_handshake returned" \
2434 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002435 -c "Read from server: .* bytes read"
2436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002437run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002438 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2439 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2440 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002441 -S "mbedtls_ssl_handshake returned" \
2442 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002443 -c "Read from server: .* bytes read"
2444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002445run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002446 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2447 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2448 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002449 -S "mbedtls_ssl_handshake returned" \
2450 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002451 -c "Read from server: .* bytes read"
2452
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002453# Tests for version negotiation
2454
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002455run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002456 "$P_SRV" \
2457 "$P_CLI" \
2458 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002459 -S "mbedtls_ssl_handshake returned" \
2460 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002461 -s "Protocol is TLSv1.2" \
2462 -c "Protocol is TLSv1.2"
2463
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002464run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002465 "$P_SRV" \
2466 "$P_CLI max_version=tls1_1" \
2467 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002468 -S "mbedtls_ssl_handshake returned" \
2469 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002470 -s "Protocol is TLSv1.1" \
2471 -c "Protocol is TLSv1.1"
2472
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002473run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002474 "$P_SRV max_version=tls1_1" \
2475 "$P_CLI" \
2476 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002477 -S "mbedtls_ssl_handshake returned" \
2478 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002479 -s "Protocol is TLSv1.1" \
2480 -c "Protocol is TLSv1.1"
2481
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002482run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002483 "$P_SRV max_version=tls1_1" \
2484 "$P_CLI max_version=tls1_1" \
2485 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002486 -S "mbedtls_ssl_handshake returned" \
2487 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002488 -s "Protocol is TLSv1.1" \
2489 -c "Protocol is TLSv1.1"
2490
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002491run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002492 "$P_SRV min_version=tls1_1" \
2493 "$P_CLI max_version=tls1_1" \
2494 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002495 -S "mbedtls_ssl_handshake returned" \
2496 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002497 -s "Protocol is TLSv1.1" \
2498 -c "Protocol is TLSv1.1"
2499
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002500run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002501 "$P_SRV max_version=tls1_1" \
2502 "$P_CLI min_version=tls1_1" \
2503 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002504 -S "mbedtls_ssl_handshake returned" \
2505 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002506 -s "Protocol is TLSv1.1" \
2507 -c "Protocol is TLSv1.1"
2508
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002509run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002510 "$P_SRV max_version=tls1_1" \
2511 "$P_CLI min_version=tls1_2" \
2512 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002513 -s "mbedtls_ssl_handshake returned" \
2514 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002515 -c "SSL - Handshake protocol not within min/max boundaries"
2516
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002517run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002518 "$P_SRV min_version=tls1_2" \
2519 "$P_CLI max_version=tls1_1" \
2520 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002521 -s "mbedtls_ssl_handshake returned" \
2522 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002523 -s "SSL - Handshake protocol not within min/max boundaries"
2524
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002525# Tests for ALPN extension
2526
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002527run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002528 "$P_SRV debug_level=3" \
2529 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002530 0 \
2531 -C "client hello, adding alpn extension" \
2532 -S "found alpn extension" \
2533 -C "got an alert message, type: \\[2:120]" \
2534 -S "server hello, adding alpn extension" \
2535 -C "found alpn extension " \
2536 -C "Application Layer Protocol is" \
2537 -S "Application Layer Protocol is"
2538
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002539run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002540 "$P_SRV debug_level=3" \
2541 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002542 0 \
2543 -c "client hello, adding alpn extension" \
2544 -s "found alpn extension" \
2545 -C "got an alert message, type: \\[2:120]" \
2546 -S "server hello, adding alpn extension" \
2547 -C "found alpn extension " \
2548 -c "Application Layer Protocol is (none)" \
2549 -S "Application Layer Protocol is"
2550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002551run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002552 "$P_SRV debug_level=3 alpn=abc,1234" \
2553 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002554 0 \
2555 -C "client hello, adding alpn extension" \
2556 -S "found alpn extension" \
2557 -C "got an alert message, type: \\[2:120]" \
2558 -S "server hello, adding alpn extension" \
2559 -C "found alpn extension " \
2560 -C "Application Layer Protocol is" \
2561 -s "Application Layer Protocol is (none)"
2562
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002563run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002564 "$P_SRV debug_level=3 alpn=abc,1234" \
2565 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002566 0 \
2567 -c "client hello, adding alpn extension" \
2568 -s "found alpn extension" \
2569 -C "got an alert message, type: \\[2:120]" \
2570 -s "server hello, adding alpn extension" \
2571 -c "found alpn extension" \
2572 -c "Application Layer Protocol is abc" \
2573 -s "Application Layer Protocol is abc"
2574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002575run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002576 "$P_SRV debug_level=3 alpn=abc,1234" \
2577 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002578 0 \
2579 -c "client hello, adding alpn extension" \
2580 -s "found alpn extension" \
2581 -C "got an alert message, type: \\[2:120]" \
2582 -s "server hello, adding alpn extension" \
2583 -c "found alpn extension" \
2584 -c "Application Layer Protocol is abc" \
2585 -s "Application Layer Protocol is abc"
2586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002587run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002588 "$P_SRV debug_level=3 alpn=abc,1234" \
2589 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002590 0 \
2591 -c "client hello, adding alpn extension" \
2592 -s "found alpn extension" \
2593 -C "got an alert message, type: \\[2:120]" \
2594 -s "server hello, adding alpn extension" \
2595 -c "found alpn extension" \
2596 -c "Application Layer Protocol is 1234" \
2597 -s "Application Layer Protocol is 1234"
2598
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002599run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002600 "$P_SRV debug_level=3 alpn=abc,123" \
2601 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002602 1 \
2603 -c "client hello, adding alpn extension" \
2604 -s "found alpn extension" \
2605 -c "got an alert message, type: \\[2:120]" \
2606 -S "server hello, adding alpn extension" \
2607 -C "found alpn extension" \
2608 -C "Application Layer Protocol is 1234" \
2609 -S "Application Layer Protocol is 1234"
2610
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002611
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002612# Tests for keyUsage in leaf certificates, part 1:
2613# server-side certificate/suite selection
2614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002615run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002616 "$P_SRV key_file=data_files/server2.key \
2617 crt_file=data_files/server2.ku-ds.crt" \
2618 "$P_CLI" \
2619 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002620 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002621
2622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002623run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002624 "$P_SRV key_file=data_files/server2.key \
2625 crt_file=data_files/server2.ku-ke.crt" \
2626 "$P_CLI" \
2627 0 \
2628 -c "Ciphersuite is TLS-RSA-WITH-"
2629
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002630run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002631 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002632 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002633 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002634 1 \
2635 -C "Ciphersuite is "
2636
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002637run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002638 "$P_SRV key_file=data_files/server5.key \
2639 crt_file=data_files/server5.ku-ds.crt" \
2640 "$P_CLI" \
2641 0 \
2642 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2643
2644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002645run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002646 "$P_SRV key_file=data_files/server5.key \
2647 crt_file=data_files/server5.ku-ka.crt" \
2648 "$P_CLI" \
2649 0 \
2650 -c "Ciphersuite is TLS-ECDH-"
2651
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002652run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002653 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002654 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002655 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002656 1 \
2657 -C "Ciphersuite is "
2658
2659# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002660# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002661
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002662run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002663 "$O_SRV -key data_files/server2.key \
2664 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002665 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002666 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2667 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002668 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002669 -C "Processing of the Certificate handshake message failed" \
2670 -c "Ciphersuite is TLS-"
2671
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002672run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002673 "$O_SRV -key data_files/server2.key \
2674 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002675 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002676 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2677 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002678 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002679 -C "Processing of the Certificate handshake message failed" \
2680 -c "Ciphersuite is TLS-"
2681
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002682run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002683 "$O_SRV -key data_files/server2.key \
2684 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002685 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002686 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2687 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002688 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002689 -C "Processing of the Certificate handshake message failed" \
2690 -c "Ciphersuite is TLS-"
2691
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002692run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002693 "$O_SRV -key data_files/server2.key \
2694 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002695 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002696 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2697 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002698 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002699 -c "Processing of the Certificate handshake message failed" \
2700 -C "Ciphersuite is TLS-"
2701
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002702run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2703 "$O_SRV -key data_files/server2.key \
2704 -cert data_files/server2.ku-ke.crt" \
2705 "$P_CLI debug_level=1 auth_mode=optional \
2706 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2707 0 \
2708 -c "bad certificate (usage extensions)" \
2709 -C "Processing of the Certificate handshake message failed" \
2710 -c "Ciphersuite is TLS-" \
2711 -c "! Usage does not match the keyUsage extension"
2712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002713run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002714 "$O_SRV -key data_files/server2.key \
2715 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002716 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002717 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2718 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002719 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002720 -C "Processing of the Certificate handshake message failed" \
2721 -c "Ciphersuite is TLS-"
2722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002723run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002724 "$O_SRV -key data_files/server2.key \
2725 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002726 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002727 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2728 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002729 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002730 -c "Processing of the Certificate handshake message failed" \
2731 -C "Ciphersuite is TLS-"
2732
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002733run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2734 "$O_SRV -key data_files/server2.key \
2735 -cert data_files/server2.ku-ds.crt" \
2736 "$P_CLI debug_level=1 auth_mode=optional \
2737 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2738 0 \
2739 -c "bad certificate (usage extensions)" \
2740 -C "Processing of the Certificate handshake message failed" \
2741 -c "Ciphersuite is TLS-" \
2742 -c "! Usage does not match the keyUsage extension"
2743
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002744# Tests for keyUsage in leaf certificates, part 3:
2745# server-side checking of client cert
2746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002747run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002748 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002749 "$O_CLI -key data_files/server2.key \
2750 -cert data_files/server2.ku-ds.crt" \
2751 0 \
2752 -S "bad certificate (usage extensions)" \
2753 -S "Processing of the Certificate handshake message failed"
2754
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002755run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002756 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002757 "$O_CLI -key data_files/server2.key \
2758 -cert data_files/server2.ku-ke.crt" \
2759 0 \
2760 -s "bad certificate (usage extensions)" \
2761 -S "Processing of the Certificate handshake message failed"
2762
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002763run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002764 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002765 "$O_CLI -key data_files/server2.key \
2766 -cert data_files/server2.ku-ke.crt" \
2767 1 \
2768 -s "bad certificate (usage extensions)" \
2769 -s "Processing of the Certificate handshake message failed"
2770
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002771run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002772 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002773 "$O_CLI -key data_files/server5.key \
2774 -cert data_files/server5.ku-ds.crt" \
2775 0 \
2776 -S "bad certificate (usage extensions)" \
2777 -S "Processing of the Certificate handshake message failed"
2778
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002779run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002780 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002781 "$O_CLI -key data_files/server5.key \
2782 -cert data_files/server5.ku-ka.crt" \
2783 0 \
2784 -s "bad certificate (usage extensions)" \
2785 -S "Processing of the Certificate handshake message failed"
2786
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002787# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2788
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002789run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002790 "$P_SRV key_file=data_files/server5.key \
2791 crt_file=data_files/server5.eku-srv.crt" \
2792 "$P_CLI" \
2793 0
2794
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002795run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002796 "$P_SRV key_file=data_files/server5.key \
2797 crt_file=data_files/server5.eku-srv.crt" \
2798 "$P_CLI" \
2799 0
2800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002801run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002802 "$P_SRV key_file=data_files/server5.key \
2803 crt_file=data_files/server5.eku-cs_any.crt" \
2804 "$P_CLI" \
2805 0
2806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002807run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002808 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002809 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002810 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002811 1
2812
2813# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002815run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002816 "$O_SRV -key data_files/server5.key \
2817 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002818 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002819 0 \
2820 -C "bad certificate (usage extensions)" \
2821 -C "Processing of the Certificate handshake message failed" \
2822 -c "Ciphersuite is TLS-"
2823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002824run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002825 "$O_SRV -key data_files/server5.key \
2826 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002827 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002828 0 \
2829 -C "bad certificate (usage extensions)" \
2830 -C "Processing of the Certificate handshake message failed" \
2831 -c "Ciphersuite is TLS-"
2832
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002833run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002834 "$O_SRV -key data_files/server5.key \
2835 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002836 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002837 0 \
2838 -C "bad certificate (usage extensions)" \
2839 -C "Processing of the Certificate handshake message failed" \
2840 -c "Ciphersuite is TLS-"
2841
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002842run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002843 "$O_SRV -key data_files/server5.key \
2844 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002845 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002846 1 \
2847 -c "bad certificate (usage extensions)" \
2848 -c "Processing of the Certificate handshake message failed" \
2849 -C "Ciphersuite is TLS-"
2850
2851# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2852
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002853run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002854 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002855 "$O_CLI -key data_files/server5.key \
2856 -cert data_files/server5.eku-cli.crt" \
2857 0 \
2858 -S "bad certificate (usage extensions)" \
2859 -S "Processing of the Certificate handshake message failed"
2860
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002861run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002862 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002863 "$O_CLI -key data_files/server5.key \
2864 -cert data_files/server5.eku-srv_cli.crt" \
2865 0 \
2866 -S "bad certificate (usage extensions)" \
2867 -S "Processing of the Certificate handshake message failed"
2868
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002869run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002870 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002871 "$O_CLI -key data_files/server5.key \
2872 -cert data_files/server5.eku-cs_any.crt" \
2873 0 \
2874 -S "bad certificate (usage extensions)" \
2875 -S "Processing of the Certificate handshake message failed"
2876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002877run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002878 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002879 "$O_CLI -key data_files/server5.key \
2880 -cert data_files/server5.eku-cs.crt" \
2881 0 \
2882 -s "bad certificate (usage extensions)" \
2883 -S "Processing of the Certificate handshake message failed"
2884
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002885run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002886 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002887 "$O_CLI -key data_files/server5.key \
2888 -cert data_files/server5.eku-cs.crt" \
2889 1 \
2890 -s "bad certificate (usage extensions)" \
2891 -s "Processing of the Certificate handshake message failed"
2892
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002893# Tests for DHM parameters loading
2894
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002895run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002896 "$P_SRV" \
2897 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2898 debug_level=3" \
2899 0 \
2900 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker80e0d462017-10-13 16:51:54 +01002901 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002903run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002904 "$P_SRV dhm_file=data_files/dhparams.pem" \
2905 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2906 debug_level=3" \
2907 0 \
2908 -c "value of 'DHM: P ' (1024 bits)" \
2909 -c "value of 'DHM: G ' (2 bits)"
2910
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002911# Tests for DHM client-side size checking
2912
2913run_test "DHM size: server default, client default, OK" \
2914 "$P_SRV" \
2915 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2916 debug_level=1" \
2917 0 \
2918 -C "DHM prime too short:"
2919
2920run_test "DHM size: server default, client 2048, OK" \
2921 "$P_SRV" \
2922 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2923 debug_level=1 dhmlen=2048" \
2924 0 \
2925 -C "DHM prime too short:"
2926
2927run_test "DHM size: server 1024, client default, OK" \
2928 "$P_SRV dhm_file=data_files/dhparams.pem" \
2929 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2930 debug_level=1" \
2931 0 \
2932 -C "DHM prime too short:"
2933
2934run_test "DHM size: server 1000, client default, rejected" \
2935 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2936 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2937 debug_level=1" \
2938 1 \
2939 -c "DHM prime too short:"
2940
2941run_test "DHM size: server default, client 2049, rejected" \
2942 "$P_SRV" \
2943 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2944 debug_level=1 dhmlen=2049" \
2945 1 \
2946 -c "DHM prime too short:"
2947
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002948# Tests for PSK callback
2949
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002950run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002951 "$P_SRV psk=abc123 psk_identity=foo" \
2952 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2953 psk_identity=foo psk=abc123" \
2954 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002955 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002956 -S "SSL - Unknown identity received" \
2957 -S "SSL - Verification of the message MAC failed"
2958
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002959run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002960 "$P_SRV" \
2961 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2962 psk_identity=foo psk=abc123" \
2963 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002964 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002965 -S "SSL - Unknown identity received" \
2966 -S "SSL - Verification of the message MAC failed"
2967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002968run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002969 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2970 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2971 psk_identity=foo psk=abc123" \
2972 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002973 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002974 -s "SSL - Unknown identity received" \
2975 -S "SSL - Verification of the message MAC failed"
2976
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002977run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002978 "$P_SRV psk_list=abc,dead,def,beef" \
2979 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2980 psk_identity=abc psk=dead" \
2981 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002982 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002983 -S "SSL - Unknown identity received" \
2984 -S "SSL - Verification of the message MAC failed"
2985
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002986run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002987 "$P_SRV psk_list=abc,dead,def,beef" \
2988 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2989 psk_identity=def psk=beef" \
2990 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002991 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002992 -S "SSL - Unknown identity received" \
2993 -S "SSL - Verification of the message MAC failed"
2994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002995run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002996 "$P_SRV psk_list=abc,dead,def,beef" \
2997 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2998 psk_identity=ghi psk=beef" \
2999 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003000 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003001 -s "SSL - Unknown identity received" \
3002 -S "SSL - Verification of the message MAC failed"
3003
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003004run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003005 "$P_SRV psk_list=abc,dead,def,beef" \
3006 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3007 psk_identity=abc psk=beef" \
3008 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003009 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003010 -S "SSL - Unknown identity received" \
3011 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003012
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003013# Tests for ciphersuites per version
3014
Janos Follath542ee5d2016-03-07 15:57:05 +00003015requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003016run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003017 "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003018 "$P_CLI force_version=ssl3" \
3019 0 \
3020 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3021
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003022run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003023 "$P_SRV arc4=1 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01003024 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003025 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003026 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003028run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003029 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003030 "$P_CLI force_version=tls1_1" \
3031 0 \
3032 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3033
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003034run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003035 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003036 "$P_CLI force_version=tls1_2" \
3037 0 \
3038 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3039
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003040# Test for ClientHello without extensions
3041
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003042requires_gnutls
Gilles Peskine7344e1b2017-05-12 13:16:40 +02003043run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003044 "$P_SRV debug_level=3" \
3045 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3046 0 \
3047 -s "dumping 'client hello extensions' (0 bytes)"
3048
Gilles Peskine7344e1b2017-05-12 13:16:40 +02003049requires_gnutls
3050run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3051 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3052 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3053 0 \
3054 -s "dumping 'client hello extensions' (0 bytes)"
3055
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003056# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003057
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003058run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003059 "$P_SRV" \
3060 "$P_CLI request_size=100" \
3061 0 \
3062 -s "Read from client: 100 bytes read$"
3063
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003064run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003065 "$P_SRV" \
3066 "$P_CLI request_size=500" \
3067 0 \
3068 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003069
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003070# Tests for small packets
3071
Janos Follath542ee5d2016-03-07 15:57:05 +00003072requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003073run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003074 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003075 "$P_CLI request_size=1 force_version=ssl3 \
3076 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3077 0 \
3078 -s "Read from client: 1 bytes read"
3079
Janos Follath542ee5d2016-03-07 15:57:05 +00003080requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003081run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003082 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003083 "$P_CLI request_size=1 force_version=ssl3 \
3084 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3085 0 \
3086 -s "Read from client: 1 bytes read"
3087
3088run_test "Small packet TLS 1.0 BlockCipher" \
3089 "$P_SRV" \
3090 "$P_CLI request_size=1 force_version=tls1 \
3091 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3092 0 \
3093 -s "Read from client: 1 bytes read"
3094
Hanno Becker7aae46c2017-11-10 08:59:04 +00003095run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003096 "$P_SRV" \
3097 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3098 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3099 0 \
3100 -s "Read from client: 1 bytes read"
3101
Hanno Beckera83fafa2017-11-10 08:42:54 +00003102requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003103run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003104 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003105 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003106 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003107 0 \
3108 -s "Read from client: 1 bytes read"
3109
Hanno Beckera83fafa2017-11-10 08:42:54 +00003110requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003111run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003112 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003113 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003114 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003115 0 \
3116 -s "Read from client: 1 bytes read"
3117
3118run_test "Small packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003119 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003120 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003121 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3122 0 \
3123 -s "Read from client: 1 bytes read"
3124
3125run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3126 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3127 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003128 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003129 0 \
3130 -s "Read from client: 1 bytes read"
3131
3132requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3133run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003134 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003135 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003136 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003137 0 \
3138 -s "Read from client: 1 bytes read"
3139
Hanno Becker7aae46c2017-11-10 08:59:04 +00003140requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3141run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003142 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3143 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3144 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003145 0 \
3146 -s "Read from client: 1 bytes read"
3147
3148run_test "Small packet TLS 1.1 BlockCipher" \
3149 "$P_SRV" \
3150 "$P_CLI request_size=1 force_version=tls1_1 \
3151 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3152 0 \
3153 -s "Read from client: 1 bytes read"
3154
Hanno Becker7aae46c2017-11-10 08:59:04 +00003155run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003156 "$P_SRV" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003157 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003158 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003159 0 \
3160 -s "Read from client: 1 bytes read"
3161
3162requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3163run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003164 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003165 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003166 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003167 0 \
3168 -s "Read from client: 1 bytes read"
3169
3170requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3171run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003172 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003173 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003174 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003175 0 \
3176 -s "Read from client: 1 bytes read"
3177
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003178run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003179 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003180 "$P_CLI request_size=1 force_version=tls1_1 \
3181 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3182 0 \
3183 -s "Read from client: 1 bytes read"
3184
Hanno Becker7aae46c2017-11-10 08:59:04 +00003185run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3186 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003187 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003188 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003189 0 \
3190 -s "Read from client: 1 bytes read"
3191
Hanno Becker7aae46c2017-11-10 08:59:04 +00003192requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3193run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003194 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003195 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003196 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003197 0 \
3198 -s "Read from client: 1 bytes read"
3199
Hanno Beckera83fafa2017-11-10 08:42:54 +00003200requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003201run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003202 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003203 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003204 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003205 0 \
3206 -s "Read from client: 1 bytes read"
3207
3208run_test "Small packet TLS 1.2 BlockCipher" \
3209 "$P_SRV" \
3210 "$P_CLI request_size=1 force_version=tls1_2 \
3211 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3212 0 \
3213 -s "Read from client: 1 bytes read"
3214
Hanno Becker7aae46c2017-11-10 08:59:04 +00003215run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003216 "$P_SRV" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003217 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003218 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003219 0 \
3220 -s "Read from client: 1 bytes read"
3221
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003222run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3223 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003224 "$P_CLI request_size=1 force_version=tls1_2 \
3225 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003226 0 \
3227 -s "Read from client: 1 bytes read"
3228
Hanno Beckera83fafa2017-11-10 08:42:54 +00003229requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003230run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003231 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003232 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003233 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003234 0 \
3235 -s "Read from client: 1 bytes read"
3236
Hanno Becker7aae46c2017-11-10 08:59:04 +00003237requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3238run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003239 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003240 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003241 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003242 0 \
3243 -s "Read from client: 1 bytes read"
3244
3245run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003246 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003247 "$P_CLI request_size=1 force_version=tls1_2 \
3248 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3249 0 \
3250 -s "Read from client: 1 bytes read"
3251
Hanno Becker7aae46c2017-11-10 08:59:04 +00003252run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003253 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003254 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003255 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003256 0 \
3257 -s "Read from client: 1 bytes read"
3258
Hanno Beckera83fafa2017-11-10 08:42:54 +00003259requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003260run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003261 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003262 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003263 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003264 0 \
3265 -s "Read from client: 1 bytes read"
3266
Hanno Becker7aae46c2017-11-10 08:59:04 +00003267requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3268run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003269 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003270 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003271 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003272 0 \
3273 -s "Read from client: 1 bytes read"
3274
3275run_test "Small packet TLS 1.2 AEAD" \
3276 "$P_SRV" \
3277 "$P_CLI request_size=1 force_version=tls1_2 \
3278 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3279 0 \
3280 -s "Read from client: 1 bytes read"
3281
3282run_test "Small packet TLS 1.2 AEAD shorter tag" \
3283 "$P_SRV" \
3284 "$P_CLI request_size=1 force_version=tls1_2 \
3285 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3286 0 \
3287 -s "Read from client: 1 bytes read"
3288
Hanno Becker461cb812017-11-10 08:59:18 +00003289# Tests for small packets in DTLS
3290
3291requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3292run_test "Small packet DTLS 1.0" \
3293 "$P_SRV dtls=1 force_version=dtls1" \
3294 "$P_CLI dtls=1 request_size=1 \
3295 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3296 0 \
3297 -s "Read from client: 1 bytes read"
3298
3299requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3300run_test "Small packet DTLS 1.0, without EtM" \
3301 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3302 "$P_CLI dtls=1 request_size=1 \
3303 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3304 0 \
3305 -s "Read from client: 1 bytes read"
3306
3307requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3308requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3309run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003310 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3311 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Becker461cb812017-11-10 08:59:18 +00003312 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3313 0 \
3314 -s "Read from client: 1 bytes read"
3315
3316requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3317requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3318run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003319 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Becker461cb812017-11-10 08:59:18 +00003320 "$P_CLI dtls=1 request_size=1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003321 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Becker461cb812017-11-10 08:59:18 +00003322 0 \
3323 -s "Read from client: 1 bytes read"
3324
3325requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3326run_test "Small packet DTLS 1.2" \
3327 "$P_SRV dtls=1 force_version=dtls1_2" \
3328 "$P_CLI dtls=1 request_size=1 \
3329 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3330 0 \
3331 -s "Read from client: 1 bytes read"
3332
3333requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3334run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003335 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Becker461cb812017-11-10 08:59:18 +00003336 "$P_CLI dtls=1 request_size=1 \
3337 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3338 0 \
3339 -s "Read from client: 1 bytes read"
3340
3341requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3342requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3343run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003344 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Becker461cb812017-11-10 08:59:18 +00003345 "$P_CLI dtls=1 request_size=1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003346 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker461cb812017-11-10 08:59:18 +00003347 0 \
3348 -s "Read from client: 1 bytes read"
3349
3350requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3351requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3352run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003353 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Becker461cb812017-11-10 08:59:18 +00003354 "$P_CLI dtls=1 request_size=1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003355 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Becker461cb812017-11-10 08:59:18 +00003356 0 \
3357 -s "Read from client: 1 bytes read"
3358
Janos Follathb700c462016-05-06 13:48:23 +01003359# A test for extensions in SSLv3
3360
3361requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3362run_test "SSLv3 with extensions, server side" \
3363 "$P_SRV min_version=ssl3 debug_level=3" \
3364 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3365 0 \
3366 -S "dumping 'client hello extensions'" \
3367 -S "server hello, total extension length:"
3368
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003369# Test for large packets
3370
Janos Follath542ee5d2016-03-07 15:57:05 +00003371requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003372run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003373 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003374 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003375 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3376 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003377 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003378 -s "Read from client: 16384 bytes read"
3379
Janos Follath542ee5d2016-03-07 15:57:05 +00003380requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003381run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003382 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003383 "$P_CLI request_size=16384 force_version=ssl3 \
3384 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3385 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003386 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003387 -s "Read from client: 16384 bytes read"
3388
3389run_test "Large packet TLS 1.0 BlockCipher" \
3390 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003391 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003392 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3393 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003394 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003395 -s "Read from client: 16384 bytes read"
3396
Hanno Becker0b9d9132017-11-10 09:16:28 +00003397run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003398 "$P_SRV" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003399 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3400 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3401 0 \
3402 -s "Read from client: 16384 bytes read"
3403
Hanno Beckera83fafa2017-11-10 08:42:54 +00003404requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003405run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003406 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003407 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003408 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003409 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003410 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003411 -s "Read from client: 16384 bytes read"
3412
Hanno Beckera83fafa2017-11-10 08:42:54 +00003413requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003414run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003415 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003416 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003417 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003418 0 \
3419 -s "Read from client: 16384 bytes read"
3420
3421run_test "Large packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003422 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003423 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003424 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3425 0 \
3426 -s "Read from client: 16384 bytes read"
3427
3428run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
3429 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3430 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003431 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003432 0 \
3433 -s "Read from client: 16384 bytes read"
3434
3435requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3436run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003437 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003438 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003439 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003440 0 \
3441 -s "Read from client: 16384 bytes read"
3442
Hanno Becker0b9d9132017-11-10 09:16:28 +00003443requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3444run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003445 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003446 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003447 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003448 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003449 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003450 -s "Read from client: 16384 bytes read"
3451
3452run_test "Large packet TLS 1.1 BlockCipher" \
3453 "$P_SRV" \
3454 "$P_CLI request_size=16384 force_version=tls1_1 \
3455 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3456 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003457 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003458 -s "Read from client: 16384 bytes read"
3459
Hanno Becker0b9d9132017-11-10 09:16:28 +00003460run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
3461 "$P_SRV" \
3462 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
3463 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003464 0 \
3465 -s "Read from client: 16384 bytes read"
3466
Hanno Beckera83fafa2017-11-10 08:42:54 +00003467requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003468run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003469 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003470 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003471 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003472 0 \
3473 -s "Read from client: 16384 bytes read"
3474
Hanno Beckera83fafa2017-11-10 08:42:54 +00003475requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003476run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003477 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003478 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003479 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003480 0 \
3481 -s "Read from client: 16384 bytes read"
3482
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003483run_test "Large packet TLS 1.1 StreamCipher" \
3484 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3485 "$P_CLI request_size=16384 force_version=tls1_1 \
3486 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3487 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003488 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003489 -s "Read from client: 16384 bytes read"
3490
Hanno Becker0b9d9132017-11-10 09:16:28 +00003491run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
3492 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003493 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003494 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003495 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003496 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003497 -s "Read from client: 16384 bytes read"
3498
Hanno Becker0b9d9132017-11-10 09:16:28 +00003499requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3500run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003501 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003502 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003503 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003504 0 \
3505 -s "Read from client: 16384 bytes read"
3506
Hanno Becker0b9d9132017-11-10 09:16:28 +00003507requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3508run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003509 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003510 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003511 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003512 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003513 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003514 -s "Read from client: 16384 bytes read"
3515
3516run_test "Large packet TLS 1.2 BlockCipher" \
3517 "$P_SRV" \
3518 "$P_CLI request_size=16384 force_version=tls1_2 \
3519 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3520 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003521 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003522 -s "Read from client: 16384 bytes read"
3523
Hanno Becker0b9d9132017-11-10 09:16:28 +00003524run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
3525 "$P_SRV" \
3526 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
3527 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3528 0 \
3529 -s "Read from client: 16384 bytes read"
3530
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003531run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3532 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003533 "$P_CLI request_size=16384 force_version=tls1_2 \
3534 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003535 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003536 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003537 -s "Read from client: 16384 bytes read"
3538
Hanno Beckera83fafa2017-11-10 08:42:54 +00003539requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003540run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003541 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003542 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003543 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003544 0 \
3545 -s "Read from client: 16384 bytes read"
3546
Hanno Becker0b9d9132017-11-10 09:16:28 +00003547requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3548run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003549 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003550 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003551 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003552 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003553 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003554 -s "Read from client: 16384 bytes read"
3555
3556run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003557 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003558 "$P_CLI request_size=16384 force_version=tls1_2 \
3559 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3560 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003561 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003562 -s "Read from client: 16384 bytes read"
3563
Hanno Becker0b9d9132017-11-10 09:16:28 +00003564run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003565 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003566 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003567 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
3568 0 \
3569 -s "Read from client: 16384 bytes read"
3570
Hanno Beckera83fafa2017-11-10 08:42:54 +00003571requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003572run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003573 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003574 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003575 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003576 0 \
3577 -s "Read from client: 16384 bytes read"
3578
Hanno Becker0b9d9132017-11-10 09:16:28 +00003579requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3580run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003581 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003582 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003583 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003584 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003585 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003586 -s "Read from client: 16384 bytes read"
3587
3588run_test "Large packet TLS 1.2 AEAD" \
3589 "$P_SRV" \
3590 "$P_CLI request_size=16384 force_version=tls1_2 \
3591 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3592 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003593 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003594 -s "Read from client: 16384 bytes read"
3595
3596run_test "Large packet TLS 1.2 AEAD shorter tag" \
3597 "$P_SRV" \
3598 "$P_CLI request_size=16384 force_version=tls1_2 \
3599 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3600 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003601 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003602 -s "Read from client: 16384 bytes read"
3603
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003604# Tests for DTLS HelloVerifyRequest
3605
3606run_test "DTLS cookie: enabled" \
3607 "$P_SRV dtls=1 debug_level=2" \
3608 "$P_CLI dtls=1 debug_level=2" \
3609 0 \
3610 -s "cookie verification failed" \
3611 -s "cookie verification passed" \
3612 -S "cookie verification skipped" \
3613 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003614 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003615 -S "SSL - The requested feature is not available"
3616
3617run_test "DTLS cookie: disabled" \
3618 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3619 "$P_CLI dtls=1 debug_level=2" \
3620 0 \
3621 -S "cookie verification failed" \
3622 -S "cookie verification passed" \
3623 -s "cookie verification skipped" \
3624 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003625 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003626 -S "SSL - The requested feature is not available"
3627
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003628run_test "DTLS cookie: default (failing)" \
3629 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3630 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3631 1 \
3632 -s "cookie verification failed" \
3633 -S "cookie verification passed" \
3634 -S "cookie verification skipped" \
3635 -C "received hello verify request" \
3636 -S "hello verification requested" \
3637 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003638
3639requires_ipv6
3640run_test "DTLS cookie: enabled, IPv6" \
3641 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3642 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3643 0 \
3644 -s "cookie verification failed" \
3645 -s "cookie verification passed" \
3646 -S "cookie verification skipped" \
3647 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003648 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003649 -S "SSL - The requested feature is not available"
3650
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003651run_test "DTLS cookie: enabled, nbio" \
3652 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3653 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3654 0 \
3655 -s "cookie verification failed" \
3656 -s "cookie verification passed" \
3657 -S "cookie verification skipped" \
3658 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003659 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003660 -S "SSL - The requested feature is not available"
3661
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003662# Tests for client reconnecting from the same port with DTLS
3663
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003664not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003665run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003666 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3667 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003668 0 \
3669 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003670 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003671 -S "Client initiated reconnection from same port"
3672
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003673not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003674run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003675 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3676 "$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 +02003677 0 \
3678 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003679 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003680 -s "Client initiated reconnection from same port"
3681
Paul Bakker3b224ff2016-05-13 10:33:25 +01003682not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3683run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003684 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3685 "$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 +02003686 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003687 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003688 -s "Client initiated reconnection from same port"
3689
Paul Bakker3b224ff2016-05-13 10:33:25 +01003690only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3691run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3692 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3693 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3694 0 \
3695 -S "The operation timed out" \
3696 -s "Client initiated reconnection from same port"
3697
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003698run_test "DTLS client reconnect from same port: no cookies" \
3699 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003700 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3701 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003702 -s "The operation timed out" \
3703 -S "Client initiated reconnection from same port"
3704
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003705# Tests for various cases of client authentication with DTLS
3706# (focused on handshake flows and message parsing)
3707
3708run_test "DTLS client auth: required" \
3709 "$P_SRV dtls=1 auth_mode=required" \
3710 "$P_CLI dtls=1" \
3711 0 \
3712 -s "Verifying peer X.509 certificate... ok"
3713
3714run_test "DTLS client auth: optional, client has no cert" \
3715 "$P_SRV dtls=1 auth_mode=optional" \
3716 "$P_CLI dtls=1 crt_file=none key_file=none" \
3717 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003718 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003719
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003720run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003721 "$P_SRV dtls=1 auth_mode=none" \
3722 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3723 0 \
3724 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003725 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003726
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003727run_test "DTLS wrong PSK: badmac alert" \
3728 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3729 "$P_CLI dtls=1 psk=abc124" \
3730 1 \
3731 -s "SSL - Verification of the message MAC failed" \
3732 -c "SSL - A fatal alert message was received from our peer"
3733
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003734# Tests for receiving fragmented handshake messages with DTLS
3735
3736requires_gnutls
3737run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3738 "$G_SRV -u --mtu 2048 -a" \
3739 "$P_CLI dtls=1 debug_level=2" \
3740 0 \
3741 -C "found fragmented DTLS handshake message" \
3742 -C "error"
3743
3744requires_gnutls
3745run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3746 "$G_SRV -u --mtu 512" \
3747 "$P_CLI dtls=1 debug_level=2" \
3748 0 \
3749 -c "found fragmented DTLS handshake message" \
3750 -C "error"
3751
3752requires_gnutls
3753run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3754 "$G_SRV -u --mtu 128" \
3755 "$P_CLI dtls=1 debug_level=2" \
3756 0 \
3757 -c "found fragmented DTLS handshake message" \
3758 -C "error"
3759
3760requires_gnutls
3761run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3762 "$G_SRV -u --mtu 128" \
3763 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3764 0 \
3765 -c "found fragmented DTLS handshake message" \
3766 -C "error"
3767
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003768requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01003769requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003770run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3771 "$G_SRV -u --mtu 256" \
3772 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3773 0 \
3774 -c "found fragmented DTLS handshake message" \
3775 -c "client hello, adding renegotiation extension" \
3776 -c "found renegotiation extension" \
3777 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003778 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003779 -C "error" \
3780 -s "Extra-header:"
3781
3782requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01003783requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003784run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3785 "$G_SRV -u --mtu 256" \
3786 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3787 0 \
3788 -c "found fragmented DTLS handshake message" \
3789 -c "client hello, adding renegotiation extension" \
3790 -c "found renegotiation extension" \
3791 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003792 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003793 -C "error" \
3794 -s "Extra-header:"
3795
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003796run_test "DTLS reassembly: no fragmentation (openssl server)" \
3797 "$O_SRV -dtls1 -mtu 2048" \
3798 "$P_CLI dtls=1 debug_level=2" \
3799 0 \
3800 -C "found fragmented DTLS handshake message" \
3801 -C "error"
3802
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003803run_test "DTLS reassembly: some fragmentation (openssl server)" \
3804 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003805 "$P_CLI dtls=1 debug_level=2" \
3806 0 \
3807 -c "found fragmented DTLS handshake message" \
3808 -C "error"
3809
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003810run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003811 "$O_SRV -dtls1 -mtu 256" \
3812 "$P_CLI dtls=1 debug_level=2" \
3813 0 \
3814 -c "found fragmented DTLS handshake message" \
3815 -C "error"
3816
3817run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3818 "$O_SRV -dtls1 -mtu 256" \
3819 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3820 0 \
3821 -c "found fragmented DTLS handshake message" \
3822 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003823
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003824# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003825
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003826not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003827run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003828 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003829 "$P_SRV dtls=1 debug_level=2" \
3830 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003831 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003832 -C "replayed record" \
3833 -S "replayed record" \
3834 -C "record from another epoch" \
3835 -S "record from another epoch" \
3836 -C "discarding invalid record" \
3837 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003838 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003839 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003840 -c "HTTP/1.0 200 OK"
3841
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003842not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003843run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003844 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003845 "$P_SRV dtls=1 debug_level=2" \
3846 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003847 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003848 -c "replayed record" \
3849 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003850 -c "discarding invalid record" \
3851 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003852 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003853 -s "Extra-header:" \
3854 -c "HTTP/1.0 200 OK"
3855
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003856run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3857 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003858 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3859 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003860 0 \
3861 -c "replayed record" \
3862 -S "replayed record" \
3863 -c "discarding invalid record" \
3864 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003865 -c "resend" \
3866 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003867 -s "Extra-header:" \
3868 -c "HTTP/1.0 200 OK"
3869
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003870run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003871 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003872 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003873 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003874 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003875 -c "discarding invalid record (mac)" \
3876 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003877 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003878 -c "HTTP/1.0 200 OK" \
3879 -S "too many records with bad MAC" \
3880 -S "Verification of the message MAC failed"
3881
3882run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3883 -p "$P_PXY bad_ad=1" \
3884 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3885 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3886 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003887 -C "discarding invalid record (mac)" \
3888 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003889 -S "Extra-header:" \
3890 -C "HTTP/1.0 200 OK" \
3891 -s "too many records with bad MAC" \
3892 -s "Verification of the message MAC failed"
3893
3894run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3895 -p "$P_PXY bad_ad=1" \
3896 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3897 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3898 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003899 -c "discarding invalid record (mac)" \
3900 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003901 -s "Extra-header:" \
3902 -c "HTTP/1.0 200 OK" \
3903 -S "too many records with bad MAC" \
3904 -S "Verification of the message MAC failed"
3905
3906run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3907 -p "$P_PXY bad_ad=1" \
3908 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3909 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3910 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003911 -c "discarding invalid record (mac)" \
3912 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003913 -s "Extra-header:" \
3914 -c "HTTP/1.0 200 OK" \
3915 -s "too many records with bad MAC" \
3916 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003917
3918run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003919 -p "$P_PXY delay_ccs=1" \
3920 "$P_SRV dtls=1 debug_level=1" \
3921 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003922 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003923 -c "record from another epoch" \
3924 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003925 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003926 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003927 -s "Extra-header:" \
3928 -c "HTTP/1.0 200 OK"
3929
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003930# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003931
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003932needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003933run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003934 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003935 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3936 psk=abc123" \
3937 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003938 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3939 0 \
3940 -s "Extra-header:" \
3941 -c "HTTP/1.0 200 OK"
3942
3943needs_more_time 2
3944run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3945 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003946 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3947 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003948 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3949 0 \
3950 -s "Extra-header:" \
3951 -c "HTTP/1.0 200 OK"
3952
3953needs_more_time 2
3954run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3955 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003956 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3957 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003958 0 \
3959 -s "Extra-header:" \
3960 -c "HTTP/1.0 200 OK"
3961
3962needs_more_time 2
3963run_test "DTLS proxy: 3d, FS, client auth" \
3964 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003965 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3966 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003967 0 \
3968 -s "Extra-header:" \
3969 -c "HTTP/1.0 200 OK"
3970
3971needs_more_time 2
3972run_test "DTLS proxy: 3d, FS, ticket" \
3973 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003974 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3975 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003976 0 \
3977 -s "Extra-header:" \
3978 -c "HTTP/1.0 200 OK"
3979
3980needs_more_time 2
3981run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3982 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003983 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3984 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003985 0 \
3986 -s "Extra-header:" \
3987 -c "HTTP/1.0 200 OK"
3988
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003989needs_more_time 2
3990run_test "DTLS proxy: 3d, max handshake, nbio" \
3991 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003992 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3993 auth_mode=required" \
3994 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003995 0 \
3996 -s "Extra-header:" \
3997 -c "HTTP/1.0 200 OK"
3998
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003999needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004000run_test "DTLS proxy: 3d, min handshake, resumption" \
4001 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4002 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4003 psk=abc123 debug_level=3" \
4004 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4005 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4006 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4007 0 \
4008 -s "a session has been resumed" \
4009 -c "a session has been resumed" \
4010 -s "Extra-header:" \
4011 -c "HTTP/1.0 200 OK"
4012
4013needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004014run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4015 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4016 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4017 psk=abc123 debug_level=3 nbio=2" \
4018 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4019 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4020 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4021 0 \
4022 -s "a session has been resumed" \
4023 -c "a session has been resumed" \
4024 -s "Extra-header:" \
4025 -c "HTTP/1.0 200 OK"
4026
4027needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004028requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004029run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004030 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004031 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4032 psk=abc123 renegotiation=1 debug_level=2" \
4033 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4034 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004035 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4036 0 \
4037 -c "=> renegotiate" \
4038 -s "=> renegotiate" \
4039 -s "Extra-header:" \
4040 -c "HTTP/1.0 200 OK"
4041
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004042needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004043requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004044run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4045 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004046 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4047 psk=abc123 renegotiation=1 debug_level=2" \
4048 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4049 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004050 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4051 0 \
4052 -c "=> renegotiate" \
4053 -s "=> renegotiate" \
4054 -s "Extra-header:" \
4055 -c "HTTP/1.0 200 OK"
4056
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004057needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004058requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004059run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004060 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004061 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004062 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004063 debug_level=2" \
4064 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004065 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004066 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4067 0 \
4068 -c "=> renegotiate" \
4069 -s "=> renegotiate" \
4070 -s "Extra-header:" \
4071 -c "HTTP/1.0 200 OK"
4072
4073needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004074requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004075run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004076 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004077 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004078 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004079 debug_level=2 nbio=2" \
4080 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004081 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004082 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4083 0 \
4084 -c "=> renegotiate" \
4085 -s "=> renegotiate" \
4086 -s "Extra-header:" \
4087 -c "HTTP/1.0 200 OK"
4088
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02004089needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004090not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004091run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004092 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4093 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004094 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004095 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004096 -c "HTTP/1.0 200 OK"
4097
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004098needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004099not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004100run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4101 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4102 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004103 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004104 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004105 -c "HTTP/1.0 200 OK"
4106
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004107needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004108not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004109run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4110 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4111 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004112 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004113 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004114 -c "HTTP/1.0 200 OK"
4115
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004116requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02004117needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004118not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004119run_test "DTLS proxy: 3d, gnutls server" \
4120 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4121 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004122 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004123 0 \
4124 -s "Extra-header:" \
4125 -c "Extra-header:"
4126
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004127requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004128needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004129not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004130run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4131 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4132 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004133 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004134 0 \
4135 -s "Extra-header:" \
4136 -c "Extra-header:"
4137
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004138requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004139needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004140not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004141run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4142 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4143 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004144 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004145 0 \
4146 -s "Extra-header:" \
4147 -c "Extra-header:"
4148
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004149# Final report
4150
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004151echo "------------------------------------------------------------------------"
4152
4153if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004154 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004155else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004156 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004157fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004158PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004159echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004160
4161exit $FAILS