blob: 4c6512142fd9463c683ff3f37af6c4e893fb7411 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020031: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010032
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020033O_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 +010034O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020035G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010036G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020037TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010038
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010039TESTS=0
40FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020041SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010042
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000043CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020044
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020047EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010048
Paul Bakkere20310a2016-05-10 11:18:17 +010049SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010050RUN_TEST_NUMBER=''
51
Paul Bakkeracaac852016-05-10 11:47:13 +010052PRESERVE_LOGS=0
53
Gilles Peskinef93c7d32017-04-14 17:55:28 +020054# Pick a "unique" server port in the range 10000-19999, and a proxy
55# port which is this plus 10000. Each port number may be independently
56# overridden by a command line option.
57SRV_PORT=$(($$ % 10000 + 10000))
58PXY_PORT=$((SRV_PORT + 10000))
59
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010060print_usage() {
61 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010062 printf " -h|--help\tPrint this help.\n"
63 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020064 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
65 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010066 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010067 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010068 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020069 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
70 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010071 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072}
73
74get_options() {
75 while [ $# -gt 0 ]; do
76 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010077 -f|--filter)
78 shift; FILTER=$1
79 ;;
80 -e|--exclude)
81 shift; EXCLUDE=$1
82 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010083 -m|--memcheck)
84 MEMCHECK=1
85 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010086 -n|--number)
87 shift; RUN_TEST_NUMBER=$1
88 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010089 -s|--show-numbers)
90 SHOW_TEST_NUMBER=1
91 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010092 -p|--preserve-logs)
93 PRESERVE_LOGS=1
94 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020095 --port)
96 shift; SRV_PORT=$1
97 ;;
98 --proxy-port)
99 shift; PXY_PORT=$1
100 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100101 --seed)
102 shift; SEED="$1"
103 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100104 -h|--help)
105 print_usage
106 exit 0
107 ;;
108 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200109 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100110 print_usage
111 exit 1
112 ;;
113 esac
114 shift
115 done
116}
117
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100118# skip next test if the flag is not enabled in config.h
119requires_config_enabled() {
120 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
121 SKIP_NEXT="YES"
122 fi
123}
124
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200125# skip next test if the flag is enabled in config.h
126requires_config_disabled() {
127 if grep "^#define $1" $CONFIG_H > /dev/null; then
128 SKIP_NEXT="YES"
129 fi
130}
131
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200132# skip next test if OpenSSL doesn't support FALLBACK_SCSV
133requires_openssl_with_fallback_scsv() {
134 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
135 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
136 then
137 OPENSSL_HAS_FBSCSV="YES"
138 else
139 OPENSSL_HAS_FBSCSV="NO"
140 fi
141 fi
142 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
143 SKIP_NEXT="YES"
144 fi
145}
146
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200147# skip next test if GnuTLS isn't available
148requires_gnutls() {
149 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200150 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200151 GNUTLS_AVAILABLE="YES"
152 else
153 GNUTLS_AVAILABLE="NO"
154 fi
155 fi
156 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200161# skip next test if IPv6 isn't available on this host
162requires_ipv6() {
163 if [ -z "${HAS_IPV6:-}" ]; then
164 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
165 SRV_PID=$!
166 sleep 1
167 kill $SRV_PID >/dev/null 2>&1
168 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
169 HAS_IPV6="NO"
170 else
171 HAS_IPV6="YES"
172 fi
173 rm -r $SRV_OUT
174 fi
175
176 if [ "$HAS_IPV6" = "NO" ]; then
177 SKIP_NEXT="YES"
178 fi
179}
180
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200181# skip the next test if valgrind is in use
182not_with_valgrind() {
183 if [ "$MEMCHECK" -gt 0 ]; then
184 SKIP_NEXT="YES"
185 fi
186}
187
Paul Bakker362689d2016-05-13 10:33:25 +0100188# skip the next test if valgrind is NOT in use
189only_with_valgrind() {
190 if [ "$MEMCHECK" -eq 0 ]; then
191 SKIP_NEXT="YES"
192 fi
193}
194
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200195# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100196client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200197 CLI_DELAY_FACTOR=$1
198}
199
Janos Follath74537a62016-09-02 13:45:28 +0100200# wait for the given seconds after the client finished in the next test
201server_needs_more_time() {
202 SRV_DELAY_SECONDS=$1
203}
204
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100205# print_name <name>
206print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100207 TESTS=$(( $TESTS + 1 ))
208 LINE=""
209
210 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
211 LINE="$TESTS "
212 fi
213
214 LINE="$LINE$1"
215 printf "$LINE "
216 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100217 for i in `seq 1 $LEN`; do printf '.'; done
218 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100219
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100220}
221
222# fail <message>
223fail() {
224 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100225 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100226
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200227 mv $SRV_OUT o-srv-${TESTS}.log
228 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200229 if [ -n "$PXY_CMD" ]; then
230 mv $PXY_OUT o-pxy-${TESTS}.log
231 fi
232 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100233
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200234 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
235 echo " ! server output:"
236 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200237 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200238 echo " ! client output:"
239 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200240 if [ -n "$PXY_CMD" ]; then
241 echo " ! ========================================================"
242 echo " ! proxy output:"
243 cat o-pxy-${TESTS}.log
244 fi
245 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200246 fi
247
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200248 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100249}
250
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100251# is_polar <cmd_line>
252is_polar() {
253 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
254}
255
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200256# openssl s_server doesn't have -www with DTLS
257check_osrv_dtls() {
258 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
259 NEEDS_INPUT=1
260 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
261 else
262 NEEDS_INPUT=0
263 fi
264}
265
266# provide input to commands that need it
267provide_input() {
268 if [ $NEEDS_INPUT -eq 0 ]; then
269 return
270 fi
271
272 while true; do
273 echo "HTTP/1.0 200 OK"
274 sleep 1
275 done
276}
277
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100278# has_mem_err <log_file_name>
279has_mem_err() {
280 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
281 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
282 then
283 return 1 # false: does not have errors
284 else
285 return 0 # true: has errors
286 fi
287}
288
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200289# wait for server to start: two versions depending on lsof availability
290wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200291 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200292 START_TIME=$( date +%s )
293 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200294
295 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200296 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200297 while [ $DONE -eq 0 ]; do
298 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
299 then
300 DONE=1
301 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
302 echo "SERVERSTART TIMEOUT"
303 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
304 DONE=1
305 fi
306 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200307 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200308 while [ $DONE -eq 0 ]; do
309 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
310 then
311 DONE=1
312 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
313 echo "SERVERSTART TIMEOUT"
314 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
315 DONE=1
316 fi
317 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200318 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200319 else
320 sleep "$START_DELAY"
321 fi
322}
323
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200324# wait for client to terminate and set CLI_EXIT
325# must be called right after starting the client
326wait_client_done() {
327 CLI_PID=$!
328
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200329 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
330 CLI_DELAY_FACTOR=1
331
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200332 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200333 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200334
335 wait $CLI_PID
336 CLI_EXIT=$?
337
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200338 kill $DOG_PID >/dev/null 2>&1
339 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200340
341 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100342
343 sleep $SRV_DELAY_SECONDS
344 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200345}
346
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200347# check if the given command uses dtls and sets global variable DTLS
348detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200349 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200350 DTLS=1
351 else
352 DTLS=0
353 fi
354}
355
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200356# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100357# Options: -s pattern pattern that must be present in server output
358# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100359# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100360# -S pattern pattern that must be absent in server output
361# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100362# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100363run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100364 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200365 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100366
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100367 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
368 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200369 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100370 return
371 fi
372
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100373 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100374
Paul Bakkerb7584a52016-05-10 10:50:43 +0100375 # Do we only run numbered tests?
376 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
377 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
378 else
379 SKIP_NEXT="YES"
380 fi
381
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200382 # should we skip?
383 if [ "X$SKIP_NEXT" = "XYES" ]; then
384 SKIP_NEXT="NO"
385 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200386 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200387 return
388 fi
389
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200390 # does this test use a proxy?
391 if [ "X$1" = "X-p" ]; then
392 PXY_CMD="$2"
393 shift 2
394 else
395 PXY_CMD=""
396 fi
397
398 # get commands and client output
399 SRV_CMD="$1"
400 CLI_CMD="$2"
401 CLI_EXPECT="$3"
402 shift 3
403
404 # fix client port
405 if [ -n "$PXY_CMD" ]; then
406 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
407 else
408 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
409 fi
410
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200411 # update DTLS variable
412 detect_dtls "$SRV_CMD"
413
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100414 # prepend valgrind to our commands if active
415 if [ "$MEMCHECK" -gt 0 ]; then
416 if is_polar "$SRV_CMD"; then
417 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
418 fi
419 if is_polar "$CLI_CMD"; then
420 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
421 fi
422 fi
423
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200424 TIMES_LEFT=2
425 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200426 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200427
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200428 # run the commands
429 if [ -n "$PXY_CMD" ]; then
430 echo "$PXY_CMD" > $PXY_OUT
431 $PXY_CMD >> $PXY_OUT 2>&1 &
432 PXY_PID=$!
433 # assume proxy starts faster than server
434 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200435
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200436 check_osrv_dtls
437 echo "$SRV_CMD" > $SRV_OUT
438 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
439 SRV_PID=$!
440 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200441
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200442 echo "$CLI_CMD" > $CLI_OUT
443 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
444 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100445
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100446 sleep 0.05
447
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200448 # terminate the server (and the proxy)
449 kill $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100450 sleep 0.01
451 if kill -0 $SRV_PID >/dev/null 2>&1; then
452 kill -KILL $SRV_PID
453 wait $SRV_PID
454 fi
455
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200456 if [ -n "$PXY_CMD" ]; then
457 kill $PXY_PID >/dev/null 2>&1
Hanno Beckerd82d8462017-05-29 21:37:46 +0100458 sleep 0.01
459 if kill -0 $PXY_PID >/dev/null 2>&1; then
Hanno Becker4ac73e72017-10-23 15:27:37 +0100460 kill -KILL $PXY_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100461 wait $PXY_PID
462 fi
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200463 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100464
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200465 # retry only on timeouts
466 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
467 printf "RETRY "
468 else
469 TIMES_LEFT=0
470 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200471 done
472
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100473 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200474 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100475 # expected client exit to incorrectly succeed in case of catastrophic
476 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100477 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200478 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100479 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100480 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100481 return
482 fi
483 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100484 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200485 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100486 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100487 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100488 return
489 fi
490 fi
491
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100492 # check server exit code
493 if [ $? != 0 ]; then
494 fail "server fail"
495 return
496 fi
497
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100498 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100499 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
500 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100501 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200502 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100503 return
504 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100505
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100506 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200507 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100508 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100509 while [ $# -gt 0 ]
510 do
511 case $1 in
512 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100513 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100514 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100515 return
516 fi
517 ;;
518
519 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100520 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100521 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100522 return
523 fi
524 ;;
525
526 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100527 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100528 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100529 return
530 fi
531 ;;
532
533 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100534 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100535 fail "pattern '$2' MUST NOT be present in the Client output"
536 return
537 fi
538 ;;
539
540 # The filtering in the following two options (-u and -U) do the following
541 # - ignore valgrind output
542 # - filter out everything but lines right after the pattern occurances
543 # - keep one of each non-unique line
544 # - count how many lines remain
545 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
546 # if there were no duplicates.
547 "-U")
548 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
549 fail "lines following pattern '$2' must be unique in Server output"
550 return
551 fi
552 ;;
553
554 "-u")
555 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
556 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100557 return
558 fi
559 ;;
560
561 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200562 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100563 exit 1
564 esac
565 shift 2
566 done
567
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100568 # check valgrind's results
569 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200570 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100571 fail "Server has memory errors"
572 return
573 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200574 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100575 fail "Client has memory errors"
576 return
577 fi
578 fi
579
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100580 # if we're here, everything is ok
581 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100582 if [ "$PRESERVE_LOGS" -gt 0 ]; then
583 mv $SRV_OUT o-srv-${TESTS}.log
584 mv $CLI_OUT o-cli-${TESTS}.log
585 fi
586
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200587 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100588}
589
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100590cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200591 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200592 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
593 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
594 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
595 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100596 exit 1
597}
598
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100599#
600# MAIN
601#
602
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000603if cd $( dirname $0 ); then :; else
604 echo "cd $( dirname $0 ) failed" >&2
605 exit 1
606fi
607
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100608get_options "$@"
609
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100610# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100611P_SRV_BIN="${P_SRV%%[ ]*}"
612P_CLI_BIN="${P_CLI%%[ ]*}"
613P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100614if [ ! -x "$P_SRV_BIN" ]; then
615 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100616 exit 1
617fi
Hanno Becker17c04932017-10-10 14:44:53 +0100618if [ ! -x "$P_CLI_BIN" ]; then
619 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100620 exit 1
621fi
Hanno Becker17c04932017-10-10 14:44:53 +0100622if [ ! -x "$P_PXY_BIN" ]; then
623 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200624 exit 1
625fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100626if [ "$MEMCHECK" -gt 0 ]; then
627 if which valgrind >/dev/null 2>&1; then :; else
628 echo "Memcheck not possible. Valgrind not found"
629 exit 1
630 fi
631fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100632if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
633 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100634 exit 1
635fi
636
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200637# used by watchdog
638MAIN_PID="$$"
639
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200640# be more patient with valgrind
641if [ "$MEMCHECK" -gt 0 ]; then
642 START_DELAY=3
643 DOG_DELAY=30
644else
645 START_DELAY=1
646 DOG_DELAY=10
647fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200648CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100649SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200650
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200651# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000652# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200653P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
654P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100655P_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 +0200656O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200657O_CLI="$O_CLI -connect localhost:+SRV_PORT"
658G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000659G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200660
Gilles Peskine62469d92017-05-10 10:13:59 +0200661# Allow SHA-1, because many of our test certificates use it
662P_SRV="$P_SRV allow_sha1=1"
663P_CLI="$P_CLI allow_sha1=1"
664
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200665# Also pick a unique name for intermediate files
666SRV_OUT="srv_out.$$"
667CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200668PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200669SESSION="session.$$"
670
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200671SKIP_NEXT="NO"
672
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100673trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100674
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200675# Basic test
676
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200677# Checks that:
678# - things work with all ciphersuites active (used with config-full in all.sh)
679# - the expected (highest security) parameters are selected
680# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200681run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200682 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200683 "$P_CLI" \
684 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200685 -s "Protocol is TLSv1.2" \
686 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
687 -s "client hello v3, signature_algorithm ext: 6" \
688 -s "ECDHE curve: secp521r1" \
689 -S "error" \
690 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200691
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000692run_test "Default, DTLS" \
693 "$P_SRV dtls=1" \
694 "$P_CLI dtls=1" \
695 0 \
696 -s "Protocol is DTLSv1.2" \
697 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
698
Simon Butcher8e004102016-10-14 00:48:33 +0100699# Test for uniqueness of IVs in AEAD ciphersuites
700run_test "Unique IV in GCM" \
701 "$P_SRV exchanges=20 debug_level=4" \
702 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
703 0 \
704 -u "IV used" \
705 -U "IV used"
706
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100707# Tests for rc4 option
708
Simon Butchera410af52016-05-19 22:12:18 +0100709requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100710run_test "RC4: server disabled, client enabled" \
711 "$P_SRV" \
712 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
713 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100714 -s "SSL - The server has no ciphersuites in common"
715
Simon Butchera410af52016-05-19 22:12:18 +0100716requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100717run_test "RC4: server half, client enabled" \
718 "$P_SRV arc4=1" \
719 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
720 1 \
721 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100722
723run_test "RC4: server enabled, client disabled" \
724 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
725 "$P_CLI" \
726 1 \
727 -s "SSL - The server has no ciphersuites in common"
728
729run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100730 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100731 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
732 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100733 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100734 -S "SSL - The server has no ciphersuites in common"
735
Gilles Peskinebc70a182017-05-09 15:59:24 +0200736# Tests for SHA-1 support
737
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200738requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200739run_test "SHA-1 forbidden by default in server certificate" \
740 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
741 "$P_CLI debug_level=2 allow_sha1=0" \
742 1 \
743 -c "The certificate is signed with an unacceptable hash"
744
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200745requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
746run_test "SHA-1 forbidden by default in server certificate" \
747 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
748 "$P_CLI debug_level=2 allow_sha1=0" \
749 0
750
Gilles Peskinebc70a182017-05-09 15:59:24 +0200751run_test "SHA-1 explicitly allowed in server certificate" \
752 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
753 "$P_CLI allow_sha1=1" \
754 0
755
756run_test "SHA-256 allowed by default in server certificate" \
757 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
758 "$P_CLI allow_sha1=0" \
759 0
760
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200761requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200762run_test "SHA-1 forbidden by default in client certificate" \
763 "$P_SRV auth_mode=required allow_sha1=0" \
764 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
765 1 \
766 -s "The certificate is signed with an unacceptable hash"
767
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200768requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
769run_test "SHA-1 forbidden by default in client certificate" \
770 "$P_SRV auth_mode=required allow_sha1=0" \
771 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
772 0
773
Gilles Peskinebc70a182017-05-09 15:59:24 +0200774run_test "SHA-1 explicitly allowed in client certificate" \
775 "$P_SRV auth_mode=required allow_sha1=1" \
776 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
777 0
778
779run_test "SHA-256 allowed by default in client certificate" \
780 "$P_SRV auth_mode=required allow_sha1=0" \
781 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
782 0
783
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100784# Tests for Truncated HMAC extension
785
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100786run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200787 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100788 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100789 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100790 -s "dumping 'computed mac' (20 bytes)" \
791 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100792
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100793run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200794 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100795 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
796 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100797 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100798 -s "dumping 'computed mac' (20 bytes)" \
799 -S "dumping 'computed mac' (10 bytes)"
800
801run_test "Truncated HMAC: client enabled, server default" \
802 "$P_SRV debug_level=4" \
803 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
804 trunc_hmac=1" \
805 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100806 -s "dumping 'computed mac' (20 bytes)" \
807 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100808
809run_test "Truncated HMAC: client enabled, server disabled" \
810 "$P_SRV debug_level=4 trunc_hmac=0" \
811 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
812 trunc_hmac=1" \
813 0 \
814 -s "dumping 'computed mac' (20 bytes)" \
815 -S "dumping 'computed mac' (10 bytes)"
816
817run_test "Truncated HMAC: client enabled, server enabled" \
818 "$P_SRV debug_level=4 trunc_hmac=1" \
819 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
820 trunc_hmac=1" \
821 0 \
822 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100823 -s "dumping 'computed mac' (10 bytes)"
824
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100825# Tests for Encrypt-then-MAC extension
826
827run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100828 "$P_SRV debug_level=3 \
829 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100830 "$P_CLI debug_level=3" \
831 0 \
832 -c "client hello, adding encrypt_then_mac extension" \
833 -s "found encrypt then mac extension" \
834 -s "server hello, adding encrypt then mac extension" \
835 -c "found encrypt_then_mac extension" \
836 -c "using encrypt then mac" \
837 -s "using encrypt then mac"
838
839run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100840 "$P_SRV debug_level=3 etm=0 \
841 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100842 "$P_CLI debug_level=3 etm=1" \
843 0 \
844 -c "client hello, adding encrypt_then_mac extension" \
845 -s "found encrypt then mac extension" \
846 -S "server hello, adding encrypt then mac extension" \
847 -C "found encrypt_then_mac extension" \
848 -C "using encrypt then mac" \
849 -S "using encrypt then mac"
850
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100851run_test "Encrypt then MAC: client enabled, aead cipher" \
852 "$P_SRV debug_level=3 etm=1 \
853 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
854 "$P_CLI debug_level=3 etm=1" \
855 0 \
856 -c "client hello, adding encrypt_then_mac extension" \
857 -s "found encrypt then mac extension" \
858 -S "server hello, adding encrypt then mac extension" \
859 -C "found encrypt_then_mac extension" \
860 -C "using encrypt then mac" \
861 -S "using encrypt then mac"
862
863run_test "Encrypt then MAC: client enabled, stream cipher" \
864 "$P_SRV debug_level=3 etm=1 \
865 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100866 "$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 +0100867 0 \
868 -c "client hello, adding encrypt_then_mac extension" \
869 -s "found encrypt then mac extension" \
870 -S "server hello, adding encrypt then mac extension" \
871 -C "found encrypt_then_mac extension" \
872 -C "using encrypt then mac" \
873 -S "using encrypt then mac"
874
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100875run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100876 "$P_SRV debug_level=3 etm=1 \
877 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100878 "$P_CLI debug_level=3 etm=0" \
879 0 \
880 -C "client hello, adding encrypt_then_mac extension" \
881 -S "found encrypt then mac extension" \
882 -S "server hello, adding encrypt then mac extension" \
883 -C "found encrypt_then_mac extension" \
884 -C "using encrypt then mac" \
885 -S "using encrypt then mac"
886
Janos Follathe2681a42016-03-07 15:57:05 +0000887requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100888run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100889 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100890 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100891 "$P_CLI debug_level=3 force_version=ssl3" \
892 0 \
893 -C "client hello, adding encrypt_then_mac extension" \
894 -S "found encrypt then mac extension" \
895 -S "server hello, adding encrypt then mac extension" \
896 -C "found encrypt_then_mac extension" \
897 -C "using encrypt then mac" \
898 -S "using encrypt then mac"
899
Janos Follathe2681a42016-03-07 15:57:05 +0000900requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100901run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100902 "$P_SRV debug_level=3 force_version=ssl3 \
903 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100904 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100905 0 \
906 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100907 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100908 -S "server hello, adding encrypt then mac extension" \
909 -C "found encrypt_then_mac extension" \
910 -C "using encrypt then mac" \
911 -S "using encrypt then mac"
912
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200913# Tests for Extended Master Secret extension
914
915run_test "Extended Master Secret: default" \
916 "$P_SRV debug_level=3" \
917 "$P_CLI debug_level=3" \
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
926run_test "Extended Master Secret: client enabled, server disabled" \
927 "$P_SRV debug_level=3 extended_ms=0" \
928 "$P_CLI debug_level=3 extended_ms=1" \
929 0 \
930 -c "client hello, adding extended_master_secret extension" \
931 -s "found extended master secret extension" \
932 -S "server hello, adding extended master secret extension" \
933 -C "found extended_master_secret extension" \
934 -C "using extended master secret" \
935 -S "using extended master secret"
936
937run_test "Extended Master Secret: client disabled, server enabled" \
938 "$P_SRV debug_level=3 extended_ms=1" \
939 "$P_CLI debug_level=3 extended_ms=0" \
940 0 \
941 -C "client hello, adding extended_master_secret extension" \
942 -S "found extended master secret extension" \
943 -S "server hello, adding extended master secret extension" \
944 -C "found extended_master_secret extension" \
945 -C "using extended master secret" \
946 -S "using extended master secret"
947
Janos Follathe2681a42016-03-07 15:57:05 +0000948requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200949run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100950 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200951 "$P_CLI debug_level=3 force_version=ssl3" \
952 0 \
953 -C "client hello, adding extended_master_secret extension" \
954 -S "found extended master secret extension" \
955 -S "server hello, adding extended master secret extension" \
956 -C "found extended_master_secret extension" \
957 -C "using extended master secret" \
958 -S "using extended master secret"
959
Janos Follathe2681a42016-03-07 15:57:05 +0000960requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200961run_test "Extended Master Secret: client enabled, server SSLv3" \
962 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100963 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200964 0 \
965 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100966 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200967 -S "server hello, adding extended master secret extension" \
968 -C "found extended_master_secret extension" \
969 -C "using extended master secret" \
970 -S "using extended master secret"
971
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200972# Tests for FALLBACK_SCSV
973
974run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200975 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200976 "$P_CLI debug_level=3 force_version=tls1_1" \
977 0 \
978 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200979 -S "received FALLBACK_SCSV" \
980 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200981 -C "is a fatal alert message (msg 86)"
982
983run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200984 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200985 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
986 0 \
987 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200988 -S "received FALLBACK_SCSV" \
989 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200990 -C "is a fatal alert message (msg 86)"
991
992run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200993 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200994 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200995 1 \
996 -c "adding FALLBACK_SCSV" \
997 -s "received FALLBACK_SCSV" \
998 -s "inapropriate fallback" \
999 -c "is a fatal alert message (msg 86)"
1000
1001run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001002 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001003 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001004 0 \
1005 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001006 -s "received FALLBACK_SCSV" \
1007 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001008 -C "is a fatal alert message (msg 86)"
1009
1010requires_openssl_with_fallback_scsv
1011run_test "Fallback SCSV: default, openssl server" \
1012 "$O_SRV" \
1013 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1014 0 \
1015 -C "adding FALLBACK_SCSV" \
1016 -C "is a fatal alert message (msg 86)"
1017
1018requires_openssl_with_fallback_scsv
1019run_test "Fallback SCSV: enabled, openssl server" \
1020 "$O_SRV" \
1021 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1022 1 \
1023 -c "adding FALLBACK_SCSV" \
1024 -c "is a fatal alert message (msg 86)"
1025
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001026requires_openssl_with_fallback_scsv
1027run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001028 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001029 "$O_CLI -tls1_1" \
1030 0 \
1031 -S "received FALLBACK_SCSV" \
1032 -S "inapropriate fallback"
1033
1034requires_openssl_with_fallback_scsv
1035run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001036 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001037 "$O_CLI -tls1_1 -fallback_scsv" \
1038 1 \
1039 -s "received FALLBACK_SCSV" \
1040 -s "inapropriate fallback"
1041
1042requires_openssl_with_fallback_scsv
1043run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001044 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001045 "$O_CLI -fallback_scsv" \
1046 0 \
1047 -s "received FALLBACK_SCSV" \
1048 -S "inapropriate fallback"
1049
Gilles Peskined50177f2017-05-16 17:53:03 +02001050## ClientHello generated with
1051## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1052## then manually twiddling the ciphersuite list.
1053## The ClientHello content is spelled out below as a hex string as
1054## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1055## The expected response is an inappropriate_fallback alert.
1056requires_openssl_with_fallback_scsv
1057run_test "Fallback SCSV: beginning of list" \
1058 "$P_SRV debug_level=2" \
1059 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1060 0 \
1061 -s "received FALLBACK_SCSV" \
1062 -s "inapropriate fallback"
1063
1064requires_openssl_with_fallback_scsv
1065run_test "Fallback SCSV: end of list" \
1066 "$P_SRV debug_level=2" \
1067 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1068 0 \
1069 -s "received FALLBACK_SCSV" \
1070 -s "inapropriate fallback"
1071
1072## Here the expected response is a valid ServerHello prefix, up to the random.
1073requires_openssl_with_fallback_scsv
1074run_test "Fallback SCSV: not in list" \
1075 "$P_SRV debug_level=2" \
1076 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1077 0 \
1078 -S "received FALLBACK_SCSV" \
1079 -S "inapropriate fallback"
1080
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001081# Tests for CBC 1/n-1 record splitting
1082
1083run_test "CBC Record splitting: TLS 1.2, no splitting" \
1084 "$P_SRV" \
1085 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1086 request_size=123 force_version=tls1_2" \
1087 0 \
1088 -s "Read from client: 123 bytes read" \
1089 -S "Read from client: 1 bytes read" \
1090 -S "122 bytes read"
1091
1092run_test "CBC Record splitting: TLS 1.1, no splitting" \
1093 "$P_SRV" \
1094 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1095 request_size=123 force_version=tls1_1" \
1096 0 \
1097 -s "Read from client: 123 bytes read" \
1098 -S "Read from client: 1 bytes read" \
1099 -S "122 bytes read"
1100
1101run_test "CBC Record splitting: TLS 1.0, splitting" \
1102 "$P_SRV" \
1103 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1104 request_size=123 force_version=tls1" \
1105 0 \
1106 -S "Read from client: 123 bytes read" \
1107 -s "Read from client: 1 bytes read" \
1108 -s "122 bytes read"
1109
Janos Follathe2681a42016-03-07 15:57:05 +00001110requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001111run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001112 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001113 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1114 request_size=123 force_version=ssl3" \
1115 0 \
1116 -S "Read from client: 123 bytes read" \
1117 -s "Read from client: 1 bytes read" \
1118 -s "122 bytes read"
1119
1120run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001121 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001122 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1123 request_size=123 force_version=tls1" \
1124 0 \
1125 -s "Read from client: 123 bytes read" \
1126 -S "Read from client: 1 bytes read" \
1127 -S "122 bytes read"
1128
1129run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1130 "$P_SRV" \
1131 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1132 request_size=123 force_version=tls1 recsplit=0" \
1133 0 \
1134 -s "Read from client: 123 bytes read" \
1135 -S "Read from client: 1 bytes read" \
1136 -S "122 bytes read"
1137
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001138run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1139 "$P_SRV nbio=2" \
1140 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1141 request_size=123 force_version=tls1" \
1142 0 \
1143 -S "Read from client: 123 bytes read" \
1144 -s "Read from client: 1 bytes read" \
1145 -s "122 bytes read"
1146
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001147# Tests for Session Tickets
1148
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001149run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001150 "$P_SRV debug_level=3 tickets=1" \
1151 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001152 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001153 -c "client hello, adding session ticket extension" \
1154 -s "found session ticket extension" \
1155 -s "server hello, adding session ticket extension" \
1156 -c "found session_ticket extension" \
1157 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001158 -S "session successfully restored from cache" \
1159 -s "session successfully restored from ticket" \
1160 -s "a session has been resumed" \
1161 -c "a session has been resumed"
1162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001163run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001164 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1165 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001166 0 \
1167 -c "client hello, adding session ticket extension" \
1168 -s "found session ticket extension" \
1169 -s "server hello, adding session ticket extension" \
1170 -c "found session_ticket extension" \
1171 -c "parse new session ticket" \
1172 -S "session successfully restored from cache" \
1173 -s "session successfully restored from ticket" \
1174 -s "a session has been resumed" \
1175 -c "a session has been resumed"
1176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001177run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001178 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1179 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001180 0 \
1181 -c "client hello, adding session ticket extension" \
1182 -s "found session ticket extension" \
1183 -s "server hello, adding session ticket extension" \
1184 -c "found session_ticket extension" \
1185 -c "parse new session ticket" \
1186 -S "session successfully restored from cache" \
1187 -S "session successfully restored from ticket" \
1188 -S "a session has been resumed" \
1189 -C "a session has been resumed"
1190
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001191run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001192 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001193 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001194 0 \
1195 -c "client hello, adding session ticket extension" \
1196 -c "found session_ticket extension" \
1197 -c "parse new session ticket" \
1198 -c "a session has been resumed"
1199
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001200run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001201 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001202 "( $O_CLI -sess_out $SESSION; \
1203 $O_CLI -sess_in $SESSION; \
1204 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001205 0 \
1206 -s "found session ticket extension" \
1207 -s "server hello, adding session ticket extension" \
1208 -S "session successfully restored from cache" \
1209 -s "session successfully restored from ticket" \
1210 -s "a session has been resumed"
1211
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001212# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001214run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001215 "$P_SRV debug_level=3 tickets=0" \
1216 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001217 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001218 -c "client hello, adding session ticket extension" \
1219 -s "found session ticket extension" \
1220 -S "server hello, adding session ticket extension" \
1221 -C "found session_ticket extension" \
1222 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001223 -s "session successfully restored from cache" \
1224 -S "session successfully restored from ticket" \
1225 -s "a session has been resumed" \
1226 -c "a session has been resumed"
1227
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001228run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001229 "$P_SRV debug_level=3 tickets=1" \
1230 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001231 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001232 -C "client hello, adding session ticket extension" \
1233 -S "found session ticket extension" \
1234 -S "server hello, adding session ticket extension" \
1235 -C "found session_ticket extension" \
1236 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001237 -s "session successfully restored from cache" \
1238 -S "session successfully restored from ticket" \
1239 -s "a session has been resumed" \
1240 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001242run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001243 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1244 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001245 0 \
1246 -S "session successfully restored from cache" \
1247 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001248 -S "a session has been resumed" \
1249 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001251run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001252 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1253 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001254 0 \
1255 -s "session successfully restored from cache" \
1256 -S "session successfully restored from ticket" \
1257 -s "a session has been resumed" \
1258 -c "a session has been resumed"
1259
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001260run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001261 "$P_SRV debug_level=3 tickets=0" \
1262 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001263 0 \
1264 -s "session successfully restored from cache" \
1265 -S "session successfully restored from ticket" \
1266 -s "a session has been resumed" \
1267 -c "a session has been resumed"
1268
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001269run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001270 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1271 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001272 0 \
1273 -S "session successfully restored from cache" \
1274 -S "session successfully restored from ticket" \
1275 -S "a session has been resumed" \
1276 -C "a session has been resumed"
1277
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001278run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001279 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1280 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001281 0 \
1282 -s "session successfully restored from cache" \
1283 -S "session successfully restored from ticket" \
1284 -s "a session has been resumed" \
1285 -c "a session has been resumed"
1286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001287run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001288 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001289 "( $O_CLI -sess_out $SESSION; \
1290 $O_CLI -sess_in $SESSION; \
1291 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001292 0 \
1293 -s "found session ticket extension" \
1294 -S "server hello, adding session ticket extension" \
1295 -s "session successfully restored from cache" \
1296 -S "session successfully restored from ticket" \
1297 -s "a session has been resumed"
1298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001299run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001300 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001301 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001302 0 \
1303 -C "found session_ticket extension" \
1304 -C "parse new session ticket" \
1305 -c "a session has been resumed"
1306
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001307# Tests for Max Fragment Length extension
1308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001309run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001310 "$P_SRV debug_level=3" \
1311 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001312 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001313 -c "Maximum fragment length is 16384" \
1314 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001315 -C "client hello, adding max_fragment_length extension" \
1316 -S "found max fragment length extension" \
1317 -S "server hello, max_fragment_length extension" \
1318 -C "found max_fragment_length extension"
1319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001320run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001321 "$P_SRV debug_level=3" \
1322 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001323 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001324 -c "Maximum fragment length is 4096" \
1325 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001326 -c "client hello, adding max_fragment_length extension" \
1327 -s "found max fragment length extension" \
1328 -s "server hello, max_fragment_length extension" \
1329 -c "found max_fragment_length extension"
1330
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001331run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001332 "$P_SRV debug_level=3 max_frag_len=4096" \
1333 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001334 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001335 -c "Maximum fragment length is 16384" \
1336 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001337 -C "client hello, adding max_fragment_length extension" \
1338 -S "found max fragment length extension" \
1339 -S "server hello, max_fragment_length extension" \
1340 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001341
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001342requires_gnutls
1343run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001344 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001345 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001346 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001347 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001348 -c "client hello, adding max_fragment_length extension" \
1349 -c "found max_fragment_length extension"
1350
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001351run_test "Max fragment length: client, message just fits" \
1352 "$P_SRV debug_level=3" \
1353 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1354 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001355 -c "Maximum fragment length is 2048" \
1356 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001357 -c "client hello, adding max_fragment_length extension" \
1358 -s "found max fragment length extension" \
1359 -s "server hello, max_fragment_length extension" \
1360 -c "found max_fragment_length extension" \
1361 -c "2048 bytes written in 1 fragments" \
1362 -s "2048 bytes read"
1363
1364run_test "Max fragment length: client, larger message" \
1365 "$P_SRV debug_level=3" \
1366 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1367 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001368 -c "Maximum fragment length is 2048" \
1369 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001370 -c "client hello, adding max_fragment_length extension" \
1371 -s "found max fragment length extension" \
1372 -s "server hello, max_fragment_length extension" \
1373 -c "found max_fragment_length extension" \
1374 -c "2345 bytes written in 2 fragments" \
1375 -s "2048 bytes read" \
1376 -s "297 bytes read"
1377
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001378run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001379 "$P_SRV debug_level=3 dtls=1" \
1380 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1381 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001382 -c "Maximum fragment length is 2048" \
1383 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001384 -c "client hello, adding max_fragment_length extension" \
1385 -s "found max fragment length extension" \
1386 -s "server hello, max_fragment_length extension" \
1387 -c "found max_fragment_length extension" \
1388 -c "fragment larger than.*maximum"
1389
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001390# Tests for renegotiation
1391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001392run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001393 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001394 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001395 0 \
1396 -C "client hello, adding renegotiation extension" \
1397 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1398 -S "found renegotiation extension" \
1399 -s "server hello, secure renegotiation extension" \
1400 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001401 -C "=> renegotiate" \
1402 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001403 -S "write hello request"
1404
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001405run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001406 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001407 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001408 0 \
1409 -c "client hello, adding renegotiation extension" \
1410 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1411 -s "found renegotiation extension" \
1412 -s "server hello, secure renegotiation extension" \
1413 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001414 -c "=> renegotiate" \
1415 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001416 -S "write hello request"
1417
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001418run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001419 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001420 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001421 0 \
1422 -c "client hello, adding renegotiation extension" \
1423 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1424 -s "found renegotiation extension" \
1425 -s "server hello, secure renegotiation extension" \
1426 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001427 -c "=> renegotiate" \
1428 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001429 -s "write hello request"
1430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001431run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001432 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001433 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001434 0 \
1435 -c "client hello, adding renegotiation extension" \
1436 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1437 -s "found renegotiation extension" \
1438 -s "server hello, secure renegotiation extension" \
1439 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001440 -c "=> renegotiate" \
1441 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001442 -s "write hello request"
1443
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001444run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001445 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001446 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001447 1 \
1448 -c "client hello, adding renegotiation extension" \
1449 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1450 -S "found renegotiation extension" \
1451 -s "server hello, secure renegotiation extension" \
1452 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001453 -c "=> renegotiate" \
1454 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001455 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001456 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001457 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001459run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001460 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001461 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001462 0 \
1463 -C "client hello, adding renegotiation extension" \
1464 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1465 -S "found renegotiation extension" \
1466 -s "server hello, secure renegotiation extension" \
1467 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001468 -C "=> renegotiate" \
1469 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001470 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001471 -S "SSL - An unexpected message was received from our peer" \
1472 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001474run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001475 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001476 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001477 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001478 0 \
1479 -C "client hello, adding renegotiation extension" \
1480 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1481 -S "found renegotiation extension" \
1482 -s "server hello, secure renegotiation extension" \
1483 -c "found renegotiation extension" \
1484 -C "=> renegotiate" \
1485 -S "=> renegotiate" \
1486 -s "write hello request" \
1487 -S "SSL - An unexpected message was received from our peer" \
1488 -S "failed"
1489
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001490# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001491run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001492 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001493 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001494 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001495 0 \
1496 -C "client hello, adding renegotiation extension" \
1497 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1498 -S "found renegotiation extension" \
1499 -s "server hello, secure renegotiation extension" \
1500 -c "found renegotiation extension" \
1501 -C "=> renegotiate" \
1502 -S "=> renegotiate" \
1503 -s "write hello request" \
1504 -S "SSL - An unexpected message was received from our peer" \
1505 -S "failed"
1506
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001507run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001508 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001509 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001510 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001511 0 \
1512 -C "client hello, adding renegotiation extension" \
1513 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1514 -S "found renegotiation extension" \
1515 -s "server hello, secure renegotiation extension" \
1516 -c "found renegotiation extension" \
1517 -C "=> renegotiate" \
1518 -S "=> renegotiate" \
1519 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001520 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001522run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001523 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001524 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001525 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001526 0 \
1527 -c "client hello, adding renegotiation extension" \
1528 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1529 -s "found renegotiation extension" \
1530 -s "server hello, secure renegotiation extension" \
1531 -c "found renegotiation extension" \
1532 -c "=> renegotiate" \
1533 -s "=> renegotiate" \
1534 -s "write hello request" \
1535 -S "SSL - An unexpected message was received from our peer" \
1536 -S "failed"
1537
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001538run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001539 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001540 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1541 0 \
1542 -C "client hello, adding renegotiation extension" \
1543 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1544 -S "found renegotiation extension" \
1545 -s "server hello, secure renegotiation extension" \
1546 -c "found renegotiation extension" \
1547 -S "record counter limit reached: renegotiate" \
1548 -C "=> renegotiate" \
1549 -S "=> renegotiate" \
1550 -S "write hello request" \
1551 -S "SSL - An unexpected message was received from our peer" \
1552 -S "failed"
1553
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001554# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001555run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001556 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001557 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001558 0 \
1559 -c "client hello, adding renegotiation extension" \
1560 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1561 -s "found renegotiation extension" \
1562 -s "server hello, secure renegotiation extension" \
1563 -c "found renegotiation extension" \
1564 -s "record counter limit reached: renegotiate" \
1565 -c "=> renegotiate" \
1566 -s "=> renegotiate" \
1567 -s "write hello request" \
1568 -S "SSL - An unexpected message was received from our peer" \
1569 -S "failed"
1570
1571run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001572 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001573 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001574 0 \
1575 -c "client hello, adding renegotiation extension" \
1576 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1577 -s "found renegotiation extension" \
1578 -s "server hello, secure renegotiation extension" \
1579 -c "found renegotiation extension" \
1580 -s "record counter limit reached: renegotiate" \
1581 -c "=> renegotiate" \
1582 -s "=> renegotiate" \
1583 -s "write hello request" \
1584 -S "SSL - An unexpected message was received from our peer" \
1585 -S "failed"
1586
1587run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001588 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001589 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1590 0 \
1591 -C "client hello, adding renegotiation extension" \
1592 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1593 -S "found renegotiation extension" \
1594 -s "server hello, secure renegotiation extension" \
1595 -c "found renegotiation extension" \
1596 -S "record counter limit reached: renegotiate" \
1597 -C "=> renegotiate" \
1598 -S "=> renegotiate" \
1599 -S "write hello request" \
1600 -S "SSL - An unexpected message was received from our peer" \
1601 -S "failed"
1602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001603run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001604 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001605 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001606 0 \
1607 -c "client hello, adding renegotiation extension" \
1608 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1609 -s "found renegotiation extension" \
1610 -s "server hello, secure renegotiation extension" \
1611 -c "found renegotiation extension" \
1612 -c "=> renegotiate" \
1613 -s "=> renegotiate" \
1614 -S "write hello request"
1615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001616run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001617 "$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 +02001618 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001629run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001630 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001631 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001632 0 \
1633 -c "client hello, adding renegotiation extension" \
1634 -c "found renegotiation extension" \
1635 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001636 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001637 -C "error" \
1638 -c "HTTP/1.0 200 [Oo][Kk]"
1639
Paul Bakker539d9722015-02-08 16:18:35 +01001640requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001641run_test "Renegotiation: gnutls server strict, client-initiated" \
1642 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001643 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001644 0 \
1645 -c "client hello, adding renegotiation extension" \
1646 -c "found renegotiation extension" \
1647 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001648 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001649 -C "error" \
1650 -c "HTTP/1.0 200 [Oo][Kk]"
1651
Paul Bakker539d9722015-02-08 16:18:35 +01001652requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001653run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1654 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1655 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1656 1 \
1657 -c "client hello, adding renegotiation extension" \
1658 -C "found renegotiation extension" \
1659 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001660 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001661 -c "error" \
1662 -C "HTTP/1.0 200 [Oo][Kk]"
1663
Paul Bakker539d9722015-02-08 16:18:35 +01001664requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001665run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1666 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1667 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1668 allow_legacy=0" \
1669 1 \
1670 -c "client hello, adding renegotiation extension" \
1671 -C "found renegotiation extension" \
1672 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001673 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001674 -c "error" \
1675 -C "HTTP/1.0 200 [Oo][Kk]"
1676
Paul Bakker539d9722015-02-08 16:18:35 +01001677requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001678run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1679 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1680 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1681 allow_legacy=1" \
1682 0 \
1683 -c "client hello, adding renegotiation extension" \
1684 -C "found renegotiation extension" \
1685 -c "=> renegotiate" \
1686 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001687 -C "error" \
1688 -c "HTTP/1.0 200 [Oo][Kk]"
1689
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001690run_test "Renegotiation: DTLS, client-initiated" \
1691 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1692 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1693 0 \
1694 -c "client hello, adding renegotiation extension" \
1695 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1696 -s "found renegotiation extension" \
1697 -s "server hello, secure renegotiation extension" \
1698 -c "found renegotiation extension" \
1699 -c "=> renegotiate" \
1700 -s "=> renegotiate" \
1701 -S "write hello request"
1702
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001703run_test "Renegotiation: DTLS, server-initiated" \
1704 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001705 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1706 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001707 0 \
1708 -c "client hello, adding renegotiation extension" \
1709 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1710 -s "found renegotiation extension" \
1711 -s "server hello, secure renegotiation extension" \
1712 -c "found renegotiation extension" \
1713 -c "=> renegotiate" \
1714 -s "=> renegotiate" \
1715 -s "write hello request"
1716
Andres AG692ad842017-01-19 16:30:57 +00001717run_test "Renegotiation: DTLS, renego_period overflow" \
1718 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1719 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1720 0 \
1721 -c "client hello, adding renegotiation extension" \
1722 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1723 -s "found renegotiation extension" \
1724 -s "server hello, secure renegotiation extension" \
1725 -s "record counter limit reached: renegotiate" \
1726 -c "=> renegotiate" \
1727 -s "=> renegotiate" \
1728 -s "write hello request" \
1729
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001730requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001731run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1732 "$G_SRV -u --mtu 4096" \
1733 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1734 0 \
1735 -c "client hello, adding renegotiation extension" \
1736 -c "found renegotiation extension" \
1737 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001738 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001739 -C "error" \
1740 -s "Extra-header:"
1741
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001742# Test for the "secure renegotation" extension only (no actual renegotiation)
1743
Paul Bakker539d9722015-02-08 16:18:35 +01001744requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001745run_test "Renego ext: gnutls server strict, client default" \
1746 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1747 "$P_CLI debug_level=3" \
1748 0 \
1749 -c "found renegotiation extension" \
1750 -C "error" \
1751 -c "HTTP/1.0 200 [Oo][Kk]"
1752
Paul Bakker539d9722015-02-08 16:18:35 +01001753requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001754run_test "Renego ext: gnutls server unsafe, client default" \
1755 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1756 "$P_CLI debug_level=3" \
1757 0 \
1758 -C "found renegotiation extension" \
1759 -C "error" \
1760 -c "HTTP/1.0 200 [Oo][Kk]"
1761
Paul Bakker539d9722015-02-08 16:18:35 +01001762requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001763run_test "Renego ext: gnutls server unsafe, client break legacy" \
1764 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1765 "$P_CLI debug_level=3 allow_legacy=-1" \
1766 1 \
1767 -C "found renegotiation extension" \
1768 -c "error" \
1769 -C "HTTP/1.0 200 [Oo][Kk]"
1770
Paul Bakker539d9722015-02-08 16:18:35 +01001771requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001772run_test "Renego ext: gnutls client strict, server default" \
1773 "$P_SRV debug_level=3" \
1774 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1775 0 \
1776 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1777 -s "server hello, secure renegotiation extension"
1778
Paul Bakker539d9722015-02-08 16:18:35 +01001779requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001780run_test "Renego ext: gnutls client unsafe, server default" \
1781 "$P_SRV debug_level=3" \
1782 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1783 0 \
1784 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1785 -S "server hello, secure renegotiation extension"
1786
Paul Bakker539d9722015-02-08 16:18:35 +01001787requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001788run_test "Renego ext: gnutls client unsafe, server break legacy" \
1789 "$P_SRV debug_level=3 allow_legacy=-1" \
1790 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1791 1 \
1792 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1793 -S "server hello, secure renegotiation extension"
1794
Janos Follath0b242342016-02-17 10:11:21 +00001795# Tests for silently dropping trailing extra bytes in .der certificates
1796
1797requires_gnutls
1798run_test "DER format: no trailing bytes" \
1799 "$P_SRV crt_file=data_files/server5-der0.crt \
1800 key_file=data_files/server5.key" \
1801 "$G_CLI " \
1802 0 \
1803 -c "Handshake was completed" \
1804
1805requires_gnutls
1806run_test "DER format: with a trailing zero byte" \
1807 "$P_SRV crt_file=data_files/server5-der1a.crt \
1808 key_file=data_files/server5.key" \
1809 "$G_CLI " \
1810 0 \
1811 -c "Handshake was completed" \
1812
1813requires_gnutls
1814run_test "DER format: with a trailing random byte" \
1815 "$P_SRV crt_file=data_files/server5-der1b.crt \
1816 key_file=data_files/server5.key" \
1817 "$G_CLI " \
1818 0 \
1819 -c "Handshake was completed" \
1820
1821requires_gnutls
1822run_test "DER format: with 2 trailing random bytes" \
1823 "$P_SRV crt_file=data_files/server5-der2.crt \
1824 key_file=data_files/server5.key" \
1825 "$G_CLI " \
1826 0 \
1827 -c "Handshake was completed" \
1828
1829requires_gnutls
1830run_test "DER format: with 4 trailing random bytes" \
1831 "$P_SRV crt_file=data_files/server5-der4.crt \
1832 key_file=data_files/server5.key" \
1833 "$G_CLI " \
1834 0 \
1835 -c "Handshake was completed" \
1836
1837requires_gnutls
1838run_test "DER format: with 8 trailing random bytes" \
1839 "$P_SRV crt_file=data_files/server5-der8.crt \
1840 key_file=data_files/server5.key" \
1841 "$G_CLI " \
1842 0 \
1843 -c "Handshake was completed" \
1844
1845requires_gnutls
1846run_test "DER format: with 9 trailing random bytes" \
1847 "$P_SRV crt_file=data_files/server5-der9.crt \
1848 key_file=data_files/server5.key" \
1849 "$G_CLI " \
1850 0 \
1851 -c "Handshake was completed" \
1852
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001853# Tests for auth_mode
1854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001855run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001856 "$P_SRV crt_file=data_files/server5-badsign.crt \
1857 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001858 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001859 1 \
1860 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001861 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001862 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001863 -c "X509 - Certificate verification failed"
1864
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001865run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001866 "$P_SRV crt_file=data_files/server5-badsign.crt \
1867 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001868 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001869 0 \
1870 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001871 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001872 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001873 -C "X509 - Certificate verification failed"
1874
Hanno Beckere6706e62017-05-15 16:05:15 +01001875run_test "Authentication: server goodcert, client optional, no trusted CA" \
1876 "$P_SRV" \
1877 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1878 0 \
1879 -c "x509_verify_cert() returned" \
1880 -c "! The certificate is not correctly signed by the trusted CA" \
1881 -c "! Certificate verification flags"\
1882 -C "! mbedtls_ssl_handshake returned" \
1883 -C "X509 - Certificate verification failed" \
1884 -C "SSL - No CA Chain is set, but required to operate"
1885
1886run_test "Authentication: server goodcert, client required, no trusted CA" \
1887 "$P_SRV" \
1888 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1889 1 \
1890 -c "x509_verify_cert() returned" \
1891 -c "! The certificate is not correctly signed by the trusted CA" \
1892 -c "! Certificate verification flags"\
1893 -c "! mbedtls_ssl_handshake returned" \
1894 -c "SSL - No CA Chain is set, but required to operate"
1895
1896# The purpose of the next two tests is to test the client's behaviour when receiving a server
1897# certificate with an unsupported elliptic curve. This should usually not happen because
1898# the client informs the server about the supported curves - it does, though, in the
1899# corner case of a static ECDH suite, because the server doesn't check the curve on that
1900# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1901# different means to have the server ignoring the client's supported curve list.
1902
1903requires_config_enabled MBEDTLS_ECP_C
1904run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1905 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1906 crt_file=data_files/server5.ku-ka.crt" \
1907 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1908 1 \
1909 -c "bad certificate (EC key curve)"\
1910 -c "! Certificate verification flags"\
1911 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1912
1913requires_config_enabled MBEDTLS_ECP_C
1914run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1915 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1916 crt_file=data_files/server5.ku-ka.crt" \
1917 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1918 1 \
1919 -c "bad certificate (EC key curve)"\
1920 -c "! Certificate verification flags"\
1921 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001923run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001924 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001925 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001926 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001927 0 \
1928 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001929 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001930 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001931 -C "X509 - Certificate verification failed"
1932
Simon Butcher99000142016-10-13 17:21:01 +01001933run_test "Authentication: client SHA256, server required" \
1934 "$P_SRV auth_mode=required" \
1935 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1936 key_file=data_files/server6.key \
1937 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1938 0 \
1939 -c "Supported Signature Algorithm found: 4," \
1940 -c "Supported Signature Algorithm found: 5,"
1941
1942run_test "Authentication: client SHA384, server required" \
1943 "$P_SRV auth_mode=required" \
1944 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1945 key_file=data_files/server6.key \
1946 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
1947 0 \
1948 -c "Supported Signature Algorithm found: 4," \
1949 -c "Supported Signature Algorithm found: 5,"
1950
Gilles Peskinefd8332e2017-05-03 16:25:07 +02001951requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
1952run_test "Authentication: client has no cert, server required (SSLv3)" \
1953 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
1954 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
1955 key_file=data_files/server5.key" \
1956 1 \
1957 -S "skip write certificate request" \
1958 -C "skip parse certificate request" \
1959 -c "got a certificate request" \
1960 -c "got no certificate to send" \
1961 -S "x509_verify_cert() returned" \
1962 -s "client has no certificate" \
1963 -s "! mbedtls_ssl_handshake returned" \
1964 -c "! mbedtls_ssl_handshake returned" \
1965 -s "No client certification received from the client, but required by the authentication mode"
1966
1967run_test "Authentication: client has no cert, server required (TLS)" \
1968 "$P_SRV debug_level=3 auth_mode=required" \
1969 "$P_CLI debug_level=3 crt_file=none \
1970 key_file=data_files/server5.key" \
1971 1 \
1972 -S "skip write certificate request" \
1973 -C "skip parse certificate request" \
1974 -c "got a certificate request" \
1975 -c "= write certificate$" \
1976 -C "skip write certificate$" \
1977 -S "x509_verify_cert() returned" \
1978 -s "client has no certificate" \
1979 -s "! mbedtls_ssl_handshake returned" \
1980 -c "! mbedtls_ssl_handshake returned" \
1981 -s "No client certification received from the client, but required by the authentication mode"
1982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001983run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001984 "$P_SRV debug_level=3 auth_mode=required" \
1985 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001986 key_file=data_files/server5.key" \
1987 1 \
1988 -S "skip write certificate request" \
1989 -C "skip parse certificate request" \
1990 -c "got a certificate request" \
1991 -C "skip write certificate" \
1992 -C "skip write certificate verify" \
1993 -S "skip parse certificate verify" \
1994 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001995 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001996 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02001997 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001998 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001999 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002000# We don't check that the client receives the alert because it might
2001# detect that its write end of the connection is closed and abort
2002# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002003
Janos Follath89baba22017-04-10 14:34:35 +01002004run_test "Authentication: client cert not trusted, server required" \
2005 "$P_SRV debug_level=3 auth_mode=required" \
2006 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2007 key_file=data_files/server5.key" \
2008 1 \
2009 -S "skip write certificate request" \
2010 -C "skip parse certificate request" \
2011 -c "got a certificate request" \
2012 -C "skip write certificate" \
2013 -C "skip write certificate verify" \
2014 -S "skip parse certificate verify" \
2015 -s "x509_verify_cert() returned" \
2016 -s "! The certificate is not correctly signed by the trusted CA" \
2017 -s "! mbedtls_ssl_handshake returned" \
2018 -c "! mbedtls_ssl_handshake returned" \
2019 -s "X509 - Certificate verification failed"
2020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002021run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002022 "$P_SRV debug_level=3 auth_mode=optional" \
2023 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002024 key_file=data_files/server5.key" \
2025 0 \
2026 -S "skip write certificate request" \
2027 -C "skip parse certificate request" \
2028 -c "got a certificate request" \
2029 -C "skip write certificate" \
2030 -C "skip write certificate verify" \
2031 -S "skip parse certificate verify" \
2032 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002033 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002034 -S "! mbedtls_ssl_handshake returned" \
2035 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002036 -S "X509 - Certificate verification failed"
2037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002038run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002039 "$P_SRV debug_level=3 auth_mode=none" \
2040 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002041 key_file=data_files/server5.key" \
2042 0 \
2043 -s "skip write certificate request" \
2044 -C "skip parse certificate request" \
2045 -c "got no certificate request" \
2046 -c "skip write certificate" \
2047 -c "skip write certificate verify" \
2048 -s "skip parse certificate verify" \
2049 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002050 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002051 -S "! mbedtls_ssl_handshake returned" \
2052 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002053 -S "X509 - Certificate verification failed"
2054
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002055run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002056 "$P_SRV debug_level=3 auth_mode=optional" \
2057 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002058 0 \
2059 -S "skip write certificate request" \
2060 -C "skip parse certificate request" \
2061 -c "got a certificate request" \
2062 -C "skip write certificate$" \
2063 -C "got no certificate to send" \
2064 -S "SSLv3 client has no certificate" \
2065 -c "skip write certificate verify" \
2066 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002067 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002068 -S "! mbedtls_ssl_handshake returned" \
2069 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002070 -S "X509 - Certificate verification failed"
2071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002072run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002073 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002074 "$O_CLI" \
2075 0 \
2076 -S "skip write certificate request" \
2077 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002078 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002079 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002080 -S "X509 - Certificate verification failed"
2081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002082run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002083 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002084 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002085 0 \
2086 -C "skip parse certificate request" \
2087 -c "got a certificate request" \
2088 -C "skip write certificate$" \
2089 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002090 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002091
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002092run_test "Authentication: client no cert, openssl server required" \
2093 "$O_SRV -Verify 10" \
2094 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2095 1 \
2096 -C "skip parse certificate request" \
2097 -c "got a certificate request" \
2098 -C "skip write certificate$" \
2099 -c "skip write certificate verify" \
2100 -c "! mbedtls_ssl_handshake returned"
2101
Janos Follathe2681a42016-03-07 15:57:05 +00002102requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002103run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002104 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002105 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002106 0 \
2107 -S "skip write certificate request" \
2108 -C "skip parse certificate request" \
2109 -c "got a certificate request" \
2110 -C "skip write certificate$" \
2111 -c "skip write certificate verify" \
2112 -c "got no certificate to send" \
2113 -s "SSLv3 client has no certificate" \
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" \
2117 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002118 -S "X509 - Certificate verification failed"
2119
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002120# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2121# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002122
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002123MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002124MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002125
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002126if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002127 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002128 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002129 printf "test value of ${MAX_IM_CA}. \n"
2130 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002131 printf "The tests assume this value and if it changes, the tests in this\n"
2132 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002133 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002134
2135 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002136fi
2137
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002138run_test "Authentication: server max_int chain, client default" \
2139 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2140 key_file=data_files/dir-maxpath/09.key" \
2141 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2142 0 \
2143 -C "X509 - A fatal error occured"
2144
2145run_test "Authentication: server max_int+1 chain, client default" \
2146 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2147 key_file=data_files/dir-maxpath/10.key" \
2148 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2149 1 \
2150 -c "X509 - A fatal error occured"
2151
2152run_test "Authentication: server max_int+1 chain, client optional" \
2153 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2154 key_file=data_files/dir-maxpath/10.key" \
2155 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2156 auth_mode=optional" \
2157 1 \
2158 -c "X509 - A fatal error occured"
2159
2160run_test "Authentication: server max_int+1 chain, client none" \
2161 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2162 key_file=data_files/dir-maxpath/10.key" \
2163 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2164 auth_mode=none" \
2165 0 \
2166 -C "X509 - A fatal error occured"
2167
2168run_test "Authentication: client max_int+1 chain, server default" \
2169 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2170 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2171 key_file=data_files/dir-maxpath/10.key" \
2172 0 \
2173 -S "X509 - A fatal error occured"
2174
2175run_test "Authentication: client max_int+1 chain, server optional" \
2176 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2177 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2178 key_file=data_files/dir-maxpath/10.key" \
2179 1 \
2180 -s "X509 - A fatal error occured"
2181
2182run_test "Authentication: client max_int+1 chain, server required" \
2183 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2184 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2185 key_file=data_files/dir-maxpath/10.key" \
2186 1 \
2187 -s "X509 - A fatal error occured"
2188
2189run_test "Authentication: client max_int chain, server required" \
2190 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2191 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2192 key_file=data_files/dir-maxpath/09.key" \
2193 0 \
2194 -S "X509 - A fatal error occured"
2195
Janos Follath89baba22017-04-10 14:34:35 +01002196# Tests for CA list in CertificateRequest messages
2197
2198run_test "Authentication: send CA list in CertificateRequest (default)" \
2199 "$P_SRV debug_level=3 auth_mode=required" \
2200 "$P_CLI crt_file=data_files/server6.crt \
2201 key_file=data_files/server6.key" \
2202 0 \
2203 -s "requested DN"
2204
2205run_test "Authentication: do not send CA list in CertificateRequest" \
2206 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2207 "$P_CLI crt_file=data_files/server6.crt \
2208 key_file=data_files/server6.key" \
2209 0 \
2210 -S "requested DN"
2211
2212run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2213 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2214 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2215 key_file=data_files/server5.key" \
2216 1 \
2217 -S "requested DN" \
2218 -s "x509_verify_cert() returned" \
2219 -s "! The certificate is not correctly signed by the trusted CA" \
2220 -s "! mbedtls_ssl_handshake returned" \
2221 -c "! mbedtls_ssl_handshake returned" \
2222 -s "X509 - Certificate verification failed"
2223
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002224# Tests for certificate selection based on SHA verson
2225
2226run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2227 "$P_SRV crt_file=data_files/server5.crt \
2228 key_file=data_files/server5.key \
2229 crt_file2=data_files/server5-sha1.crt \
2230 key_file2=data_files/server5.key" \
2231 "$P_CLI force_version=tls1_2" \
2232 0 \
2233 -c "signed using.*ECDSA with SHA256" \
2234 -C "signed using.*ECDSA with SHA1"
2235
2236run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2237 "$P_SRV crt_file=data_files/server5.crt \
2238 key_file=data_files/server5.key \
2239 crt_file2=data_files/server5-sha1.crt \
2240 key_file2=data_files/server5.key" \
2241 "$P_CLI force_version=tls1_1" \
2242 0 \
2243 -C "signed using.*ECDSA with SHA256" \
2244 -c "signed using.*ECDSA with SHA1"
2245
2246run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2247 "$P_SRV crt_file=data_files/server5.crt \
2248 key_file=data_files/server5.key \
2249 crt_file2=data_files/server5-sha1.crt \
2250 key_file2=data_files/server5.key" \
2251 "$P_CLI force_version=tls1" \
2252 0 \
2253 -C "signed using.*ECDSA with SHA256" \
2254 -c "signed using.*ECDSA with SHA1"
2255
2256run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2257 "$P_SRV crt_file=data_files/server5.crt \
2258 key_file=data_files/server5.key \
2259 crt_file2=data_files/server6.crt \
2260 key_file2=data_files/server6.key" \
2261 "$P_CLI force_version=tls1_1" \
2262 0 \
2263 -c "serial number.*09" \
2264 -c "signed using.*ECDSA with SHA256" \
2265 -C "signed using.*ECDSA with SHA1"
2266
2267run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2268 "$P_SRV crt_file=data_files/server6.crt \
2269 key_file=data_files/server6.key \
2270 crt_file2=data_files/server5.crt \
2271 key_file2=data_files/server5.key" \
2272 "$P_CLI force_version=tls1_1" \
2273 0 \
2274 -c "serial number.*0A" \
2275 -c "signed using.*ECDSA with SHA256" \
2276 -C "signed using.*ECDSA with SHA1"
2277
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002278# tests for SNI
2279
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002280run_test "SNI: no SNI callback" \
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é-Gonnard0eb6cab2014-07-23 20:17:47 +02002283 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002284 0 \
2285 -S "parse ServerName extension" \
2286 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2287 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002288
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002289run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002290 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002291 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002292 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 +02002293 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002294 0 \
2295 -s "parse ServerName extension" \
2296 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2297 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002299run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002300 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002301 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002302 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 +02002303 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002304 0 \
2305 -s "parse ServerName extension" \
2306 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2307 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002309run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002310 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002311 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002312 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 +02002313 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002314 1 \
2315 -s "parse ServerName extension" \
2316 -s "ssl_sni_wrapper() returned" \
2317 -s "mbedtls_ssl_handshake returned" \
2318 -c "mbedtls_ssl_handshake returned" \
2319 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002320
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002321run_test "SNI: client auth no override: optional" \
2322 "$P_SRV debug_level=3 auth_mode=optional \
2323 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2324 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2325 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002326 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002327 -S "skip write certificate request" \
2328 -C "skip parse certificate request" \
2329 -c "got a certificate request" \
2330 -C "skip write certificate" \
2331 -C "skip write certificate verify" \
2332 -S "skip parse certificate verify"
2333
2334run_test "SNI: client auth override: none -> optional" \
2335 "$P_SRV debug_level=3 auth_mode=none \
2336 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2337 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2338 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002339 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002340 -S "skip write certificate request" \
2341 -C "skip parse certificate request" \
2342 -c "got a certificate request" \
2343 -C "skip write certificate" \
2344 -C "skip write certificate verify" \
2345 -S "skip parse certificate verify"
2346
2347run_test "SNI: client auth override: optional -> none" \
2348 "$P_SRV debug_level=3 auth_mode=optional \
2349 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2350 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2351 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002352 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002353 -s "skip write certificate request" \
2354 -C "skip parse certificate request" \
2355 -c "got no certificate request" \
2356 -c "skip write certificate" \
2357 -c "skip write certificate verify" \
2358 -s "skip parse certificate verify"
2359
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002360run_test "SNI: CA no override" \
2361 "$P_SRV debug_level=3 auth_mode=optional \
2362 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2363 ca_file=data_files/test-ca.crt \
2364 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2365 "$P_CLI debug_level=3 server_name=localhost \
2366 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2367 1 \
2368 -S "skip write certificate request" \
2369 -C "skip parse certificate request" \
2370 -c "got a certificate request" \
2371 -C "skip write certificate" \
2372 -C "skip write certificate verify" \
2373 -S "skip parse certificate verify" \
2374 -s "x509_verify_cert() returned" \
2375 -s "! The certificate is not correctly signed by the trusted CA" \
2376 -S "The certificate has been revoked (is on a CRL)"
2377
2378run_test "SNI: CA override" \
2379 "$P_SRV debug_level=3 auth_mode=optional \
2380 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2381 ca_file=data_files/test-ca.crt \
2382 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2383 "$P_CLI debug_level=3 server_name=localhost \
2384 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2385 0 \
2386 -S "skip write certificate request" \
2387 -C "skip parse certificate request" \
2388 -c "got a certificate request" \
2389 -C "skip write certificate" \
2390 -C "skip write certificate verify" \
2391 -S "skip parse certificate verify" \
2392 -S "x509_verify_cert() returned" \
2393 -S "! The certificate is not correctly signed by the trusted CA" \
2394 -S "The certificate has been revoked (is on a CRL)"
2395
2396run_test "SNI: CA override with CRL" \
2397 "$P_SRV debug_level=3 auth_mode=optional \
2398 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2399 ca_file=data_files/test-ca.crt \
2400 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2401 "$P_CLI debug_level=3 server_name=localhost \
2402 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2403 1 \
2404 -S "skip write certificate request" \
2405 -C "skip parse certificate request" \
2406 -c "got a certificate request" \
2407 -C "skip write certificate" \
2408 -C "skip write certificate verify" \
2409 -S "skip parse certificate verify" \
2410 -s "x509_verify_cert() returned" \
2411 -S "! The certificate is not correctly signed by the trusted CA" \
2412 -s "The certificate has been revoked (is on a CRL)"
2413
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002414# Tests for non-blocking I/O: exercise a variety of handshake flows
2415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002416run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002417 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2418 "$P_CLI nbio=2 tickets=0" \
2419 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002420 -S "mbedtls_ssl_handshake returned" \
2421 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002422 -c "Read from server: .* bytes read"
2423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002424run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002425 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2426 "$P_CLI nbio=2 tickets=0" \
2427 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002428 -S "mbedtls_ssl_handshake returned" \
2429 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002430 -c "Read from server: .* bytes read"
2431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002432run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002433 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2434 "$P_CLI nbio=2 tickets=1" \
2435 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002436 -S "mbedtls_ssl_handshake returned" \
2437 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002438 -c "Read from server: .* bytes read"
2439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002440run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002441 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2442 "$P_CLI nbio=2 tickets=1" \
2443 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002444 -S "mbedtls_ssl_handshake returned" \
2445 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002446 -c "Read from server: .* bytes read"
2447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002448run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002449 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2450 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2451 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002452 -S "mbedtls_ssl_handshake returned" \
2453 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002454 -c "Read from server: .* bytes read"
2455
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002456run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002457 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2458 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2459 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002460 -S "mbedtls_ssl_handshake returned" \
2461 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002462 -c "Read from server: .* bytes read"
2463
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002464run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002465 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2466 "$P_CLI nbio=2 tickets=0 reconnect=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é-Gonnard0b6609b2014-02-26 14:45:12 +01002470 -c "Read from server: .* bytes read"
2471
Hanno Becker00076712017-11-15 16:39:08 +00002472# Tests for event-driven I/O: exercise a variety of handshake flows
2473
2474run_test "Event-driven I/O: basic handshake" \
2475 "$P_SRV event=1 tickets=0 auth_mode=none" \
2476 "$P_CLI event=1 tickets=0" \
2477 0 \
2478 -S "mbedtls_ssl_handshake returned" \
2479 -C "mbedtls_ssl_handshake returned" \
2480 -c "Read from server: .* bytes read"
2481
2482run_test "Event-driven I/O: client auth" \
2483 "$P_SRV event=1 tickets=0 auth_mode=required" \
2484 "$P_CLI event=1 tickets=0" \
2485 0 \
2486 -S "mbedtls_ssl_handshake returned" \
2487 -C "mbedtls_ssl_handshake returned" \
2488 -c "Read from server: .* bytes read"
2489
2490run_test "Event-driven I/O: ticket" \
2491 "$P_SRV event=1 tickets=1 auth_mode=none" \
2492 "$P_CLI event=1 tickets=1" \
2493 0 \
2494 -S "mbedtls_ssl_handshake returned" \
2495 -C "mbedtls_ssl_handshake returned" \
2496 -c "Read from server: .* bytes read"
2497
2498run_test "Event-driven I/O: ticket + client auth" \
2499 "$P_SRV event=1 tickets=1 auth_mode=required" \
2500 "$P_CLI event=1 tickets=1" \
2501 0 \
2502 -S "mbedtls_ssl_handshake returned" \
2503 -C "mbedtls_ssl_handshake returned" \
2504 -c "Read from server: .* bytes read"
2505
2506run_test "Event-driven I/O: ticket + client auth + resume" \
2507 "$P_SRV event=1 tickets=1 auth_mode=required" \
2508 "$P_CLI event=1 tickets=1 reconnect=1" \
2509 0 \
2510 -S "mbedtls_ssl_handshake returned" \
2511 -C "mbedtls_ssl_handshake returned" \
2512 -c "Read from server: .* bytes read"
2513
2514run_test "Event-driven I/O: ticket + resume" \
2515 "$P_SRV event=1 tickets=1 auth_mode=none" \
2516 "$P_CLI event=1 tickets=1 reconnect=1" \
2517 0 \
2518 -S "mbedtls_ssl_handshake returned" \
2519 -C "mbedtls_ssl_handshake returned" \
2520 -c "Read from server: .* bytes read"
2521
2522run_test "Event-driven I/O: session-id resume" \
2523 "$P_SRV event=1 tickets=0 auth_mode=none" \
2524 "$P_CLI event=1 tickets=0 reconnect=1" \
2525 0 \
2526 -S "mbedtls_ssl_handshake returned" \
2527 -C "mbedtls_ssl_handshake returned" \
2528 -c "Read from server: .* bytes read"
2529
Hanno Becker6a33f592018-03-13 11:38:46 +00002530run_test "Event-driven I/O, DTLS: basic handshake" \
2531 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
2532 "$P_CLI dtls=1 event=1 tickets=0" \
2533 0 \
2534 -c "Read from server: .* bytes read"
2535
2536run_test "Event-driven I/O, DTLS: client auth" \
2537 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
2538 "$P_CLI dtls=1 event=1 tickets=0" \
2539 0 \
2540 -c "Read from server: .* bytes read"
2541
2542run_test "Event-driven I/O, DTLS: ticket" \
2543 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
2544 "$P_CLI dtls=1 event=1 tickets=1" \
2545 0 \
2546 -c "Read from server: .* bytes read"
2547
2548run_test "Event-driven I/O, DTLS: ticket + client auth" \
2549 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
2550 "$P_CLI dtls=1 event=1 tickets=1" \
2551 0 \
2552 -c "Read from server: .* bytes read"
2553
2554run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
2555 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
2556 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
2557 0 \
2558 -c "Read from server: .* bytes read"
2559
2560run_test "Event-driven I/O, DTLS: ticket + resume" \
2561 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
2562 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \
2563 0 \
2564 -c "Read from server: .* bytes read"
2565
2566run_test "Event-driven I/O, DTLS: session-id resume" \
2567 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
2568 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \
2569 0 \
2570 -c "Read from server: .* bytes read"
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002571# Tests for version negotiation
2572
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002573run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002574 "$P_SRV" \
2575 "$P_CLI" \
2576 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002577 -S "mbedtls_ssl_handshake returned" \
2578 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002579 -s "Protocol is TLSv1.2" \
2580 -c "Protocol is TLSv1.2"
2581
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002582run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002583 "$P_SRV" \
2584 "$P_CLI max_version=tls1_1" \
2585 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002586 -S "mbedtls_ssl_handshake returned" \
2587 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002588 -s "Protocol is TLSv1.1" \
2589 -c "Protocol is TLSv1.1"
2590
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002591run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002592 "$P_SRV max_version=tls1_1" \
2593 "$P_CLI" \
2594 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002595 -S "mbedtls_ssl_handshake returned" \
2596 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002597 -s "Protocol is TLSv1.1" \
2598 -c "Protocol is TLSv1.1"
2599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002600run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002601 "$P_SRV max_version=tls1_1" \
2602 "$P_CLI max_version=tls1_1" \
2603 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002604 -S "mbedtls_ssl_handshake returned" \
2605 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002606 -s "Protocol is TLSv1.1" \
2607 -c "Protocol is TLSv1.1"
2608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002609run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002610 "$P_SRV min_version=tls1_1" \
2611 "$P_CLI max_version=tls1_1" \
2612 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002613 -S "mbedtls_ssl_handshake returned" \
2614 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002615 -s "Protocol is TLSv1.1" \
2616 -c "Protocol is TLSv1.1"
2617
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002618run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002619 "$P_SRV max_version=tls1_1" \
2620 "$P_CLI min_version=tls1_1" \
2621 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002622 -S "mbedtls_ssl_handshake returned" \
2623 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002624 -s "Protocol is TLSv1.1" \
2625 -c "Protocol is TLSv1.1"
2626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002627run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002628 "$P_SRV max_version=tls1_1" \
2629 "$P_CLI min_version=tls1_2" \
2630 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002631 -s "mbedtls_ssl_handshake returned" \
2632 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002633 -c "SSL - Handshake protocol not within min/max boundaries"
2634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002635run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002636 "$P_SRV min_version=tls1_2" \
2637 "$P_CLI max_version=tls1_1" \
2638 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002639 -s "mbedtls_ssl_handshake returned" \
2640 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002641 -s "SSL - Handshake protocol not within min/max boundaries"
2642
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002643# Tests for ALPN extension
2644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002645run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002646 "$P_SRV debug_level=3" \
2647 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002648 0 \
2649 -C "client hello, adding alpn extension" \
2650 -S "found alpn extension" \
2651 -C "got an alert message, type: \\[2:120]" \
2652 -S "server hello, adding alpn extension" \
2653 -C "found alpn extension " \
2654 -C "Application Layer Protocol is" \
2655 -S "Application Layer Protocol is"
2656
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002657run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002658 "$P_SRV debug_level=3" \
2659 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002660 0 \
2661 -c "client hello, adding alpn extension" \
2662 -s "found alpn extension" \
2663 -C "got an alert message, type: \\[2:120]" \
2664 -S "server hello, adding alpn extension" \
2665 -C "found alpn extension " \
2666 -c "Application Layer Protocol is (none)" \
2667 -S "Application Layer Protocol is"
2668
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002669run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002670 "$P_SRV debug_level=3 alpn=abc,1234" \
2671 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002672 0 \
2673 -C "client hello, adding alpn extension" \
2674 -S "found alpn extension" \
2675 -C "got an alert message, type: \\[2:120]" \
2676 -S "server hello, adding alpn extension" \
2677 -C "found alpn extension " \
2678 -C "Application Layer Protocol is" \
2679 -s "Application Layer Protocol is (none)"
2680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002681run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002682 "$P_SRV debug_level=3 alpn=abc,1234" \
2683 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002684 0 \
2685 -c "client hello, adding alpn extension" \
2686 -s "found alpn extension" \
2687 -C "got an alert message, type: \\[2:120]" \
2688 -s "server hello, adding alpn extension" \
2689 -c "found alpn extension" \
2690 -c "Application Layer Protocol is abc" \
2691 -s "Application Layer Protocol is abc"
2692
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002693run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002694 "$P_SRV debug_level=3 alpn=abc,1234" \
2695 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002696 0 \
2697 -c "client hello, adding alpn extension" \
2698 -s "found alpn extension" \
2699 -C "got an alert message, type: \\[2:120]" \
2700 -s "server hello, adding alpn extension" \
2701 -c "found alpn extension" \
2702 -c "Application Layer Protocol is abc" \
2703 -s "Application Layer Protocol is abc"
2704
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002705run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002706 "$P_SRV debug_level=3 alpn=abc,1234" \
2707 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002708 0 \
2709 -c "client hello, adding alpn extension" \
2710 -s "found alpn extension" \
2711 -C "got an alert message, type: \\[2:120]" \
2712 -s "server hello, adding alpn extension" \
2713 -c "found alpn extension" \
2714 -c "Application Layer Protocol is 1234" \
2715 -s "Application Layer Protocol is 1234"
2716
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002717run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002718 "$P_SRV debug_level=3 alpn=abc,123" \
2719 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002720 1 \
2721 -c "client hello, adding alpn extension" \
2722 -s "found alpn extension" \
2723 -c "got an alert message, type: \\[2:120]" \
2724 -S "server hello, adding alpn extension" \
2725 -C "found alpn extension" \
2726 -C "Application Layer Protocol is 1234" \
2727 -S "Application Layer Protocol is 1234"
2728
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002729
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002730# Tests for keyUsage in leaf certificates, part 1:
2731# server-side certificate/suite selection
2732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002733run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002734 "$P_SRV key_file=data_files/server2.key \
2735 crt_file=data_files/server2.ku-ds.crt" \
2736 "$P_CLI" \
2737 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002738 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002739
2740
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002741run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002742 "$P_SRV key_file=data_files/server2.key \
2743 crt_file=data_files/server2.ku-ke.crt" \
2744 "$P_CLI" \
2745 0 \
2746 -c "Ciphersuite is TLS-RSA-WITH-"
2747
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002748run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002749 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002750 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002751 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002752 1 \
2753 -C "Ciphersuite is "
2754
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002755run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002756 "$P_SRV key_file=data_files/server5.key \
2757 crt_file=data_files/server5.ku-ds.crt" \
2758 "$P_CLI" \
2759 0 \
2760 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2761
2762
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002763run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002764 "$P_SRV key_file=data_files/server5.key \
2765 crt_file=data_files/server5.ku-ka.crt" \
2766 "$P_CLI" \
2767 0 \
2768 -c "Ciphersuite is TLS-ECDH-"
2769
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002770run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002771 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002772 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002773 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002774 1 \
2775 -C "Ciphersuite is "
2776
2777# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002778# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002779
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002780run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002781 "$O_SRV -key data_files/server2.key \
2782 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002783 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002784 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2785 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002786 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002787 -C "Processing of the Certificate handshake message failed" \
2788 -c "Ciphersuite is TLS-"
2789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002790run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002791 "$O_SRV -key data_files/server2.key \
2792 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002793 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002794 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2795 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002796 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002797 -C "Processing of the Certificate handshake message failed" \
2798 -c "Ciphersuite is TLS-"
2799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002800run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002801 "$O_SRV -key data_files/server2.key \
2802 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002803 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002804 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2805 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002806 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002807 -C "Processing of the Certificate handshake message failed" \
2808 -c "Ciphersuite is TLS-"
2809
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002810run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002811 "$O_SRV -key data_files/server2.key \
2812 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002813 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002814 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2815 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002816 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002817 -c "Processing of the Certificate handshake message failed" \
2818 -C "Ciphersuite is TLS-"
2819
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002820run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2821 "$O_SRV -key data_files/server2.key \
2822 -cert data_files/server2.ku-ke.crt" \
2823 "$P_CLI debug_level=1 auth_mode=optional \
2824 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2825 0 \
2826 -c "bad certificate (usage extensions)" \
2827 -C "Processing of the Certificate handshake message failed" \
2828 -c "Ciphersuite is TLS-" \
2829 -c "! Usage does not match the keyUsage extension"
2830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002831run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002832 "$O_SRV -key data_files/server2.key \
2833 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002834 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002835 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2836 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002837 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002838 -C "Processing of the Certificate handshake message failed" \
2839 -c "Ciphersuite is TLS-"
2840
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002841run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002842 "$O_SRV -key data_files/server2.key \
2843 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002844 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002845 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2846 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002847 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002848 -c "Processing of the Certificate handshake message failed" \
2849 -C "Ciphersuite is TLS-"
2850
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002851run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2852 "$O_SRV -key data_files/server2.key \
2853 -cert data_files/server2.ku-ds.crt" \
2854 "$P_CLI debug_level=1 auth_mode=optional \
2855 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2856 0 \
2857 -c "bad certificate (usage extensions)" \
2858 -C "Processing of the Certificate handshake message failed" \
2859 -c "Ciphersuite is TLS-" \
2860 -c "! Usage does not match the keyUsage extension"
2861
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002862# Tests for keyUsage in leaf certificates, part 3:
2863# server-side checking of client cert
2864
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002865run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002866 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002867 "$O_CLI -key data_files/server2.key \
2868 -cert data_files/server2.ku-ds.crt" \
2869 0 \
2870 -S "bad certificate (usage extensions)" \
2871 -S "Processing of the Certificate handshake message failed"
2872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002873run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002874 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002875 "$O_CLI -key data_files/server2.key \
2876 -cert data_files/server2.ku-ke.crt" \
2877 0 \
2878 -s "bad certificate (usage extensions)" \
2879 -S "Processing of the Certificate handshake message failed"
2880
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002881run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002882 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002883 "$O_CLI -key data_files/server2.key \
2884 -cert data_files/server2.ku-ke.crt" \
2885 1 \
2886 -s "bad certificate (usage extensions)" \
2887 -s "Processing of the Certificate handshake message failed"
2888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002889run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002890 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002891 "$O_CLI -key data_files/server5.key \
2892 -cert data_files/server5.ku-ds.crt" \
2893 0 \
2894 -S "bad certificate (usage extensions)" \
2895 -S "Processing of the Certificate handshake message failed"
2896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002897run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002898 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002899 "$O_CLI -key data_files/server5.key \
2900 -cert data_files/server5.ku-ka.crt" \
2901 0 \
2902 -s "bad certificate (usage extensions)" \
2903 -S "Processing of the Certificate handshake message failed"
2904
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002905# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002907run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002908 "$P_SRV key_file=data_files/server5.key \
2909 crt_file=data_files/server5.eku-srv.crt" \
2910 "$P_CLI" \
2911 0
2912
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002913run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002914 "$P_SRV key_file=data_files/server5.key \
2915 crt_file=data_files/server5.eku-srv.crt" \
2916 "$P_CLI" \
2917 0
2918
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002919run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002920 "$P_SRV key_file=data_files/server5.key \
2921 crt_file=data_files/server5.eku-cs_any.crt" \
2922 "$P_CLI" \
2923 0
2924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002925run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002926 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002927 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002928 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002929 1
2930
2931# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2932
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002933run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002934 "$O_SRV -key data_files/server5.key \
2935 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002936 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002937 0 \
2938 -C "bad certificate (usage extensions)" \
2939 -C "Processing of the Certificate handshake message failed" \
2940 -c "Ciphersuite is TLS-"
2941
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002942run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002943 "$O_SRV -key data_files/server5.key \
2944 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002945 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002946 0 \
2947 -C "bad certificate (usage extensions)" \
2948 -C "Processing of the Certificate handshake message failed" \
2949 -c "Ciphersuite is TLS-"
2950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002951run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002952 "$O_SRV -key data_files/server5.key \
2953 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002954 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002955 0 \
2956 -C "bad certificate (usage extensions)" \
2957 -C "Processing of the Certificate handshake message failed" \
2958 -c "Ciphersuite is TLS-"
2959
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002960run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002961 "$O_SRV -key data_files/server5.key \
2962 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002963 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002964 1 \
2965 -c "bad certificate (usage extensions)" \
2966 -c "Processing of the Certificate handshake message failed" \
2967 -C "Ciphersuite is TLS-"
2968
2969# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002971run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002972 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002973 "$O_CLI -key data_files/server5.key \
2974 -cert data_files/server5.eku-cli.crt" \
2975 0 \
2976 -S "bad certificate (usage extensions)" \
2977 -S "Processing of the Certificate handshake message failed"
2978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002979run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002980 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002981 "$O_CLI -key data_files/server5.key \
2982 -cert data_files/server5.eku-srv_cli.crt" \
2983 0 \
2984 -S "bad certificate (usage extensions)" \
2985 -S "Processing of the Certificate handshake message failed"
2986
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002987run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002988 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002989 "$O_CLI -key data_files/server5.key \
2990 -cert data_files/server5.eku-cs_any.crt" \
2991 0 \
2992 -S "bad certificate (usage extensions)" \
2993 -S "Processing of the Certificate handshake message failed"
2994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002995run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002996 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002997 "$O_CLI -key data_files/server5.key \
2998 -cert data_files/server5.eku-cs.crt" \
2999 0 \
3000 -s "bad certificate (usage extensions)" \
3001 -S "Processing of the Certificate handshake message failed"
3002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003003run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003004 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003005 "$O_CLI -key data_files/server5.key \
3006 -cert data_files/server5.eku-cs.crt" \
3007 1 \
3008 -s "bad certificate (usage extensions)" \
3009 -s "Processing of the Certificate handshake message failed"
3010
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003011# Tests for DHM parameters loading
3012
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003013run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003014 "$P_SRV" \
3015 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3016 debug_level=3" \
3017 0 \
3018 -c "value of 'DHM: P ' (2048 bits)" \
3019 -c "value of 'DHM: G ' (2048 bits)"
3020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003021run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003022 "$P_SRV dhm_file=data_files/dhparams.pem" \
3023 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3024 debug_level=3" \
3025 0 \
3026 -c "value of 'DHM: P ' (1024 bits)" \
3027 -c "value of 'DHM: G ' (2 bits)"
3028
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003029# Tests for DHM client-side size checking
3030
3031run_test "DHM size: server default, client default, OK" \
3032 "$P_SRV" \
3033 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3034 debug_level=1" \
3035 0 \
3036 -C "DHM prime too short:"
3037
3038run_test "DHM size: server default, client 2048, OK" \
3039 "$P_SRV" \
3040 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3041 debug_level=1 dhmlen=2048" \
3042 0 \
3043 -C "DHM prime too short:"
3044
3045run_test "DHM size: server 1024, client default, OK" \
3046 "$P_SRV dhm_file=data_files/dhparams.pem" \
3047 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3048 debug_level=1" \
3049 0 \
3050 -C "DHM prime too short:"
3051
3052run_test "DHM size: server 1000, client default, rejected" \
3053 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3054 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3055 debug_level=1" \
3056 1 \
3057 -c "DHM prime too short:"
3058
3059run_test "DHM size: server default, client 2049, rejected" \
3060 "$P_SRV" \
3061 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3062 debug_level=1 dhmlen=2049" \
3063 1 \
3064 -c "DHM prime too short:"
3065
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003066# Tests for PSK callback
3067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003068run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003069 "$P_SRV psk=abc123 psk_identity=foo" \
3070 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3071 psk_identity=foo psk=abc123" \
3072 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003073 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003074 -S "SSL - Unknown identity received" \
3075 -S "SSL - Verification of the message MAC failed"
3076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003077run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003078 "$P_SRV" \
3079 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3080 psk_identity=foo psk=abc123" \
3081 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003082 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003083 -S "SSL - Unknown identity received" \
3084 -S "SSL - Verification of the message MAC failed"
3085
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003086run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003087 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3088 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3089 psk_identity=foo psk=abc123" \
3090 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003091 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003092 -s "SSL - Unknown identity received" \
3093 -S "SSL - Verification of the message MAC failed"
3094
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003095run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003096 "$P_SRV psk_list=abc,dead,def,beef" \
3097 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3098 psk_identity=abc psk=dead" \
3099 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003100 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003101 -S "SSL - Unknown identity received" \
3102 -S "SSL - Verification of the message MAC failed"
3103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003104run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003105 "$P_SRV psk_list=abc,dead,def,beef" \
3106 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3107 psk_identity=def psk=beef" \
3108 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003109 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003110 -S "SSL - Unknown identity received" \
3111 -S "SSL - Verification of the message MAC failed"
3112
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003113run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003114 "$P_SRV psk_list=abc,dead,def,beef" \
3115 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3116 psk_identity=ghi psk=beef" \
3117 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003118 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003119 -s "SSL - Unknown identity received" \
3120 -S "SSL - Verification of the message MAC failed"
3121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003122run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003123 "$P_SRV psk_list=abc,dead,def,beef" \
3124 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3125 psk_identity=abc psk=beef" \
3126 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003127 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003128 -S "SSL - Unknown identity received" \
3129 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003130
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003131# Tests for EC J-PAKE
3132
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003133requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003134run_test "ECJPAKE: client not configured" \
3135 "$P_SRV debug_level=3" \
3136 "$P_CLI debug_level=3" \
3137 0 \
3138 -C "add ciphersuite: c0ff" \
3139 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003140 -S "found ecjpake kkpp extension" \
3141 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003142 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003143 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003144 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003145 -S "None of the common ciphersuites is usable"
3146
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003147requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003148run_test "ECJPAKE: server not configured" \
3149 "$P_SRV debug_level=3" \
3150 "$P_CLI debug_level=3 ecjpake_pw=bla \
3151 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3152 1 \
3153 -c "add ciphersuite: c0ff" \
3154 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003155 -s "found ecjpake kkpp extension" \
3156 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003157 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003158 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003159 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003160 -s "None of the common ciphersuites is usable"
3161
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003162requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003163run_test "ECJPAKE: working, TLS" \
3164 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3165 "$P_CLI debug_level=3 ecjpake_pw=bla \
3166 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003167 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003168 -c "add ciphersuite: c0ff" \
3169 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003170 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003171 -s "found ecjpake kkpp extension" \
3172 -S "skip ecjpake kkpp extension" \
3173 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003174 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003175 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003176 -S "None of the common ciphersuites is usable" \
3177 -S "SSL - Verification of the message MAC failed"
3178
Janos Follath74537a62016-09-02 13:45:28 +01003179server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003180requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003181run_test "ECJPAKE: password mismatch, TLS" \
3182 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3183 "$P_CLI debug_level=3 ecjpake_pw=bad \
3184 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3185 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003186 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003187 -s "SSL - Verification of the message MAC failed"
3188
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003189requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003190run_test "ECJPAKE: working, DTLS" \
3191 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3192 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3193 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3194 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003195 -c "re-using cached ecjpake parameters" \
3196 -S "SSL - Verification of the message MAC failed"
3197
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003198requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003199run_test "ECJPAKE: working, DTLS, no cookie" \
3200 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3201 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3202 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3203 0 \
3204 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003205 -S "SSL - Verification of the message MAC failed"
3206
Janos Follath74537a62016-09-02 13:45:28 +01003207server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003208requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003209run_test "ECJPAKE: password mismatch, DTLS" \
3210 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3211 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3212 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3213 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003214 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003215 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003216
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003217# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003218requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003219run_test "ECJPAKE: working, DTLS, nolog" \
3220 "$P_SRV dtls=1 ecjpake_pw=bla" \
3221 "$P_CLI dtls=1 ecjpake_pw=bla \
3222 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3223 0
3224
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003225# Tests for ciphersuites per version
3226
Janos Follathe2681a42016-03-07 15:57:05 +00003227requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003228run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003229 "$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 +02003230 "$P_CLI force_version=ssl3" \
3231 0 \
3232 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003234run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003235 "$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 +01003236 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003237 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003238 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003239
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003240run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003241 "$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 +02003242 "$P_CLI force_version=tls1_1" \
3243 0 \
3244 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3245
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003246run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003247 "$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 +02003248 "$P_CLI force_version=tls1_2" \
3249 0 \
3250 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3251
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003252# Test for ClientHello without extensions
3253
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003254requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003255run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003256 "$P_SRV debug_level=3" \
3257 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3258 0 \
3259 -s "dumping 'client hello extensions' (0 bytes)"
3260
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003261requires_gnutls
3262run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3263 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3264 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3265 0 \
3266 -s "dumping 'client hello extensions' (0 bytes)"
3267
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003268# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003269
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003270run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003271 "$P_SRV" \
3272 "$P_CLI request_size=100" \
3273 0 \
3274 -s "Read from client: 100 bytes read$"
3275
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003276run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003277 "$P_SRV" \
3278 "$P_CLI request_size=500" \
3279 0 \
3280 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003281
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003282# Tests for small packets
3283
Janos Follathe2681a42016-03-07 15:57:05 +00003284requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003285run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003286 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003287 "$P_CLI request_size=1 force_version=ssl3 \
3288 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3289 0 \
3290 -s "Read from client: 1 bytes read"
3291
Janos Follathe2681a42016-03-07 15:57:05 +00003292requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003293run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003294 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003295 "$P_CLI request_size=1 force_version=ssl3 \
3296 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3297 0 \
3298 -s "Read from client: 1 bytes read"
3299
3300run_test "Small packet TLS 1.0 BlockCipher" \
3301 "$P_SRV" \
3302 "$P_CLI request_size=1 force_version=tls1 \
3303 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3304 0 \
3305 -s "Read from client: 1 bytes read"
3306
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003307run_test "Small packet TLS 1.0 BlockCipher without EtM" \
3308 "$P_SRV" \
3309 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3310 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3311 0 \
3312 -s "Read from client: 1 bytes read"
3313
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003314run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
3315 "$P_SRV" \
3316 "$P_CLI request_size=1 force_version=tls1 \
3317 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3318 trunc_hmac=1" \
3319 0 \
3320 -s "Read from client: 1 bytes read"
3321
3322run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003323 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003324 "$P_CLI request_size=1 force_version=tls1 \
3325 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3326 trunc_hmac=1" \
3327 0 \
3328 -s "Read from client: 1 bytes read"
3329
3330run_test "Small packet TLS 1.1 BlockCipher" \
3331 "$P_SRV" \
3332 "$P_CLI request_size=1 force_version=tls1_1 \
3333 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3334 0 \
3335 -s "Read from client: 1 bytes read"
3336
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003337run_test "Small packet TLS 1.1 BlockCipher without EtM" \
3338 "$P_SRV" \
3339 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
3340 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3341 0 \
3342 -s "Read from client: 1 bytes read"
3343
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003344run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003345 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003346 "$P_CLI request_size=1 force_version=tls1_1 \
3347 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3348 0 \
3349 -s "Read from client: 1 bytes read"
3350
3351run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3352 "$P_SRV" \
3353 "$P_CLI request_size=1 force_version=tls1_1 \
3354 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3355 trunc_hmac=1" \
3356 0 \
3357 -s "Read from client: 1 bytes read"
3358
3359run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003360 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003361 "$P_CLI request_size=1 force_version=tls1_1 \
3362 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3363 trunc_hmac=1" \
3364 0 \
3365 -s "Read from client: 1 bytes read"
3366
3367run_test "Small packet TLS 1.2 BlockCipher" \
3368 "$P_SRV" \
3369 "$P_CLI request_size=1 force_version=tls1_2 \
3370 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3371 0 \
3372 -s "Read from client: 1 bytes read"
3373
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003374run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3375 "$P_SRV" \
3376 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3377 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3378 0 \
3379 -s "Read from client: 1 bytes read"
3380
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003381run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3382 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003383 "$P_CLI request_size=1 force_version=tls1_2 \
3384 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003385 0 \
3386 -s "Read from client: 1 bytes read"
3387
3388run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3389 "$P_SRV" \
3390 "$P_CLI request_size=1 force_version=tls1_2 \
3391 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3392 trunc_hmac=1" \
3393 0 \
3394 -s "Read from client: 1 bytes read"
3395
3396run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003397 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003398 "$P_CLI request_size=1 force_version=tls1_2 \
3399 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3400 0 \
3401 -s "Read from client: 1 bytes read"
3402
3403run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003404 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003405 "$P_CLI request_size=1 force_version=tls1_2 \
3406 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3407 trunc_hmac=1" \
3408 0 \
3409 -s "Read from client: 1 bytes read"
3410
3411run_test "Small packet TLS 1.2 AEAD" \
3412 "$P_SRV" \
3413 "$P_CLI request_size=1 force_version=tls1_2 \
3414 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3415 0 \
3416 -s "Read from client: 1 bytes read"
3417
3418run_test "Small packet TLS 1.2 AEAD shorter tag" \
3419 "$P_SRV" \
3420 "$P_CLI request_size=1 force_version=tls1_2 \
3421 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3422 0 \
3423 -s "Read from client: 1 bytes read"
3424
Janos Follath00efff72016-05-06 13:48:23 +01003425# A test for extensions in SSLv3
3426
3427requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3428run_test "SSLv3 with extensions, server side" \
3429 "$P_SRV min_version=ssl3 debug_level=3" \
3430 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3431 0 \
3432 -S "dumping 'client hello extensions'" \
3433 -S "server hello, total extension length:"
3434
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003435# Test for large packets
3436
Janos Follathe2681a42016-03-07 15:57:05 +00003437requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003438run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003439 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003440 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003441 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3442 0 \
3443 -s "Read from client: 16384 bytes read"
3444
Janos Follathe2681a42016-03-07 15:57:05 +00003445requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003446run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003447 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003448 "$P_CLI request_size=16384 force_version=ssl3 \
3449 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3450 0 \
3451 -s "Read from client: 16384 bytes read"
3452
3453run_test "Large packet TLS 1.0 BlockCipher" \
3454 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003455 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003456 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3457 0 \
3458 -s "Read from client: 16384 bytes read"
3459
3460run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3461 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003462 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003463 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3464 trunc_hmac=1" \
3465 0 \
3466 -s "Read from client: 16384 bytes read"
3467
3468run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003469 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003470 "$P_CLI request_size=16384 force_version=tls1 \
3471 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3472 trunc_hmac=1" \
3473 0 \
3474 -s "Read from client: 16384 bytes read"
3475
3476run_test "Large packet TLS 1.1 BlockCipher" \
3477 "$P_SRV" \
3478 "$P_CLI request_size=16384 force_version=tls1_1 \
3479 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3480 0 \
3481 -s "Read from client: 16384 bytes read"
3482
3483run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003484 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003485 "$P_CLI request_size=16384 force_version=tls1_1 \
3486 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3487 0 \
3488 -s "Read from client: 16384 bytes read"
3489
3490run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3491 "$P_SRV" \
3492 "$P_CLI request_size=16384 force_version=tls1_1 \
3493 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3494 trunc_hmac=1" \
3495 0 \
3496 -s "Read from client: 16384 bytes read"
3497
3498run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003499 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003500 "$P_CLI request_size=16384 force_version=tls1_1 \
3501 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3502 trunc_hmac=1" \
3503 0 \
3504 -s "Read from client: 16384 bytes read"
3505
3506run_test "Large packet TLS 1.2 BlockCipher" \
3507 "$P_SRV" \
3508 "$P_CLI request_size=16384 force_version=tls1_2 \
3509 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3510 0 \
3511 -s "Read from client: 16384 bytes read"
3512
3513run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3514 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003515 "$P_CLI request_size=16384 force_version=tls1_2 \
3516 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003517 0 \
3518 -s "Read from client: 16384 bytes read"
3519
3520run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3521 "$P_SRV" \
3522 "$P_CLI request_size=16384 force_version=tls1_2 \
3523 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3524 trunc_hmac=1" \
3525 0 \
3526 -s "Read from client: 16384 bytes read"
3527
3528run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003529 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003530 "$P_CLI request_size=16384 force_version=tls1_2 \
3531 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3532 0 \
3533 -s "Read from client: 16384 bytes read"
3534
3535run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003536 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003537 "$P_CLI request_size=16384 force_version=tls1_2 \
3538 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3539 trunc_hmac=1" \
3540 0 \
3541 -s "Read from client: 16384 bytes read"
3542
3543run_test "Large packet TLS 1.2 AEAD" \
3544 "$P_SRV" \
3545 "$P_CLI request_size=16384 force_version=tls1_2 \
3546 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3547 0 \
3548 -s "Read from client: 16384 bytes read"
3549
3550run_test "Large packet TLS 1.2 AEAD shorter tag" \
3551 "$P_SRV" \
3552 "$P_CLI request_size=16384 force_version=tls1_2 \
3553 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3554 0 \
3555 -s "Read from client: 16384 bytes read"
3556
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003557# Tests for DTLS HelloVerifyRequest
3558
3559run_test "DTLS cookie: enabled" \
3560 "$P_SRV dtls=1 debug_level=2" \
3561 "$P_CLI dtls=1 debug_level=2" \
3562 0 \
3563 -s "cookie verification failed" \
3564 -s "cookie verification passed" \
3565 -S "cookie verification skipped" \
3566 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003567 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003568 -S "SSL - The requested feature is not available"
3569
3570run_test "DTLS cookie: disabled" \
3571 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3572 "$P_CLI dtls=1 debug_level=2" \
3573 0 \
3574 -S "cookie verification failed" \
3575 -S "cookie verification passed" \
3576 -s "cookie verification skipped" \
3577 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003578 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003579 -S "SSL - The requested feature is not available"
3580
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003581run_test "DTLS cookie: default (failing)" \
3582 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3583 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3584 1 \
3585 -s "cookie verification failed" \
3586 -S "cookie verification passed" \
3587 -S "cookie verification skipped" \
3588 -C "received hello verify request" \
3589 -S "hello verification requested" \
3590 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003591
3592requires_ipv6
3593run_test "DTLS cookie: enabled, IPv6" \
3594 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3595 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3596 0 \
3597 -s "cookie verification failed" \
3598 -s "cookie verification passed" \
3599 -S "cookie verification skipped" \
3600 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003601 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003602 -S "SSL - The requested feature is not available"
3603
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003604run_test "DTLS cookie: enabled, nbio" \
3605 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3606 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3607 0 \
3608 -s "cookie verification failed" \
3609 -s "cookie verification passed" \
3610 -S "cookie verification skipped" \
3611 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003612 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003613 -S "SSL - The requested feature is not available"
3614
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003615# Tests for client reconnecting from the same port with DTLS
3616
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003617not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003618run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003619 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3620 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003621 0 \
3622 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003623 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003624 -S "Client initiated reconnection from same port"
3625
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003626not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003627run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003628 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3629 "$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 +02003630 0 \
3631 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003632 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003633 -s "Client initiated reconnection from same port"
3634
Paul Bakker362689d2016-05-13 10:33:25 +01003635not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3636run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003637 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3638 "$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 +02003639 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003640 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003641 -s "Client initiated reconnection from same port"
3642
Paul Bakker362689d2016-05-13 10:33:25 +01003643only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3644run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3645 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3646 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3647 0 \
3648 -S "The operation timed out" \
3649 -s "Client initiated reconnection from same port"
3650
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003651run_test "DTLS client reconnect from same port: no cookies" \
3652 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003653 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3654 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003655 -s "The operation timed out" \
3656 -S "Client initiated reconnection from same port"
3657
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003658# Tests for various cases of client authentication with DTLS
3659# (focused on handshake flows and message parsing)
3660
3661run_test "DTLS client auth: required" \
3662 "$P_SRV dtls=1 auth_mode=required" \
3663 "$P_CLI dtls=1" \
3664 0 \
3665 -s "Verifying peer X.509 certificate... ok"
3666
3667run_test "DTLS client auth: optional, client has no cert" \
3668 "$P_SRV dtls=1 auth_mode=optional" \
3669 "$P_CLI dtls=1 crt_file=none key_file=none" \
3670 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003671 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003672
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003673run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003674 "$P_SRV dtls=1 auth_mode=none" \
3675 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3676 0 \
3677 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003678 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003679
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003680run_test "DTLS wrong PSK: badmac alert" \
3681 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3682 "$P_CLI dtls=1 psk=abc124" \
3683 1 \
3684 -s "SSL - Verification of the message MAC failed" \
3685 -c "SSL - A fatal alert message was received from our peer"
3686
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003687# Tests for receiving fragmented handshake messages with DTLS
3688
3689requires_gnutls
3690run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3691 "$G_SRV -u --mtu 2048 -a" \
3692 "$P_CLI dtls=1 debug_level=2" \
3693 0 \
3694 -C "found fragmented DTLS handshake message" \
3695 -C "error"
3696
3697requires_gnutls
3698run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3699 "$G_SRV -u --mtu 512" \
3700 "$P_CLI dtls=1 debug_level=2" \
3701 0 \
3702 -c "found fragmented DTLS handshake message" \
3703 -C "error"
3704
3705requires_gnutls
3706run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3707 "$G_SRV -u --mtu 128" \
3708 "$P_CLI dtls=1 debug_level=2" \
3709 0 \
3710 -c "found fragmented DTLS handshake message" \
3711 -C "error"
3712
3713requires_gnutls
3714run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3715 "$G_SRV -u --mtu 128" \
3716 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3717 0 \
3718 -c "found fragmented DTLS handshake message" \
3719 -C "error"
3720
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003721requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003722run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3723 "$G_SRV -u --mtu 256" \
3724 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3725 0 \
3726 -c "found fragmented DTLS handshake message" \
3727 -c "client hello, adding renegotiation extension" \
3728 -c "found renegotiation extension" \
3729 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003730 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003731 -C "error" \
3732 -s "Extra-header:"
3733
3734requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003735run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3736 "$G_SRV -u --mtu 256" \
3737 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3738 0 \
3739 -c "found fragmented DTLS handshake message" \
3740 -c "client hello, adding renegotiation extension" \
3741 -c "found renegotiation extension" \
3742 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003743 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003744 -C "error" \
3745 -s "Extra-header:"
3746
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003747run_test "DTLS reassembly: no fragmentation (openssl server)" \
3748 "$O_SRV -dtls1 -mtu 2048" \
3749 "$P_CLI dtls=1 debug_level=2" \
3750 0 \
3751 -C "found fragmented DTLS handshake message" \
3752 -C "error"
3753
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003754run_test "DTLS reassembly: some fragmentation (openssl server)" \
3755 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003756 "$P_CLI dtls=1 debug_level=2" \
3757 0 \
3758 -c "found fragmented DTLS handshake message" \
3759 -C "error"
3760
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003761run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003762 "$O_SRV -dtls1 -mtu 256" \
3763 "$P_CLI dtls=1 debug_level=2" \
3764 0 \
3765 -c "found fragmented DTLS handshake message" \
3766 -C "error"
3767
3768run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3769 "$O_SRV -dtls1 -mtu 256" \
3770 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3771 0 \
3772 -c "found fragmented DTLS handshake message" \
3773 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003774
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003775# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003776
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003777not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003778run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003779 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003780 "$P_SRV dtls=1 debug_level=2" \
3781 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003782 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003783 -C "replayed record" \
3784 -S "replayed record" \
3785 -C "record from another epoch" \
3786 -S "record from another epoch" \
3787 -C "discarding invalid record" \
3788 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003789 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003790 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003791 -c "HTTP/1.0 200 OK"
3792
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003793not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003794run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003795 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003796 "$P_SRV dtls=1 debug_level=2" \
3797 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003798 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003799 -c "replayed record" \
3800 -s "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01003801 -c "record from another epoch" \
3802 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003803 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003804 -s "Extra-header:" \
3805 -c "HTTP/1.0 200 OK"
3806
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003807run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3808 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003809 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3810 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003811 0 \
3812 -c "replayed record" \
3813 -S "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01003814 -c "record from another epoch" \
3815 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003816 -c "resend" \
3817 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003818 -s "Extra-header:" \
3819 -c "HTTP/1.0 200 OK"
3820
Hanno Becker72a4f032017-11-15 16:39:20 +00003821run_test "DTLS proxy: multiple records in same datagram" \
3822 -p "$P_PXY pack=10" \
3823 "$P_SRV dtls=1 debug_level=2" \
3824 "$P_CLI dtls=1 debug_level=2" \
3825 0 \
3826 -c "next record in same datagram" \
3827 -s "next record in same datagram"
3828
3829run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
3830 -p "$P_PXY pack=10 duplicate=1" \
3831 "$P_SRV dtls=1 debug_level=2" \
3832 "$P_CLI dtls=1 debug_level=2" \
3833 0 \
3834 -c "next record in same datagram" \
3835 -s "next record in same datagram"
3836
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003837run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003838 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003839 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003840 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003841 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003842 -c "discarding invalid record (mac)" \
3843 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003844 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003845 -c "HTTP/1.0 200 OK" \
3846 -S "too many records with bad MAC" \
3847 -S "Verification of the message MAC failed"
3848
3849run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3850 -p "$P_PXY bad_ad=1" \
3851 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3852 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3853 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003854 -C "discarding invalid record (mac)" \
3855 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003856 -S "Extra-header:" \
3857 -C "HTTP/1.0 200 OK" \
3858 -s "too many records with bad MAC" \
3859 -s "Verification of the message MAC failed"
3860
3861run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3862 -p "$P_PXY bad_ad=1" \
3863 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3864 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3865 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003866 -c "discarding invalid record (mac)" \
3867 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003868 -s "Extra-header:" \
3869 -c "HTTP/1.0 200 OK" \
3870 -S "too many records with bad MAC" \
3871 -S "Verification of the message MAC failed"
3872
3873run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3874 -p "$P_PXY bad_ad=1" \
3875 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3876 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3877 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003878 -c "discarding invalid record (mac)" \
3879 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003880 -s "Extra-header:" \
3881 -c "HTTP/1.0 200 OK" \
3882 -s "too many records with bad MAC" \
3883 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003884
3885run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003886 -p "$P_PXY delay_ccs=1" \
3887 "$P_SRV dtls=1 debug_level=1" \
3888 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003889 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003890 -c "record from another epoch" \
3891 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003892 -s "Extra-header:" \
3893 -c "HTTP/1.0 200 OK"
3894
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003895# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003896
Janos Follath74537a62016-09-02 13:45:28 +01003897client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003898run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003899 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003900 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3901 psk=abc123" \
3902 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003903 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3904 0 \
3905 -s "Extra-header:" \
3906 -c "HTTP/1.0 200 OK"
3907
Janos Follath74537a62016-09-02 13:45:28 +01003908client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003909run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3910 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003911 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3912 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003913 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3914 0 \
3915 -s "Extra-header:" \
3916 -c "HTTP/1.0 200 OK"
3917
Janos Follath74537a62016-09-02 13:45:28 +01003918client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003919run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3920 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003921 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3922 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003923 0 \
3924 -s "Extra-header:" \
3925 -c "HTTP/1.0 200 OK"
3926
Janos Follath74537a62016-09-02 13:45:28 +01003927client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003928run_test "DTLS proxy: 3d, FS, client auth" \
3929 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003930 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3931 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003932 0 \
3933 -s "Extra-header:" \
3934 -c "HTTP/1.0 200 OK"
3935
Janos Follath74537a62016-09-02 13:45:28 +01003936client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003937run_test "DTLS proxy: 3d, FS, ticket" \
3938 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003939 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3940 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003941 0 \
3942 -s "Extra-header:" \
3943 -c "HTTP/1.0 200 OK"
3944
Janos Follath74537a62016-09-02 13:45:28 +01003945client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003946run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3947 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003948 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3949 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003950 0 \
3951 -s "Extra-header:" \
3952 -c "HTTP/1.0 200 OK"
3953
Janos Follath74537a62016-09-02 13:45:28 +01003954client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003955run_test "DTLS proxy: 3d, max handshake, nbio" \
3956 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003957 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3958 auth_mode=required" \
3959 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003960 0 \
3961 -s "Extra-header:" \
3962 -c "HTTP/1.0 200 OK"
3963
Janos Follath74537a62016-09-02 13:45:28 +01003964client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003965run_test "DTLS proxy: 3d, min handshake, resumption" \
3966 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3967 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3968 psk=abc123 debug_level=3" \
3969 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3970 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3971 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3972 0 \
3973 -s "a session has been resumed" \
3974 -c "a session has been resumed" \
3975 -s "Extra-header:" \
3976 -c "HTTP/1.0 200 OK"
3977
Janos Follath74537a62016-09-02 13:45:28 +01003978client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003979run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3980 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3981 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3982 psk=abc123 debug_level=3 nbio=2" \
3983 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3984 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3985 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3986 0 \
3987 -s "a session has been resumed" \
3988 -c "a session has been resumed" \
3989 -s "Extra-header:" \
3990 -c "HTTP/1.0 200 OK"
3991
Janos Follath74537a62016-09-02 13:45:28 +01003992client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003993run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003994 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003995 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3996 psk=abc123 renegotiation=1 debug_level=2" \
3997 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3998 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003999 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4000 0 \
4001 -c "=> renegotiate" \
4002 -s "=> renegotiate" \
4003 -s "Extra-header:" \
4004 -c "HTTP/1.0 200 OK"
4005
Janos Follath74537a62016-09-02 13:45:28 +01004006client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004007run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4008 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004009 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4010 psk=abc123 renegotiation=1 debug_level=2" \
4011 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4012 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004013 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4014 0 \
4015 -c "=> renegotiate" \
4016 -s "=> renegotiate" \
4017 -s "Extra-header:" \
4018 -c "HTTP/1.0 200 OK"
4019
Janos Follath74537a62016-09-02 13:45:28 +01004020client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004021run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004022 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004023 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004024 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004025 debug_level=2" \
4026 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004027 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004028 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4029 0 \
4030 -c "=> renegotiate" \
4031 -s "=> renegotiate" \
4032 -s "Extra-header:" \
4033 -c "HTTP/1.0 200 OK"
4034
Janos Follath74537a62016-09-02 13:45:28 +01004035client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004036run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004037 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004038 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004039 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004040 debug_level=2 nbio=2" \
4041 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004042 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004043 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4044 0 \
4045 -c "=> renegotiate" \
4046 -s "=> renegotiate" \
4047 -s "Extra-header:" \
4048 -c "HTTP/1.0 200 OK"
4049
Janos Follath74537a62016-09-02 13:45:28 +01004050client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004051not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004052run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004053 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4054 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004055 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004056 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004057 -c "HTTP/1.0 200 OK"
4058
Janos Follath74537a62016-09-02 13:45:28 +01004059client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004060not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004061run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4062 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4063 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004064 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004065 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004066 -c "HTTP/1.0 200 OK"
4067
Janos Follath74537a62016-09-02 13:45:28 +01004068client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004069not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004070run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4071 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4072 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004073 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004074 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004075 -c "HTTP/1.0 200 OK"
4076
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004077requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004078client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004079not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004080run_test "DTLS proxy: 3d, gnutls server" \
4081 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4082 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004083 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004084 0 \
4085 -s "Extra-header:" \
4086 -c "Extra-header:"
4087
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004088requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004089client_needs_more_time 8
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, gnutls server, fragmentation" \
4092 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4093 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004094 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004095 0 \
4096 -s "Extra-header:" \
4097 -c "Extra-header:"
4098
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004099requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004100client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004101not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004102run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4103 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4104 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004105 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004106 0 \
4107 -s "Extra-header:" \
4108 -c "Extra-header:"
4109
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004110# Final report
4111
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004112echo "------------------------------------------------------------------------"
4113
4114if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004115 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004116else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004117 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004118fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004119PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004120echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004121
4122exit $FAILS