blob: 821df212c89bd95104534cad202f10f852e5c13b [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020031: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010032
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020033O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010034O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020035G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010036G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020037TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010038
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010039TESTS=0
40FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020041SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010042
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000043CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020044
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020047EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010048
Paul Bakkere20310a2016-05-10 11:18:17 +010049SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010050RUN_TEST_NUMBER=''
51
Paul Bakkeracaac852016-05-10 11:47:13 +010052PRESERVE_LOGS=0
53
Gilles Peskinef93c7d32017-04-14 17:55:28 +020054# Pick a "unique" server port in the range 10000-19999, and a proxy
55# port which is this plus 10000. Each port number may be independently
56# overridden by a command line option.
57SRV_PORT=$(($$ % 10000 + 10000))
58PXY_PORT=$((SRV_PORT + 10000))
59
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010060print_usage() {
61 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010062 printf " -h|--help\tPrint this help.\n"
63 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020064 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
65 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010066 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010067 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010068 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020069 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
70 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010071 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072}
73
74get_options() {
75 while [ $# -gt 0 ]; do
76 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010077 -f|--filter)
78 shift; FILTER=$1
79 ;;
80 -e|--exclude)
81 shift; EXCLUDE=$1
82 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010083 -m|--memcheck)
84 MEMCHECK=1
85 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010086 -n|--number)
87 shift; RUN_TEST_NUMBER=$1
88 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010089 -s|--show-numbers)
90 SHOW_TEST_NUMBER=1
91 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010092 -p|--preserve-logs)
93 PRESERVE_LOGS=1
94 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020095 --port)
96 shift; SRV_PORT=$1
97 ;;
98 --proxy-port)
99 shift; PXY_PORT=$1
100 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100101 --seed)
102 shift; SEED="$1"
103 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100104 -h|--help)
105 print_usage
106 exit 0
107 ;;
108 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200109 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100110 print_usage
111 exit 1
112 ;;
113 esac
114 shift
115 done
116}
117
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100118# skip next test if the flag is not enabled in config.h
119requires_config_enabled() {
120 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
121 SKIP_NEXT="YES"
122 fi
123}
124
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200125# skip next test if the flag is enabled in config.h
126requires_config_disabled() {
127 if grep "^#define $1" $CONFIG_H > /dev/null; then
128 SKIP_NEXT="YES"
129 fi
130}
131
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200132# skip next test if OpenSSL doesn't support FALLBACK_SCSV
133requires_openssl_with_fallback_scsv() {
134 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
135 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
136 then
137 OPENSSL_HAS_FBSCSV="YES"
138 else
139 OPENSSL_HAS_FBSCSV="NO"
140 fi
141 fi
142 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
143 SKIP_NEXT="YES"
144 fi
145}
146
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200147# skip next test if GnuTLS isn't available
148requires_gnutls() {
149 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200150 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200151 GNUTLS_AVAILABLE="YES"
152 else
153 GNUTLS_AVAILABLE="NO"
154 fi
155 fi
156 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200161# skip next test if IPv6 isn't available on this host
162requires_ipv6() {
163 if [ -z "${HAS_IPV6:-}" ]; then
164 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
165 SRV_PID=$!
166 sleep 1
167 kill $SRV_PID >/dev/null 2>&1
168 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
169 HAS_IPV6="NO"
170 else
171 HAS_IPV6="YES"
172 fi
173 rm -r $SRV_OUT
174 fi
175
176 if [ "$HAS_IPV6" = "NO" ]; then
177 SKIP_NEXT="YES"
178 fi
179}
180
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200181# skip the next test if valgrind is in use
182not_with_valgrind() {
183 if [ "$MEMCHECK" -gt 0 ]; then
184 SKIP_NEXT="YES"
185 fi
186}
187
Paul Bakker362689d2016-05-13 10:33:25 +0100188# skip the next test if valgrind is NOT in use
189only_with_valgrind() {
190 if [ "$MEMCHECK" -eq 0 ]; then
191 SKIP_NEXT="YES"
192 fi
193}
194
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200195# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100196client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200197 CLI_DELAY_FACTOR=$1
198}
199
Janos Follath74537a62016-09-02 13:45:28 +0100200# wait for the given seconds after the client finished in the next test
201server_needs_more_time() {
202 SRV_DELAY_SECONDS=$1
203}
204
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100205# print_name <name>
206print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100207 TESTS=$(( $TESTS + 1 ))
208 LINE=""
209
210 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
211 LINE="$TESTS "
212 fi
213
214 LINE="$LINE$1"
215 printf "$LINE "
216 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100217 for i in `seq 1 $LEN`; do printf '.'; done
218 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100219
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100220}
221
222# fail <message>
223fail() {
224 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100225 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100226
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200227 mv $SRV_OUT o-srv-${TESTS}.log
228 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200229 if [ -n "$PXY_CMD" ]; then
230 mv $PXY_OUT o-pxy-${TESTS}.log
231 fi
232 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100233
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200234 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
235 echo " ! server output:"
236 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200237 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200238 echo " ! client output:"
239 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200240 if [ -n "$PXY_CMD" ]; then
241 echo " ! ========================================================"
242 echo " ! proxy output:"
243 cat o-pxy-${TESTS}.log
244 fi
245 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200246 fi
247
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200248 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100249}
250
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100251# is_polar <cmd_line>
252is_polar() {
253 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
254}
255
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200256# openssl s_server doesn't have -www with DTLS
257check_osrv_dtls() {
258 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
259 NEEDS_INPUT=1
260 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
261 else
262 NEEDS_INPUT=0
263 fi
264}
265
266# provide input to commands that need it
267provide_input() {
268 if [ $NEEDS_INPUT -eq 0 ]; then
269 return
270 fi
271
272 while true; do
273 echo "HTTP/1.0 200 OK"
274 sleep 1
275 done
276}
277
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100278# has_mem_err <log_file_name>
279has_mem_err() {
280 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
281 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
282 then
283 return 1 # false: does not have errors
284 else
285 return 0 # true: has errors
286 fi
287}
288
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200289# wait for server to start: two versions depending on lsof availability
290wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200291 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200292 START_TIME=$( date +%s )
293 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200294
295 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200296 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200297 while [ $DONE -eq 0 ]; do
298 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
299 then
300 DONE=1
301 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
302 echo "SERVERSTART TIMEOUT"
303 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
304 DONE=1
305 fi
306 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200307 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200308 while [ $DONE -eq 0 ]; do
309 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
310 then
311 DONE=1
312 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
313 echo "SERVERSTART TIMEOUT"
314 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
315 DONE=1
316 fi
317 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200318 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200319 else
320 sleep "$START_DELAY"
321 fi
322}
323
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200324# wait for client to terminate and set CLI_EXIT
325# must be called right after starting the client
326wait_client_done() {
327 CLI_PID=$!
328
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200329 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
330 CLI_DELAY_FACTOR=1
331
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200332 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200333 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200334
335 wait $CLI_PID
336 CLI_EXIT=$?
337
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200338 kill $DOG_PID >/dev/null 2>&1
339 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200340
341 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100342
343 sleep $SRV_DELAY_SECONDS
344 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200345}
346
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200347# check if the given command uses dtls and sets global variable DTLS
348detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200349 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200350 DTLS=1
351 else
352 DTLS=0
353 fi
354}
355
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200356# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100357# Options: -s pattern pattern that must be present in server output
358# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100359# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100360# -S pattern pattern that must be absent in server output
361# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100362# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100363run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100364 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200365 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100366
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100367 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
368 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200369 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100370 return
371 fi
372
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100373 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100374
Paul Bakkerb7584a52016-05-10 10:50:43 +0100375 # Do we only run numbered tests?
376 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
377 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
378 else
379 SKIP_NEXT="YES"
380 fi
381
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200382 # should we skip?
383 if [ "X$SKIP_NEXT" = "XYES" ]; then
384 SKIP_NEXT="NO"
385 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200386 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200387 return
388 fi
389
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200390 # does this test use a proxy?
391 if [ "X$1" = "X-p" ]; then
392 PXY_CMD="$2"
393 shift 2
394 else
395 PXY_CMD=""
396 fi
397
398 # get commands and client output
399 SRV_CMD="$1"
400 CLI_CMD="$2"
401 CLI_EXPECT="$3"
402 shift 3
403
404 # fix client port
405 if [ -n "$PXY_CMD" ]; then
406 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
407 else
408 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
409 fi
410
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200411 # update DTLS variable
412 detect_dtls "$SRV_CMD"
413
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100414 # prepend valgrind to our commands if active
415 if [ "$MEMCHECK" -gt 0 ]; then
416 if is_polar "$SRV_CMD"; then
417 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
418 fi
419 if is_polar "$CLI_CMD"; then
420 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
421 fi
422 fi
423
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200424 TIMES_LEFT=2
425 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200426 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200427
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200428 # run the commands
429 if [ -n "$PXY_CMD" ]; then
430 echo "$PXY_CMD" > $PXY_OUT
431 $PXY_CMD >> $PXY_OUT 2>&1 &
432 PXY_PID=$!
433 # assume proxy starts faster than server
434 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200435
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200436 check_osrv_dtls
437 echo "$SRV_CMD" > $SRV_OUT
438 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
439 SRV_PID=$!
440 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200441
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200442 echo "$CLI_CMD" > $CLI_OUT
443 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
444 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100445
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100446 sleep 0.05
447
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200448 # terminate the server (and the proxy)
449 kill $SRV_PID
450 wait $SRV_PID
451 if [ -n "$PXY_CMD" ]; then
452 kill $PXY_PID >/dev/null 2>&1
453 wait $PXY_PID
454 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100455
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200456 # retry only on timeouts
457 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
458 printf "RETRY "
459 else
460 TIMES_LEFT=0
461 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200462 done
463
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100464 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200465 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100466 # expected client exit to incorrectly succeed in case of catastrophic
467 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100468 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200469 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100470 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100471 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100472 return
473 fi
474 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100475 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200476 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100477 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100478 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100479 return
480 fi
481 fi
482
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100483 # check server exit code
484 if [ $? != 0 ]; then
485 fail "server fail"
486 return
487 fi
488
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100489 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100490 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
491 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100492 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200493 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100494 return
495 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100496
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100497 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200498 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100499 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100500 while [ $# -gt 0 ]
501 do
502 case $1 in
503 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100504 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100505 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100506 return
507 fi
508 ;;
509
510 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100511 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100512 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100513 return
514 fi
515 ;;
516
517 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100518 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100519 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100520 return
521 fi
522 ;;
523
524 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100525 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100526 fail "pattern '$2' MUST NOT be present in the Client output"
527 return
528 fi
529 ;;
530
531 # The filtering in the following two options (-u and -U) do the following
532 # - ignore valgrind output
533 # - filter out everything but lines right after the pattern occurances
534 # - keep one of each non-unique line
535 # - count how many lines remain
536 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
537 # if there were no duplicates.
538 "-U")
539 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
540 fail "lines following pattern '$2' must be unique in Server output"
541 return
542 fi
543 ;;
544
545 "-u")
546 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
547 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100548 return
549 fi
550 ;;
551
552 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200553 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100554 exit 1
555 esac
556 shift 2
557 done
558
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100559 # check valgrind's results
560 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200561 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100562 fail "Server has memory errors"
563 return
564 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200565 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100566 fail "Client has memory errors"
567 return
568 fi
569 fi
570
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100571 # if we're here, everything is ok
572 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100573 if [ "$PRESERVE_LOGS" -gt 0 ]; then
574 mv $SRV_OUT o-srv-${TESTS}.log
575 mv $CLI_OUT o-cli-${TESTS}.log
576 fi
577
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200578 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100579}
580
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100581cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200582 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200583 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
584 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
585 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
586 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100587 exit 1
588}
589
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100590#
591# MAIN
592#
593
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000594if cd $( dirname $0 ); then :; else
595 echo "cd $( dirname $0 ) failed" >&2
596 exit 1
597fi
598
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100599get_options "$@"
600
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100601# sanity checks, avoid an avalanche of errors
Hanno Becker17c04932017-10-10 14:44:53 +0100602P_SRV_BIN=$(echo "$P_SRV" | sed -r -n "s/^([^ ]*).*$/\1/p")
603echo "Server binary: ${P_SRV_BIN}"
604P_CLI_BIN=$(echo "$P_CLI" | sed -r -n "s/^([^ ]*).*$/\1/p")
605echo "Client binary: ${P_CLI_BIN}"
606P_PXY_BIN=$(echo "$P_PXY" | sed -r -n "s/^([^ ]*).*$/\1/p")
607echo "Proxy binary: ${P_PXY_BIN}"
608if [ ! -x "$P_SRV_BIN" ]; then
609 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100610 exit 1
611fi
Hanno Becker17c04932017-10-10 14:44:53 +0100612if [ ! -x "$P_CLI_BIN" ]; then
613 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100614 exit 1
615fi
Hanno Becker17c04932017-10-10 14:44:53 +0100616if [ ! -x "$P_PXY_BIN" ]; then
617 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200618 exit 1
619fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100620if [ "$MEMCHECK" -gt 0 ]; then
621 if which valgrind >/dev/null 2>&1; then :; else
622 echo "Memcheck not possible. Valgrind not found"
623 exit 1
624 fi
625fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100626if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
627 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100628 exit 1
629fi
630
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200631# used by watchdog
632MAIN_PID="$$"
633
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200634# be more patient with valgrind
635if [ "$MEMCHECK" -gt 0 ]; then
636 START_DELAY=3
637 DOG_DELAY=30
638else
639 START_DELAY=1
640 DOG_DELAY=10
641fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200642CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100643SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200644
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200645# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000646# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200647P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
648P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100649P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200650O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200651O_CLI="$O_CLI -connect localhost:+SRV_PORT"
652G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000653G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200654
Gilles Peskine62469d92017-05-10 10:13:59 +0200655# Allow SHA-1, because many of our test certificates use it
656P_SRV="$P_SRV allow_sha1=1"
657P_CLI="$P_CLI allow_sha1=1"
658
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200659# Also pick a unique name for intermediate files
660SRV_OUT="srv_out.$$"
661CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200662PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200663SESSION="session.$$"
664
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200665SKIP_NEXT="NO"
666
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100667trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100668
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200669# Basic test
670
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200671# Checks that:
672# - things work with all ciphersuites active (used with config-full in all.sh)
673# - the expected (highest security) parameters are selected
674# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200675run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200676 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200677 "$P_CLI" \
678 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200679 -s "Protocol is TLSv1.2" \
680 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
681 -s "client hello v3, signature_algorithm ext: 6" \
682 -s "ECDHE curve: secp521r1" \
683 -S "error" \
684 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200685
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000686run_test "Default, DTLS" \
687 "$P_SRV dtls=1" \
688 "$P_CLI dtls=1" \
689 0 \
690 -s "Protocol is DTLSv1.2" \
691 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
692
Simon Butcher8e004102016-10-14 00:48:33 +0100693# Test for uniqueness of IVs in AEAD ciphersuites
694run_test "Unique IV in GCM" \
695 "$P_SRV exchanges=20 debug_level=4" \
696 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
697 0 \
698 -u "IV used" \
699 -U "IV used"
700
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100701# Tests for rc4 option
702
Simon Butchera410af52016-05-19 22:12:18 +0100703requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100704run_test "RC4: server disabled, client enabled" \
705 "$P_SRV" \
706 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
707 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100708 -s "SSL - The server has no ciphersuites in common"
709
Simon Butchera410af52016-05-19 22:12:18 +0100710requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100711run_test "RC4: server half, client enabled" \
712 "$P_SRV arc4=1" \
713 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
714 1 \
715 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100716
717run_test "RC4: server enabled, client disabled" \
718 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
719 "$P_CLI" \
720 1 \
721 -s "SSL - The server has no ciphersuites in common"
722
723run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100724 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100725 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
726 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100727 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100728 -S "SSL - The server has no ciphersuites in common"
729
Gilles Peskinebc70a182017-05-09 15:59:24 +0200730# Tests for SHA-1 support
731
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200732requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200733run_test "SHA-1 forbidden by default in server certificate" \
734 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
735 "$P_CLI debug_level=2 allow_sha1=0" \
736 1 \
737 -c "The certificate is signed with an unacceptable hash"
738
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200739requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
740run_test "SHA-1 forbidden by default in server certificate" \
741 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
742 "$P_CLI debug_level=2 allow_sha1=0" \
743 0
744
Gilles Peskinebc70a182017-05-09 15:59:24 +0200745run_test "SHA-1 explicitly allowed in server certificate" \
746 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
747 "$P_CLI allow_sha1=1" \
748 0
749
750run_test "SHA-256 allowed by default in server certificate" \
751 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
752 "$P_CLI allow_sha1=0" \
753 0
754
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200755requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200756run_test "SHA-1 forbidden by default in client certificate" \
757 "$P_SRV auth_mode=required allow_sha1=0" \
758 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
759 1 \
760 -s "The certificate is signed with an unacceptable hash"
761
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200762requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
763run_test "SHA-1 forbidden by default in client certificate" \
764 "$P_SRV auth_mode=required allow_sha1=0" \
765 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
766 0
767
Gilles Peskinebc70a182017-05-09 15:59:24 +0200768run_test "SHA-1 explicitly allowed in client certificate" \
769 "$P_SRV auth_mode=required allow_sha1=1" \
770 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
771 0
772
773run_test "SHA-256 allowed by default in client certificate" \
774 "$P_SRV auth_mode=required allow_sha1=0" \
775 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
776 0
777
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100778# Tests for Truncated HMAC extension
779
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100780run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200781 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100782 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100783 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100784 -s "dumping 'computed mac' (20 bytes)" \
785 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100786
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100787run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200788 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100789 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
790 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100791 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100792 -s "dumping 'computed mac' (20 bytes)" \
793 -S "dumping 'computed mac' (10 bytes)"
794
795run_test "Truncated HMAC: client enabled, server default" \
796 "$P_SRV debug_level=4" \
797 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
798 trunc_hmac=1" \
799 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100800 -s "dumping 'computed mac' (20 bytes)" \
801 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100802
803run_test "Truncated HMAC: client enabled, server disabled" \
804 "$P_SRV debug_level=4 trunc_hmac=0" \
805 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
806 trunc_hmac=1" \
807 0 \
808 -s "dumping 'computed mac' (20 bytes)" \
809 -S "dumping 'computed mac' (10 bytes)"
810
811run_test "Truncated HMAC: client enabled, server enabled" \
812 "$P_SRV debug_level=4 trunc_hmac=1" \
813 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
814 trunc_hmac=1" \
815 0 \
816 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100817 -s "dumping 'computed mac' (10 bytes)"
818
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100819# Tests for Encrypt-then-MAC extension
820
821run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100822 "$P_SRV debug_level=3 \
823 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100824 "$P_CLI debug_level=3" \
825 0 \
826 -c "client hello, adding encrypt_then_mac extension" \
827 -s "found encrypt then mac extension" \
828 -s "server hello, adding encrypt then mac extension" \
829 -c "found encrypt_then_mac extension" \
830 -c "using encrypt then mac" \
831 -s "using encrypt then mac"
832
833run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100834 "$P_SRV debug_level=3 etm=0 \
835 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100836 "$P_CLI debug_level=3 etm=1" \
837 0 \
838 -c "client hello, adding encrypt_then_mac extension" \
839 -s "found encrypt then mac extension" \
840 -S "server hello, adding encrypt then mac extension" \
841 -C "found encrypt_then_mac extension" \
842 -C "using encrypt then mac" \
843 -S "using encrypt then mac"
844
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100845run_test "Encrypt then MAC: client enabled, aead cipher" \
846 "$P_SRV debug_level=3 etm=1 \
847 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
848 "$P_CLI debug_level=3 etm=1" \
849 0 \
850 -c "client hello, adding encrypt_then_mac extension" \
851 -s "found encrypt then mac extension" \
852 -S "server hello, adding encrypt then mac extension" \
853 -C "found encrypt_then_mac extension" \
854 -C "using encrypt then mac" \
855 -S "using encrypt then mac"
856
857run_test "Encrypt then MAC: client enabled, stream cipher" \
858 "$P_SRV debug_level=3 etm=1 \
859 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100860 "$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 +0100861 0 \
862 -c "client hello, adding encrypt_then_mac extension" \
863 -s "found encrypt then mac extension" \
864 -S "server hello, adding encrypt then mac extension" \
865 -C "found encrypt_then_mac extension" \
866 -C "using encrypt then mac" \
867 -S "using encrypt then mac"
868
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100869run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100870 "$P_SRV debug_level=3 etm=1 \
871 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100872 "$P_CLI debug_level=3 etm=0" \
873 0 \
874 -C "client hello, adding encrypt_then_mac extension" \
875 -S "found encrypt then mac extension" \
876 -S "server hello, adding encrypt then mac extension" \
877 -C "found encrypt_then_mac extension" \
878 -C "using encrypt then mac" \
879 -S "using encrypt then mac"
880
Janos Follathe2681a42016-03-07 15:57:05 +0000881requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100882run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100883 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100884 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100885 "$P_CLI debug_level=3 force_version=ssl3" \
886 0 \
887 -C "client hello, adding encrypt_then_mac extension" \
888 -S "found encrypt then mac extension" \
889 -S "server hello, adding encrypt then mac extension" \
890 -C "found encrypt_then_mac extension" \
891 -C "using encrypt then mac" \
892 -S "using encrypt then mac"
893
Janos Follathe2681a42016-03-07 15:57:05 +0000894requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100895run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100896 "$P_SRV debug_level=3 force_version=ssl3 \
897 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100898 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100899 0 \
900 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100901 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100902 -S "server hello, adding encrypt then mac extension" \
903 -C "found encrypt_then_mac extension" \
904 -C "using encrypt then mac" \
905 -S "using encrypt then mac"
906
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200907# Tests for Extended Master Secret extension
908
909run_test "Extended Master Secret: default" \
910 "$P_SRV debug_level=3" \
911 "$P_CLI debug_level=3" \
912 0 \
913 -c "client hello, adding extended_master_secret extension" \
914 -s "found extended master secret extension" \
915 -s "server hello, adding extended master secret extension" \
916 -c "found extended_master_secret extension" \
917 -c "using extended master secret" \
918 -s "using extended master secret"
919
920run_test "Extended Master Secret: client enabled, server disabled" \
921 "$P_SRV debug_level=3 extended_ms=0" \
922 "$P_CLI debug_level=3 extended_ms=1" \
923 0 \
924 -c "client hello, adding extended_master_secret extension" \
925 -s "found extended master secret extension" \
926 -S "server hello, adding extended master secret extension" \
927 -C "found extended_master_secret extension" \
928 -C "using extended master secret" \
929 -S "using extended master secret"
930
931run_test "Extended Master Secret: client disabled, server enabled" \
932 "$P_SRV debug_level=3 extended_ms=1" \
933 "$P_CLI debug_level=3 extended_ms=0" \
934 0 \
935 -C "client hello, adding extended_master_secret extension" \
936 -S "found extended master secret extension" \
937 -S "server hello, adding extended master secret extension" \
938 -C "found extended_master_secret extension" \
939 -C "using extended master secret" \
940 -S "using extended master secret"
941
Janos Follathe2681a42016-03-07 15:57:05 +0000942requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200943run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100944 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200945 "$P_CLI debug_level=3 force_version=ssl3" \
946 0 \
947 -C "client hello, adding extended_master_secret extension" \
948 -S "found extended master secret extension" \
949 -S "server hello, adding extended master secret extension" \
950 -C "found extended_master_secret extension" \
951 -C "using extended master secret" \
952 -S "using extended master secret"
953
Janos Follathe2681a42016-03-07 15:57:05 +0000954requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200955run_test "Extended Master Secret: client enabled, server SSLv3" \
956 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100957 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200958 0 \
959 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100960 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200961 -S "server hello, adding extended master secret extension" \
962 -C "found extended_master_secret extension" \
963 -C "using extended master secret" \
964 -S "using extended master secret"
965
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200966# Tests for FALLBACK_SCSV
967
968run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200969 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200970 "$P_CLI debug_level=3 force_version=tls1_1" \
971 0 \
972 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200973 -S "received FALLBACK_SCSV" \
974 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200975 -C "is a fatal alert message (msg 86)"
976
977run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200978 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200979 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
980 0 \
981 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200982 -S "received FALLBACK_SCSV" \
983 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200984 -C "is a fatal alert message (msg 86)"
985
986run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200987 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200988 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200989 1 \
990 -c "adding FALLBACK_SCSV" \
991 -s "received FALLBACK_SCSV" \
992 -s "inapropriate fallback" \
993 -c "is a fatal alert message (msg 86)"
994
995run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200996 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200997 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200998 0 \
999 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001000 -s "received FALLBACK_SCSV" \
1001 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001002 -C "is a fatal alert message (msg 86)"
1003
1004requires_openssl_with_fallback_scsv
1005run_test "Fallback SCSV: default, openssl server" \
1006 "$O_SRV" \
1007 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1008 0 \
1009 -C "adding FALLBACK_SCSV" \
1010 -C "is a fatal alert message (msg 86)"
1011
1012requires_openssl_with_fallback_scsv
1013run_test "Fallback SCSV: enabled, openssl server" \
1014 "$O_SRV" \
1015 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1016 1 \
1017 -c "adding FALLBACK_SCSV" \
1018 -c "is a fatal alert message (msg 86)"
1019
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001020requires_openssl_with_fallback_scsv
1021run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001022 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001023 "$O_CLI -tls1_1" \
1024 0 \
1025 -S "received FALLBACK_SCSV" \
1026 -S "inapropriate fallback"
1027
1028requires_openssl_with_fallback_scsv
1029run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001030 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001031 "$O_CLI -tls1_1 -fallback_scsv" \
1032 1 \
1033 -s "received FALLBACK_SCSV" \
1034 -s "inapropriate fallback"
1035
1036requires_openssl_with_fallback_scsv
1037run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001038 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001039 "$O_CLI -fallback_scsv" \
1040 0 \
1041 -s "received FALLBACK_SCSV" \
1042 -S "inapropriate fallback"
1043
Gilles Peskined50177f2017-05-16 17:53:03 +02001044## ClientHello generated with
1045## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1046## then manually twiddling the ciphersuite list.
1047## The ClientHello content is spelled out below as a hex string as
1048## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1049## The expected response is an inappropriate_fallback alert.
1050requires_openssl_with_fallback_scsv
1051run_test "Fallback SCSV: beginning of list" \
1052 "$P_SRV debug_level=2" \
1053 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1054 0 \
1055 -s "received FALLBACK_SCSV" \
1056 -s "inapropriate fallback"
1057
1058requires_openssl_with_fallback_scsv
1059run_test "Fallback SCSV: end of list" \
1060 "$P_SRV debug_level=2" \
1061 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1062 0 \
1063 -s "received FALLBACK_SCSV" \
1064 -s "inapropriate fallback"
1065
1066## Here the expected response is a valid ServerHello prefix, up to the random.
1067requires_openssl_with_fallback_scsv
1068run_test "Fallback SCSV: not in list" \
1069 "$P_SRV debug_level=2" \
1070 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1071 0 \
1072 -S "received FALLBACK_SCSV" \
1073 -S "inapropriate fallback"
1074
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001075# Tests for CBC 1/n-1 record splitting
1076
1077run_test "CBC Record splitting: TLS 1.2, no splitting" \
1078 "$P_SRV" \
1079 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1080 request_size=123 force_version=tls1_2" \
1081 0 \
1082 -s "Read from client: 123 bytes read" \
1083 -S "Read from client: 1 bytes read" \
1084 -S "122 bytes read"
1085
1086run_test "CBC Record splitting: TLS 1.1, no splitting" \
1087 "$P_SRV" \
1088 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1089 request_size=123 force_version=tls1_1" \
1090 0 \
1091 -s "Read from client: 123 bytes read" \
1092 -S "Read from client: 1 bytes read" \
1093 -S "122 bytes read"
1094
1095run_test "CBC Record splitting: TLS 1.0, splitting" \
1096 "$P_SRV" \
1097 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1098 request_size=123 force_version=tls1" \
1099 0 \
1100 -S "Read from client: 123 bytes read" \
1101 -s "Read from client: 1 bytes read" \
1102 -s "122 bytes read"
1103
Janos Follathe2681a42016-03-07 15:57:05 +00001104requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001105run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001106 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001107 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1108 request_size=123 force_version=ssl3" \
1109 0 \
1110 -S "Read from client: 123 bytes read" \
1111 -s "Read from client: 1 bytes read" \
1112 -s "122 bytes read"
1113
1114run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001115 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001116 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1117 request_size=123 force_version=tls1" \
1118 0 \
1119 -s "Read from client: 123 bytes read" \
1120 -S "Read from client: 1 bytes read" \
1121 -S "122 bytes read"
1122
1123run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1124 "$P_SRV" \
1125 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1126 request_size=123 force_version=tls1 recsplit=0" \
1127 0 \
1128 -s "Read from client: 123 bytes read" \
1129 -S "Read from client: 1 bytes read" \
1130 -S "122 bytes read"
1131
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001132run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1133 "$P_SRV nbio=2" \
1134 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1135 request_size=123 force_version=tls1" \
1136 0 \
1137 -S "Read from client: 123 bytes read" \
1138 -s "Read from client: 1 bytes read" \
1139 -s "122 bytes read"
1140
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001141# Tests for Session Tickets
1142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001143run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001144 "$P_SRV debug_level=3 tickets=1" \
1145 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001146 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001147 -c "client hello, adding session ticket extension" \
1148 -s "found session ticket extension" \
1149 -s "server hello, adding session ticket extension" \
1150 -c "found session_ticket extension" \
1151 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001152 -S "session successfully restored from cache" \
1153 -s "session successfully restored from ticket" \
1154 -s "a session has been resumed" \
1155 -c "a session has been resumed"
1156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001157run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001158 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1159 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001160 0 \
1161 -c "client hello, adding session ticket extension" \
1162 -s "found session ticket extension" \
1163 -s "server hello, adding session ticket extension" \
1164 -c "found session_ticket extension" \
1165 -c "parse new session ticket" \
1166 -S "session successfully restored from cache" \
1167 -s "session successfully restored from ticket" \
1168 -s "a session has been resumed" \
1169 -c "a session has been resumed"
1170
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001171run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001172 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1173 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001174 0 \
1175 -c "client hello, adding session ticket extension" \
1176 -s "found session ticket extension" \
1177 -s "server hello, adding session ticket extension" \
1178 -c "found session_ticket extension" \
1179 -c "parse new session ticket" \
1180 -S "session successfully restored from cache" \
1181 -S "session successfully restored from ticket" \
1182 -S "a session has been resumed" \
1183 -C "a session has been resumed"
1184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001185run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001186 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001187 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001188 0 \
1189 -c "client hello, adding session ticket extension" \
1190 -c "found session_ticket extension" \
1191 -c "parse new session ticket" \
1192 -c "a session has been resumed"
1193
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001194run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001195 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001196 "( $O_CLI -sess_out $SESSION; \
1197 $O_CLI -sess_in $SESSION; \
1198 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001199 0 \
1200 -s "found session ticket extension" \
1201 -s "server hello, adding session ticket extension" \
1202 -S "session successfully restored from cache" \
1203 -s "session successfully restored from ticket" \
1204 -s "a session has been resumed"
1205
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001206# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001208run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001209 "$P_SRV debug_level=3 tickets=0" \
1210 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001211 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001212 -c "client hello, adding session ticket extension" \
1213 -s "found session ticket extension" \
1214 -S "server hello, adding session ticket extension" \
1215 -C "found session_ticket extension" \
1216 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001217 -s "session successfully restored from cache" \
1218 -S "session successfully restored from ticket" \
1219 -s "a session has been resumed" \
1220 -c "a session has been resumed"
1221
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001222run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001223 "$P_SRV debug_level=3 tickets=1" \
1224 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001225 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001226 -C "client hello, adding session ticket extension" \
1227 -S "found session ticket extension" \
1228 -S "server hello, adding session ticket extension" \
1229 -C "found session_ticket extension" \
1230 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001231 -s "session successfully restored from cache" \
1232 -S "session successfully restored from ticket" \
1233 -s "a session has been resumed" \
1234 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001235
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001236run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001237 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1238 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001239 0 \
1240 -S "session successfully restored from cache" \
1241 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001242 -S "a session has been resumed" \
1243 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001244
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001245run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001246 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1247 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001248 0 \
1249 -s "session successfully restored from cache" \
1250 -S "session successfully restored from ticket" \
1251 -s "a session has been resumed" \
1252 -c "a session has been resumed"
1253
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001254run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001255 "$P_SRV debug_level=3 tickets=0" \
1256 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001257 0 \
1258 -s "session successfully restored from cache" \
1259 -S "session successfully restored from ticket" \
1260 -s "a session has been resumed" \
1261 -c "a session has been resumed"
1262
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001263run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001264 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1265 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001266 0 \
1267 -S "session successfully restored from cache" \
1268 -S "session successfully restored from ticket" \
1269 -S "a session has been resumed" \
1270 -C "a session has been resumed"
1271
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001272run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001273 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1274 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001275 0 \
1276 -s "session successfully restored from cache" \
1277 -S "session successfully restored from ticket" \
1278 -s "a session has been resumed" \
1279 -c "a session has been resumed"
1280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001281run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001282 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001283 "( $O_CLI -sess_out $SESSION; \
1284 $O_CLI -sess_in $SESSION; \
1285 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001286 0 \
1287 -s "found session ticket extension" \
1288 -S "server hello, adding session ticket extension" \
1289 -s "session successfully restored from cache" \
1290 -S "session successfully restored from ticket" \
1291 -s "a session has been resumed"
1292
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001293run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001294 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001295 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001296 0 \
1297 -C "found session_ticket extension" \
1298 -C "parse new session ticket" \
1299 -c "a session has been resumed"
1300
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001301# Tests for Max Fragment Length extension
1302
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001303run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001304 "$P_SRV debug_level=3" \
1305 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001306 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001307 -c "Maximum fragment length is 16384" \
1308 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001309 -C "client hello, adding max_fragment_length extension" \
1310 -S "found max fragment length extension" \
1311 -S "server hello, max_fragment_length extension" \
1312 -C "found max_fragment_length extension"
1313
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001314run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001315 "$P_SRV debug_level=3" \
1316 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001317 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001318 -c "Maximum fragment length is 4096" \
1319 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001320 -c "client hello, adding max_fragment_length extension" \
1321 -s "found max fragment length extension" \
1322 -s "server hello, max_fragment_length extension" \
1323 -c "found max_fragment_length extension"
1324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001325run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001326 "$P_SRV debug_level=3 max_frag_len=4096" \
1327 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001328 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001329 -c "Maximum fragment length is 16384" \
1330 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001331 -C "client hello, adding max_fragment_length extension" \
1332 -S "found max fragment length extension" \
1333 -S "server hello, max_fragment_length extension" \
1334 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001335
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001336requires_gnutls
1337run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001338 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001339 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001340 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001341 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001342 -c "client hello, adding max_fragment_length extension" \
1343 -c "found max_fragment_length extension"
1344
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001345run_test "Max fragment length: client, message just fits" \
1346 "$P_SRV debug_level=3" \
1347 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1348 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001349 -c "Maximum fragment length is 2048" \
1350 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001351 -c "client hello, adding max_fragment_length extension" \
1352 -s "found max fragment length extension" \
1353 -s "server hello, max_fragment_length extension" \
1354 -c "found max_fragment_length extension" \
1355 -c "2048 bytes written in 1 fragments" \
1356 -s "2048 bytes read"
1357
1358run_test "Max fragment length: client, larger message" \
1359 "$P_SRV debug_level=3" \
1360 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1361 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001362 -c "Maximum fragment length is 2048" \
1363 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001364 -c "client hello, adding max_fragment_length extension" \
1365 -s "found max fragment length extension" \
1366 -s "server hello, max_fragment_length extension" \
1367 -c "found max_fragment_length extension" \
1368 -c "2345 bytes written in 2 fragments" \
1369 -s "2048 bytes read" \
1370 -s "297 bytes read"
1371
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001372run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001373 "$P_SRV debug_level=3 dtls=1" \
1374 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1375 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001376 -c "Maximum fragment length is 2048" \
1377 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001378 -c "client hello, adding max_fragment_length extension" \
1379 -s "found max fragment length extension" \
1380 -s "server hello, max_fragment_length extension" \
1381 -c "found max_fragment_length extension" \
1382 -c "fragment larger than.*maximum"
1383
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001384# Tests for renegotiation
1385
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001386run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001387 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001388 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001389 0 \
1390 -C "client hello, adding renegotiation extension" \
1391 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1392 -S "found renegotiation extension" \
1393 -s "server hello, secure renegotiation extension" \
1394 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001395 -C "=> renegotiate" \
1396 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001397 -S "write hello request"
1398
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001399run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001400 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001401 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001402 0 \
1403 -c "client hello, adding renegotiation extension" \
1404 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1405 -s "found renegotiation extension" \
1406 -s "server hello, secure renegotiation extension" \
1407 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001408 -c "=> renegotiate" \
1409 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001410 -S "write hello request"
1411
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001412run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001413 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001414 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001415 0 \
1416 -c "client hello, adding renegotiation extension" \
1417 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1418 -s "found renegotiation extension" \
1419 -s "server hello, secure renegotiation extension" \
1420 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001421 -c "=> renegotiate" \
1422 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001423 -s "write hello request"
1424
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001425run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001426 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001427 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001428 0 \
1429 -c "client hello, adding renegotiation extension" \
1430 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1431 -s "found renegotiation extension" \
1432 -s "server hello, secure renegotiation extension" \
1433 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001434 -c "=> renegotiate" \
1435 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001436 -s "write hello request"
1437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001438run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001439 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001440 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001441 1 \
1442 -c "client hello, adding renegotiation extension" \
1443 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1444 -S "found renegotiation extension" \
1445 -s "server hello, secure renegotiation extension" \
1446 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001447 -c "=> renegotiate" \
1448 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001449 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001450 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001451 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001453run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001454 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001455 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001456 0 \
1457 -C "client hello, adding renegotiation extension" \
1458 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1459 -S "found renegotiation extension" \
1460 -s "server hello, secure renegotiation extension" \
1461 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001462 -C "=> renegotiate" \
1463 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001464 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001465 -S "SSL - An unexpected message was received from our peer" \
1466 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001467
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001468run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001469 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001470 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001471 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001472 0 \
1473 -C "client hello, adding renegotiation extension" \
1474 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1475 -S "found renegotiation extension" \
1476 -s "server hello, secure renegotiation extension" \
1477 -c "found renegotiation extension" \
1478 -C "=> renegotiate" \
1479 -S "=> renegotiate" \
1480 -s "write hello request" \
1481 -S "SSL - An unexpected message was received from our peer" \
1482 -S "failed"
1483
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001484# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001485run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
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=2 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é-Gonnard8e03c712014-08-30 21:42:40 +02001501run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001502 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001503 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001504 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001505 0 \
1506 -C "client hello, adding renegotiation extension" \
1507 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1508 -S "found renegotiation extension" \
1509 -s "server hello, secure renegotiation extension" \
1510 -c "found renegotiation extension" \
1511 -C "=> renegotiate" \
1512 -S "=> renegotiate" \
1513 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001514 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001516run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001517 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001518 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001519 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001520 0 \
1521 -c "client hello, adding renegotiation extension" \
1522 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1523 -s "found renegotiation extension" \
1524 -s "server hello, secure renegotiation extension" \
1525 -c "found renegotiation extension" \
1526 -c "=> renegotiate" \
1527 -s "=> renegotiate" \
1528 -s "write hello request" \
1529 -S "SSL - An unexpected message was received from our peer" \
1530 -S "failed"
1531
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001532run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001533 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001534 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1535 0 \
1536 -C "client hello, adding renegotiation extension" \
1537 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1538 -S "found renegotiation extension" \
1539 -s "server hello, secure renegotiation extension" \
1540 -c "found renegotiation extension" \
1541 -S "record counter limit reached: renegotiate" \
1542 -C "=> renegotiate" \
1543 -S "=> renegotiate" \
1544 -S "write hello request" \
1545 -S "SSL - An unexpected message was received from our peer" \
1546 -S "failed"
1547
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001548# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001549run_test "Renegotiation: periodic, just above 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é-Gonnard9835bc02015-01-14 14:41:58 +01001551 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001552 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
1565run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001566 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001567 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001568 0 \
1569 -c "client hello, adding renegotiation extension" \
1570 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1571 -s "found renegotiation extension" \
1572 -s "server hello, secure renegotiation extension" \
1573 -c "found renegotiation extension" \
1574 -s "record counter limit reached: renegotiate" \
1575 -c "=> renegotiate" \
1576 -s "=> renegotiate" \
1577 -s "write hello request" \
1578 -S "SSL - An unexpected message was received from our peer" \
1579 -S "failed"
1580
1581run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001582 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001583 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1584 0 \
1585 -C "client hello, adding renegotiation extension" \
1586 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1587 -S "found renegotiation extension" \
1588 -s "server hello, secure renegotiation extension" \
1589 -c "found renegotiation extension" \
1590 -S "record counter limit reached: renegotiate" \
1591 -C "=> renegotiate" \
1592 -S "=> renegotiate" \
1593 -S "write hello request" \
1594 -S "SSL - An unexpected message was received from our peer" \
1595 -S "failed"
1596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001597run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001598 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001599 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001600 0 \
1601 -c "client hello, adding renegotiation extension" \
1602 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1603 -s "found renegotiation extension" \
1604 -s "server hello, secure renegotiation extension" \
1605 -c "found renegotiation extension" \
1606 -c "=> renegotiate" \
1607 -s "=> renegotiate" \
1608 -S "write hello request"
1609
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001610run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001611 "$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 +02001612 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001613 0 \
1614 -c "client hello, adding renegotiation extension" \
1615 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1616 -s "found renegotiation extension" \
1617 -s "server hello, secure renegotiation extension" \
1618 -c "found renegotiation extension" \
1619 -c "=> renegotiate" \
1620 -s "=> renegotiate" \
1621 -s "write hello request"
1622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001623run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001624 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001625 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001626 0 \
1627 -c "client hello, adding renegotiation extension" \
1628 -c "found renegotiation extension" \
1629 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001630 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001631 -C "error" \
1632 -c "HTTP/1.0 200 [Oo][Kk]"
1633
Paul Bakker539d9722015-02-08 16:18:35 +01001634requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001635run_test "Renegotiation: gnutls server strict, client-initiated" \
1636 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001637 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001638 0 \
1639 -c "client hello, adding renegotiation extension" \
1640 -c "found renegotiation extension" \
1641 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001642 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001643 -C "error" \
1644 -c "HTTP/1.0 200 [Oo][Kk]"
1645
Paul Bakker539d9722015-02-08 16:18:35 +01001646requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001647run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1648 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1649 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1650 1 \
1651 -c "client hello, adding renegotiation extension" \
1652 -C "found renegotiation extension" \
1653 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001654 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001655 -c "error" \
1656 -C "HTTP/1.0 200 [Oo][Kk]"
1657
Paul Bakker539d9722015-02-08 16:18:35 +01001658requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001659run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1660 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1661 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1662 allow_legacy=0" \
1663 1 \
1664 -c "client hello, adding renegotiation extension" \
1665 -C "found renegotiation extension" \
1666 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001667 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001668 -c "error" \
1669 -C "HTTP/1.0 200 [Oo][Kk]"
1670
Paul Bakker539d9722015-02-08 16:18:35 +01001671requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001672run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1673 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1674 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1675 allow_legacy=1" \
1676 0 \
1677 -c "client hello, adding renegotiation extension" \
1678 -C "found renegotiation extension" \
1679 -c "=> renegotiate" \
1680 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001681 -C "error" \
1682 -c "HTTP/1.0 200 [Oo][Kk]"
1683
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001684run_test "Renegotiation: DTLS, client-initiated" \
1685 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1686 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1687 0 \
1688 -c "client hello, adding renegotiation extension" \
1689 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1690 -s "found renegotiation extension" \
1691 -s "server hello, secure renegotiation extension" \
1692 -c "found renegotiation extension" \
1693 -c "=> renegotiate" \
1694 -s "=> renegotiate" \
1695 -S "write hello request"
1696
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001697run_test "Renegotiation: DTLS, server-initiated" \
1698 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001699 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1700 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001701 0 \
1702 -c "client hello, adding renegotiation extension" \
1703 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1704 -s "found renegotiation extension" \
1705 -s "server hello, secure renegotiation extension" \
1706 -c "found renegotiation extension" \
1707 -c "=> renegotiate" \
1708 -s "=> renegotiate" \
1709 -s "write hello request"
1710
Andres AG692ad842017-01-19 16:30:57 +00001711run_test "Renegotiation: DTLS, renego_period overflow" \
1712 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1713 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1714 0 \
1715 -c "client hello, adding renegotiation extension" \
1716 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1717 -s "found renegotiation extension" \
1718 -s "server hello, secure renegotiation extension" \
1719 -s "record counter limit reached: renegotiate" \
1720 -c "=> renegotiate" \
1721 -s "=> renegotiate" \
1722 -s "write hello request" \
1723
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001724requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001725run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1726 "$G_SRV -u --mtu 4096" \
1727 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1728 0 \
1729 -c "client hello, adding renegotiation extension" \
1730 -c "found renegotiation extension" \
1731 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001732 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001733 -C "error" \
1734 -s "Extra-header:"
1735
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001736# Test for the "secure renegotation" extension only (no actual renegotiation)
1737
Paul Bakker539d9722015-02-08 16:18:35 +01001738requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001739run_test "Renego ext: gnutls server strict, client default" \
1740 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1741 "$P_CLI debug_level=3" \
1742 0 \
1743 -c "found renegotiation extension" \
1744 -C "error" \
1745 -c "HTTP/1.0 200 [Oo][Kk]"
1746
Paul Bakker539d9722015-02-08 16:18:35 +01001747requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001748run_test "Renego ext: gnutls server unsafe, client default" \
1749 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1750 "$P_CLI debug_level=3" \
1751 0 \
1752 -C "found renegotiation extension" \
1753 -C "error" \
1754 -c "HTTP/1.0 200 [Oo][Kk]"
1755
Paul Bakker539d9722015-02-08 16:18:35 +01001756requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001757run_test "Renego ext: gnutls server unsafe, client break legacy" \
1758 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1759 "$P_CLI debug_level=3 allow_legacy=-1" \
1760 1 \
1761 -C "found renegotiation extension" \
1762 -c "error" \
1763 -C "HTTP/1.0 200 [Oo][Kk]"
1764
Paul Bakker539d9722015-02-08 16:18:35 +01001765requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001766run_test "Renego ext: gnutls client strict, server default" \
1767 "$P_SRV debug_level=3" \
1768 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1769 0 \
1770 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1771 -s "server hello, secure renegotiation extension"
1772
Paul Bakker539d9722015-02-08 16:18:35 +01001773requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001774run_test "Renego ext: gnutls client unsafe, server default" \
1775 "$P_SRV debug_level=3" \
1776 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1777 0 \
1778 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1779 -S "server hello, secure renegotiation extension"
1780
Paul Bakker539d9722015-02-08 16:18:35 +01001781requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001782run_test "Renego ext: gnutls client unsafe, server break legacy" \
1783 "$P_SRV debug_level=3 allow_legacy=-1" \
1784 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1785 1 \
1786 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1787 -S "server hello, secure renegotiation extension"
1788
Janos Follath0b242342016-02-17 10:11:21 +00001789# Tests for silently dropping trailing extra bytes in .der certificates
1790
1791requires_gnutls
1792run_test "DER format: no trailing bytes" \
1793 "$P_SRV crt_file=data_files/server5-der0.crt \
1794 key_file=data_files/server5.key" \
1795 "$G_CLI " \
1796 0 \
1797 -c "Handshake was completed" \
1798
1799requires_gnutls
1800run_test "DER format: with a trailing zero byte" \
1801 "$P_SRV crt_file=data_files/server5-der1a.crt \
1802 key_file=data_files/server5.key" \
1803 "$G_CLI " \
1804 0 \
1805 -c "Handshake was completed" \
1806
1807requires_gnutls
1808run_test "DER format: with a trailing random byte" \
1809 "$P_SRV crt_file=data_files/server5-der1b.crt \
1810 key_file=data_files/server5.key" \
1811 "$G_CLI " \
1812 0 \
1813 -c "Handshake was completed" \
1814
1815requires_gnutls
1816run_test "DER format: with 2 trailing random bytes" \
1817 "$P_SRV crt_file=data_files/server5-der2.crt \
1818 key_file=data_files/server5.key" \
1819 "$G_CLI " \
1820 0 \
1821 -c "Handshake was completed" \
1822
1823requires_gnutls
1824run_test "DER format: with 4 trailing random bytes" \
1825 "$P_SRV crt_file=data_files/server5-der4.crt \
1826 key_file=data_files/server5.key" \
1827 "$G_CLI " \
1828 0 \
1829 -c "Handshake was completed" \
1830
1831requires_gnutls
1832run_test "DER format: with 8 trailing random bytes" \
1833 "$P_SRV crt_file=data_files/server5-der8.crt \
1834 key_file=data_files/server5.key" \
1835 "$G_CLI " \
1836 0 \
1837 -c "Handshake was completed" \
1838
1839requires_gnutls
1840run_test "DER format: with 9 trailing random bytes" \
1841 "$P_SRV crt_file=data_files/server5-der9.crt \
1842 key_file=data_files/server5.key" \
1843 "$G_CLI " \
1844 0 \
1845 -c "Handshake was completed" \
1846
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001847# Tests for auth_mode
1848
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001849run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001850 "$P_SRV crt_file=data_files/server5-badsign.crt \
1851 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001852 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001853 1 \
1854 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001855 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001856 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001857 -c "X509 - Certificate verification failed"
1858
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001859run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001860 "$P_SRV crt_file=data_files/server5-badsign.crt \
1861 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001862 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001863 0 \
1864 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001865 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001866 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001867 -C "X509 - Certificate verification failed"
1868
Hanno Beckere6706e62017-05-15 16:05:15 +01001869run_test "Authentication: server goodcert, client optional, no trusted CA" \
1870 "$P_SRV" \
1871 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1872 0 \
1873 -c "x509_verify_cert() returned" \
1874 -c "! The certificate is not correctly signed by the trusted CA" \
1875 -c "! Certificate verification flags"\
1876 -C "! mbedtls_ssl_handshake returned" \
1877 -C "X509 - Certificate verification failed" \
1878 -C "SSL - No CA Chain is set, but required to operate"
1879
1880run_test "Authentication: server goodcert, client required, no trusted CA" \
1881 "$P_SRV" \
1882 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1883 1 \
1884 -c "x509_verify_cert() returned" \
1885 -c "! The certificate is not correctly signed by the trusted CA" \
1886 -c "! Certificate verification flags"\
1887 -c "! mbedtls_ssl_handshake returned" \
1888 -c "SSL - No CA Chain is set, but required to operate"
1889
1890# The purpose of the next two tests is to test the client's behaviour when receiving a server
1891# certificate with an unsupported elliptic curve. This should usually not happen because
1892# the client informs the server about the supported curves - it does, though, in the
1893# corner case of a static ECDH suite, because the server doesn't check the curve on that
1894# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1895# different means to have the server ignoring the client's supported curve list.
1896
1897requires_config_enabled MBEDTLS_ECP_C
1898run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1899 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1900 crt_file=data_files/server5.ku-ka.crt" \
1901 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1902 1 \
1903 -c "bad certificate (EC key curve)"\
1904 -c "! Certificate verification flags"\
1905 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1906
1907requires_config_enabled MBEDTLS_ECP_C
1908run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1909 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1910 crt_file=data_files/server5.ku-ka.crt" \
1911 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1912 1 \
1913 -c "bad certificate (EC key curve)"\
1914 -c "! Certificate verification flags"\
1915 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1916
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001917run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001918 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001919 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001920 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001921 0 \
1922 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001923 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001924 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001925 -C "X509 - Certificate verification failed"
1926
Simon Butcher99000142016-10-13 17:21:01 +01001927run_test "Authentication: client SHA256, server required" \
1928 "$P_SRV auth_mode=required" \
1929 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1930 key_file=data_files/server6.key \
1931 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1932 0 \
1933 -c "Supported Signature Algorithm found: 4," \
1934 -c "Supported Signature Algorithm found: 5,"
1935
1936run_test "Authentication: client SHA384, server required" \
1937 "$P_SRV auth_mode=required" \
1938 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1939 key_file=data_files/server6.key \
1940 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
1941 0 \
1942 -c "Supported Signature Algorithm found: 4," \
1943 -c "Supported Signature Algorithm found: 5,"
1944
Gilles Peskinefd8332e2017-05-03 16:25:07 +02001945requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
1946run_test "Authentication: client has no cert, server required (SSLv3)" \
1947 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
1948 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
1949 key_file=data_files/server5.key" \
1950 1 \
1951 -S "skip write certificate request" \
1952 -C "skip parse certificate request" \
1953 -c "got a certificate request" \
1954 -c "got no certificate to send" \
1955 -S "x509_verify_cert() returned" \
1956 -s "client has no certificate" \
1957 -s "! mbedtls_ssl_handshake returned" \
1958 -c "! mbedtls_ssl_handshake returned" \
1959 -s "No client certification received from the client, but required by the authentication mode"
1960
1961run_test "Authentication: client has no cert, server required (TLS)" \
1962 "$P_SRV debug_level=3 auth_mode=required" \
1963 "$P_CLI debug_level=3 crt_file=none \
1964 key_file=data_files/server5.key" \
1965 1 \
1966 -S "skip write certificate request" \
1967 -C "skip parse certificate request" \
1968 -c "got a certificate request" \
1969 -c "= write certificate$" \
1970 -C "skip write certificate$" \
1971 -S "x509_verify_cert() returned" \
1972 -s "client has no certificate" \
1973 -s "! mbedtls_ssl_handshake returned" \
1974 -c "! mbedtls_ssl_handshake returned" \
1975 -s "No client certification received from the client, but required by the authentication mode"
1976
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001977run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001978 "$P_SRV debug_level=3 auth_mode=required" \
1979 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001980 key_file=data_files/server5.key" \
1981 1 \
1982 -S "skip write certificate request" \
1983 -C "skip parse certificate request" \
1984 -c "got a certificate request" \
1985 -C "skip write certificate" \
1986 -C "skip write certificate verify" \
1987 -S "skip parse certificate verify" \
1988 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001989 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001990 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02001991 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001992 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001993 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02001994# We don't check that the client receives the alert because it might
1995# detect that its write end of the connection is closed and abort
1996# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001997
Janos Follath89baba22017-04-10 14:34:35 +01001998run_test "Authentication: client cert not trusted, server required" \
1999 "$P_SRV debug_level=3 auth_mode=required" \
2000 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2001 key_file=data_files/server5.key" \
2002 1 \
2003 -S "skip write certificate request" \
2004 -C "skip parse certificate request" \
2005 -c "got a certificate request" \
2006 -C "skip write certificate" \
2007 -C "skip write certificate verify" \
2008 -S "skip parse certificate verify" \
2009 -s "x509_verify_cert() returned" \
2010 -s "! The certificate is not correctly signed by the trusted CA" \
2011 -s "! mbedtls_ssl_handshake returned" \
2012 -c "! mbedtls_ssl_handshake returned" \
2013 -s "X509 - Certificate verification failed"
2014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002015run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002016 "$P_SRV debug_level=3 auth_mode=optional" \
2017 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002018 key_file=data_files/server5.key" \
2019 0 \
2020 -S "skip write certificate request" \
2021 -C "skip parse certificate request" \
2022 -c "got a certificate request" \
2023 -C "skip write certificate" \
2024 -C "skip write certificate verify" \
2025 -S "skip parse certificate verify" \
2026 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002027 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002028 -S "! mbedtls_ssl_handshake returned" \
2029 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002030 -S "X509 - Certificate verification failed"
2031
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002032run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002033 "$P_SRV debug_level=3 auth_mode=none" \
2034 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002035 key_file=data_files/server5.key" \
2036 0 \
2037 -s "skip write certificate request" \
2038 -C "skip parse certificate request" \
2039 -c "got no certificate request" \
2040 -c "skip write certificate" \
2041 -c "skip write certificate verify" \
2042 -s "skip parse certificate verify" \
2043 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002044 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002045 -S "! mbedtls_ssl_handshake returned" \
2046 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002047 -S "X509 - Certificate verification failed"
2048
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002049run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002050 "$P_SRV debug_level=3 auth_mode=optional" \
2051 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002052 0 \
2053 -S "skip write certificate request" \
2054 -C "skip parse certificate request" \
2055 -c "got a certificate request" \
2056 -C "skip write certificate$" \
2057 -C "got no certificate to send" \
2058 -S "SSLv3 client has no certificate" \
2059 -c "skip write certificate verify" \
2060 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002061 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002062 -S "! mbedtls_ssl_handshake returned" \
2063 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002064 -S "X509 - Certificate verification failed"
2065
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002066run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002067 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002068 "$O_CLI" \
2069 0 \
2070 -S "skip write certificate request" \
2071 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002072 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002073 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002074 -S "X509 - Certificate verification failed"
2075
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002076run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002077 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002078 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002079 0 \
2080 -C "skip parse certificate request" \
2081 -c "got a certificate request" \
2082 -C "skip write certificate$" \
2083 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002084 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002085
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002086run_test "Authentication: client no cert, openssl server required" \
2087 "$O_SRV -Verify 10" \
2088 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2089 1 \
2090 -C "skip parse certificate request" \
2091 -c "got a certificate request" \
2092 -C "skip write certificate$" \
2093 -c "skip write certificate verify" \
2094 -c "! mbedtls_ssl_handshake returned"
2095
Janos Follathe2681a42016-03-07 15:57:05 +00002096requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002097run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002098 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002099 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002100 0 \
2101 -S "skip write certificate request" \
2102 -C "skip parse certificate request" \
2103 -c "got a certificate request" \
2104 -C "skip write certificate$" \
2105 -c "skip write certificate verify" \
2106 -c "got no certificate to send" \
2107 -s "SSLv3 client has no certificate" \
2108 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002109 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002110 -S "! mbedtls_ssl_handshake returned" \
2111 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002112 -S "X509 - Certificate verification failed"
2113
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002114# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2115# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002116
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002117MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002118MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002119
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002120if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002121 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002122 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002123 printf "test value of ${MAX_IM_CA}. \n"
2124 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002125 printf "The tests assume this value and if it changes, the tests in this\n"
2126 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002127 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002128
2129 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002130fi
2131
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002132run_test "Authentication: server max_int chain, client default" \
2133 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2134 key_file=data_files/dir-maxpath/09.key" \
2135 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2136 0 \
2137 -C "X509 - A fatal error occured"
2138
2139run_test "Authentication: server max_int+1 chain, client default" \
2140 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2141 key_file=data_files/dir-maxpath/10.key" \
2142 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2143 1 \
2144 -c "X509 - A fatal error occured"
2145
2146run_test "Authentication: server max_int+1 chain, client optional" \
2147 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2148 key_file=data_files/dir-maxpath/10.key" \
2149 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2150 auth_mode=optional" \
2151 1 \
2152 -c "X509 - A fatal error occured"
2153
2154run_test "Authentication: server max_int+1 chain, client none" \
2155 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2156 key_file=data_files/dir-maxpath/10.key" \
2157 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2158 auth_mode=none" \
2159 0 \
2160 -C "X509 - A fatal error occured"
2161
2162run_test "Authentication: client max_int+1 chain, server default" \
2163 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2164 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2165 key_file=data_files/dir-maxpath/10.key" \
2166 0 \
2167 -S "X509 - A fatal error occured"
2168
2169run_test "Authentication: client max_int+1 chain, server optional" \
2170 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2171 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2172 key_file=data_files/dir-maxpath/10.key" \
2173 1 \
2174 -s "X509 - A fatal error occured"
2175
2176run_test "Authentication: client max_int+1 chain, server required" \
2177 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2178 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2179 key_file=data_files/dir-maxpath/10.key" \
2180 1 \
2181 -s "X509 - A fatal error occured"
2182
2183run_test "Authentication: client max_int chain, server required" \
2184 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2185 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2186 key_file=data_files/dir-maxpath/09.key" \
2187 0 \
2188 -S "X509 - A fatal error occured"
2189
Janos Follath89baba22017-04-10 14:34:35 +01002190# Tests for CA list in CertificateRequest messages
2191
2192run_test "Authentication: send CA list in CertificateRequest (default)" \
2193 "$P_SRV debug_level=3 auth_mode=required" \
2194 "$P_CLI crt_file=data_files/server6.crt \
2195 key_file=data_files/server6.key" \
2196 0 \
2197 -s "requested DN"
2198
2199run_test "Authentication: do not send CA list in CertificateRequest" \
2200 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2201 "$P_CLI crt_file=data_files/server6.crt \
2202 key_file=data_files/server6.key" \
2203 0 \
2204 -S "requested DN"
2205
2206run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2207 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2208 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2209 key_file=data_files/server5.key" \
2210 1 \
2211 -S "requested DN" \
2212 -s "x509_verify_cert() returned" \
2213 -s "! The certificate is not correctly signed by the trusted CA" \
2214 -s "! mbedtls_ssl_handshake returned" \
2215 -c "! mbedtls_ssl_handshake returned" \
2216 -s "X509 - Certificate verification failed"
2217
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002218# Tests for certificate selection based on SHA verson
2219
2220run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2221 "$P_SRV crt_file=data_files/server5.crt \
2222 key_file=data_files/server5.key \
2223 crt_file2=data_files/server5-sha1.crt \
2224 key_file2=data_files/server5.key" \
2225 "$P_CLI force_version=tls1_2" \
2226 0 \
2227 -c "signed using.*ECDSA with SHA256" \
2228 -C "signed using.*ECDSA with SHA1"
2229
2230run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2231 "$P_SRV crt_file=data_files/server5.crt \
2232 key_file=data_files/server5.key \
2233 crt_file2=data_files/server5-sha1.crt \
2234 key_file2=data_files/server5.key" \
2235 "$P_CLI force_version=tls1_1" \
2236 0 \
2237 -C "signed using.*ECDSA with SHA256" \
2238 -c "signed using.*ECDSA with SHA1"
2239
2240run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2241 "$P_SRV crt_file=data_files/server5.crt \
2242 key_file=data_files/server5.key \
2243 crt_file2=data_files/server5-sha1.crt \
2244 key_file2=data_files/server5.key" \
2245 "$P_CLI force_version=tls1" \
2246 0 \
2247 -C "signed using.*ECDSA with SHA256" \
2248 -c "signed using.*ECDSA with SHA1"
2249
2250run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2251 "$P_SRV crt_file=data_files/server5.crt \
2252 key_file=data_files/server5.key \
2253 crt_file2=data_files/server6.crt \
2254 key_file2=data_files/server6.key" \
2255 "$P_CLI force_version=tls1_1" \
2256 0 \
2257 -c "serial number.*09" \
2258 -c "signed using.*ECDSA with SHA256" \
2259 -C "signed using.*ECDSA with SHA1"
2260
2261run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2262 "$P_SRV crt_file=data_files/server6.crt \
2263 key_file=data_files/server6.key \
2264 crt_file2=data_files/server5.crt \
2265 key_file2=data_files/server5.key" \
2266 "$P_CLI force_version=tls1_1" \
2267 0 \
2268 -c "serial number.*0A" \
2269 -c "signed using.*ECDSA with SHA256" \
2270 -C "signed using.*ECDSA with SHA1"
2271
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002272# tests for SNI
2273
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002274run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002275 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002276 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002277 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002278 0 \
2279 -S "parse ServerName extension" \
2280 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2281 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002283run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002284 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002285 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002286 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 +02002287 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002288 0 \
2289 -s "parse ServerName extension" \
2290 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2291 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002292
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002293run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002294 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002295 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002296 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 +02002297 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002298 0 \
2299 -s "parse ServerName extension" \
2300 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2301 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002302
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002303run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002304 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002305 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002306 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 +02002307 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002308 1 \
2309 -s "parse ServerName extension" \
2310 -s "ssl_sni_wrapper() returned" \
2311 -s "mbedtls_ssl_handshake returned" \
2312 -c "mbedtls_ssl_handshake returned" \
2313 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002314
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002315run_test "SNI: client auth no override: optional" \
2316 "$P_SRV debug_level=3 auth_mode=optional \
2317 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2318 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2319 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002320 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002321 -S "skip write certificate request" \
2322 -C "skip parse certificate request" \
2323 -c "got a certificate request" \
2324 -C "skip write certificate" \
2325 -C "skip write certificate verify" \
2326 -S "skip parse certificate verify"
2327
2328run_test "SNI: client auth override: none -> optional" \
2329 "$P_SRV debug_level=3 auth_mode=none \
2330 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2331 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2332 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002333 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002334 -S "skip write certificate request" \
2335 -C "skip parse certificate request" \
2336 -c "got a certificate request" \
2337 -C "skip write certificate" \
2338 -C "skip write certificate verify" \
2339 -S "skip parse certificate verify"
2340
2341run_test "SNI: client auth override: optional -> none" \
2342 "$P_SRV debug_level=3 auth_mode=optional \
2343 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2344 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2345 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002346 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002347 -s "skip write certificate request" \
2348 -C "skip parse certificate request" \
2349 -c "got no certificate request" \
2350 -c "skip write certificate" \
2351 -c "skip write certificate verify" \
2352 -s "skip parse certificate verify"
2353
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002354run_test "SNI: CA no override" \
2355 "$P_SRV debug_level=3 auth_mode=optional \
2356 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2357 ca_file=data_files/test-ca.crt \
2358 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2359 "$P_CLI debug_level=3 server_name=localhost \
2360 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2361 1 \
2362 -S "skip write certificate request" \
2363 -C "skip parse certificate request" \
2364 -c "got a certificate request" \
2365 -C "skip write certificate" \
2366 -C "skip write certificate verify" \
2367 -S "skip parse certificate verify" \
2368 -s "x509_verify_cert() returned" \
2369 -s "! The certificate is not correctly signed by the trusted CA" \
2370 -S "The certificate has been revoked (is on a CRL)"
2371
2372run_test "SNI: CA override" \
2373 "$P_SRV debug_level=3 auth_mode=optional \
2374 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2375 ca_file=data_files/test-ca.crt \
2376 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2377 "$P_CLI debug_level=3 server_name=localhost \
2378 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2379 0 \
2380 -S "skip write certificate request" \
2381 -C "skip parse certificate request" \
2382 -c "got a certificate request" \
2383 -C "skip write certificate" \
2384 -C "skip write certificate verify" \
2385 -S "skip parse certificate verify" \
2386 -S "x509_verify_cert() returned" \
2387 -S "! The certificate is not correctly signed by the trusted CA" \
2388 -S "The certificate has been revoked (is on a CRL)"
2389
2390run_test "SNI: CA override with CRL" \
2391 "$P_SRV debug_level=3 auth_mode=optional \
2392 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2393 ca_file=data_files/test-ca.crt \
2394 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2395 "$P_CLI debug_level=3 server_name=localhost \
2396 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2397 1 \
2398 -S "skip write certificate request" \
2399 -C "skip parse certificate request" \
2400 -c "got a certificate request" \
2401 -C "skip write certificate" \
2402 -C "skip write certificate verify" \
2403 -S "skip parse certificate verify" \
2404 -s "x509_verify_cert() returned" \
2405 -S "! The certificate is not correctly signed by the trusted CA" \
2406 -s "The certificate has been revoked (is on a CRL)"
2407
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002408# Tests for non-blocking I/O: exercise a variety of handshake flows
2409
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002410run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002411 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2412 "$P_CLI nbio=2 tickets=0" \
2413 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002414 -S "mbedtls_ssl_handshake returned" \
2415 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002416 -c "Read from server: .* bytes read"
2417
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002418run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002419 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2420 "$P_CLI nbio=2 tickets=0" \
2421 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002422 -S "mbedtls_ssl_handshake returned" \
2423 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002424 -c "Read from server: .* bytes read"
2425
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002426run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002427 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2428 "$P_CLI nbio=2 tickets=1" \
2429 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002430 -S "mbedtls_ssl_handshake returned" \
2431 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002432 -c "Read from server: .* bytes read"
2433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002434run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002435 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2436 "$P_CLI nbio=2 tickets=1" \
2437 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002438 -S "mbedtls_ssl_handshake returned" \
2439 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002440 -c "Read from server: .* bytes read"
2441
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002442run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002443 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2444 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2445 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002446 -S "mbedtls_ssl_handshake returned" \
2447 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002448 -c "Read from server: .* bytes read"
2449
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002450run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002451 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2452 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2453 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002454 -S "mbedtls_ssl_handshake returned" \
2455 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002456 -c "Read from server: .* bytes read"
2457
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002458run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002459 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2460 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2461 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002462 -S "mbedtls_ssl_handshake returned" \
2463 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002464 -c "Read from server: .* bytes read"
2465
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002466# Tests for version negotiation
2467
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002468run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002469 "$P_SRV" \
2470 "$P_CLI" \
2471 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002472 -S "mbedtls_ssl_handshake returned" \
2473 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002474 -s "Protocol is TLSv1.2" \
2475 -c "Protocol is TLSv1.2"
2476
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002477run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002478 "$P_SRV" \
2479 "$P_CLI max_version=tls1_1" \
2480 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002481 -S "mbedtls_ssl_handshake returned" \
2482 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002483 -s "Protocol is TLSv1.1" \
2484 -c "Protocol is TLSv1.1"
2485
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002486run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002487 "$P_SRV max_version=tls1_1" \
2488 "$P_CLI" \
2489 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002490 -S "mbedtls_ssl_handshake returned" \
2491 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002492 -s "Protocol is TLSv1.1" \
2493 -c "Protocol is TLSv1.1"
2494
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002495run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002496 "$P_SRV max_version=tls1_1" \
2497 "$P_CLI max_version=tls1_1" \
2498 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002499 -S "mbedtls_ssl_handshake returned" \
2500 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002501 -s "Protocol is TLSv1.1" \
2502 -c "Protocol is TLSv1.1"
2503
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002504run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002505 "$P_SRV min_version=tls1_1" \
2506 "$P_CLI max_version=tls1_1" \
2507 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002508 -S "mbedtls_ssl_handshake returned" \
2509 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002510 -s "Protocol is TLSv1.1" \
2511 -c "Protocol is TLSv1.1"
2512
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002513run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002514 "$P_SRV max_version=tls1_1" \
2515 "$P_CLI min_version=tls1_1" \
2516 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002517 -S "mbedtls_ssl_handshake returned" \
2518 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002519 -s "Protocol is TLSv1.1" \
2520 -c "Protocol is TLSv1.1"
2521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002522run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002523 "$P_SRV max_version=tls1_1" \
2524 "$P_CLI min_version=tls1_2" \
2525 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002526 -s "mbedtls_ssl_handshake returned" \
2527 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002528 -c "SSL - Handshake protocol not within min/max boundaries"
2529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002530run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002531 "$P_SRV min_version=tls1_2" \
2532 "$P_CLI max_version=tls1_1" \
2533 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002534 -s "mbedtls_ssl_handshake returned" \
2535 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002536 -s "SSL - Handshake protocol not within min/max boundaries"
2537
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002538# Tests for ALPN extension
2539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002540run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002541 "$P_SRV debug_level=3" \
2542 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002543 0 \
2544 -C "client hello, adding alpn extension" \
2545 -S "found alpn extension" \
2546 -C "got an alert message, type: \\[2:120]" \
2547 -S "server hello, adding alpn extension" \
2548 -C "found alpn extension " \
2549 -C "Application Layer Protocol is" \
2550 -S "Application Layer Protocol is"
2551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002552run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002553 "$P_SRV debug_level=3" \
2554 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002555 0 \
2556 -c "client hello, adding alpn extension" \
2557 -s "found alpn extension" \
2558 -C "got an alert message, type: \\[2:120]" \
2559 -S "server hello, adding alpn extension" \
2560 -C "found alpn extension " \
2561 -c "Application Layer Protocol is (none)" \
2562 -S "Application Layer Protocol is"
2563
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002564run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002565 "$P_SRV debug_level=3 alpn=abc,1234" \
2566 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002567 0 \
2568 -C "client hello, adding alpn extension" \
2569 -S "found alpn extension" \
2570 -C "got an alert message, type: \\[2:120]" \
2571 -S "server hello, adding alpn extension" \
2572 -C "found alpn extension " \
2573 -C "Application Layer Protocol is" \
2574 -s "Application Layer Protocol is (none)"
2575
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002576run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002577 "$P_SRV debug_level=3 alpn=abc,1234" \
2578 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002579 0 \
2580 -c "client hello, adding alpn extension" \
2581 -s "found alpn extension" \
2582 -C "got an alert message, type: \\[2:120]" \
2583 -s "server hello, adding alpn extension" \
2584 -c "found alpn extension" \
2585 -c "Application Layer Protocol is abc" \
2586 -s "Application Layer Protocol is abc"
2587
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002588run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002589 "$P_SRV debug_level=3 alpn=abc,1234" \
2590 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002591 0 \
2592 -c "client hello, adding alpn extension" \
2593 -s "found alpn extension" \
2594 -C "got an alert message, type: \\[2:120]" \
2595 -s "server hello, adding alpn extension" \
2596 -c "found alpn extension" \
2597 -c "Application Layer Protocol is abc" \
2598 -s "Application Layer Protocol is abc"
2599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002600run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002601 "$P_SRV debug_level=3 alpn=abc,1234" \
2602 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002603 0 \
2604 -c "client hello, adding alpn extension" \
2605 -s "found alpn extension" \
2606 -C "got an alert message, type: \\[2:120]" \
2607 -s "server hello, adding alpn extension" \
2608 -c "found alpn extension" \
2609 -c "Application Layer Protocol is 1234" \
2610 -s "Application Layer Protocol is 1234"
2611
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002612run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002613 "$P_SRV debug_level=3 alpn=abc,123" \
2614 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002615 1 \
2616 -c "client hello, adding alpn extension" \
2617 -s "found alpn extension" \
2618 -c "got an alert message, type: \\[2:120]" \
2619 -S "server hello, adding alpn extension" \
2620 -C "found alpn extension" \
2621 -C "Application Layer Protocol is 1234" \
2622 -S "Application Layer Protocol is 1234"
2623
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002624
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002625# Tests for keyUsage in leaf certificates, part 1:
2626# server-side certificate/suite selection
2627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002628run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002629 "$P_SRV key_file=data_files/server2.key \
2630 crt_file=data_files/server2.ku-ds.crt" \
2631 "$P_CLI" \
2632 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002633 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002634
2635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002636run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002637 "$P_SRV key_file=data_files/server2.key \
2638 crt_file=data_files/server2.ku-ke.crt" \
2639 "$P_CLI" \
2640 0 \
2641 -c "Ciphersuite is TLS-RSA-WITH-"
2642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002643run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002644 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002645 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002646 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002647 1 \
2648 -C "Ciphersuite is "
2649
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002650run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002651 "$P_SRV key_file=data_files/server5.key \
2652 crt_file=data_files/server5.ku-ds.crt" \
2653 "$P_CLI" \
2654 0 \
2655 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2656
2657
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002658run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002659 "$P_SRV key_file=data_files/server5.key \
2660 crt_file=data_files/server5.ku-ka.crt" \
2661 "$P_CLI" \
2662 0 \
2663 -c "Ciphersuite is TLS-ECDH-"
2664
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002665run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002666 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002667 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002668 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002669 1 \
2670 -C "Ciphersuite is "
2671
2672# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002673# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002675run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002676 "$O_SRV -key data_files/server2.key \
2677 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002678 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002679 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2680 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002681 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002682 -C "Processing of the Certificate handshake message failed" \
2683 -c "Ciphersuite is TLS-"
2684
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002685run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002686 "$O_SRV -key data_files/server2.key \
2687 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002688 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002689 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2690 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002691 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002692 -C "Processing of the Certificate handshake message failed" \
2693 -c "Ciphersuite is TLS-"
2694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002695run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002696 "$O_SRV -key data_files/server2.key \
2697 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002698 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002699 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2700 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002701 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002702 -C "Processing of the Certificate handshake message failed" \
2703 -c "Ciphersuite is TLS-"
2704
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002705run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002706 "$O_SRV -key data_files/server2.key \
2707 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002708 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002709 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2710 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002711 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002712 -c "Processing of the Certificate handshake message failed" \
2713 -C "Ciphersuite is TLS-"
2714
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002715run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2716 "$O_SRV -key data_files/server2.key \
2717 -cert data_files/server2.ku-ke.crt" \
2718 "$P_CLI debug_level=1 auth_mode=optional \
2719 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2720 0 \
2721 -c "bad certificate (usage extensions)" \
2722 -C "Processing of the Certificate handshake message failed" \
2723 -c "Ciphersuite is TLS-" \
2724 -c "! Usage does not match the keyUsage extension"
2725
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002726run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002727 "$O_SRV -key data_files/server2.key \
2728 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002729 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002730 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2731 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002732 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002733 -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 "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002737 "$O_SRV -key data_files/server2.key \
2738 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002739 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002740 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2741 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002742 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002743 -c "Processing of the Certificate handshake message failed" \
2744 -C "Ciphersuite is TLS-"
2745
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002746run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2747 "$O_SRV -key data_files/server2.key \
2748 -cert data_files/server2.ku-ds.crt" \
2749 "$P_CLI debug_level=1 auth_mode=optional \
2750 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2751 0 \
2752 -c "bad certificate (usage extensions)" \
2753 -C "Processing of the Certificate handshake message failed" \
2754 -c "Ciphersuite is TLS-" \
2755 -c "! Usage does not match the keyUsage extension"
2756
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002757# Tests for keyUsage in leaf certificates, part 3:
2758# server-side checking of client cert
2759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002760run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002761 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002762 "$O_CLI -key data_files/server2.key \
2763 -cert data_files/server2.ku-ds.crt" \
2764 0 \
2765 -S "bad certificate (usage extensions)" \
2766 -S "Processing of the Certificate handshake message failed"
2767
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002768run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002769 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002770 "$O_CLI -key data_files/server2.key \
2771 -cert data_files/server2.ku-ke.crt" \
2772 0 \
2773 -s "bad certificate (usage extensions)" \
2774 -S "Processing of the Certificate handshake message failed"
2775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002776run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002777 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002778 "$O_CLI -key data_files/server2.key \
2779 -cert data_files/server2.ku-ke.crt" \
2780 1 \
2781 -s "bad certificate (usage extensions)" \
2782 -s "Processing of the Certificate handshake message failed"
2783
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002784run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002785 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002786 "$O_CLI -key data_files/server5.key \
2787 -cert data_files/server5.ku-ds.crt" \
2788 0 \
2789 -S "bad certificate (usage extensions)" \
2790 -S "Processing of the Certificate handshake message failed"
2791
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002792run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002793 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002794 "$O_CLI -key data_files/server5.key \
2795 -cert data_files/server5.ku-ka.crt" \
2796 0 \
2797 -s "bad certificate (usage extensions)" \
2798 -S "Processing of the Certificate handshake message failed"
2799
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002800# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2801
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002802run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002803 "$P_SRV key_file=data_files/server5.key \
2804 crt_file=data_files/server5.eku-srv.crt" \
2805 "$P_CLI" \
2806 0
2807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002808run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002809 "$P_SRV key_file=data_files/server5.key \
2810 crt_file=data_files/server5.eku-srv.crt" \
2811 "$P_CLI" \
2812 0
2813
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002814run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002815 "$P_SRV key_file=data_files/server5.key \
2816 crt_file=data_files/server5.eku-cs_any.crt" \
2817 "$P_CLI" \
2818 0
2819
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002820run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002821 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002822 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002823 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002824 1
2825
2826# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2827
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002828run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002829 "$O_SRV -key data_files/server5.key \
2830 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002831 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002832 0 \
2833 -C "bad certificate (usage extensions)" \
2834 -C "Processing of the Certificate handshake message failed" \
2835 -c "Ciphersuite is TLS-"
2836
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002837run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002838 "$O_SRV -key data_files/server5.key \
2839 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002840 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002841 0 \
2842 -C "bad certificate (usage extensions)" \
2843 -C "Processing of the Certificate handshake message failed" \
2844 -c "Ciphersuite is TLS-"
2845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002846run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002847 "$O_SRV -key data_files/server5.key \
2848 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002849 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002850 0 \
2851 -C "bad certificate (usage extensions)" \
2852 -C "Processing of the Certificate handshake message failed" \
2853 -c "Ciphersuite is TLS-"
2854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002855run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002856 "$O_SRV -key data_files/server5.key \
2857 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002858 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002859 1 \
2860 -c "bad certificate (usage extensions)" \
2861 -c "Processing of the Certificate handshake message failed" \
2862 -C "Ciphersuite is TLS-"
2863
2864# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002866run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002867 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002868 "$O_CLI -key data_files/server5.key \
2869 -cert data_files/server5.eku-cli.crt" \
2870 0 \
2871 -S "bad certificate (usage extensions)" \
2872 -S "Processing of the Certificate handshake message failed"
2873
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002874run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002875 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002876 "$O_CLI -key data_files/server5.key \
2877 -cert data_files/server5.eku-srv_cli.crt" \
2878 0 \
2879 -S "bad certificate (usage extensions)" \
2880 -S "Processing of the Certificate handshake message failed"
2881
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002882run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002883 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002884 "$O_CLI -key data_files/server5.key \
2885 -cert data_files/server5.eku-cs_any.crt" \
2886 0 \
2887 -S "bad certificate (usage extensions)" \
2888 -S "Processing of the Certificate handshake message failed"
2889
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002890run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002891 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002892 "$O_CLI -key data_files/server5.key \
2893 -cert data_files/server5.eku-cs.crt" \
2894 0 \
2895 -s "bad certificate (usage extensions)" \
2896 -S "Processing of the Certificate handshake message failed"
2897
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002898run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002899 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002900 "$O_CLI -key data_files/server5.key \
2901 -cert data_files/server5.eku-cs.crt" \
2902 1 \
2903 -s "bad certificate (usage extensions)" \
2904 -s "Processing of the Certificate handshake message failed"
2905
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002906# Tests for DHM parameters loading
2907
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002908run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002909 "$P_SRV" \
2910 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2911 debug_level=3" \
2912 0 \
2913 -c "value of 'DHM: P ' (2048 bits)" \
2914 -c "value of 'DHM: G ' (2048 bits)"
2915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002916run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002917 "$P_SRV dhm_file=data_files/dhparams.pem" \
2918 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2919 debug_level=3" \
2920 0 \
2921 -c "value of 'DHM: P ' (1024 bits)" \
2922 -c "value of 'DHM: G ' (2 bits)"
2923
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002924# Tests for DHM client-side size checking
2925
2926run_test "DHM size: server default, client default, OK" \
2927 "$P_SRV" \
2928 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2929 debug_level=1" \
2930 0 \
2931 -C "DHM prime too short:"
2932
2933run_test "DHM size: server default, client 2048, OK" \
2934 "$P_SRV" \
2935 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2936 debug_level=1 dhmlen=2048" \
2937 0 \
2938 -C "DHM prime too short:"
2939
2940run_test "DHM size: server 1024, client default, OK" \
2941 "$P_SRV dhm_file=data_files/dhparams.pem" \
2942 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2943 debug_level=1" \
2944 0 \
2945 -C "DHM prime too short:"
2946
2947run_test "DHM size: server 1000, client default, rejected" \
2948 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2949 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2950 debug_level=1" \
2951 1 \
2952 -c "DHM prime too short:"
2953
2954run_test "DHM size: server default, client 2049, rejected" \
2955 "$P_SRV" \
2956 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2957 debug_level=1 dhmlen=2049" \
2958 1 \
2959 -c "DHM prime too short:"
2960
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002961# Tests for PSK callback
2962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002963run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002964 "$P_SRV psk=abc123 psk_identity=foo" \
2965 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2966 psk_identity=foo psk=abc123" \
2967 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002968 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002969 -S "SSL - Unknown identity received" \
2970 -S "SSL - Verification of the message MAC failed"
2971
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002972run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002973 "$P_SRV" \
2974 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2975 psk_identity=foo psk=abc123" \
2976 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002977 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002978 -S "SSL - Unknown identity received" \
2979 -S "SSL - Verification of the message MAC failed"
2980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002981run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002982 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2983 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2984 psk_identity=foo psk=abc123" \
2985 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002986 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002987 -s "SSL - Unknown identity received" \
2988 -S "SSL - Verification of the message MAC failed"
2989
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002990run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002991 "$P_SRV psk_list=abc,dead,def,beef" \
2992 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2993 psk_identity=abc psk=dead" \
2994 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002995 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002996 -S "SSL - Unknown identity received" \
2997 -S "SSL - Verification of the message MAC failed"
2998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002999run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003000 "$P_SRV psk_list=abc,dead,def,beef" \
3001 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3002 psk_identity=def psk=beef" \
3003 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003004 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003005 -S "SSL - Unknown identity received" \
3006 -S "SSL - Verification of the message MAC failed"
3007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003008run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003009 "$P_SRV psk_list=abc,dead,def,beef" \
3010 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3011 psk_identity=ghi psk=beef" \
3012 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003013 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003014 -s "SSL - Unknown identity received" \
3015 -S "SSL - Verification of the message MAC failed"
3016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003017run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003018 "$P_SRV psk_list=abc,dead,def,beef" \
3019 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3020 psk_identity=abc psk=beef" \
3021 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003022 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003023 -S "SSL - Unknown identity received" \
3024 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003025
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003026# Tests for EC J-PAKE
3027
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003028requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003029run_test "ECJPAKE: client not configured" \
3030 "$P_SRV debug_level=3" \
3031 "$P_CLI debug_level=3" \
3032 0 \
3033 -C "add ciphersuite: c0ff" \
3034 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003035 -S "found ecjpake kkpp extension" \
3036 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003037 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003038 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003039 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003040 -S "None of the common ciphersuites is usable"
3041
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003042requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003043run_test "ECJPAKE: server not configured" \
3044 "$P_SRV debug_level=3" \
3045 "$P_CLI debug_level=3 ecjpake_pw=bla \
3046 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3047 1 \
3048 -c "add ciphersuite: c0ff" \
3049 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003050 -s "found ecjpake kkpp extension" \
3051 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003052 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003053 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003054 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003055 -s "None of the common ciphersuites is usable"
3056
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003057requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003058run_test "ECJPAKE: working, TLS" \
3059 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3060 "$P_CLI debug_level=3 ecjpake_pw=bla \
3061 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003062 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003063 -c "add ciphersuite: c0ff" \
3064 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003065 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003066 -s "found ecjpake kkpp extension" \
3067 -S "skip ecjpake kkpp extension" \
3068 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003069 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003070 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003071 -S "None of the common ciphersuites is usable" \
3072 -S "SSL - Verification of the message MAC failed"
3073
Janos Follath74537a62016-09-02 13:45:28 +01003074server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003075requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003076run_test "ECJPAKE: password mismatch, TLS" \
3077 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3078 "$P_CLI debug_level=3 ecjpake_pw=bad \
3079 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3080 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003081 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003082 -s "SSL - Verification of the message MAC failed"
3083
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003084requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003085run_test "ECJPAKE: working, DTLS" \
3086 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3087 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3088 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3089 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003090 -c "re-using cached ecjpake parameters" \
3091 -S "SSL - Verification of the message MAC failed"
3092
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003093requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003094run_test "ECJPAKE: working, DTLS, no cookie" \
3095 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3096 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3097 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3098 0 \
3099 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003100 -S "SSL - Verification of the message MAC failed"
3101
Janos Follath74537a62016-09-02 13:45:28 +01003102server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003103requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003104run_test "ECJPAKE: password mismatch, DTLS" \
3105 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3106 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3107 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3108 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003109 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003110 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003111
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003112# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003113requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003114run_test "ECJPAKE: working, DTLS, nolog" \
3115 "$P_SRV dtls=1 ecjpake_pw=bla" \
3116 "$P_CLI dtls=1 ecjpake_pw=bla \
3117 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3118 0
3119
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003120# Tests for ciphersuites per version
3121
Janos Follathe2681a42016-03-07 15:57:05 +00003122requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003123run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003124 "$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 +02003125 "$P_CLI force_version=ssl3" \
3126 0 \
3127 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3128
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003129run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003130 "$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 +01003131 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003132 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003133 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003134
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003135run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003136 "$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 +02003137 "$P_CLI force_version=tls1_1" \
3138 0 \
3139 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003141run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003142 "$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 +02003143 "$P_CLI force_version=tls1_2" \
3144 0 \
3145 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3146
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003147# Test for ClientHello without extensions
3148
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003149requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003150run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003151 "$P_SRV debug_level=3" \
3152 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3153 0 \
3154 -s "dumping 'client hello extensions' (0 bytes)"
3155
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003156requires_gnutls
3157run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3158 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3159 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3160 0 \
3161 -s "dumping 'client hello extensions' (0 bytes)"
3162
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003163# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003164
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003165run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003166 "$P_SRV" \
3167 "$P_CLI request_size=100" \
3168 0 \
3169 -s "Read from client: 100 bytes read$"
3170
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003171run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003172 "$P_SRV" \
3173 "$P_CLI request_size=500" \
3174 0 \
3175 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003176
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003177# Tests for small packets
3178
Janos Follathe2681a42016-03-07 15:57:05 +00003179requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003180run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003181 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003182 "$P_CLI request_size=1 force_version=ssl3 \
3183 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3184 0 \
3185 -s "Read from client: 1 bytes read"
3186
Janos Follathe2681a42016-03-07 15:57:05 +00003187requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003188run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003189 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003190 "$P_CLI request_size=1 force_version=ssl3 \
3191 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3192 0 \
3193 -s "Read from client: 1 bytes read"
3194
3195run_test "Small packet TLS 1.0 BlockCipher" \
3196 "$P_SRV" \
3197 "$P_CLI request_size=1 force_version=tls1 \
3198 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3199 0 \
3200 -s "Read from client: 1 bytes read"
3201
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003202run_test "Small packet TLS 1.0 BlockCipher without EtM" \
3203 "$P_SRV" \
3204 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3205 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3206 0 \
3207 -s "Read from client: 1 bytes read"
3208
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003209run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
3210 "$P_SRV" \
3211 "$P_CLI request_size=1 force_version=tls1 \
3212 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3213 trunc_hmac=1" \
3214 0 \
3215 -s "Read from client: 1 bytes read"
3216
3217run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003218 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003219 "$P_CLI request_size=1 force_version=tls1 \
3220 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3221 trunc_hmac=1" \
3222 0 \
3223 -s "Read from client: 1 bytes read"
3224
3225run_test "Small packet TLS 1.1 BlockCipher" \
3226 "$P_SRV" \
3227 "$P_CLI request_size=1 force_version=tls1_1 \
3228 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3229 0 \
3230 -s "Read from client: 1 bytes read"
3231
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003232run_test "Small packet TLS 1.1 BlockCipher without EtM" \
3233 "$P_SRV" \
3234 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
3235 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3236 0 \
3237 -s "Read from client: 1 bytes read"
3238
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003239run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003240 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003241 "$P_CLI request_size=1 force_version=tls1_1 \
3242 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3243 0 \
3244 -s "Read from client: 1 bytes read"
3245
3246run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3247 "$P_SRV" \
3248 "$P_CLI request_size=1 force_version=tls1_1 \
3249 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3250 trunc_hmac=1" \
3251 0 \
3252 -s "Read from client: 1 bytes read"
3253
3254run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003255 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003256 "$P_CLI request_size=1 force_version=tls1_1 \
3257 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3258 trunc_hmac=1" \
3259 0 \
3260 -s "Read from client: 1 bytes read"
3261
3262run_test "Small packet TLS 1.2 BlockCipher" \
3263 "$P_SRV" \
3264 "$P_CLI request_size=1 force_version=tls1_2 \
3265 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3266 0 \
3267 -s "Read from client: 1 bytes read"
3268
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003269run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3270 "$P_SRV" \
3271 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3272 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3273 0 \
3274 -s "Read from client: 1 bytes read"
3275
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003276run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3277 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003278 "$P_CLI request_size=1 force_version=tls1_2 \
3279 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003280 0 \
3281 -s "Read from client: 1 bytes read"
3282
3283run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3284 "$P_SRV" \
3285 "$P_CLI request_size=1 force_version=tls1_2 \
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
3291run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003292 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003293 "$P_CLI request_size=1 force_version=tls1_2 \
3294 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3295 0 \
3296 -s "Read from client: 1 bytes read"
3297
3298run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003299 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003300 "$P_CLI request_size=1 force_version=tls1_2 \
3301 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3302 trunc_hmac=1" \
3303 0 \
3304 -s "Read from client: 1 bytes read"
3305
3306run_test "Small packet TLS 1.2 AEAD" \
3307 "$P_SRV" \
3308 "$P_CLI request_size=1 force_version=tls1_2 \
3309 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3310 0 \
3311 -s "Read from client: 1 bytes read"
3312
3313run_test "Small packet TLS 1.2 AEAD shorter tag" \
3314 "$P_SRV" \
3315 "$P_CLI request_size=1 force_version=tls1_2 \
3316 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3317 0 \
3318 -s "Read from client: 1 bytes read"
3319
Janos Follath00efff72016-05-06 13:48:23 +01003320# A test for extensions in SSLv3
3321
3322requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3323run_test "SSLv3 with extensions, server side" \
3324 "$P_SRV min_version=ssl3 debug_level=3" \
3325 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3326 0 \
3327 -S "dumping 'client hello extensions'" \
3328 -S "server hello, total extension length:"
3329
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003330# Test for large packets
3331
Janos Follathe2681a42016-03-07 15:57:05 +00003332requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003333run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003334 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003335 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003336 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3337 0 \
3338 -s "Read from client: 16384 bytes read"
3339
Janos Follathe2681a42016-03-07 15:57:05 +00003340requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003341run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003342 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003343 "$P_CLI request_size=16384 force_version=ssl3 \
3344 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3345 0 \
3346 -s "Read from client: 16384 bytes read"
3347
3348run_test "Large packet TLS 1.0 BlockCipher" \
3349 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003350 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003351 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3352 0 \
3353 -s "Read from client: 16384 bytes read"
3354
3355run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3356 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003357 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003358 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3359 trunc_hmac=1" \
3360 0 \
3361 -s "Read from client: 16384 bytes read"
3362
3363run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003364 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003365 "$P_CLI request_size=16384 force_version=tls1 \
3366 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3367 trunc_hmac=1" \
3368 0 \
3369 -s "Read from client: 16384 bytes read"
3370
3371run_test "Large packet TLS 1.1 BlockCipher" \
3372 "$P_SRV" \
3373 "$P_CLI request_size=16384 force_version=tls1_1 \
3374 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3375 0 \
3376 -s "Read from client: 16384 bytes read"
3377
3378run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003379 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003380 "$P_CLI request_size=16384 force_version=tls1_1 \
3381 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3382 0 \
3383 -s "Read from client: 16384 bytes read"
3384
3385run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3386 "$P_SRV" \
3387 "$P_CLI request_size=16384 force_version=tls1_1 \
3388 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3389 trunc_hmac=1" \
3390 0 \
3391 -s "Read from client: 16384 bytes read"
3392
3393run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003394 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003395 "$P_CLI request_size=16384 force_version=tls1_1 \
3396 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3397 trunc_hmac=1" \
3398 0 \
3399 -s "Read from client: 16384 bytes read"
3400
3401run_test "Large packet TLS 1.2 BlockCipher" \
3402 "$P_SRV" \
3403 "$P_CLI request_size=16384 force_version=tls1_2 \
3404 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3405 0 \
3406 -s "Read from client: 16384 bytes read"
3407
3408run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3409 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003410 "$P_CLI request_size=16384 force_version=tls1_2 \
3411 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003412 0 \
3413 -s "Read from client: 16384 bytes read"
3414
3415run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3416 "$P_SRV" \
3417 "$P_CLI request_size=16384 force_version=tls1_2 \
3418 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3419 trunc_hmac=1" \
3420 0 \
3421 -s "Read from client: 16384 bytes read"
3422
3423run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003424 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003425 "$P_CLI request_size=16384 force_version=tls1_2 \
3426 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3427 0 \
3428 -s "Read from client: 16384 bytes read"
3429
3430run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003431 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003432 "$P_CLI request_size=16384 force_version=tls1_2 \
3433 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3434 trunc_hmac=1" \
3435 0 \
3436 -s "Read from client: 16384 bytes read"
3437
3438run_test "Large packet TLS 1.2 AEAD" \
3439 "$P_SRV" \
3440 "$P_CLI request_size=16384 force_version=tls1_2 \
3441 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3442 0 \
3443 -s "Read from client: 16384 bytes read"
3444
3445run_test "Large packet TLS 1.2 AEAD shorter tag" \
3446 "$P_SRV" \
3447 "$P_CLI request_size=16384 force_version=tls1_2 \
3448 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3449 0 \
3450 -s "Read from client: 16384 bytes read"
3451
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003452# Tests for DTLS HelloVerifyRequest
3453
3454run_test "DTLS cookie: enabled" \
3455 "$P_SRV dtls=1 debug_level=2" \
3456 "$P_CLI dtls=1 debug_level=2" \
3457 0 \
3458 -s "cookie verification failed" \
3459 -s "cookie verification passed" \
3460 -S "cookie verification skipped" \
3461 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003462 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003463 -S "SSL - The requested feature is not available"
3464
3465run_test "DTLS cookie: disabled" \
3466 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3467 "$P_CLI dtls=1 debug_level=2" \
3468 0 \
3469 -S "cookie verification failed" \
3470 -S "cookie verification passed" \
3471 -s "cookie verification skipped" \
3472 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003473 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003474 -S "SSL - The requested feature is not available"
3475
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003476run_test "DTLS cookie: default (failing)" \
3477 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3478 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3479 1 \
3480 -s "cookie verification failed" \
3481 -S "cookie verification passed" \
3482 -S "cookie verification skipped" \
3483 -C "received hello verify request" \
3484 -S "hello verification requested" \
3485 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003486
3487requires_ipv6
3488run_test "DTLS cookie: enabled, IPv6" \
3489 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3490 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3491 0 \
3492 -s "cookie verification failed" \
3493 -s "cookie verification passed" \
3494 -S "cookie verification skipped" \
3495 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003496 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003497 -S "SSL - The requested feature is not available"
3498
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003499run_test "DTLS cookie: enabled, nbio" \
3500 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3501 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3502 0 \
3503 -s "cookie verification failed" \
3504 -s "cookie verification passed" \
3505 -S "cookie verification skipped" \
3506 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003507 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003508 -S "SSL - The requested feature is not available"
3509
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003510# Tests for client reconnecting from the same port with DTLS
3511
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003512not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003513run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003514 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3515 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003516 0 \
3517 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003518 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003519 -S "Client initiated reconnection from same port"
3520
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003521not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003522run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003523 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3524 "$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 +02003525 0 \
3526 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003527 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003528 -s "Client initiated reconnection from same port"
3529
Paul Bakker362689d2016-05-13 10:33:25 +01003530not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3531run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003532 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3533 "$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 +02003534 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003535 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003536 -s "Client initiated reconnection from same port"
3537
Paul Bakker362689d2016-05-13 10:33:25 +01003538only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3539run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3540 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3541 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3542 0 \
3543 -S "The operation timed out" \
3544 -s "Client initiated reconnection from same port"
3545
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003546run_test "DTLS client reconnect from same port: no cookies" \
3547 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003548 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3549 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003550 -s "The operation timed out" \
3551 -S "Client initiated reconnection from same port"
3552
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003553# Tests for various cases of client authentication with DTLS
3554# (focused on handshake flows and message parsing)
3555
3556run_test "DTLS client auth: required" \
3557 "$P_SRV dtls=1 auth_mode=required" \
3558 "$P_CLI dtls=1" \
3559 0 \
3560 -s "Verifying peer X.509 certificate... ok"
3561
3562run_test "DTLS client auth: optional, client has no cert" \
3563 "$P_SRV dtls=1 auth_mode=optional" \
3564 "$P_CLI dtls=1 crt_file=none key_file=none" \
3565 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003566 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003567
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003568run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003569 "$P_SRV dtls=1 auth_mode=none" \
3570 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3571 0 \
3572 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003573 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003574
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003575run_test "DTLS wrong PSK: badmac alert" \
3576 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3577 "$P_CLI dtls=1 psk=abc124" \
3578 1 \
3579 -s "SSL - Verification of the message MAC failed" \
3580 -c "SSL - A fatal alert message was received from our peer"
3581
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003582# Tests for receiving fragmented handshake messages with DTLS
3583
3584requires_gnutls
3585run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3586 "$G_SRV -u --mtu 2048 -a" \
3587 "$P_CLI dtls=1 debug_level=2" \
3588 0 \
3589 -C "found fragmented DTLS handshake message" \
3590 -C "error"
3591
3592requires_gnutls
3593run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3594 "$G_SRV -u --mtu 512" \
3595 "$P_CLI dtls=1 debug_level=2" \
3596 0 \
3597 -c "found fragmented DTLS handshake message" \
3598 -C "error"
3599
3600requires_gnutls
3601run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3602 "$G_SRV -u --mtu 128" \
3603 "$P_CLI dtls=1 debug_level=2" \
3604 0 \
3605 -c "found fragmented DTLS handshake message" \
3606 -C "error"
3607
3608requires_gnutls
3609run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3610 "$G_SRV -u --mtu 128" \
3611 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3612 0 \
3613 -c "found fragmented DTLS handshake message" \
3614 -C "error"
3615
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003616requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003617run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3618 "$G_SRV -u --mtu 256" \
3619 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3620 0 \
3621 -c "found fragmented DTLS handshake message" \
3622 -c "client hello, adding renegotiation extension" \
3623 -c "found renegotiation extension" \
3624 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003625 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003626 -C "error" \
3627 -s "Extra-header:"
3628
3629requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003630run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3631 "$G_SRV -u --mtu 256" \
3632 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3633 0 \
3634 -c "found fragmented DTLS handshake message" \
3635 -c "client hello, adding renegotiation extension" \
3636 -c "found renegotiation extension" \
3637 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003638 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003639 -C "error" \
3640 -s "Extra-header:"
3641
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003642run_test "DTLS reassembly: no fragmentation (openssl server)" \
3643 "$O_SRV -dtls1 -mtu 2048" \
3644 "$P_CLI dtls=1 debug_level=2" \
3645 0 \
3646 -C "found fragmented DTLS handshake message" \
3647 -C "error"
3648
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003649run_test "DTLS reassembly: some fragmentation (openssl server)" \
3650 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003651 "$P_CLI dtls=1 debug_level=2" \
3652 0 \
3653 -c "found fragmented DTLS handshake message" \
3654 -C "error"
3655
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003656run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003657 "$O_SRV -dtls1 -mtu 256" \
3658 "$P_CLI dtls=1 debug_level=2" \
3659 0 \
3660 -c "found fragmented DTLS handshake message" \
3661 -C "error"
3662
3663run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3664 "$O_SRV -dtls1 -mtu 256" \
3665 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3666 0 \
3667 -c "found fragmented DTLS handshake message" \
3668 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003669
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003670# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003671
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003672not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003673run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003674 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003675 "$P_SRV dtls=1 debug_level=2" \
3676 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003677 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003678 -C "replayed record" \
3679 -S "replayed record" \
3680 -C "record from another epoch" \
3681 -S "record from another epoch" \
3682 -C "discarding invalid record" \
3683 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003684 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003685 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003686 -c "HTTP/1.0 200 OK"
3687
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003688not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003689run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003690 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003691 "$P_SRV dtls=1 debug_level=2" \
3692 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003693 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003694 -c "replayed record" \
3695 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003696 -c "discarding invalid record" \
3697 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003698 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003699 -s "Extra-header:" \
3700 -c "HTTP/1.0 200 OK"
3701
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003702run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3703 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003704 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3705 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003706 0 \
3707 -c "replayed record" \
3708 -S "replayed record" \
3709 -c "discarding invalid record" \
3710 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003711 -c "resend" \
3712 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003713 -s "Extra-header:" \
3714 -c "HTTP/1.0 200 OK"
3715
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003716run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003717 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003718 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003719 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003720 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003721 -c "discarding invalid record (mac)" \
3722 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003723 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003724 -c "HTTP/1.0 200 OK" \
3725 -S "too many records with bad MAC" \
3726 -S "Verification of the message MAC failed"
3727
3728run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3729 -p "$P_PXY bad_ad=1" \
3730 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3731 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3732 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003733 -C "discarding invalid record (mac)" \
3734 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003735 -S "Extra-header:" \
3736 -C "HTTP/1.0 200 OK" \
3737 -s "too many records with bad MAC" \
3738 -s "Verification of the message MAC failed"
3739
3740run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3741 -p "$P_PXY bad_ad=1" \
3742 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3743 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3744 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003745 -c "discarding invalid record (mac)" \
3746 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003747 -s "Extra-header:" \
3748 -c "HTTP/1.0 200 OK" \
3749 -S "too many records with bad MAC" \
3750 -S "Verification of the message MAC failed"
3751
3752run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3753 -p "$P_PXY bad_ad=1" \
3754 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3755 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3756 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003757 -c "discarding invalid record (mac)" \
3758 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003759 -s "Extra-header:" \
3760 -c "HTTP/1.0 200 OK" \
3761 -s "too many records with bad MAC" \
3762 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003763
3764run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003765 -p "$P_PXY delay_ccs=1" \
3766 "$P_SRV dtls=1 debug_level=1" \
3767 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003768 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003769 -c "record from another epoch" \
3770 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003771 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003772 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003773 -s "Extra-header:" \
3774 -c "HTTP/1.0 200 OK"
3775
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003776# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003777
Janos Follath74537a62016-09-02 13:45:28 +01003778client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003779run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003780 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003781 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3782 psk=abc123" \
3783 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003784 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3785 0 \
3786 -s "Extra-header:" \
3787 -c "HTTP/1.0 200 OK"
3788
Janos Follath74537a62016-09-02 13:45:28 +01003789client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003790run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3791 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003792 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3793 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003794 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3795 0 \
3796 -s "Extra-header:" \
3797 -c "HTTP/1.0 200 OK"
3798
Janos Follath74537a62016-09-02 13:45:28 +01003799client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003800run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3801 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003802 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3803 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003804 0 \
3805 -s "Extra-header:" \
3806 -c "HTTP/1.0 200 OK"
3807
Janos Follath74537a62016-09-02 13:45:28 +01003808client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003809run_test "DTLS proxy: 3d, FS, client auth" \
3810 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003811 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3812 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003813 0 \
3814 -s "Extra-header:" \
3815 -c "HTTP/1.0 200 OK"
3816
Janos Follath74537a62016-09-02 13:45:28 +01003817client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003818run_test "DTLS proxy: 3d, FS, ticket" \
3819 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003820 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3821 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003822 0 \
3823 -s "Extra-header:" \
3824 -c "HTTP/1.0 200 OK"
3825
Janos Follath74537a62016-09-02 13:45:28 +01003826client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003827run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3828 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003829 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3830 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003831 0 \
3832 -s "Extra-header:" \
3833 -c "HTTP/1.0 200 OK"
3834
Janos Follath74537a62016-09-02 13:45:28 +01003835client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003836run_test "DTLS proxy: 3d, max handshake, nbio" \
3837 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003838 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3839 auth_mode=required" \
3840 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003841 0 \
3842 -s "Extra-header:" \
3843 -c "HTTP/1.0 200 OK"
3844
Janos Follath74537a62016-09-02 13:45:28 +01003845client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003846run_test "DTLS proxy: 3d, min handshake, resumption" \
3847 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3848 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3849 psk=abc123 debug_level=3" \
3850 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3851 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3852 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3853 0 \
3854 -s "a session has been resumed" \
3855 -c "a session has been resumed" \
3856 -s "Extra-header:" \
3857 -c "HTTP/1.0 200 OK"
3858
Janos Follath74537a62016-09-02 13:45:28 +01003859client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003860run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3861 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3862 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3863 psk=abc123 debug_level=3 nbio=2" \
3864 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3865 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3866 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3867 0 \
3868 -s "a session has been resumed" \
3869 -c "a session has been resumed" \
3870 -s "Extra-header:" \
3871 -c "HTTP/1.0 200 OK"
3872
Janos Follath74537a62016-09-02 13:45:28 +01003873client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003874run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003875 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003876 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3877 psk=abc123 renegotiation=1 debug_level=2" \
3878 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3879 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003880 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3881 0 \
3882 -c "=> renegotiate" \
3883 -s "=> renegotiate" \
3884 -s "Extra-header:" \
3885 -c "HTTP/1.0 200 OK"
3886
Janos Follath74537a62016-09-02 13:45:28 +01003887client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003888run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3889 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003890 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3891 psk=abc123 renegotiation=1 debug_level=2" \
3892 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3893 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003894 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3895 0 \
3896 -c "=> renegotiate" \
3897 -s "=> renegotiate" \
3898 -s "Extra-header:" \
3899 -c "HTTP/1.0 200 OK"
3900
Janos Follath74537a62016-09-02 13:45:28 +01003901client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003902run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003903 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003904 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003905 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003906 debug_level=2" \
3907 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003908 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003909 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3910 0 \
3911 -c "=> renegotiate" \
3912 -s "=> renegotiate" \
3913 -s "Extra-header:" \
3914 -c "HTTP/1.0 200 OK"
3915
Janos Follath74537a62016-09-02 13:45:28 +01003916client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003917run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003918 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003919 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003920 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003921 debug_level=2 nbio=2" \
3922 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003923 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003924 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3925 0 \
3926 -c "=> renegotiate" \
3927 -s "=> renegotiate" \
3928 -s "Extra-header:" \
3929 -c "HTTP/1.0 200 OK"
3930
Janos Follath74537a62016-09-02 13:45:28 +01003931client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003932not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003933run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003934 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3935 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003936 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003937 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003938 -c "HTTP/1.0 200 OK"
3939
Janos Follath74537a62016-09-02 13:45:28 +01003940client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003941not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003942run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3943 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3944 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003945 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003946 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003947 -c "HTTP/1.0 200 OK"
3948
Janos Follath74537a62016-09-02 13:45:28 +01003949client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003950not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003951run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3952 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3953 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003954 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003955 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003956 -c "HTTP/1.0 200 OK"
3957
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003958requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003959client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003960not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003961run_test "DTLS proxy: 3d, gnutls server" \
3962 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3963 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003964 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003965 0 \
3966 -s "Extra-header:" \
3967 -c "Extra-header:"
3968
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003969requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003970client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003971not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003972run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3973 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3974 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003975 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003976 0 \
3977 -s "Extra-header:" \
3978 -c "Extra-header:"
3979
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003980requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003981client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003982not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003983run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3984 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3985 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003986 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003987 0 \
3988 -s "Extra-header:" \
3989 -c "Extra-header:"
3990
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003991# Final report
3992
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003993echo "------------------------------------------------------------------------"
3994
3995if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003996 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003997else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003998 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003999fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004000PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004001echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004002
4003exit $FAILS