blob: 887be4f008d09bd8418f6058b77656b88b8618f8 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02009# Assumes a build with default options.
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010010
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020016: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010017: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020018: ${GNUTLS_CLI:=gnutls-cli}
19: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskine39e29812017-05-16 17:53:03 +020020: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020022O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010023O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020024G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010025G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskine39e29812017-05-16 17:53:03 +020026TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010027
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028TESTS=0
29FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020030SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010031
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000032CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020033
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010035FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020036EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010037
38print_usage() {
39 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010040 printf " -h|--help\tPrint this help.\n"
41 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
42 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
43 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010044}
45
46get_options() {
47 while [ $# -gt 0 ]; do
48 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010049 -f|--filter)
50 shift; FILTER=$1
51 ;;
52 -e|--exclude)
53 shift; EXCLUDE=$1
54 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010055 -m|--memcheck)
56 MEMCHECK=1
57 ;;
58 -h|--help)
59 print_usage
60 exit 0
61 ;;
62 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020063 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010064 print_usage
65 exit 1
66 ;;
67 esac
68 shift
69 done
70}
71
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010072# skip next test if the flag is not enabled in config.h
73requires_config_enabled() {
74 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
75 SKIP_NEXT="YES"
76 fi
77}
78
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +020079# skip next test if the flag is enabled in config.h
80requires_config_disabled() {
81 if grep "^#define $1" $CONFIG_H > /dev/null; then
82 SKIP_NEXT="YES"
83 fi
84}
85
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020086# skip next test if OpenSSL doesn't support FALLBACK_SCSV
87requires_openssl_with_fallback_scsv() {
88 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
89 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
90 then
91 OPENSSL_HAS_FBSCSV="YES"
92 else
93 OPENSSL_HAS_FBSCSV="NO"
94 fi
95 fi
96 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
97 SKIP_NEXT="YES"
98 fi
99}
100
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200101# skip next test if GnuTLS isn't available
102requires_gnutls() {
103 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200104 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200105 GNUTLS_AVAILABLE="YES"
106 else
107 GNUTLS_AVAILABLE="NO"
108 fi
109 fi
110 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
111 SKIP_NEXT="YES"
112 fi
113}
114
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200115# skip next test if IPv6 isn't available on this host
116requires_ipv6() {
117 if [ -z "${HAS_IPV6:-}" ]; then
118 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
119 SRV_PID=$!
120 sleep 1
121 kill $SRV_PID >/dev/null 2>&1
122 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
123 HAS_IPV6="NO"
124 else
125 HAS_IPV6="YES"
126 fi
127 rm -r $SRV_OUT
128 fi
129
130 if [ "$HAS_IPV6" = "NO" ]; then
131 SKIP_NEXT="YES"
132 fi
133}
134
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200135# skip the next test if valgrind is in use
136not_with_valgrind() {
137 if [ "$MEMCHECK" -gt 0 ]; then
138 SKIP_NEXT="YES"
139 fi
140}
141
Paul Bakker3b224ff2016-05-13 10:33:25 +0100142# skip the next test if valgrind is NOT in use
143only_with_valgrind() {
144 if [ "$MEMCHECK" -eq 0 ]; then
145 SKIP_NEXT="YES"
146 fi
147}
148
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200149# multiply the client timeout delay by the given factor for the next test
150needs_more_time() {
151 CLI_DELAY_FACTOR=$1
152}
153
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100154# print_name <name>
155print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100156 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200157 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100158 for i in `seq 1 $LEN`; do printf '.'; done
159 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100160
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200161 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100162}
163
164# fail <message>
165fail() {
166 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100167 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100168
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200169 mv $SRV_OUT o-srv-${TESTS}.log
170 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200171 if [ -n "$PXY_CMD" ]; then
172 mv $PXY_OUT o-pxy-${TESTS}.log
173 fi
174 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100175
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200176 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
177 echo " ! server output:"
178 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200179 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200180 echo " ! client output:"
181 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200182 if [ -n "$PXY_CMD" ]; then
183 echo " ! ========================================================"
184 echo " ! proxy output:"
185 cat o-pxy-${TESTS}.log
186 fi
187 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200188 fi
189
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200190 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100191}
192
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100193# is_polar <cmd_line>
194is_polar() {
195 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
196}
197
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200198# openssl s_server doesn't have -www with DTLS
199check_osrv_dtls() {
200 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
201 NEEDS_INPUT=1
202 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
203 else
204 NEEDS_INPUT=0
205 fi
206}
207
208# provide input to commands that need it
209provide_input() {
210 if [ $NEEDS_INPUT -eq 0 ]; then
211 return
212 fi
213
214 while true; do
215 echo "HTTP/1.0 200 OK"
216 sleep 1
217 done
218}
219
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100220# has_mem_err <log_file_name>
221has_mem_err() {
222 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
223 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
224 then
225 return 1 # false: does not have errors
226 else
227 return 0 # true: has errors
228 fi
229}
230
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200231# wait for server to start: two versions depending on lsof availability
232wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200233 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200234 START_TIME=$( date +%s )
235 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200236
237 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200238 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200239 while [ $DONE -eq 0 ]; do
240 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
241 then
242 DONE=1
243 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
244 echo "SERVERSTART TIMEOUT"
245 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
246 DONE=1
247 fi
248 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200249 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200250 while [ $DONE -eq 0 ]; do
251 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
252 then
253 DONE=1
254 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
255 echo "SERVERSTART TIMEOUT"
256 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
257 DONE=1
258 fi
259 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200260 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200261 else
262 sleep "$START_DELAY"
263 fi
264}
265
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200266# wait for client to terminate and set CLI_EXIT
267# must be called right after starting the client
268wait_client_done() {
269 CLI_PID=$!
270
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200271 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
272 CLI_DELAY_FACTOR=1
273
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200274 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200275 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200276
277 wait $CLI_PID
278 CLI_EXIT=$?
279
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200280 kill $DOG_PID >/dev/null 2>&1
281 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200282
283 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
284}
285
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200286# check if the given command uses dtls and sets global variable DTLS
287detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200288 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200289 DTLS=1
290 else
291 DTLS=0
292 fi
293}
294
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200295# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100296# Options: -s pattern pattern that must be present in server output
297# -c pattern pattern that must be present in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100298# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100299# -S pattern pattern that must be absent in server output
300# -C pattern pattern that must be absent in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100301# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100302run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100303 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200304 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100305
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100306 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
307 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200308 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100309 return
310 fi
311
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100312 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100313
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200314 # should we skip?
315 if [ "X$SKIP_NEXT" = "XYES" ]; then
316 SKIP_NEXT="NO"
317 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200318 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200319 return
320 fi
321
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200322 # does this test use a proxy?
323 if [ "X$1" = "X-p" ]; then
324 PXY_CMD="$2"
325 shift 2
326 else
327 PXY_CMD=""
328 fi
329
330 # get commands and client output
331 SRV_CMD="$1"
332 CLI_CMD="$2"
333 CLI_EXPECT="$3"
334 shift 3
335
336 # fix client port
337 if [ -n "$PXY_CMD" ]; then
338 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
339 else
340 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
341 fi
342
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200343 # update DTLS variable
344 detect_dtls "$SRV_CMD"
345
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100346 # prepend valgrind to our commands if active
347 if [ "$MEMCHECK" -gt 0 ]; then
348 if is_polar "$SRV_CMD"; then
349 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
350 fi
351 if is_polar "$CLI_CMD"; then
352 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
353 fi
354 fi
355
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200356 TIMES_LEFT=2
357 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200358 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200359
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200360 # run the commands
361 if [ -n "$PXY_CMD" ]; then
362 echo "$PXY_CMD" > $PXY_OUT
363 $PXY_CMD >> $PXY_OUT 2>&1 &
364 PXY_PID=$!
365 # assume proxy starts faster than server
366 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200367
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200368 check_osrv_dtls
369 echo "$SRV_CMD" > $SRV_OUT
370 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
371 SRV_PID=$!
372 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200373
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200374 echo "$CLI_CMD" > $CLI_OUT
375 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
376 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100377
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200378 # terminate the server (and the proxy)
379 kill $SRV_PID
380 wait $SRV_PID
381 if [ -n "$PXY_CMD" ]; then
382 kill $PXY_PID >/dev/null 2>&1
383 wait $PXY_PID
384 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100385
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200386 # retry only on timeouts
387 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
388 printf "RETRY "
389 else
390 TIMES_LEFT=0
391 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200392 done
393
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100394 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200395 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100396 # expected client exit to incorrectly succeed in case of catastrophic
397 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100398 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200399 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100400 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100401 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100402 return
403 fi
404 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100405 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200406 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100407 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100408 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100409 return
410 fi
411 fi
412
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100413 # check server exit code
414 if [ $? != 0 ]; then
415 fail "server fail"
416 return
417 fi
418
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100419 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100420 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
421 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100422 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200423 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100424 return
425 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100426
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100427 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200428 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100429 while [ $# -gt 0 ]
430 do
431 case $1 in
432 "-s")
Janos Follath6d3e3382016-09-07 15:48:48 +0100433 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
434 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100435 return
436 fi
437 ;;
438
439 "-c")
Janos Follath6d3e3382016-09-07 15:48:48 +0100440 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
441 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100442 return
443 fi
444 ;;
445
446 "-S")
Janos Follath6d3e3382016-09-07 15:48:48 +0100447 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
448 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100449 return
450 fi
451 ;;
452
453 "-C")
Janos Follath6d3e3382016-09-07 15:48:48 +0100454 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
455 fail "pattern '$2' MUST NOT be present in the Client output"
456 return
457 fi
458 ;;
459
460 # The filtering in the following two options (-u and -U) do the following
461 # - ignore valgrind output
462 # - filter out everything but lines right after the pattern occurances
463 # - keep one of each non-unique line
464 # - count how many lines remain
465 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
466 # if there were no duplicates.
467 "-U")
468 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
469 fail "lines following pattern '$2' must be unique in Server output"
470 return
471 fi
472 ;;
473
474 "-u")
475 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
476 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100477 return
478 fi
479 ;;
480
481 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200482 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100483 exit 1
484 esac
485 shift 2
486 done
487
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100488 # check valgrind's results
489 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200490 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100491 fail "Server has memory errors"
492 return
493 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200494 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100495 fail "Client has memory errors"
496 return
497 fi
498 fi
499
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100500 # if we're here, everything is ok
501 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200502 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100503}
504
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100505cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200506 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200507 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
508 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
509 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
510 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100511 exit 1
512}
513
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100514#
515# MAIN
516#
517
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000518if cd $( dirname $0 ); then :; else
519 echo "cd $( dirname $0 ) failed" >&2
520 exit 1
521fi
522
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100523get_options "$@"
524
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100525# sanity checks, avoid an avalanche of errors
526if [ ! -x "$P_SRV" ]; then
527 echo "Command '$P_SRV' is not an executable file"
528 exit 1
529fi
530if [ ! -x "$P_CLI" ]; then
531 echo "Command '$P_CLI' is not an executable file"
532 exit 1
533fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200534if [ ! -x "$P_PXY" ]; then
535 echo "Command '$P_PXY' is not an executable file"
536 exit 1
537fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100538if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
539 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100540 exit 1
541fi
542
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200543# used by watchdog
544MAIN_PID="$$"
545
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200546# be more patient with valgrind
547if [ "$MEMCHECK" -gt 0 ]; then
548 START_DELAY=3
549 DOG_DELAY=30
550else
551 START_DELAY=1
552 DOG_DELAY=10
553fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200554CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200555
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200556# Pick a "unique" server port in the range 10000-19999, and a proxy port
557PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000558PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200559SRV_PORT="1$PORT_BASE"
560PXY_PORT="2$PORT_BASE"
561unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200562
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200563# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000564# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200565P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
566P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
567P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200568O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200569O_CLI="$O_CLI -connect localhost:+SRV_PORT"
570G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000571G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200572
Gilles Peskine35db5ba2017-05-10 10:13:59 +0200573# Allow SHA-1, because many of our test certificates use it
574P_SRV="$P_SRV allow_sha1=1"
575P_CLI="$P_CLI allow_sha1=1"
576
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200577# Also pick a unique name for intermediate files
578SRV_OUT="srv_out.$$"
579CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200580PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200581SESSION="session.$$"
582
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200583SKIP_NEXT="NO"
584
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100585trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100586
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200587# Basic test
588
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200589# Checks that:
590# - things work with all ciphersuites active (used with config-full in all.sh)
591# - the expected (highest security) parameters are selected
592# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200593run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200594 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200595 "$P_CLI" \
596 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200597 -s "Protocol is TLSv1.2" \
598 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
599 -s "client hello v3, signature_algorithm ext: 6" \
600 -s "ECDHE curve: secp521r1" \
601 -S "error" \
602 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200603
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000604run_test "Default, DTLS" \
605 "$P_SRV dtls=1" \
606 "$P_CLI dtls=1" \
607 0 \
608 -s "Protocol is DTLSv1.2" \
609 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
610
Janos Follath6d3e3382016-09-07 15:48:48 +0100611# Test for uniqueness of IVs in AEAD ciphersuites
612run_test "Unique IV in GCM" \
613 "$P_SRV exchanges=20 debug_level=4" \
614 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
615 0 \
616 -u "IV used" \
617 -U "IV used"
618
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100619# Tests for rc4 option
620
Simon Butcher6eb066e2016-05-19 22:12:18 +0100621requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100622run_test "RC4: server disabled, client enabled" \
623 "$P_SRV" \
624 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
625 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100626 -s "SSL - The server has no ciphersuites in common"
627
Simon Butcher6eb066e2016-05-19 22:12:18 +0100628requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100629run_test "RC4: server half, client enabled" \
630 "$P_SRV arc4=1" \
631 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
632 1 \
633 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100634
635run_test "RC4: server enabled, client disabled" \
636 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
637 "$P_CLI" \
638 1 \
639 -s "SSL - The server has no ciphersuites in common"
640
641run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100642 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100643 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
644 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100645 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100646 -S "SSL - The server has no ciphersuites in common"
647
Gilles Peskineae765992017-05-09 15:59:24 +0200648# Tests for SHA-1 support
649
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200650requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200651run_test "SHA-1 forbidden by default in server certificate" \
652 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
653 "$P_CLI debug_level=2 allow_sha1=0" \
654 1 \
655 -c "The certificate is signed with an unacceptable hash"
656
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200657requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
658run_test "SHA-1 forbidden by default in server certificate" \
659 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
660 "$P_CLI debug_level=2 allow_sha1=0" \
661 0
662
Gilles Peskineae765992017-05-09 15:59:24 +0200663run_test "SHA-1 explicitly allowed in server certificate" \
664 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
665 "$P_CLI allow_sha1=1" \
666 0
667
668run_test "SHA-256 allowed by default in server certificate" \
669 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
670 "$P_CLI allow_sha1=0" \
671 0
672
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200673requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200674run_test "SHA-1 forbidden by default in client certificate" \
675 "$P_SRV auth_mode=required allow_sha1=0" \
676 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
677 1 \
678 -s "The certificate is signed with an unacceptable hash"
679
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200680requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
681run_test "SHA-1 forbidden by default in client certificate" \
682 "$P_SRV auth_mode=required allow_sha1=0" \
683 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
684 0
685
Gilles Peskineae765992017-05-09 15:59:24 +0200686run_test "SHA-1 explicitly allowed in client certificate" \
687 "$P_SRV auth_mode=required allow_sha1=1" \
688 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
689 0
690
691run_test "SHA-256 allowed by default in client certificate" \
692 "$P_SRV auth_mode=required allow_sha1=0" \
693 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
694 0
695
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100696# Tests for Truncated HMAC extension
697
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100698run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200699 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100700 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100701 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000702 -s "dumping 'expected mac' (20 bytes)" \
703 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100704
Hanno Beckera83fafa2017-11-10 08:42:54 +0000705requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100706run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200707 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100708 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
709 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100710 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000711 -s "dumping 'expected mac' (20 bytes)" \
712 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100713
Hanno Beckera83fafa2017-11-10 08:42:54 +0000714requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100715run_test "Truncated HMAC: client enabled, server default" \
716 "$P_SRV debug_level=4" \
717 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
718 trunc_hmac=1" \
719 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000720 -s "dumping 'expected mac' (20 bytes)" \
721 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100722
Hanno Beckera83fafa2017-11-10 08:42:54 +0000723requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100724run_test "Truncated HMAC: client enabled, server disabled" \
725 "$P_SRV debug_level=4 trunc_hmac=0" \
726 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
727 trunc_hmac=1" \
728 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000729 -s "dumping 'expected mac' (20 bytes)" \
730 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100731
Hanno Beckera83fafa2017-11-10 08:42:54 +0000732requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Beckerd51bec72017-11-17 15:46:24 +0000733run_test "Truncated HMAC: client disabled, server enabled" \
734 "$P_SRV debug_level=4 trunc_hmac=1" \
735 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
736 trunc_hmac=0" \
737 0 \
738 -s "dumping 'expected mac' (20 bytes)" \
739 -S "dumping 'expected mac' (10 bytes)"
740
741requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100742run_test "Truncated HMAC: client enabled, server enabled" \
743 "$P_SRV debug_level=4 trunc_hmac=1" \
744 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
745 trunc_hmac=1" \
746 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000747 -S "dumping 'expected mac' (20 bytes)" \
748 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100749
Hanno Becker02f632e2017-11-10 09:16:05 +0000750run_test "Truncated HMAC, DTLS: client default, server default" \
751 "$P_SRV dtls=1 debug_level=4" \
752 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
753 0 \
754 -s "dumping 'expected mac' (20 bytes)" \
755 -S "dumping 'expected mac' (10 bytes)"
756
757requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
758run_test "Truncated HMAC, DTLS: client disabled, server default" \
759 "$P_SRV dtls=1 debug_level=4" \
760 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
761 trunc_hmac=0" \
762 0 \
763 -s "dumping 'expected mac' (20 bytes)" \
764 -S "dumping 'expected mac' (10 bytes)"
765
766requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
767run_test "Truncated HMAC, DTLS: client enabled, server default" \
768 "$P_SRV dtls=1 debug_level=4" \
769 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
770 trunc_hmac=1" \
771 0 \
772 -s "dumping 'expected mac' (20 bytes)" \
773 -S "dumping 'expected mac' (10 bytes)"
774
775requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
776run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
777 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
778 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
779 trunc_hmac=1" \
780 0 \
781 -s "dumping 'expected mac' (20 bytes)" \
782 -S "dumping 'expected mac' (10 bytes)"
783
784requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
785run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
786 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
787 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
788 trunc_hmac=0" \
789 0 \
790 -s "dumping 'expected mac' (20 bytes)" \
791 -S "dumping 'expected mac' (10 bytes)"
792
793requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
794run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
795 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
796 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
797 trunc_hmac=1" \
798 0 \
799 -S "dumping 'expected mac' (20 bytes)" \
800 -s "dumping 'expected mac' (10 bytes)"
801
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100802# Tests for Encrypt-then-MAC extension
803
804run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100805 "$P_SRV debug_level=3 \
806 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100807 "$P_CLI debug_level=3" \
808 0 \
809 -c "client hello, adding encrypt_then_mac extension" \
810 -s "found encrypt then mac extension" \
811 -s "server hello, adding encrypt then mac extension" \
812 -c "found encrypt_then_mac extension" \
813 -c "using encrypt then mac" \
814 -s "using encrypt then mac"
815
816run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100817 "$P_SRV debug_level=3 etm=0 \
818 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100819 "$P_CLI debug_level=3 etm=1" \
820 0 \
821 -c "client hello, adding encrypt_then_mac extension" \
822 -s "found encrypt then mac extension" \
823 -S "server hello, adding encrypt then mac extension" \
824 -C "found encrypt_then_mac extension" \
825 -C "using encrypt then mac" \
826 -S "using encrypt then mac"
827
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100828run_test "Encrypt then MAC: client enabled, aead cipher" \
829 "$P_SRV debug_level=3 etm=1 \
830 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
831 "$P_CLI debug_level=3 etm=1" \
832 0 \
833 -c "client hello, adding encrypt_then_mac extension" \
834 -s "found encrypt then mac extension" \
835 -S "server hello, adding encrypt then mac extension" \
836 -C "found encrypt_then_mac extension" \
837 -C "using encrypt then mac" \
838 -S "using encrypt then mac"
839
840run_test "Encrypt then MAC: client enabled, stream cipher" \
841 "$P_SRV debug_level=3 etm=1 \
842 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100843 "$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 +0100844 0 \
845 -c "client hello, adding encrypt_then_mac extension" \
846 -s "found encrypt then mac extension" \
847 -S "server hello, adding encrypt then mac extension" \
848 -C "found encrypt_then_mac extension" \
849 -C "using encrypt then mac" \
850 -S "using encrypt then mac"
851
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100852run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100853 "$P_SRV debug_level=3 etm=1 \
854 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100855 "$P_CLI debug_level=3 etm=0" \
856 0 \
857 -C "client hello, adding encrypt_then_mac extension" \
858 -S "found encrypt then mac extension" \
859 -S "server hello, adding encrypt then mac extension" \
860 -C "found encrypt_then_mac extension" \
861 -C "using encrypt then mac" \
862 -S "using encrypt then mac"
863
Janos Follath542ee5d2016-03-07 15:57:05 +0000864requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100865run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100866 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100867 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100868 "$P_CLI debug_level=3 force_version=ssl3" \
869 0 \
870 -C "client hello, adding encrypt_then_mac extension" \
871 -S "found encrypt then mac extension" \
872 -S "server hello, adding encrypt then mac extension" \
873 -C "found encrypt_then_mac extension" \
874 -C "using encrypt then mac" \
875 -S "using encrypt then mac"
876
Janos Follath542ee5d2016-03-07 15:57:05 +0000877requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100878run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100879 "$P_SRV debug_level=3 force_version=ssl3 \
880 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100881 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100882 0 \
883 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100884 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100885 -S "server hello, adding encrypt then mac extension" \
886 -C "found encrypt_then_mac extension" \
887 -C "using encrypt then mac" \
888 -S "using encrypt then mac"
889
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200890# Tests for Extended Master Secret extension
891
892run_test "Extended Master Secret: default" \
893 "$P_SRV debug_level=3" \
894 "$P_CLI debug_level=3" \
895 0 \
896 -c "client hello, adding extended_master_secret extension" \
897 -s "found extended master secret extension" \
898 -s "server hello, adding extended master secret extension" \
899 -c "found extended_master_secret extension" \
900 -c "using extended master secret" \
901 -s "using extended master secret"
902
903run_test "Extended Master Secret: client enabled, server disabled" \
904 "$P_SRV debug_level=3 extended_ms=0" \
905 "$P_CLI debug_level=3 extended_ms=1" \
906 0 \
907 -c "client hello, adding extended_master_secret extension" \
908 -s "found extended master secret extension" \
909 -S "server hello, adding extended master secret extension" \
910 -C "found extended_master_secret extension" \
911 -C "using extended master secret" \
912 -S "using extended master secret"
913
914run_test "Extended Master Secret: client disabled, server enabled" \
915 "$P_SRV debug_level=3 extended_ms=1" \
916 "$P_CLI debug_level=3 extended_ms=0" \
917 0 \
918 -C "client hello, adding extended_master_secret extension" \
919 -S "found extended master secret extension" \
920 -S "server hello, adding extended master secret extension" \
921 -C "found extended_master_secret extension" \
922 -C "using extended master secret" \
923 -S "using extended master secret"
924
Janos Follath542ee5d2016-03-07 15:57:05 +0000925requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200926run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100927 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200928 "$P_CLI debug_level=3 force_version=ssl3" \
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
Janos Follath542ee5d2016-03-07 15:57:05 +0000937requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200938run_test "Extended Master Secret: client enabled, server SSLv3" \
939 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100940 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200941 0 \
942 -c "client hello, adding extended_master_secret extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100943 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200944 -S "server hello, adding extended master secret extension" \
945 -C "found extended_master_secret extension" \
946 -C "using extended master secret" \
947 -S "using extended master secret"
948
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200949# Tests for FALLBACK_SCSV
950
951run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200952 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200953 "$P_CLI debug_level=3 force_version=tls1_1" \
954 0 \
955 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200956 -S "received FALLBACK_SCSV" \
957 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200958 -C "is a fatal alert message (msg 86)"
959
960run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200961 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200962 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
963 0 \
964 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200965 -S "received FALLBACK_SCSV" \
966 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200967 -C "is a fatal alert message (msg 86)"
968
969run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200970 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200971 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200972 1 \
973 -c "adding FALLBACK_SCSV" \
974 -s "received FALLBACK_SCSV" \
975 -s "inapropriate fallback" \
976 -c "is a fatal alert message (msg 86)"
977
978run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200979 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200980 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200981 0 \
982 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200983 -s "received FALLBACK_SCSV" \
984 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200985 -C "is a fatal alert message (msg 86)"
986
987requires_openssl_with_fallback_scsv
988run_test "Fallback SCSV: default, openssl server" \
989 "$O_SRV" \
990 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
991 0 \
992 -C "adding FALLBACK_SCSV" \
993 -C "is a fatal alert message (msg 86)"
994
995requires_openssl_with_fallback_scsv
996run_test "Fallback SCSV: enabled, openssl server" \
997 "$O_SRV" \
998 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
999 1 \
1000 -c "adding FALLBACK_SCSV" \
1001 -c "is a fatal alert message (msg 86)"
1002
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001003requires_openssl_with_fallback_scsv
1004run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001005 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001006 "$O_CLI -tls1_1" \
1007 0 \
1008 -S "received FALLBACK_SCSV" \
1009 -S "inapropriate fallback"
1010
1011requires_openssl_with_fallback_scsv
1012run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001013 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001014 "$O_CLI -tls1_1 -fallback_scsv" \
1015 1 \
1016 -s "received FALLBACK_SCSV" \
1017 -s "inapropriate fallback"
1018
1019requires_openssl_with_fallback_scsv
1020run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001021 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001022 "$O_CLI -fallback_scsv" \
1023 0 \
1024 -s "received FALLBACK_SCSV" \
1025 -S "inapropriate fallback"
1026
Gilles Peskine39e29812017-05-16 17:53:03 +02001027## ClientHello generated with
1028## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1029## then manually twiddling the ciphersuite list.
1030## The ClientHello content is spelled out below as a hex string as
1031## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1032## The expected response is an inappropriate_fallback alert.
1033requires_openssl_with_fallback_scsv
1034run_test "Fallback SCSV: beginning of list" \
1035 "$P_SRV debug_level=2" \
1036 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1037 0 \
1038 -s "received FALLBACK_SCSV" \
1039 -s "inapropriate fallback"
1040
1041requires_openssl_with_fallback_scsv
1042run_test "Fallback SCSV: end of list" \
1043 "$P_SRV debug_level=2" \
1044 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1045 0 \
1046 -s "received FALLBACK_SCSV" \
1047 -s "inapropriate fallback"
1048
1049## Here the expected response is a valid ServerHello prefix, up to the random.
1050requires_openssl_with_fallback_scsv
1051run_test "Fallback SCSV: not in list" \
1052 "$P_SRV debug_level=2" \
1053 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1054 0 \
1055 -S "received FALLBACK_SCSV" \
1056 -S "inapropriate fallback"
1057
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001058# Tests for CBC 1/n-1 record splitting
1059
1060run_test "CBC Record splitting: TLS 1.2, no splitting" \
1061 "$P_SRV" \
1062 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1063 request_size=123 force_version=tls1_2" \
1064 0 \
1065 -s "Read from client: 123 bytes read" \
1066 -S "Read from client: 1 bytes read" \
1067 -S "122 bytes read"
1068
1069run_test "CBC Record splitting: TLS 1.1, no splitting" \
1070 "$P_SRV" \
1071 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1072 request_size=123 force_version=tls1_1" \
1073 0 \
1074 -s "Read from client: 123 bytes read" \
1075 -S "Read from client: 1 bytes read" \
1076 -S "122 bytes read"
1077
1078run_test "CBC Record splitting: TLS 1.0, splitting" \
1079 "$P_SRV" \
1080 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1081 request_size=123 force_version=tls1" \
1082 0 \
1083 -S "Read from client: 123 bytes read" \
1084 -s "Read from client: 1 bytes read" \
1085 -s "122 bytes read"
1086
Janos Follath542ee5d2016-03-07 15:57:05 +00001087requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001088run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001089 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001090 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1091 request_size=123 force_version=ssl3" \
1092 0 \
1093 -S "Read from client: 123 bytes read" \
1094 -s "Read from client: 1 bytes read" \
1095 -s "122 bytes read"
1096
1097run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001098 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001099 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1100 request_size=123 force_version=tls1" \
1101 0 \
1102 -s "Read from client: 123 bytes read" \
1103 -S "Read from client: 1 bytes read" \
1104 -S "122 bytes read"
1105
1106run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1107 "$P_SRV" \
1108 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1109 request_size=123 force_version=tls1 recsplit=0" \
1110 0 \
1111 -s "Read from client: 123 bytes read" \
1112 -S "Read from client: 1 bytes read" \
1113 -S "122 bytes read"
1114
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001115run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1116 "$P_SRV nbio=2" \
1117 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1118 request_size=123 force_version=tls1" \
1119 0 \
1120 -S "Read from client: 123 bytes read" \
1121 -s "Read from client: 1 bytes read" \
1122 -s "122 bytes read"
1123
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001124# Tests for Session Tickets
1125
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001126run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001127 "$P_SRV debug_level=3 tickets=1" \
1128 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001129 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001130 -c "client hello, adding session ticket extension" \
1131 -s "found session ticket extension" \
1132 -s "server hello, adding session ticket extension" \
1133 -c "found session_ticket extension" \
1134 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001135 -S "session successfully restored from cache" \
1136 -s "session successfully restored from ticket" \
1137 -s "a session has been resumed" \
1138 -c "a session has been resumed"
1139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001140run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001141 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1142 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001143 0 \
1144 -c "client hello, adding session ticket extension" \
1145 -s "found session ticket extension" \
1146 -s "server hello, adding session ticket extension" \
1147 -c "found session_ticket extension" \
1148 -c "parse new session ticket" \
1149 -S "session successfully restored from cache" \
1150 -s "session successfully restored from ticket" \
1151 -s "a session has been resumed" \
1152 -c "a session has been resumed"
1153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001154run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001155 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1156 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001157 0 \
1158 -c "client hello, adding session ticket extension" \
1159 -s "found session ticket extension" \
1160 -s "server hello, adding session ticket extension" \
1161 -c "found session_ticket extension" \
1162 -c "parse new session ticket" \
1163 -S "session successfully restored from cache" \
1164 -S "session successfully restored from ticket" \
1165 -S "a session has been resumed" \
1166 -C "a session has been resumed"
1167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001168run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001169 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001170 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001171 0 \
1172 -c "client hello, adding session ticket extension" \
1173 -c "found session_ticket extension" \
1174 -c "parse new session ticket" \
1175 -c "a session has been resumed"
1176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001177run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001178 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001179 "( $O_CLI -sess_out $SESSION; \
1180 $O_CLI -sess_in $SESSION; \
1181 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001182 0 \
1183 -s "found session ticket extension" \
1184 -s "server hello, adding session ticket extension" \
1185 -S "session successfully restored from cache" \
1186 -s "session successfully restored from ticket" \
1187 -s "a session has been resumed"
1188
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001189# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001190
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001191run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001192 "$P_SRV debug_level=3 tickets=0" \
1193 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001194 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001195 -c "client hello, adding session ticket extension" \
1196 -s "found session ticket extension" \
1197 -S "server hello, adding session ticket extension" \
1198 -C "found session_ticket extension" \
1199 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001200 -s "session successfully restored from cache" \
1201 -S "session successfully restored from ticket" \
1202 -s "a session has been resumed" \
1203 -c "a session has been resumed"
1204
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001205run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001206 "$P_SRV debug_level=3 tickets=1" \
1207 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001208 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001209 -C "client hello, adding session ticket extension" \
1210 -S "found session ticket extension" \
1211 -S "server hello, adding session ticket extension" \
1212 -C "found session_ticket extension" \
1213 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001214 -s "session successfully restored from cache" \
1215 -S "session successfully restored from ticket" \
1216 -s "a session has been resumed" \
1217 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001218
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001219run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001220 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1221 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001222 0 \
1223 -S "session successfully restored from cache" \
1224 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001225 -S "a session has been resumed" \
1226 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001227
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001228run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001229 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1230 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001231 0 \
1232 -s "session successfully restored from cache" \
1233 -S "session successfully restored from ticket" \
1234 -s "a session has been resumed" \
1235 -c "a session has been resumed"
1236
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001237run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001238 "$P_SRV debug_level=3 tickets=0" \
1239 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001240 0 \
1241 -s "session successfully restored from cache" \
1242 -S "session successfully restored from ticket" \
1243 -s "a session has been resumed" \
1244 -c "a session has been resumed"
1245
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001246run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001247 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1248 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001249 0 \
1250 -S "session successfully restored from cache" \
1251 -S "session successfully restored from ticket" \
1252 -S "a session has been resumed" \
1253 -C "a session has been resumed"
1254
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001255run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001256 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1257 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001258 0 \
1259 -s "session successfully restored from cache" \
1260 -S "session successfully restored from ticket" \
1261 -s "a session has been resumed" \
1262 -c "a session has been resumed"
1263
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001264run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001265 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001266 "( $O_CLI -sess_out $SESSION; \
1267 $O_CLI -sess_in $SESSION; \
1268 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001269 0 \
1270 -s "found session ticket extension" \
1271 -S "server hello, adding session ticket extension" \
1272 -s "session successfully restored from cache" \
1273 -S "session successfully restored from ticket" \
1274 -s "a session has been resumed"
1275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001276run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001277 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001278 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001279 0 \
1280 -C "found session_ticket extension" \
1281 -C "parse new session ticket" \
1282 -c "a session has been resumed"
1283
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001284# Tests for Max Fragment Length extension
1285
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001286run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001287 "$P_SRV debug_level=3" \
1288 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001289 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001290 -c "Maximum fragment length is 16384" \
1291 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001292 -C "client hello, adding max_fragment_length extension" \
1293 -S "found max fragment length extension" \
1294 -S "server hello, max_fragment_length extension" \
1295 -C "found max_fragment_length extension"
1296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001297run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001298 "$P_SRV debug_level=3" \
1299 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001300 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001301 -c "Maximum fragment length is 4096" \
1302 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001303 -c "client hello, adding max_fragment_length extension" \
1304 -s "found max fragment length extension" \
1305 -s "server hello, max_fragment_length extension" \
1306 -c "found max_fragment_length extension"
1307
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001308run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001309 "$P_SRV debug_level=3 max_frag_len=4096" \
1310 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001311 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001312 -c "Maximum fragment length is 16384" \
1313 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001314 -C "client hello, adding max_fragment_length extension" \
1315 -S "found max fragment length extension" \
1316 -S "server hello, max_fragment_length extension" \
1317 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001318
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001319requires_gnutls
1320run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001321 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001322 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001323 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001324 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001325 -c "client hello, adding max_fragment_length extension" \
1326 -c "found max_fragment_length extension"
1327
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001328run_test "Max fragment length: client, message just fits" \
1329 "$P_SRV debug_level=3" \
1330 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1331 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001332 -c "Maximum fragment length is 2048" \
1333 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001334 -c "client hello, adding max_fragment_length extension" \
1335 -s "found max fragment length extension" \
1336 -s "server hello, max_fragment_length extension" \
1337 -c "found max_fragment_length extension" \
1338 -c "2048 bytes written in 1 fragments" \
1339 -s "2048 bytes read"
1340
1341run_test "Max fragment length: client, larger message" \
1342 "$P_SRV debug_level=3" \
1343 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1344 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001345 -c "Maximum fragment length is 2048" \
1346 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001347 -c "client hello, adding max_fragment_length extension" \
1348 -s "found max fragment length extension" \
1349 -s "server hello, max_fragment_length extension" \
1350 -c "found max_fragment_length extension" \
1351 -c "2345 bytes written in 2 fragments" \
1352 -s "2048 bytes read" \
1353 -s "297 bytes read"
1354
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001355run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001356 "$P_SRV debug_level=3 dtls=1" \
1357 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1358 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001359 -c "Maximum fragment length is 2048" \
1360 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001361 -c "client hello, adding max_fragment_length extension" \
1362 -s "found max fragment length extension" \
1363 -s "server hello, max_fragment_length extension" \
1364 -c "found max_fragment_length extension" \
1365 -c "fragment larger than.*maximum"
1366
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001367# Tests for renegotiation
1368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001369run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001370 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001371 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001372 0 \
1373 -C "client hello, adding renegotiation extension" \
1374 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1375 -S "found renegotiation extension" \
1376 -s "server hello, secure renegotiation extension" \
1377 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001378 -C "=> renegotiate" \
1379 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001380 -S "write hello request"
1381
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001382run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001383 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001384 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001385 0 \
1386 -c "client hello, adding renegotiation extension" \
1387 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1388 -s "found renegotiation extension" \
1389 -s "server hello, secure renegotiation extension" \
1390 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001391 -c "=> renegotiate" \
1392 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001393 -S "write hello request"
1394
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001395run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001396 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001397 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001398 0 \
1399 -c "client hello, adding renegotiation extension" \
1400 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1401 -s "found renegotiation extension" \
1402 -s "server hello, secure renegotiation extension" \
1403 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001404 -c "=> renegotiate" \
1405 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001406 -s "write hello request"
1407
Janos Follath5f1dd802017-10-05 12:29:42 +01001408# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1409# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1410# algorithm stronger than SHA-1 is enabled in config.h
1411run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1412 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1413 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1414 0 \
1415 -c "client hello, adding renegotiation extension" \
1416 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1417 -s "found renegotiation extension" \
1418 -s "server hello, secure renegotiation extension" \
1419 -c "found renegotiation extension" \
1420 -c "=> renegotiate" \
1421 -s "=> renegotiate" \
1422 -S "write hello request" \
1423 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1424
1425# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1426# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1427# algorithm stronger than SHA-1 is enabled in config.h
1428run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1429 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1430 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1431 0 \
1432 -c "client hello, adding renegotiation extension" \
1433 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1434 -s "found renegotiation extension" \
1435 -s "server hello, secure renegotiation extension" \
1436 -c "found renegotiation extension" \
1437 -c "=> renegotiate" \
1438 -s "=> renegotiate" \
1439 -s "write hello request" \
1440 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1441
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001442run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001443 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001444 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001445 0 \
1446 -c "client hello, adding renegotiation extension" \
1447 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1448 -s "found renegotiation extension" \
1449 -s "server hello, secure renegotiation extension" \
1450 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001451 -c "=> renegotiate" \
1452 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001453 -s "write hello request"
1454
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001455run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001456 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001457 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001458 1 \
1459 -c "client hello, adding renegotiation extension" \
1460 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1461 -S "found renegotiation extension" \
1462 -s "server hello, secure renegotiation extension" \
1463 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001464 -c "=> renegotiate" \
1465 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001466 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001467 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001468 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001469
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001470run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001471 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001472 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001473 0 \
1474 -C "client hello, adding renegotiation extension" \
1475 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1476 -S "found renegotiation extension" \
1477 -s "server hello, secure renegotiation extension" \
1478 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001479 -C "=> renegotiate" \
1480 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001481 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001482 -S "SSL - An unexpected message was received from our peer" \
1483 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001485run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001486 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001487 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001488 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001489 0 \
1490 -C "client hello, adding renegotiation extension" \
1491 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1492 -S "found renegotiation extension" \
1493 -s "server hello, secure renegotiation extension" \
1494 -c "found renegotiation extension" \
1495 -C "=> renegotiate" \
1496 -S "=> renegotiate" \
1497 -s "write hello request" \
1498 -S "SSL - An unexpected message was received from our peer" \
1499 -S "failed"
1500
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001501# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001502run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001503 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001504 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001505 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001506 0 \
1507 -C "client hello, adding renegotiation extension" \
1508 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1509 -S "found renegotiation extension" \
1510 -s "server hello, secure renegotiation extension" \
1511 -c "found renegotiation extension" \
1512 -C "=> renegotiate" \
1513 -S "=> renegotiate" \
1514 -s "write hello request" \
1515 -S "SSL - An unexpected message was received from our peer" \
1516 -S "failed"
1517
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001518run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001519 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001520 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001521 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001522 0 \
1523 -C "client hello, adding renegotiation extension" \
1524 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1525 -S "found renegotiation extension" \
1526 -s "server hello, secure renegotiation extension" \
1527 -c "found renegotiation extension" \
1528 -C "=> renegotiate" \
1529 -S "=> renegotiate" \
1530 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001531 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001532
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001533run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001534 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001535 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001536 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001537 0 \
1538 -c "client hello, adding renegotiation extension" \
1539 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1540 -s "found renegotiation extension" \
1541 -s "server hello, secure renegotiation extension" \
1542 -c "found renegotiation extension" \
1543 -c "=> renegotiate" \
1544 -s "=> renegotiate" \
1545 -s "write hello request" \
1546 -S "SSL - An unexpected message was received from our peer" \
1547 -S "failed"
1548
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001549run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001550 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001551 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1552 0 \
1553 -C "client hello, adding renegotiation extension" \
1554 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1555 -S "found renegotiation extension" \
1556 -s "server hello, secure renegotiation extension" \
1557 -c "found renegotiation extension" \
1558 -S "record counter limit reached: renegotiate" \
1559 -C "=> renegotiate" \
1560 -S "=> renegotiate" \
1561 -S "write hello request" \
1562 -S "SSL - An unexpected message was received from our peer" \
1563 -S "failed"
1564
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001565# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001566run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001567 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001568 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001569 0 \
1570 -c "client hello, adding renegotiation extension" \
1571 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1572 -s "found renegotiation extension" \
1573 -s "server hello, secure renegotiation extension" \
1574 -c "found renegotiation extension" \
1575 -s "record counter limit reached: renegotiate" \
1576 -c "=> renegotiate" \
1577 -s "=> renegotiate" \
1578 -s "write hello request" \
1579 -S "SSL - An unexpected message was received from our peer" \
1580 -S "failed"
1581
1582run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001583 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001584 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001585 0 \
1586 -c "client hello, adding renegotiation extension" \
1587 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1588 -s "found renegotiation extension" \
1589 -s "server hello, secure renegotiation extension" \
1590 -c "found renegotiation extension" \
1591 -s "record counter limit reached: renegotiate" \
1592 -c "=> renegotiate" \
1593 -s "=> renegotiate" \
1594 -s "write hello request" \
1595 -S "SSL - An unexpected message was received from our peer" \
1596 -S "failed"
1597
1598run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001599 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001600 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1601 0 \
1602 -C "client hello, adding renegotiation extension" \
1603 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1604 -S "found renegotiation extension" \
1605 -s "server hello, secure renegotiation extension" \
1606 -c "found renegotiation extension" \
1607 -S "record counter limit reached: renegotiate" \
1608 -C "=> renegotiate" \
1609 -S "=> renegotiate" \
1610 -S "write hello request" \
1611 -S "SSL - An unexpected message was received from our peer" \
1612 -S "failed"
1613
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001614run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001615 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001616 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001617 0 \
1618 -c "client hello, adding renegotiation extension" \
1619 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1620 -s "found renegotiation extension" \
1621 -s "server hello, secure renegotiation extension" \
1622 -c "found renegotiation extension" \
1623 -c "=> renegotiate" \
1624 -s "=> renegotiate" \
1625 -S "write hello request"
1626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001627run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001628 "$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 +02001629 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001630 0 \
1631 -c "client hello, adding renegotiation extension" \
1632 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1633 -s "found renegotiation extension" \
1634 -s "server hello, secure renegotiation extension" \
1635 -c "found renegotiation extension" \
1636 -c "=> renegotiate" \
1637 -s "=> renegotiate" \
1638 -s "write hello request"
1639
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001640run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001641 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001642 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001643 0 \
1644 -c "client hello, adding renegotiation extension" \
1645 -c "found renegotiation extension" \
1646 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001647 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001648 -C "error" \
1649 -c "HTTP/1.0 200 [Oo][Kk]"
1650
Paul Bakker539d9722015-02-08 16:18:35 +01001651requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001652run_test "Renegotiation: gnutls server strict, client-initiated" \
1653 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001654 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001655 0 \
1656 -c "client hello, adding renegotiation extension" \
1657 -c "found renegotiation extension" \
1658 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001659 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001660 -C "error" \
1661 -c "HTTP/1.0 200 [Oo][Kk]"
1662
Paul Bakker539d9722015-02-08 16:18:35 +01001663requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001664run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1665 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1666 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1667 1 \
1668 -c "client hello, adding renegotiation extension" \
1669 -C "found renegotiation extension" \
1670 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001671 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001672 -c "error" \
1673 -C "HTTP/1.0 200 [Oo][Kk]"
1674
Paul Bakker539d9722015-02-08 16:18:35 +01001675requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001676run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1677 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1678 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1679 allow_legacy=0" \
1680 1 \
1681 -c "client hello, adding renegotiation extension" \
1682 -C "found renegotiation extension" \
1683 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001684 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001685 -c "error" \
1686 -C "HTTP/1.0 200 [Oo][Kk]"
1687
Paul Bakker539d9722015-02-08 16:18:35 +01001688requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001689run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1690 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1691 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1692 allow_legacy=1" \
1693 0 \
1694 -c "client hello, adding renegotiation extension" \
1695 -C "found renegotiation extension" \
1696 -c "=> renegotiate" \
1697 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001698 -C "error" \
1699 -c "HTTP/1.0 200 [Oo][Kk]"
1700
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001701run_test "Renegotiation: DTLS, client-initiated" \
1702 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1703 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1704 0 \
1705 -c "client hello, adding renegotiation extension" \
1706 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1707 -s "found renegotiation extension" \
1708 -s "server hello, secure renegotiation extension" \
1709 -c "found renegotiation extension" \
1710 -c "=> renegotiate" \
1711 -s "=> renegotiate" \
1712 -S "write hello request"
1713
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001714run_test "Renegotiation: DTLS, server-initiated" \
1715 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001716 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1717 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001718 0 \
1719 -c "client hello, adding renegotiation extension" \
1720 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1721 -s "found renegotiation extension" \
1722 -s "server hello, secure renegotiation extension" \
1723 -c "found renegotiation extension" \
1724 -c "=> renegotiate" \
1725 -s "=> renegotiate" \
1726 -s "write hello request"
1727
Andres AG9b1927b2017-01-19 16:30:57 +00001728run_test "Renegotiation: DTLS, renego_period overflow" \
1729 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1730 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1731 0 \
1732 -c "client hello, adding renegotiation extension" \
1733 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1734 -s "found renegotiation extension" \
1735 -s "server hello, secure renegotiation extension" \
1736 -s "record counter limit reached: renegotiate" \
1737 -c "=> renegotiate" \
1738 -s "=> renegotiate" \
1739 -s "write hello request" \
1740
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001741requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001742run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1743 "$G_SRV -u --mtu 4096" \
1744 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1745 0 \
1746 -c "client hello, adding renegotiation extension" \
1747 -c "found renegotiation extension" \
1748 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001749 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001750 -C "error" \
1751 -s "Extra-header:"
1752
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001753# Test for the "secure renegotation" extension only (no actual renegotiation)
1754
Paul Bakker539d9722015-02-08 16:18:35 +01001755requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001756run_test "Renego ext: gnutls server strict, client default" \
1757 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1758 "$P_CLI debug_level=3" \
1759 0 \
1760 -c "found renegotiation extension" \
1761 -C "error" \
1762 -c "HTTP/1.0 200 [Oo][Kk]"
1763
Paul Bakker539d9722015-02-08 16:18:35 +01001764requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001765run_test "Renego ext: gnutls server unsafe, client default" \
1766 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1767 "$P_CLI debug_level=3" \
1768 0 \
1769 -C "found renegotiation extension" \
1770 -C "error" \
1771 -c "HTTP/1.0 200 [Oo][Kk]"
1772
Paul Bakker539d9722015-02-08 16:18:35 +01001773requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001774run_test "Renego ext: gnutls server unsafe, client break legacy" \
1775 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1776 "$P_CLI debug_level=3 allow_legacy=-1" \
1777 1 \
1778 -C "found renegotiation extension" \
1779 -c "error" \
1780 -C "HTTP/1.0 200 [Oo][Kk]"
1781
Paul Bakker539d9722015-02-08 16:18:35 +01001782requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001783run_test "Renego ext: gnutls client strict, server default" \
1784 "$P_SRV debug_level=3" \
1785 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1786 0 \
1787 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1788 -s "server hello, secure renegotiation extension"
1789
Paul Bakker539d9722015-02-08 16:18:35 +01001790requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001791run_test "Renego ext: gnutls client unsafe, server default" \
1792 "$P_SRV debug_level=3" \
1793 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1794 0 \
1795 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1796 -S "server hello, secure renegotiation extension"
1797
Paul Bakker539d9722015-02-08 16:18:35 +01001798requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001799run_test "Renego ext: gnutls client unsafe, server break legacy" \
1800 "$P_SRV debug_level=3 allow_legacy=-1" \
1801 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1802 1 \
1803 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1804 -S "server hello, secure renegotiation extension"
1805
Janos Follath365b2262016-02-17 10:11:21 +00001806# Tests for silently dropping trailing extra bytes in .der certificates
1807
1808requires_gnutls
1809run_test "DER format: no trailing bytes" \
1810 "$P_SRV crt_file=data_files/server5-der0.crt \
1811 key_file=data_files/server5.key" \
1812 "$G_CLI " \
1813 0 \
1814 -c "Handshake was completed" \
1815
1816requires_gnutls
1817run_test "DER format: with a trailing zero byte" \
1818 "$P_SRV crt_file=data_files/server5-der1a.crt \
1819 key_file=data_files/server5.key" \
1820 "$G_CLI " \
1821 0 \
1822 -c "Handshake was completed" \
1823
1824requires_gnutls
1825run_test "DER format: with a trailing random byte" \
1826 "$P_SRV crt_file=data_files/server5-der1b.crt \
1827 key_file=data_files/server5.key" \
1828 "$G_CLI " \
1829 0 \
1830 -c "Handshake was completed" \
1831
1832requires_gnutls
1833run_test "DER format: with 2 trailing random bytes" \
1834 "$P_SRV crt_file=data_files/server5-der2.crt \
1835 key_file=data_files/server5.key" \
1836 "$G_CLI " \
1837 0 \
1838 -c "Handshake was completed" \
1839
1840requires_gnutls
1841run_test "DER format: with 4 trailing random bytes" \
1842 "$P_SRV crt_file=data_files/server5-der4.crt \
1843 key_file=data_files/server5.key" \
1844 "$G_CLI " \
1845 0 \
1846 -c "Handshake was completed" \
1847
1848requires_gnutls
1849run_test "DER format: with 8 trailing random bytes" \
1850 "$P_SRV crt_file=data_files/server5-der8.crt \
1851 key_file=data_files/server5.key" \
1852 "$G_CLI " \
1853 0 \
1854 -c "Handshake was completed" \
1855
1856requires_gnutls
1857run_test "DER format: with 9 trailing random bytes" \
1858 "$P_SRV crt_file=data_files/server5-der9.crt \
1859 key_file=data_files/server5.key" \
1860 "$G_CLI " \
1861 0 \
1862 -c "Handshake was completed" \
1863
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001864# Tests for auth_mode
1865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001866run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001867 "$P_SRV crt_file=data_files/server5-badsign.crt \
1868 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001869 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001870 1 \
1871 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001872 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001873 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001874 -c "X509 - Certificate verification failed"
1875
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001876run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001877 "$P_SRV crt_file=data_files/server5-badsign.crt \
1878 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001879 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001880 0 \
1881 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001882 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001883 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001884 -C "X509 - Certificate verification failed"
1885
Hanno Becker61c0c702017-05-15 16:05:15 +01001886run_test "Authentication: server goodcert, client optional, no trusted CA" \
1887 "$P_SRV" \
1888 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1889 0 \
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 "X509 - Certificate verification failed" \
1895 -C "SSL - No CA Chain is set, but required to operate"
1896
1897run_test "Authentication: server goodcert, client required, no trusted CA" \
1898 "$P_SRV" \
1899 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1900 1 \
1901 -c "x509_verify_cert() returned" \
1902 -c "! The certificate is not correctly signed by the trusted CA" \
1903 -c "! Certificate verification flags"\
1904 -c "! mbedtls_ssl_handshake returned" \
1905 -c "SSL - No CA Chain is set, but required to operate"
1906
1907# The purpose of the next two tests is to test the client's behaviour when receiving a server
1908# certificate with an unsupported elliptic curve. This should usually not happen because
1909# the client informs the server about the supported curves - it does, though, in the
1910# corner case of a static ECDH suite, because the server doesn't check the curve on that
1911# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1912# different means to have the server ignoring the client's supported curve list.
1913
1914requires_config_enabled MBEDTLS_ECP_C
1915run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1916 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1917 crt_file=data_files/server5.ku-ka.crt" \
1918 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1919 1 \
1920 -c "bad certificate (EC key curve)"\
1921 -c "! Certificate verification flags"\
1922 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1923
1924requires_config_enabled MBEDTLS_ECP_C
1925run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1926 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1927 crt_file=data_files/server5.ku-ka.crt" \
1928 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1929 1 \
1930 -c "bad certificate (EC key curve)"\
1931 -c "! Certificate verification flags"\
1932 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001934run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001935 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001936 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001937 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001938 0 \
1939 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001940 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001941 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001942 -C "X509 - Certificate verification failed"
1943
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001944run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001945 "$P_SRV debug_level=3 auth_mode=required" \
1946 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001947 key_file=data_files/server5.key" \
1948 1 \
1949 -S "skip write certificate request" \
1950 -C "skip parse certificate request" \
1951 -c "got a certificate request" \
1952 -C "skip write certificate" \
1953 -C "skip write certificate verify" \
1954 -S "skip parse certificate verify" \
1955 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001956 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001957 -s "! mbedtls_ssl_handshake returned" \
1958 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001959 -s "X509 - Certificate verification failed"
1960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001961run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001962 "$P_SRV debug_level=3 auth_mode=optional" \
1963 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001964 key_file=data_files/server5.key" \
1965 0 \
1966 -S "skip write certificate request" \
1967 -C "skip parse certificate request" \
1968 -c "got a certificate request" \
1969 -C "skip write certificate" \
1970 -C "skip write certificate verify" \
1971 -S "skip parse certificate verify" \
1972 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001973 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001974 -S "! mbedtls_ssl_handshake returned" \
1975 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001976 -S "X509 - Certificate verification failed"
1977
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001978run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001979 "$P_SRV debug_level=3 auth_mode=none" \
1980 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001981 key_file=data_files/server5.key" \
1982 0 \
1983 -s "skip write certificate request" \
1984 -C "skip parse certificate request" \
1985 -c "got no certificate request" \
1986 -c "skip write certificate" \
1987 -c "skip write certificate verify" \
1988 -s "skip parse certificate verify" \
1989 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001990 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001991 -S "! mbedtls_ssl_handshake returned" \
1992 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001993 -S "X509 - Certificate verification failed"
1994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001995run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001996 "$P_SRV debug_level=3 auth_mode=optional" \
1997 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001998 0 \
1999 -S "skip write certificate request" \
2000 -C "skip parse certificate request" \
2001 -c "got a certificate request" \
2002 -C "skip write certificate$" \
2003 -C "got no certificate to send" \
2004 -S "SSLv3 client has no certificate" \
2005 -c "skip write certificate verify" \
2006 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002007 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002008 -S "! mbedtls_ssl_handshake returned" \
2009 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002010 -S "X509 - Certificate verification failed"
2011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002012run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002013 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002014 "$O_CLI" \
2015 0 \
2016 -S "skip write certificate request" \
2017 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002018 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002019 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002020 -S "X509 - Certificate verification failed"
2021
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002022run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002023 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002024 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002025 0 \
2026 -C "skip parse certificate request" \
2027 -c "got a certificate request" \
2028 -C "skip write certificate$" \
2029 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002030 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002031
Janos Follath542ee5d2016-03-07 15:57:05 +00002032requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002033run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002034 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002035 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002036 0 \
2037 -S "skip write certificate request" \
2038 -C "skip parse certificate request" \
2039 -c "got a certificate request" \
2040 -C "skip write certificate$" \
2041 -c "skip write certificate verify" \
2042 -c "got no certificate to send" \
2043 -s "SSLv3 client has no certificate" \
2044 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002045 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002046 -S "! mbedtls_ssl_handshake returned" \
2047 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002048 -S "X509 - Certificate verification failed"
2049
Manuel Pégourié-Gonnard591035d2017-06-26 10:45:33 +02002050run_test "Authentication: server max_int chain, client default" \
2051 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2052 key_file=data_files/dir-maxpath/09.key" \
2053 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2054 0 \
2055 -C "X509 - A fatal error occured"
2056
2057run_test "Authentication: server max_int+1 chain, client default" \
2058 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2059 key_file=data_files/dir-maxpath/10.key" \
2060 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2061 1 \
2062 -c "X509 - A fatal error occured"
2063
2064run_test "Authentication: server max_int+1 chain, client optional" \
2065 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2066 key_file=data_files/dir-maxpath/10.key" \
2067 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2068 auth_mode=optional" \
2069 1 \
2070 -c "X509 - A fatal error occured"
2071
2072run_test "Authentication: server max_int+1 chain, client none" \
2073 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2074 key_file=data_files/dir-maxpath/10.key" \
2075 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2076 auth_mode=none" \
2077 0 \
2078 -C "X509 - A fatal error occured"
2079
2080run_test "Authentication: client max_int+1 chain, server default" \
2081 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2082 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2083 key_file=data_files/dir-maxpath/10.key" \
2084 0 \
2085 -S "X509 - A fatal error occured"
2086
2087run_test "Authentication: client max_int+1 chain, server optional" \
2088 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2089 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2090 key_file=data_files/dir-maxpath/10.key" \
2091 1 \
2092 -s "X509 - A fatal error occured"
2093
2094run_test "Authentication: client max_int+1 chain, server required" \
2095 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2096 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2097 key_file=data_files/dir-maxpath/10.key" \
2098 1 \
2099 -s "X509 - A fatal error occured"
2100
2101run_test "Authentication: client max_int chain, server required" \
2102 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2103 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2104 key_file=data_files/dir-maxpath/09.key" \
2105 0 \
2106 -S "X509 - A fatal error occured"
2107
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002108# Tests for certificate selection based on SHA verson
2109
2110run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2111 "$P_SRV crt_file=data_files/server5.crt \
2112 key_file=data_files/server5.key \
2113 crt_file2=data_files/server5-sha1.crt \
2114 key_file2=data_files/server5.key" \
2115 "$P_CLI force_version=tls1_2" \
2116 0 \
2117 -c "signed using.*ECDSA with SHA256" \
2118 -C "signed using.*ECDSA with SHA1"
2119
2120run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2121 "$P_SRV crt_file=data_files/server5.crt \
2122 key_file=data_files/server5.key \
2123 crt_file2=data_files/server5-sha1.crt \
2124 key_file2=data_files/server5.key" \
2125 "$P_CLI force_version=tls1_1" \
2126 0 \
2127 -C "signed using.*ECDSA with SHA256" \
2128 -c "signed using.*ECDSA with SHA1"
2129
2130run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2131 "$P_SRV crt_file=data_files/server5.crt \
2132 key_file=data_files/server5.key \
2133 crt_file2=data_files/server5-sha1.crt \
2134 key_file2=data_files/server5.key" \
2135 "$P_CLI force_version=tls1" \
2136 0 \
2137 -C "signed using.*ECDSA with SHA256" \
2138 -c "signed using.*ECDSA with SHA1"
2139
2140run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2141 "$P_SRV crt_file=data_files/server5.crt \
2142 key_file=data_files/server5.key \
2143 crt_file2=data_files/server6.crt \
2144 key_file2=data_files/server6.key" \
2145 "$P_CLI force_version=tls1_1" \
2146 0 \
2147 -c "serial number.*09" \
2148 -c "signed using.*ECDSA with SHA256" \
2149 -C "signed using.*ECDSA with SHA1"
2150
2151run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2152 "$P_SRV crt_file=data_files/server6.crt \
2153 key_file=data_files/server6.key \
2154 crt_file2=data_files/server5.crt \
2155 key_file2=data_files/server5.key" \
2156 "$P_CLI force_version=tls1_1" \
2157 0 \
2158 -c "serial number.*0A" \
2159 -c "signed using.*ECDSA with SHA256" \
2160 -C "signed using.*ECDSA with SHA1"
2161
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002162# tests for SNI
2163
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002164run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002165 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002166 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002167 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002168 0 \
2169 -S "parse ServerName extension" \
2170 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2171 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002172
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002173run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002174 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002175 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002176 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 +02002177 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002178 0 \
2179 -s "parse ServerName extension" \
2180 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2181 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002182
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002183run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002184 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002185 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002186 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 +02002187 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002188 0 \
2189 -s "parse ServerName extension" \
2190 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2191 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002193run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002194 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002195 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002196 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 +02002197 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002198 1 \
2199 -s "parse ServerName extension" \
2200 -s "ssl_sni_wrapper() returned" \
2201 -s "mbedtls_ssl_handshake returned" \
2202 -c "mbedtls_ssl_handshake returned" \
2203 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002204
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002205run_test "SNI: client auth no override: optional" \
2206 "$P_SRV debug_level=3 auth_mode=optional \
2207 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2208 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2209 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002210 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002211 -S "skip write certificate request" \
2212 -C "skip parse certificate request" \
2213 -c "got a certificate request" \
2214 -C "skip write certificate" \
2215 -C "skip write certificate verify" \
2216 -S "skip parse certificate verify"
2217
2218run_test "SNI: client auth override: none -> optional" \
2219 "$P_SRV debug_level=3 auth_mode=none \
2220 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2221 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2222 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002223 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002224 -S "skip write certificate request" \
2225 -C "skip parse certificate request" \
2226 -c "got a certificate request" \
2227 -C "skip write certificate" \
2228 -C "skip write certificate verify" \
2229 -S "skip parse certificate verify"
2230
2231run_test "SNI: client auth override: optional -> none" \
2232 "$P_SRV debug_level=3 auth_mode=optional \
2233 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2234 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2235 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002236 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002237 -s "skip write certificate request" \
2238 -C "skip parse certificate request" \
2239 -c "got no certificate request" \
2240 -c "skip write certificate" \
2241 -c "skip write certificate verify" \
2242 -s "skip parse certificate verify"
2243
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002244run_test "SNI: CA no override" \
2245 "$P_SRV debug_level=3 auth_mode=optional \
2246 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2247 ca_file=data_files/test-ca.crt \
2248 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2249 "$P_CLI debug_level=3 server_name=localhost \
2250 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2251 1 \
2252 -S "skip write certificate request" \
2253 -C "skip parse certificate request" \
2254 -c "got a certificate request" \
2255 -C "skip write certificate" \
2256 -C "skip write certificate verify" \
2257 -S "skip parse certificate verify" \
2258 -s "x509_verify_cert() returned" \
2259 -s "! The certificate is not correctly signed by the trusted CA" \
2260 -S "The certificate has been revoked (is on a CRL)"
2261
2262run_test "SNI: CA override" \
2263 "$P_SRV debug_level=3 auth_mode=optional \
2264 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2265 ca_file=data_files/test-ca.crt \
2266 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2267 "$P_CLI debug_level=3 server_name=localhost \
2268 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2269 0 \
2270 -S "skip write certificate request" \
2271 -C "skip parse certificate request" \
2272 -c "got a certificate request" \
2273 -C "skip write certificate" \
2274 -C "skip write certificate verify" \
2275 -S "skip parse certificate verify" \
2276 -S "x509_verify_cert() returned" \
2277 -S "! The certificate is not correctly signed by the trusted CA" \
2278 -S "The certificate has been revoked (is on a CRL)"
2279
2280run_test "SNI: CA override with CRL" \
2281 "$P_SRV debug_level=3 auth_mode=optional \
2282 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2283 ca_file=data_files/test-ca.crt \
2284 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2285 "$P_CLI debug_level=3 server_name=localhost \
2286 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2287 1 \
2288 -S "skip write certificate request" \
2289 -C "skip parse certificate request" \
2290 -c "got a certificate request" \
2291 -C "skip write certificate" \
2292 -C "skip write certificate verify" \
2293 -S "skip parse certificate verify" \
2294 -s "x509_verify_cert() returned" \
2295 -S "! The certificate is not correctly signed by the trusted CA" \
2296 -s "The certificate has been revoked (is on a CRL)"
2297
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002298# Tests for non-blocking I/O: exercise a variety of handshake flows
2299
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002300run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002301 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2302 "$P_CLI nbio=2 tickets=0" \
2303 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002304 -S "mbedtls_ssl_handshake returned" \
2305 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002306 -c "Read from server: .* bytes read"
2307
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002308run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002309 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2310 "$P_CLI nbio=2 tickets=0" \
2311 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002312 -S "mbedtls_ssl_handshake returned" \
2313 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002314 -c "Read from server: .* bytes read"
2315
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002316run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002317 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2318 "$P_CLI nbio=2 tickets=1" \
2319 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002320 -S "mbedtls_ssl_handshake returned" \
2321 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002322 -c "Read from server: .* bytes read"
2323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002324run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002325 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2326 "$P_CLI nbio=2 tickets=1" \
2327 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002328 -S "mbedtls_ssl_handshake returned" \
2329 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002330 -c "Read from server: .* bytes read"
2331
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002332run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002333 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2334 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2335 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002336 -S "mbedtls_ssl_handshake returned" \
2337 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002338 -c "Read from server: .* bytes read"
2339
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002340run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002341 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2342 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2343 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002344 -S "mbedtls_ssl_handshake returned" \
2345 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002346 -c "Read from server: .* bytes read"
2347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002348run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002349 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2350 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2351 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002352 -S "mbedtls_ssl_handshake returned" \
2353 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002354 -c "Read from server: .* bytes read"
2355
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002356# Tests for version negotiation
2357
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002358run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002359 "$P_SRV" \
2360 "$P_CLI" \
2361 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002362 -S "mbedtls_ssl_handshake returned" \
2363 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002364 -s "Protocol is TLSv1.2" \
2365 -c "Protocol is TLSv1.2"
2366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002367run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002368 "$P_SRV" \
2369 "$P_CLI max_version=tls1_1" \
2370 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002371 -S "mbedtls_ssl_handshake returned" \
2372 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002373 -s "Protocol is TLSv1.1" \
2374 -c "Protocol is TLSv1.1"
2375
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002376run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002377 "$P_SRV max_version=tls1_1" \
2378 "$P_CLI" \
2379 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002380 -S "mbedtls_ssl_handshake returned" \
2381 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002382 -s "Protocol is TLSv1.1" \
2383 -c "Protocol is TLSv1.1"
2384
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002385run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002386 "$P_SRV max_version=tls1_1" \
2387 "$P_CLI max_version=tls1_1" \
2388 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002389 -S "mbedtls_ssl_handshake returned" \
2390 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002391 -s "Protocol is TLSv1.1" \
2392 -c "Protocol is TLSv1.1"
2393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002394run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002395 "$P_SRV min_version=tls1_1" \
2396 "$P_CLI max_version=tls1_1" \
2397 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002398 -S "mbedtls_ssl_handshake returned" \
2399 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002400 -s "Protocol is TLSv1.1" \
2401 -c "Protocol is TLSv1.1"
2402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002403run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002404 "$P_SRV max_version=tls1_1" \
2405 "$P_CLI min_version=tls1_1" \
2406 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002407 -S "mbedtls_ssl_handshake returned" \
2408 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002409 -s "Protocol is TLSv1.1" \
2410 -c "Protocol is TLSv1.1"
2411
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002412run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002413 "$P_SRV max_version=tls1_1" \
2414 "$P_CLI min_version=tls1_2" \
2415 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002416 -s "mbedtls_ssl_handshake returned" \
2417 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002418 -c "SSL - Handshake protocol not within min/max boundaries"
2419
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002420run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002421 "$P_SRV min_version=tls1_2" \
2422 "$P_CLI max_version=tls1_1" \
2423 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002424 -s "mbedtls_ssl_handshake returned" \
2425 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002426 -s "SSL - Handshake protocol not within min/max boundaries"
2427
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002428# Tests for ALPN extension
2429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002430run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002431 "$P_SRV debug_level=3" \
2432 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002433 0 \
2434 -C "client hello, adding alpn extension" \
2435 -S "found alpn extension" \
2436 -C "got an alert message, type: \\[2:120]" \
2437 -S "server hello, adding alpn extension" \
2438 -C "found alpn extension " \
2439 -C "Application Layer Protocol is" \
2440 -S "Application Layer Protocol is"
2441
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002442run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002443 "$P_SRV debug_level=3" \
2444 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002445 0 \
2446 -c "client hello, adding alpn extension" \
2447 -s "found alpn extension" \
2448 -C "got an alert message, type: \\[2:120]" \
2449 -S "server hello, adding alpn extension" \
2450 -C "found alpn extension " \
2451 -c "Application Layer Protocol is (none)" \
2452 -S "Application Layer Protocol is"
2453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002454run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002455 "$P_SRV debug_level=3 alpn=abc,1234" \
2456 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002457 0 \
2458 -C "client hello, adding alpn extension" \
2459 -S "found alpn extension" \
2460 -C "got an alert message, type: \\[2:120]" \
2461 -S "server hello, adding alpn extension" \
2462 -C "found alpn extension " \
2463 -C "Application Layer Protocol is" \
2464 -s "Application Layer Protocol is (none)"
2465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002466run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002467 "$P_SRV debug_level=3 alpn=abc,1234" \
2468 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002469 0 \
2470 -c "client hello, adding alpn extension" \
2471 -s "found alpn extension" \
2472 -C "got an alert message, type: \\[2:120]" \
2473 -s "server hello, adding alpn extension" \
2474 -c "found alpn extension" \
2475 -c "Application Layer Protocol is abc" \
2476 -s "Application Layer Protocol is abc"
2477
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002478run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002479 "$P_SRV debug_level=3 alpn=abc,1234" \
2480 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002481 0 \
2482 -c "client hello, adding alpn extension" \
2483 -s "found alpn extension" \
2484 -C "got an alert message, type: \\[2:120]" \
2485 -s "server hello, adding alpn extension" \
2486 -c "found alpn extension" \
2487 -c "Application Layer Protocol is abc" \
2488 -s "Application Layer Protocol is abc"
2489
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002490run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002491 "$P_SRV debug_level=3 alpn=abc,1234" \
2492 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002493 0 \
2494 -c "client hello, adding alpn extension" \
2495 -s "found alpn extension" \
2496 -C "got an alert message, type: \\[2:120]" \
2497 -s "server hello, adding alpn extension" \
2498 -c "found alpn extension" \
2499 -c "Application Layer Protocol is 1234" \
2500 -s "Application Layer Protocol is 1234"
2501
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002502run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002503 "$P_SRV debug_level=3 alpn=abc,123" \
2504 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002505 1 \
2506 -c "client hello, adding alpn extension" \
2507 -s "found alpn extension" \
2508 -c "got an alert message, type: \\[2:120]" \
2509 -S "server hello, adding alpn extension" \
2510 -C "found alpn extension" \
2511 -C "Application Layer Protocol is 1234" \
2512 -S "Application Layer Protocol is 1234"
2513
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002514
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002515# Tests for keyUsage in leaf certificates, part 1:
2516# server-side certificate/suite selection
2517
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002518run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002519 "$P_SRV key_file=data_files/server2.key \
2520 crt_file=data_files/server2.ku-ds.crt" \
2521 "$P_CLI" \
2522 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002523 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002524
2525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002526run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002527 "$P_SRV key_file=data_files/server2.key \
2528 crt_file=data_files/server2.ku-ke.crt" \
2529 "$P_CLI" \
2530 0 \
2531 -c "Ciphersuite is TLS-RSA-WITH-"
2532
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002533run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002534 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002535 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002536 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002537 1 \
2538 -C "Ciphersuite is "
2539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002540run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002541 "$P_SRV key_file=data_files/server5.key \
2542 crt_file=data_files/server5.ku-ds.crt" \
2543 "$P_CLI" \
2544 0 \
2545 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2546
2547
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002548run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002549 "$P_SRV key_file=data_files/server5.key \
2550 crt_file=data_files/server5.ku-ka.crt" \
2551 "$P_CLI" \
2552 0 \
2553 -c "Ciphersuite is TLS-ECDH-"
2554
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002555run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002556 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002557 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002558 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002559 1 \
2560 -C "Ciphersuite is "
2561
2562# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002563# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002565run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002566 "$O_SRV -key data_files/server2.key \
2567 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002568 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002569 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2570 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002571 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002572 -C "Processing of the Certificate handshake message failed" \
2573 -c "Ciphersuite is TLS-"
2574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002575run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002576 "$O_SRV -key data_files/server2.key \
2577 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002578 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002579 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2580 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002581 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002582 -C "Processing of the Certificate handshake message failed" \
2583 -c "Ciphersuite is TLS-"
2584
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002585run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002586 "$O_SRV -key data_files/server2.key \
2587 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002588 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002589 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2590 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002591 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002592 -C "Processing of the Certificate handshake message failed" \
2593 -c "Ciphersuite is TLS-"
2594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002595run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002596 "$O_SRV -key data_files/server2.key \
2597 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002598 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002599 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2600 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002601 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002602 -c "Processing of the Certificate handshake message failed" \
2603 -C "Ciphersuite is TLS-"
2604
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002605run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2606 "$O_SRV -key data_files/server2.key \
2607 -cert data_files/server2.ku-ke.crt" \
2608 "$P_CLI debug_level=1 auth_mode=optional \
2609 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2610 0 \
2611 -c "bad certificate (usage extensions)" \
2612 -C "Processing of the Certificate handshake message failed" \
2613 -c "Ciphersuite is TLS-" \
2614 -c "! Usage does not match the keyUsage extension"
2615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002616run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002617 "$O_SRV -key data_files/server2.key \
2618 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002619 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002620 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2621 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002622 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002623 -C "Processing of the Certificate handshake message failed" \
2624 -c "Ciphersuite is TLS-"
2625
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002626run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002627 "$O_SRV -key data_files/server2.key \
2628 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002629 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002630 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2631 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002632 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002633 -c "Processing of the Certificate handshake message failed" \
2634 -C "Ciphersuite is TLS-"
2635
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002636run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2637 "$O_SRV -key data_files/server2.key \
2638 -cert data_files/server2.ku-ds.crt" \
2639 "$P_CLI debug_level=1 auth_mode=optional \
2640 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2641 0 \
2642 -c "bad certificate (usage extensions)" \
2643 -C "Processing of the Certificate handshake message failed" \
2644 -c "Ciphersuite is TLS-" \
2645 -c "! Usage does not match the keyUsage extension"
2646
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002647# Tests for keyUsage in leaf certificates, part 3:
2648# server-side checking of client cert
2649
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002650run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002651 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002652 "$O_CLI -key data_files/server2.key \
2653 -cert data_files/server2.ku-ds.crt" \
2654 0 \
2655 -S "bad certificate (usage extensions)" \
2656 -S "Processing of the Certificate handshake message failed"
2657
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002658run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002659 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002660 "$O_CLI -key data_files/server2.key \
2661 -cert data_files/server2.ku-ke.crt" \
2662 0 \
2663 -s "bad certificate (usage extensions)" \
2664 -S "Processing of the Certificate handshake message failed"
2665
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002666run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002667 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002668 "$O_CLI -key data_files/server2.key \
2669 -cert data_files/server2.ku-ke.crt" \
2670 1 \
2671 -s "bad certificate (usage extensions)" \
2672 -s "Processing of the Certificate handshake message failed"
2673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002674run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002675 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002676 "$O_CLI -key data_files/server5.key \
2677 -cert data_files/server5.ku-ds.crt" \
2678 0 \
2679 -S "bad certificate (usage extensions)" \
2680 -S "Processing of the Certificate handshake message failed"
2681
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002682run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002683 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002684 "$O_CLI -key data_files/server5.key \
2685 -cert data_files/server5.ku-ka.crt" \
2686 0 \
2687 -s "bad certificate (usage extensions)" \
2688 -S "Processing of the Certificate handshake message failed"
2689
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002690# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2691
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002692run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002693 "$P_SRV key_file=data_files/server5.key \
2694 crt_file=data_files/server5.eku-srv.crt" \
2695 "$P_CLI" \
2696 0
2697
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002698run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002699 "$P_SRV key_file=data_files/server5.key \
2700 crt_file=data_files/server5.eku-srv.crt" \
2701 "$P_CLI" \
2702 0
2703
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002704run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002705 "$P_SRV key_file=data_files/server5.key \
2706 crt_file=data_files/server5.eku-cs_any.crt" \
2707 "$P_CLI" \
2708 0
2709
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002710run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002711 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002712 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002713 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002714 1
2715
2716# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002718run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002719 "$O_SRV -key data_files/server5.key \
2720 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002721 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002722 0 \
2723 -C "bad certificate (usage extensions)" \
2724 -C "Processing of the Certificate handshake message failed" \
2725 -c "Ciphersuite is TLS-"
2726
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002727run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002728 "$O_SRV -key data_files/server5.key \
2729 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002730 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002731 0 \
2732 -C "bad certificate (usage extensions)" \
2733 -C "Processing of the Certificate handshake message failed" \
2734 -c "Ciphersuite is TLS-"
2735
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002736run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002737 "$O_SRV -key data_files/server5.key \
2738 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002739 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002740 0 \
2741 -C "bad certificate (usage extensions)" \
2742 -C "Processing of the Certificate handshake message failed" \
2743 -c "Ciphersuite is TLS-"
2744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002745run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002746 "$O_SRV -key data_files/server5.key \
2747 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002748 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002749 1 \
2750 -c "bad certificate (usage extensions)" \
2751 -c "Processing of the Certificate handshake message failed" \
2752 -C "Ciphersuite is TLS-"
2753
2754# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2755
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002756run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002757 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002758 "$O_CLI -key data_files/server5.key \
2759 -cert data_files/server5.eku-cli.crt" \
2760 0 \
2761 -S "bad certificate (usage extensions)" \
2762 -S "Processing of the Certificate handshake message failed"
2763
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002764run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002765 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002766 "$O_CLI -key data_files/server5.key \
2767 -cert data_files/server5.eku-srv_cli.crt" \
2768 0 \
2769 -S "bad certificate (usage extensions)" \
2770 -S "Processing of the Certificate handshake message failed"
2771
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002772run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002773 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002774 "$O_CLI -key data_files/server5.key \
2775 -cert data_files/server5.eku-cs_any.crt" \
2776 0 \
2777 -S "bad certificate (usage extensions)" \
2778 -S "Processing of the Certificate handshake message failed"
2779
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002780run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002781 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002782 "$O_CLI -key data_files/server5.key \
2783 -cert data_files/server5.eku-cs.crt" \
2784 0 \
2785 -s "bad certificate (usage extensions)" \
2786 -S "Processing of the Certificate handshake message failed"
2787
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002788run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002789 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002790 "$O_CLI -key data_files/server5.key \
2791 -cert data_files/server5.eku-cs.crt" \
2792 1 \
2793 -s "bad certificate (usage extensions)" \
2794 -s "Processing of the Certificate handshake message failed"
2795
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002796# Tests for DHM parameters loading
2797
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002798run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002799 "$P_SRV" \
2800 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2801 debug_level=3" \
2802 0 \
2803 -c "value of 'DHM: P ' (2048 bits)" \
2804 -c "value of 'DHM: G ' (2048 bits)"
2805
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002806run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002807 "$P_SRV dhm_file=data_files/dhparams.pem" \
2808 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2809 debug_level=3" \
2810 0 \
2811 -c "value of 'DHM: P ' (1024 bits)" \
2812 -c "value of 'DHM: G ' (2 bits)"
2813
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002814# Tests for DHM client-side size checking
2815
2816run_test "DHM size: server default, client default, OK" \
2817 "$P_SRV" \
2818 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2819 debug_level=1" \
2820 0 \
2821 -C "DHM prime too short:"
2822
2823run_test "DHM size: server default, client 2048, OK" \
2824 "$P_SRV" \
2825 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2826 debug_level=1 dhmlen=2048" \
2827 0 \
2828 -C "DHM prime too short:"
2829
2830run_test "DHM size: server 1024, client default, OK" \
2831 "$P_SRV dhm_file=data_files/dhparams.pem" \
2832 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2833 debug_level=1" \
2834 0 \
2835 -C "DHM prime too short:"
2836
2837run_test "DHM size: server 1000, client default, rejected" \
2838 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2839 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2840 debug_level=1" \
2841 1 \
2842 -c "DHM prime too short:"
2843
2844run_test "DHM size: server default, client 2049, rejected" \
2845 "$P_SRV" \
2846 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2847 debug_level=1 dhmlen=2049" \
2848 1 \
2849 -c "DHM prime too short:"
2850
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002851# Tests for PSK callback
2852
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002853run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002854 "$P_SRV psk=abc123 psk_identity=foo" \
2855 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2856 psk_identity=foo psk=abc123" \
2857 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002858 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002859 -S "SSL - Unknown identity received" \
2860 -S "SSL - Verification of the message MAC failed"
2861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002862run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002863 "$P_SRV" \
2864 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2865 psk_identity=foo psk=abc123" \
2866 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002867 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002868 -S "SSL - Unknown identity received" \
2869 -S "SSL - Verification of the message MAC failed"
2870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002871run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002872 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2873 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2874 psk_identity=foo psk=abc123" \
2875 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002876 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002877 -s "SSL - Unknown identity received" \
2878 -S "SSL - Verification of the message MAC failed"
2879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002880run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002881 "$P_SRV psk_list=abc,dead,def,beef" \
2882 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2883 psk_identity=abc psk=dead" \
2884 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002885 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002886 -S "SSL - Unknown identity received" \
2887 -S "SSL - Verification of the message MAC failed"
2888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002889run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002890 "$P_SRV psk_list=abc,dead,def,beef" \
2891 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2892 psk_identity=def psk=beef" \
2893 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002894 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002895 -S "SSL - Unknown identity received" \
2896 -S "SSL - Verification of the message MAC failed"
2897
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002898run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002899 "$P_SRV psk_list=abc,dead,def,beef" \
2900 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2901 psk_identity=ghi psk=beef" \
2902 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002903 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002904 -s "SSL - Unknown identity received" \
2905 -S "SSL - Verification of the message MAC failed"
2906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002907run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002908 "$P_SRV psk_list=abc,dead,def,beef" \
2909 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2910 psk_identity=abc psk=beef" \
2911 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002912 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002913 -S "SSL - Unknown identity received" \
2914 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002915
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002916# Tests for ciphersuites per version
2917
Janos Follath542ee5d2016-03-07 15:57:05 +00002918requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002919run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002920 "$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 +02002921 "$P_CLI force_version=ssl3" \
2922 0 \
2923 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002925run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002926 "$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 +01002927 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002928 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002929 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002930
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002931run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002932 "$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 +02002933 "$P_CLI force_version=tls1_1" \
2934 0 \
2935 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2936
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002937run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002938 "$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 +02002939 "$P_CLI force_version=tls1_2" \
2940 0 \
2941 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2942
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002943# Test for ClientHello without extensions
2944
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002945requires_gnutls
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002946run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002947 "$P_SRV debug_level=3" \
2948 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2949 0 \
2950 -s "dumping 'client hello extensions' (0 bytes)"
2951
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002952requires_gnutls
2953run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
2954 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
2955 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2956 0 \
2957 -s "dumping 'client hello extensions' (0 bytes)"
2958
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002959# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002960
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002961run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002962 "$P_SRV" \
2963 "$P_CLI request_size=100" \
2964 0 \
2965 -s "Read from client: 100 bytes read$"
2966
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002967run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002968 "$P_SRV" \
2969 "$P_CLI request_size=500" \
2970 0 \
2971 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002972
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002973# Tests for small packets
2974
Janos Follath542ee5d2016-03-07 15:57:05 +00002975requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002976run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002977 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002978 "$P_CLI request_size=1 force_version=ssl3 \
2979 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2980 0 \
2981 -s "Read from client: 1 bytes read"
2982
Janos Follath542ee5d2016-03-07 15:57:05 +00002983requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002984run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002985 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002986 "$P_CLI request_size=1 force_version=ssl3 \
2987 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2988 0 \
2989 -s "Read from client: 1 bytes read"
2990
2991run_test "Small packet TLS 1.0 BlockCipher" \
2992 "$P_SRV" \
2993 "$P_CLI request_size=1 force_version=tls1 \
2994 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2995 0 \
2996 -s "Read from client: 1 bytes read"
2997
Hanno Becker7aae46c2017-11-10 08:59:04 +00002998run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002999 "$P_SRV" \
3000 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3001 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3002 0 \
3003 -s "Read from client: 1 bytes read"
3004
Hanno Beckera83fafa2017-11-10 08:42:54 +00003005requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003006run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003007 "$P_SRV" \
3008 "$P_CLI request_size=1 force_version=tls1 \
3009 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3010 trunc_hmac=1" \
3011 0 \
3012 -s "Read from client: 1 bytes read"
3013
Hanno Beckera83fafa2017-11-10 08:42:54 +00003014requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003015run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
3016 "$P_SRV" \
3017 "$P_CLI request_size=1 force_version=tls1 \
3018 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3019 trunc_hmac=1 \
3020 etm=0" \
3021 0 \
3022 -s "Read from client: 1 bytes read"
3023
3024run_test "Small packet TLS 1.0 StreamCipher" \
3025 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3026 "$P_CLI request_size=1 force_version=tls1 \
3027 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3028 0 \
3029 -s "Read from client: 1 bytes read"
3030
3031run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3032 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3033 "$P_CLI request_size=1 force_version=tls1 \
3034 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3035 etm=0" \
3036 0 \
3037 -s "Read from client: 1 bytes read"
3038
3039requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3040run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003041 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003042 "$P_CLI request_size=1 force_version=tls1 \
3043 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3044 trunc_hmac=1" \
3045 0 \
3046 -s "Read from client: 1 bytes read"
3047
Hanno Becker7aae46c2017-11-10 08:59:04 +00003048requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3049run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
3050 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3051 "$P_CLI request_size=1 force_version=tls1 \
3052 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3053 trunc_hmac=1 \
3054 etm=0" \
3055 0 \
3056 -s "Read from client: 1 bytes read"
3057
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003058run_test "Small packet TLS 1.1 BlockCipher" \
3059 "$P_SRV" \
3060 "$P_CLI request_size=1 force_version=tls1_1 \
3061 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3062 0 \
3063 -s "Read from client: 1 bytes read"
3064
Hanno Becker7aae46c2017-11-10 08:59:04 +00003065run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003066 "$P_SRV" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003067 "$P_CLI request_size=1 force_version=tls1_1 \
3068 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA
3069 etm=0" \
3070 0 \
3071 -s "Read from client: 1 bytes read"
3072
3073requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3074run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
3075 "$P_SRV" \
3076 "$P_CLI request_size=1 force_version=tls1_1 \
3077 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3078 trunc_hmac=1" \
3079 0 \
3080 -s "Read from client: 1 bytes read"
3081
3082requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3083run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
3084 "$P_SRV" \
3085 "$P_CLI request_size=1 force_version=tls1_1 \
3086 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3087 trunc_hmac=1 \
3088 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003089 0 \
3090 -s "Read from client: 1 bytes read"
3091
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003092run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003093 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003094 "$P_CLI request_size=1 force_version=tls1_1 \
3095 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3096 0 \
3097 -s "Read from client: 1 bytes read"
3098
Hanno Becker7aae46c2017-11-10 08:59:04 +00003099run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3100 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003101 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003102 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3103 etm=0" \
3104 0 \
3105 -s "Read from client: 1 bytes read"
3106
3107requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3108run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
3109 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3110 "$P_CLI request_size=1 force_version=tls1_1 \
3111 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003112 trunc_hmac=1" \
3113 0 \
3114 -s "Read from client: 1 bytes read"
3115
Hanno Beckera83fafa2017-11-10 08:42:54 +00003116requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003117run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003118 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003119 "$P_CLI request_size=1 force_version=tls1_1 \
3120 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003121 trunc_hmac=1 \
3122 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003123 0 \
3124 -s "Read from client: 1 bytes read"
3125
3126run_test "Small packet TLS 1.2 BlockCipher" \
3127 "$P_SRV" \
3128 "$P_CLI request_size=1 force_version=tls1_2 \
3129 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3130 0 \
3131 -s "Read from client: 1 bytes read"
3132
Hanno Becker7aae46c2017-11-10 08:59:04 +00003133run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003134 "$P_SRV" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003135 "$P_CLI request_size=1 force_version=tls1_2 \
3136 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3137 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003138 0 \
3139 -s "Read from client: 1 bytes read"
3140
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003141run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3142 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003143 "$P_CLI request_size=1 force_version=tls1_2 \
3144 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003145 0 \
3146 -s "Read from client: 1 bytes read"
3147
Hanno Beckera83fafa2017-11-10 08:42:54 +00003148requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003149run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003150 "$P_SRV" \
3151 "$P_CLI request_size=1 force_version=tls1_2 \
3152 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3153 trunc_hmac=1" \
3154 0 \
3155 -s "Read from client: 1 bytes read"
3156
Hanno Becker7aae46c2017-11-10 08:59:04 +00003157requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3158run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
3159 "$P_SRV" \
3160 "$P_CLI request_size=1 force_version=tls1_2 \
3161 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3162 trunc_hmac=1 \
3163 etm=0" \
3164 0 \
3165 -s "Read from client: 1 bytes read"
3166
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003167run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003168 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003169 "$P_CLI request_size=1 force_version=tls1_2 \
3170 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3171 0 \
3172 -s "Read from client: 1 bytes read"
3173
Hanno Becker7aae46c2017-11-10 08:59:04 +00003174run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
3175 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3176 "$P_CLI request_size=1 force_version=tls1_2 \
3177 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3178 etm=0" \
3179 0 \
3180 -s "Read from client: 1 bytes read"
3181
Hanno Beckera83fafa2017-11-10 08:42:54 +00003182requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003183run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003184 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003185 "$P_CLI request_size=1 force_version=tls1_2 \
3186 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3187 trunc_hmac=1" \
3188 0 \
3189 -s "Read from client: 1 bytes read"
3190
Hanno Becker7aae46c2017-11-10 08:59:04 +00003191requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3192run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
3193 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3194 "$P_CLI request_size=1 force_version=tls1_2 \
3195 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3196 trunc_hmac=1 \
3197 etm=0" \
3198 0 \
3199 -s "Read from client: 1 bytes read"
3200
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003201run_test "Small packet TLS 1.2 AEAD" \
3202 "$P_SRV" \
3203 "$P_CLI request_size=1 force_version=tls1_2 \
3204 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3205 0 \
3206 -s "Read from client: 1 bytes read"
3207
3208run_test "Small packet TLS 1.2 AEAD shorter tag" \
3209 "$P_SRV" \
3210 "$P_CLI request_size=1 force_version=tls1_2 \
3211 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3212 0 \
3213 -s "Read from client: 1 bytes read"
3214
Hanno Becker461cb812017-11-10 08:59:18 +00003215# Tests for small packets in DTLS
3216
3217requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3218run_test "Small packet DTLS 1.0" \
3219 "$P_SRV dtls=1 force_version=dtls1" \
3220 "$P_CLI dtls=1 request_size=1 \
3221 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3222 0 \
3223 -s "Read from client: 1 bytes read"
3224
3225requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3226run_test "Small packet DTLS 1.0, without EtM" \
3227 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3228 "$P_CLI dtls=1 request_size=1 \
3229 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3230 0 \
3231 -s "Read from client: 1 bytes read"
3232
3233requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3234requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3235run_test "Small packet DTLS 1.0, truncated hmac" \
3236 "$P_SRV dtls=1 force_version=dtls1" \
3237 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
3238 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3239 0 \
3240 -s "Read from client: 1 bytes read"
3241
3242requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3243requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3244run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
3245 "$P_SRV dtls=1 force_version=dtls1 \
3246 etm=0" \
3247 "$P_CLI dtls=1 request_size=1 \
3248 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3249 trunc_hmac=1"\
3250 0 \
3251 -s "Read from client: 1 bytes read"
3252
3253requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3254run_test "Small packet DTLS 1.2" \
3255 "$P_SRV dtls=1 force_version=dtls1_2" \
3256 "$P_CLI dtls=1 request_size=1 \
3257 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3258 0 \
3259 -s "Read from client: 1 bytes read"
3260
3261requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3262run_test "Small packet DTLS 1.2, without EtM" \
3263 "$P_SRV dtls=1 force_version=dtls1_2 \
3264 etm=0" \
3265 "$P_CLI dtls=1 request_size=1 \
3266 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3267 0 \
3268 -s "Read from client: 1 bytes read"
3269
3270requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3271requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3272run_test "Small packet DTLS 1.2, truncated hmac" \
3273 "$P_SRV dtls=1 force_version=dtls1_2" \
3274 "$P_CLI dtls=1 request_size=1 \
3275 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3276 trunc_hmac=1" \
3277 0 \
3278 -s "Read from client: 1 bytes read"
3279
3280requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3281requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3282run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
3283 "$P_SRV dtls=1 force_version=dtls1_2 \
3284 etm=0" \
3285 "$P_CLI dtls=1 request_size=1 \
3286 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3287 trunc_hmac=1"\
3288 0 \
3289 -s "Read from client: 1 bytes read"
3290
Janos Follathb700c462016-05-06 13:48:23 +01003291# A test for extensions in SSLv3
3292
3293requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3294run_test "SSLv3 with extensions, server side" \
3295 "$P_SRV min_version=ssl3 debug_level=3" \
3296 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3297 0 \
3298 -S "dumping 'client hello extensions'" \
3299 -S "server hello, total extension length:"
3300
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003301# Test for large packets
3302
Janos Follath542ee5d2016-03-07 15:57:05 +00003303requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003304run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003305 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003306 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003307 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3308 0 \
3309 -s "Read from client: 16384 bytes read"
3310
Janos Follath542ee5d2016-03-07 15:57:05 +00003311requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003312run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003313 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003314 "$P_CLI request_size=16384 force_version=ssl3 \
3315 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3316 0 \
3317 -s "Read from client: 16384 bytes read"
3318
3319run_test "Large packet TLS 1.0 BlockCipher" \
3320 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003321 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003322 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3323 0 \
3324 -s "Read from client: 16384 bytes read"
3325
Hanno Becker0b9d9132017-11-10 09:16:28 +00003326run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
3327 "$P_SRV" \
3328 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3329 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3330 0 \
3331 -s "Read from client: 16384 bytes read"
3332
Hanno Beckera83fafa2017-11-10 08:42:54 +00003333requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003334run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003335 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003336 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003337 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3338 trunc_hmac=1" \
3339 0 \
3340 -s "Read from client: 16384 bytes read"
3341
Hanno Beckera83fafa2017-11-10 08:42:54 +00003342requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003343run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
3344 "$P_SRV" \
3345 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3346 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3347 trunc_hmac=1" \
3348 0 \
3349 -s "Read from client: 16384 bytes read"
3350
3351run_test "Large packet TLS 1.0 StreamCipher" \
3352 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3353 "$P_CLI request_size=16384 force_version=tls1 \
3354 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3355 0 \
3356 -s "Read from client: 16384 bytes read"
3357
3358run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
3359 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3360 "$P_CLI request_size=16384 force_version=tls1 \
3361 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3362 etm=0" \
3363 0 \
3364 -s "Read from client: 16384 bytes read"
3365
3366requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3367run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003368 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003369 "$P_CLI request_size=16384 force_version=tls1 \
3370 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3371 trunc_hmac=1" \
3372 0 \
3373 -s "Read from client: 16384 bytes read"
3374
Hanno Becker0b9d9132017-11-10 09:16:28 +00003375requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3376run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
3377 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3378 "$P_CLI request_size=16384 force_version=tls1 \
3379 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3380 trunc_hmac=1 etm=0" \
3381 0 \
3382 -s "Read from client: 16384 bytes read"
3383
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003384run_test "Large packet TLS 1.1 BlockCipher" \
3385 "$P_SRV" \
3386 "$P_CLI request_size=16384 force_version=tls1_1 \
3387 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3388 0 \
3389 -s "Read from client: 16384 bytes read"
3390
Hanno Becker0b9d9132017-11-10 09:16:28 +00003391run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
3392 "$P_SRV" \
3393 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
3394 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003395 0 \
3396 -s "Read from client: 16384 bytes read"
3397
Hanno Beckera83fafa2017-11-10 08:42:54 +00003398requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003399run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003400 "$P_SRV" \
3401 "$P_CLI request_size=16384 force_version=tls1_1 \
3402 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3403 trunc_hmac=1" \
3404 0 \
3405 -s "Read from client: 16384 bytes read"
3406
Hanno Beckera83fafa2017-11-10 08:42:54 +00003407requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003408run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
3409 "$P_SRV" \
3410 "$P_CLI request_size=16384 force_version=tls1_1 \
3411 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3412 trunc_hmac=1 etm=0" \
3413 0 \
3414 -s "Read from client: 16384 bytes read"
3415
3416run_test "Large packet TLS 1.1 StreamCipher" \
3417 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3418 "$P_CLI request_size=16384 force_version=tls1_1 \
3419 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3420 0 \
3421 -s "Read from client: 16384 bytes read"
3422
3423run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
3424 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3425 "$P_CLI request_size=16384 force_version=tls1_1 \
3426 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3427 etm=0" \
3428 0 \
3429 -s "Read from client: 16384 bytes read"
3430
3431requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3432run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003433 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003434 "$P_CLI request_size=16384 force_version=tls1_1 \
3435 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3436 trunc_hmac=1" \
3437 0 \
3438 -s "Read from client: 16384 bytes read"
3439
Hanno Becker0b9d9132017-11-10 09:16:28 +00003440requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3441run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
3442 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3443 "$P_CLI request_size=16384 force_version=tls1_1 \
3444 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3445 trunc_hmac=1 etm=0" \
3446 0 \
3447 -s "Read from client: 16384 bytes read"
3448
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003449run_test "Large packet TLS 1.2 BlockCipher" \
3450 "$P_SRV" \
3451 "$P_CLI request_size=16384 force_version=tls1_2 \
3452 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3453 0 \
3454 -s "Read from client: 16384 bytes read"
3455
Hanno Becker0b9d9132017-11-10 09:16:28 +00003456run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
3457 "$P_SRV" \
3458 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
3459 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3460 0 \
3461 -s "Read from client: 16384 bytes read"
3462
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003463run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3464 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003465 "$P_CLI request_size=16384 force_version=tls1_2 \
3466 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003467 0 \
3468 -s "Read from client: 16384 bytes read"
3469
Hanno Beckera83fafa2017-11-10 08:42:54 +00003470requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003471run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003472 "$P_SRV" \
3473 "$P_CLI request_size=16384 force_version=tls1_2 \
3474 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3475 trunc_hmac=1" \
3476 0 \
3477 -s "Read from client: 16384 bytes read"
3478
Hanno Becker0b9d9132017-11-10 09:16:28 +00003479requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3480run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
3481 "$P_SRV" \
3482 "$P_CLI request_size=16384 force_version=tls1_2 \
3483 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3484 trunc_hmac=1 etm=0" \
3485 0 \
3486 -s "Read from client: 16384 bytes read"
3487
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003488run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003489 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003490 "$P_CLI request_size=16384 force_version=tls1_2 \
3491 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3492 0 \
3493 -s "Read from client: 16384 bytes read"
3494
Hanno Becker0b9d9132017-11-10 09:16:28 +00003495run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
3496 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3497 "$P_CLI request_size=16384 force_version=tls1_2 \
3498 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
3499 0 \
3500 -s "Read from client: 16384 bytes read"
3501
Hanno Beckera83fafa2017-11-10 08:42:54 +00003502requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003503run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003504 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003505 "$P_CLI request_size=16384 force_version=tls1_2 \
3506 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3507 trunc_hmac=1" \
3508 0 \
3509 -s "Read from client: 16384 bytes read"
3510
Hanno Becker0b9d9132017-11-10 09:16:28 +00003511requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3512run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
3513 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3514 "$P_CLI request_size=16384 force_version=tls1_2 \
3515 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3516 trunc_hmac=1 etm=0" \
3517 0 \
3518 -s "Read from client: 16384 bytes read"
3519
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003520run_test "Large packet TLS 1.2 AEAD" \
3521 "$P_SRV" \
3522 "$P_CLI request_size=16384 force_version=tls1_2 \
3523 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3524 0 \
3525 -s "Read from client: 16384 bytes read"
3526
3527run_test "Large packet TLS 1.2 AEAD shorter tag" \
3528 "$P_SRV" \
3529 "$P_CLI request_size=16384 force_version=tls1_2 \
3530 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3531 0 \
3532 -s "Read from client: 16384 bytes read"
3533
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003534# Tests for DTLS HelloVerifyRequest
3535
3536run_test "DTLS cookie: enabled" \
3537 "$P_SRV dtls=1 debug_level=2" \
3538 "$P_CLI dtls=1 debug_level=2" \
3539 0 \
3540 -s "cookie verification failed" \
3541 -s "cookie verification passed" \
3542 -S "cookie verification skipped" \
3543 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003544 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003545 -S "SSL - The requested feature is not available"
3546
3547run_test "DTLS cookie: disabled" \
3548 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3549 "$P_CLI dtls=1 debug_level=2" \
3550 0 \
3551 -S "cookie verification failed" \
3552 -S "cookie verification passed" \
3553 -s "cookie verification skipped" \
3554 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003555 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003556 -S "SSL - The requested feature is not available"
3557
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003558run_test "DTLS cookie: default (failing)" \
3559 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3560 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3561 1 \
3562 -s "cookie verification failed" \
3563 -S "cookie verification passed" \
3564 -S "cookie verification skipped" \
3565 -C "received hello verify request" \
3566 -S "hello verification requested" \
3567 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003568
3569requires_ipv6
3570run_test "DTLS cookie: enabled, IPv6" \
3571 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3572 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
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é-Gonnard579950c2014-09-29 17:47:33 +02003581run_test "DTLS cookie: enabled, nbio" \
3582 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3583 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3584 0 \
3585 -s "cookie verification failed" \
3586 -s "cookie verification passed" \
3587 -S "cookie verification skipped" \
3588 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003589 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003590 -S "SSL - The requested feature is not available"
3591
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003592# Tests for client reconnecting from the same port with DTLS
3593
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003594not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003595run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003596 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3597 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003598 0 \
3599 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003600 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003601 -S "Client initiated reconnection from same port"
3602
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003603not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003604run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003605 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3606 "$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 +02003607 0 \
3608 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003609 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003610 -s "Client initiated reconnection from same port"
3611
Paul Bakker3b224ff2016-05-13 10:33:25 +01003612not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3613run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003614 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3615 "$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 +02003616 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003617 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003618 -s "Client initiated reconnection from same port"
3619
Paul Bakker3b224ff2016-05-13 10:33:25 +01003620only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3621run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3622 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3623 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3624 0 \
3625 -S "The operation timed out" \
3626 -s "Client initiated reconnection from same port"
3627
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003628run_test "DTLS client reconnect from same port: no cookies" \
3629 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003630 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3631 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003632 -s "The operation timed out" \
3633 -S "Client initiated reconnection from same port"
3634
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003635# Tests for various cases of client authentication with DTLS
3636# (focused on handshake flows and message parsing)
3637
3638run_test "DTLS client auth: required" \
3639 "$P_SRV dtls=1 auth_mode=required" \
3640 "$P_CLI dtls=1" \
3641 0 \
3642 -s "Verifying peer X.509 certificate... ok"
3643
3644run_test "DTLS client auth: optional, client has no cert" \
3645 "$P_SRV dtls=1 auth_mode=optional" \
3646 "$P_CLI dtls=1 crt_file=none key_file=none" \
3647 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003648 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003649
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003650run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003651 "$P_SRV dtls=1 auth_mode=none" \
3652 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3653 0 \
3654 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003655 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003656
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003657run_test "DTLS wrong PSK: badmac alert" \
3658 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3659 "$P_CLI dtls=1 psk=abc124" \
3660 1 \
3661 -s "SSL - Verification of the message MAC failed" \
3662 -c "SSL - A fatal alert message was received from our peer"
3663
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003664# Tests for receiving fragmented handshake messages with DTLS
3665
3666requires_gnutls
3667run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3668 "$G_SRV -u --mtu 2048 -a" \
3669 "$P_CLI dtls=1 debug_level=2" \
3670 0 \
3671 -C "found fragmented DTLS handshake message" \
3672 -C "error"
3673
3674requires_gnutls
3675run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3676 "$G_SRV -u --mtu 512" \
3677 "$P_CLI dtls=1 debug_level=2" \
3678 0 \
3679 -c "found fragmented DTLS handshake message" \
3680 -C "error"
3681
3682requires_gnutls
3683run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3684 "$G_SRV -u --mtu 128" \
3685 "$P_CLI dtls=1 debug_level=2" \
3686 0 \
3687 -c "found fragmented DTLS handshake message" \
3688 -C "error"
3689
3690requires_gnutls
3691run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3692 "$G_SRV -u --mtu 128" \
3693 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3694 0 \
3695 -c "found fragmented DTLS handshake message" \
3696 -C "error"
3697
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003698requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003699run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3700 "$G_SRV -u --mtu 256" \
3701 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3702 0 \
3703 -c "found fragmented DTLS handshake message" \
3704 -c "client hello, adding renegotiation extension" \
3705 -c "found renegotiation extension" \
3706 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003707 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003708 -C "error" \
3709 -s "Extra-header:"
3710
3711requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003712run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3713 "$G_SRV -u --mtu 256" \
3714 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3715 0 \
3716 -c "found fragmented DTLS handshake message" \
3717 -c "client hello, adding renegotiation extension" \
3718 -c "found renegotiation extension" \
3719 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003720 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003721 -C "error" \
3722 -s "Extra-header:"
3723
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003724run_test "DTLS reassembly: no fragmentation (openssl server)" \
3725 "$O_SRV -dtls1 -mtu 2048" \
3726 "$P_CLI dtls=1 debug_level=2" \
3727 0 \
3728 -C "found fragmented DTLS handshake message" \
3729 -C "error"
3730
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003731run_test "DTLS reassembly: some fragmentation (openssl server)" \
3732 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003733 "$P_CLI dtls=1 debug_level=2" \
3734 0 \
3735 -c "found fragmented DTLS handshake message" \
3736 -C "error"
3737
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003738run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003739 "$O_SRV -dtls1 -mtu 256" \
3740 "$P_CLI dtls=1 debug_level=2" \
3741 0 \
3742 -c "found fragmented DTLS handshake message" \
3743 -C "error"
3744
3745run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3746 "$O_SRV -dtls1 -mtu 256" \
3747 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3748 0 \
3749 -c "found fragmented DTLS handshake message" \
3750 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003751
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003752# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003753
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003754not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003755run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003756 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003757 "$P_SRV dtls=1 debug_level=2" \
3758 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003759 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003760 -C "replayed record" \
3761 -S "replayed record" \
3762 -C "record from another epoch" \
3763 -S "record from another epoch" \
3764 -C "discarding invalid record" \
3765 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003766 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003767 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003768 -c "HTTP/1.0 200 OK"
3769
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003770not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003771run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003772 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003773 "$P_SRV dtls=1 debug_level=2" \
3774 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003775 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003776 -c "replayed record" \
3777 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003778 -c "discarding invalid record" \
3779 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003780 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003781 -s "Extra-header:" \
3782 -c "HTTP/1.0 200 OK"
3783
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003784run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3785 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003786 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3787 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003788 0 \
3789 -c "replayed record" \
3790 -S "replayed record" \
3791 -c "discarding invalid record" \
3792 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003793 -c "resend" \
3794 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003795 -s "Extra-header:" \
3796 -c "HTTP/1.0 200 OK"
3797
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003798run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003799 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003800 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003801 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003802 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003803 -c "discarding invalid record (mac)" \
3804 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003805 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003806 -c "HTTP/1.0 200 OK" \
3807 -S "too many records with bad MAC" \
3808 -S "Verification of the message MAC failed"
3809
3810run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3811 -p "$P_PXY bad_ad=1" \
3812 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3813 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3814 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003815 -C "discarding invalid record (mac)" \
3816 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003817 -S "Extra-header:" \
3818 -C "HTTP/1.0 200 OK" \
3819 -s "too many records with bad MAC" \
3820 -s "Verification of the message MAC failed"
3821
3822run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3823 -p "$P_PXY bad_ad=1" \
3824 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3825 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3826 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003827 -c "discarding invalid record (mac)" \
3828 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003829 -s "Extra-header:" \
3830 -c "HTTP/1.0 200 OK" \
3831 -S "too many records with bad MAC" \
3832 -S "Verification of the message MAC failed"
3833
3834run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3835 -p "$P_PXY bad_ad=1" \
3836 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3837 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3838 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003839 -c "discarding invalid record (mac)" \
3840 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003841 -s "Extra-header:" \
3842 -c "HTTP/1.0 200 OK" \
3843 -s "too many records with bad MAC" \
3844 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003845
3846run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003847 -p "$P_PXY delay_ccs=1" \
3848 "$P_SRV dtls=1 debug_level=1" \
3849 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003850 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003851 -c "record from another epoch" \
3852 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003853 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003854 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003855 -s "Extra-header:" \
3856 -c "HTTP/1.0 200 OK"
3857
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003858# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003859
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003860needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003861run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003862 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003863 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3864 psk=abc123" \
3865 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003866 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3867 0 \
3868 -s "Extra-header:" \
3869 -c "HTTP/1.0 200 OK"
3870
3871needs_more_time 2
3872run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3873 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003874 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3875 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003876 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3877 0 \
3878 -s "Extra-header:" \
3879 -c "HTTP/1.0 200 OK"
3880
3881needs_more_time 2
3882run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3883 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003884 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3885 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003886 0 \
3887 -s "Extra-header:" \
3888 -c "HTTP/1.0 200 OK"
3889
3890needs_more_time 2
3891run_test "DTLS proxy: 3d, FS, client auth" \
3892 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003893 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3894 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003895 0 \
3896 -s "Extra-header:" \
3897 -c "HTTP/1.0 200 OK"
3898
3899needs_more_time 2
3900run_test "DTLS proxy: 3d, FS, ticket" \
3901 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003902 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3903 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003904 0 \
3905 -s "Extra-header:" \
3906 -c "HTTP/1.0 200 OK"
3907
3908needs_more_time 2
3909run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
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=1 auth_mode=required" \
3912 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003913 0 \
3914 -s "Extra-header:" \
3915 -c "HTTP/1.0 200 OK"
3916
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003917needs_more_time 2
3918run_test "DTLS proxy: 3d, max handshake, nbio" \
3919 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003920 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3921 auth_mode=required" \
3922 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003923 0 \
3924 -s "Extra-header:" \
3925 -c "HTTP/1.0 200 OK"
3926
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003927needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003928run_test "DTLS proxy: 3d, min handshake, resumption" \
3929 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3930 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3931 psk=abc123 debug_level=3" \
3932 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3933 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3934 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3935 0 \
3936 -s "a session has been resumed" \
3937 -c "a session has been resumed" \
3938 -s "Extra-header:" \
3939 -c "HTTP/1.0 200 OK"
3940
3941needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003942run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3943 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3944 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3945 psk=abc123 debug_level=3 nbio=2" \
3946 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3947 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3948 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3949 0 \
3950 -s "a session has been resumed" \
3951 -c "a session has been resumed" \
3952 -s "Extra-header:" \
3953 -c "HTTP/1.0 200 OK"
3954
3955needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003956run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003957 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003958 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3959 psk=abc123 renegotiation=1 debug_level=2" \
3960 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3961 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003962 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3963 0 \
3964 -c "=> renegotiate" \
3965 -s "=> renegotiate" \
3966 -s "Extra-header:" \
3967 -c "HTTP/1.0 200 OK"
3968
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003969needs_more_time 4
3970run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3971 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003972 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3973 psk=abc123 renegotiation=1 debug_level=2" \
3974 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3975 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003976 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3977 0 \
3978 -c "=> renegotiate" \
3979 -s "=> renegotiate" \
3980 -s "Extra-header:" \
3981 -c "HTTP/1.0 200 OK"
3982
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003983needs_more_time 4
3984run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003985 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003986 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003987 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003988 debug_level=2" \
3989 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003990 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003991 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3992 0 \
3993 -c "=> renegotiate" \
3994 -s "=> renegotiate" \
3995 -s "Extra-header:" \
3996 -c "HTTP/1.0 200 OK"
3997
3998needs_more_time 4
3999run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004000 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004001 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004002 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004003 debug_level=2 nbio=2" \
4004 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004005 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004006 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4007 0 \
4008 -c "=> renegotiate" \
4009 -s "=> renegotiate" \
4010 -s "Extra-header:" \
4011 -c "HTTP/1.0 200 OK"
4012
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02004013needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004014not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004015run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004016 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4017 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004018 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004019 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004020 -c "HTTP/1.0 200 OK"
4021
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004022needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004023not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004024run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4025 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4026 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004027 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004028 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004029 -c "HTTP/1.0 200 OK"
4030
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004031needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004032not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004033run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4034 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4035 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004036 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004037 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004038 -c "HTTP/1.0 200 OK"
4039
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004040requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02004041needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004042not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004043run_test "DTLS proxy: 3d, gnutls server" \
4044 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4045 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004046 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004047 0 \
4048 -s "Extra-header:" \
4049 -c "Extra-header:"
4050
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004051requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004052needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004053not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004054run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4055 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4056 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004057 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004058 0 \
4059 -s "Extra-header:" \
4060 -c "Extra-header:"
4061
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004062requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004063needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004064not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004065run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4066 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4067 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004068 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004069 0 \
4070 -s "Extra-header:" \
4071 -c "Extra-header:"
4072
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004073# Final report
4074
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004075echo "------------------------------------------------------------------------"
4076
4077if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004078 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004079else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004080 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004081fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004082PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004083echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004084
4085exit $FAILS