blob: 7f5510cce1232c354e9133252474360455644b40 [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
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200446 # terminate the server (and the proxy)
447 kill $SRV_PID
448 wait $SRV_PID
449 if [ -n "$PXY_CMD" ]; then
450 kill $PXY_PID >/dev/null 2>&1
451 wait $PXY_PID
452 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100453
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200454 # retry only on timeouts
455 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
456 printf "RETRY "
457 else
458 TIMES_LEFT=0
459 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200460 done
461
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100462 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200463 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100464 # expected client exit to incorrectly succeed in case of catastrophic
465 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100466 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200467 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100468 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100469 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100470 return
471 fi
472 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100473 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200474 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100475 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100476 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100477 return
478 fi
479 fi
480
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100481 # check server exit code
482 if [ $? != 0 ]; then
483 fail "server fail"
484 return
485 fi
486
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100487 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100488 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
489 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100490 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200491 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100492 return
493 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100494
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100495 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200496 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100497 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100498 while [ $# -gt 0 ]
499 do
500 case $1 in
501 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100502 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 +0100503 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100504 return
505 fi
506 ;;
507
508 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100509 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 +0100510 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100511 return
512 fi
513 ;;
514
515 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100516 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 +0100517 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100518 return
519 fi
520 ;;
521
522 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100523 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 +0100524 fail "pattern '$2' MUST NOT be present in the Client output"
525 return
526 fi
527 ;;
528
529 # The filtering in the following two options (-u and -U) do the following
530 # - ignore valgrind output
531 # - filter out everything but lines right after the pattern occurances
532 # - keep one of each non-unique line
533 # - count how many lines remain
534 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
535 # if there were no duplicates.
536 "-U")
537 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
538 fail "lines following pattern '$2' must be unique in Server output"
539 return
540 fi
541 ;;
542
543 "-u")
544 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
545 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100546 return
547 fi
548 ;;
549
550 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200551 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100552 exit 1
553 esac
554 shift 2
555 done
556
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100557 # check valgrind's results
558 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200559 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100560 fail "Server has memory errors"
561 return
562 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200563 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100564 fail "Client has memory errors"
565 return
566 fi
567 fi
568
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100569 # if we're here, everything is ok
570 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100571 if [ "$PRESERVE_LOGS" -gt 0 ]; then
572 mv $SRV_OUT o-srv-${TESTS}.log
573 mv $CLI_OUT o-cli-${TESTS}.log
574 fi
575
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200576 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100577}
578
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100579cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200580 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200581 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
582 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
583 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
584 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100585 exit 1
586}
587
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100588#
589# MAIN
590#
591
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000592if cd $( dirname $0 ); then :; else
593 echo "cd $( dirname $0 ) failed" >&2
594 exit 1
595fi
596
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100597get_options "$@"
598
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100599# sanity checks, avoid an avalanche of errors
Hanno Becker17c04932017-10-10 14:44:53 +0100600P_SRV_BIN=$(echo "$P_SRV" | sed -r -n "s/^([^ ]*).*$/\1/p")
601echo "Server binary: ${P_SRV_BIN}"
602P_CLI_BIN=$(echo "$P_CLI" | sed -r -n "s/^([^ ]*).*$/\1/p")
603echo "Client binary: ${P_CLI_BIN}"
604P_PXY_BIN=$(echo "$P_PXY" | sed -r -n "s/^([^ ]*).*$/\1/p")
605echo "Proxy binary: ${P_PXY_BIN}"
606if [ ! -x "$P_SRV_BIN" ]; then
607 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100608 exit 1
609fi
Hanno Becker17c04932017-10-10 14:44:53 +0100610if [ ! -x "$P_CLI_BIN" ]; then
611 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100612 exit 1
613fi
Hanno Becker17c04932017-10-10 14:44:53 +0100614if [ ! -x "$P_PXY_BIN" ]; then
615 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200616 exit 1
617fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100618if [ "$MEMCHECK" -gt 0 ]; then
619 if which valgrind >/dev/null 2>&1; then :; else
620 echo "Memcheck not possible. Valgrind not found"
621 exit 1
622 fi
623fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100624if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
625 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100626 exit 1
627fi
628
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200629# used by watchdog
630MAIN_PID="$$"
631
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200632# be more patient with valgrind
633if [ "$MEMCHECK" -gt 0 ]; then
634 START_DELAY=3
635 DOG_DELAY=30
636else
637 START_DELAY=1
638 DOG_DELAY=10
639fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200640CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100641SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200642
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200643# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000644# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200645P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
646P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100647P_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 +0200648O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200649O_CLI="$O_CLI -connect localhost:+SRV_PORT"
650G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000651G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200652
Gilles Peskine62469d92017-05-10 10:13:59 +0200653# Allow SHA-1, because many of our test certificates use it
654P_SRV="$P_SRV allow_sha1=1"
655P_CLI="$P_CLI allow_sha1=1"
656
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200657# Also pick a unique name for intermediate files
658SRV_OUT="srv_out.$$"
659CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200660PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200661SESSION="session.$$"
662
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200663SKIP_NEXT="NO"
664
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100665trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100666
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200667# Basic test
668
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200669# Checks that:
670# - things work with all ciphersuites active (used with config-full in all.sh)
671# - the expected (highest security) parameters are selected
672# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200673run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200674 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200675 "$P_CLI" \
676 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200677 -s "Protocol is TLSv1.2" \
678 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
679 -s "client hello v3, signature_algorithm ext: 6" \
680 -s "ECDHE curve: secp521r1" \
681 -S "error" \
682 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200683
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000684run_test "Default, DTLS" \
685 "$P_SRV dtls=1" \
686 "$P_CLI dtls=1" \
687 0 \
688 -s "Protocol is DTLSv1.2" \
689 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
690
Simon Butcher8e004102016-10-14 00:48:33 +0100691# Test for uniqueness of IVs in AEAD ciphersuites
692run_test "Unique IV in GCM" \
693 "$P_SRV exchanges=20 debug_level=4" \
694 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
695 0 \
696 -u "IV used" \
697 -U "IV used"
698
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100699# Tests for rc4 option
700
Simon Butchera410af52016-05-19 22:12:18 +0100701requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100702run_test "RC4: server disabled, client enabled" \
703 "$P_SRV" \
704 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
705 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100706 -s "SSL - The server has no ciphersuites in common"
707
Simon Butchera410af52016-05-19 22:12:18 +0100708requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100709run_test "RC4: server half, client enabled" \
710 "$P_SRV arc4=1" \
711 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
712 1 \
713 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100714
715run_test "RC4: server enabled, client disabled" \
716 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
717 "$P_CLI" \
718 1 \
719 -s "SSL - The server has no ciphersuites in common"
720
721run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100722 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100723 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
724 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100725 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100726 -S "SSL - The server has no ciphersuites in common"
727
Gilles Peskinebc70a182017-05-09 15:59:24 +0200728# Tests for SHA-1 support
729
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200730requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200731run_test "SHA-1 forbidden by default in server certificate" \
732 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
733 "$P_CLI debug_level=2 allow_sha1=0" \
734 1 \
735 -c "The certificate is signed with an unacceptable hash"
736
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200737requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
738run_test "SHA-1 forbidden by default in server certificate" \
739 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
740 "$P_CLI debug_level=2 allow_sha1=0" \
741 0
742
Gilles Peskinebc70a182017-05-09 15:59:24 +0200743run_test "SHA-1 explicitly allowed in server certificate" \
744 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
745 "$P_CLI allow_sha1=1" \
746 0
747
748run_test "SHA-256 allowed by default in server certificate" \
749 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
750 "$P_CLI allow_sha1=0" \
751 0
752
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200753requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200754run_test "SHA-1 forbidden by default in client certificate" \
755 "$P_SRV auth_mode=required allow_sha1=0" \
756 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
757 1 \
758 -s "The certificate is signed with an unacceptable hash"
759
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200760requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
761run_test "SHA-1 forbidden by default in client certificate" \
762 "$P_SRV auth_mode=required allow_sha1=0" \
763 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
764 0
765
Gilles Peskinebc70a182017-05-09 15:59:24 +0200766run_test "SHA-1 explicitly allowed in client certificate" \
767 "$P_SRV auth_mode=required allow_sha1=1" \
768 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
769 0
770
771run_test "SHA-256 allowed by default in client certificate" \
772 "$P_SRV auth_mode=required allow_sha1=0" \
773 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
774 0
775
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100776# Tests for Truncated HMAC extension
777
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100778run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200779 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100780 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100781 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100782 -s "dumping 'computed mac' (20 bytes)" \
783 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100784
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100785run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200786 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100787 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
788 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100789 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100790 -s "dumping 'computed mac' (20 bytes)" \
791 -S "dumping 'computed mac' (10 bytes)"
792
793run_test "Truncated HMAC: client enabled, server default" \
794 "$P_SRV debug_level=4" \
795 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
796 trunc_hmac=1" \
797 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100798 -s "dumping 'computed mac' (20 bytes)" \
799 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100800
801run_test "Truncated HMAC: client enabled, server disabled" \
802 "$P_SRV debug_level=4 trunc_hmac=0" \
803 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
804 trunc_hmac=1" \
805 0 \
806 -s "dumping 'computed mac' (20 bytes)" \
807 -S "dumping 'computed mac' (10 bytes)"
808
809run_test "Truncated HMAC: client enabled, server enabled" \
810 "$P_SRV debug_level=4 trunc_hmac=1" \
811 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
812 trunc_hmac=1" \
813 0 \
814 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100815 -s "dumping 'computed mac' (10 bytes)"
816
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100817# Tests for Encrypt-then-MAC extension
818
819run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100820 "$P_SRV debug_level=3 \
821 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100822 "$P_CLI debug_level=3" \
823 0 \
824 -c "client hello, adding encrypt_then_mac extension" \
825 -s "found encrypt then mac extension" \
826 -s "server hello, adding encrypt then mac extension" \
827 -c "found encrypt_then_mac extension" \
828 -c "using encrypt then mac" \
829 -s "using encrypt then mac"
830
831run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100832 "$P_SRV debug_level=3 etm=0 \
833 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100834 "$P_CLI debug_level=3 etm=1" \
835 0 \
836 -c "client hello, adding encrypt_then_mac extension" \
837 -s "found encrypt then mac extension" \
838 -S "server hello, adding encrypt then mac extension" \
839 -C "found encrypt_then_mac extension" \
840 -C "using encrypt then mac" \
841 -S "using encrypt then mac"
842
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100843run_test "Encrypt then MAC: client enabled, aead cipher" \
844 "$P_SRV debug_level=3 etm=1 \
845 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
846 "$P_CLI debug_level=3 etm=1" \
847 0 \
848 -c "client hello, adding encrypt_then_mac extension" \
849 -s "found encrypt then mac extension" \
850 -S "server hello, adding encrypt then mac extension" \
851 -C "found encrypt_then_mac extension" \
852 -C "using encrypt then mac" \
853 -S "using encrypt then mac"
854
855run_test "Encrypt then MAC: client enabled, stream cipher" \
856 "$P_SRV debug_level=3 etm=1 \
857 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100858 "$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 +0100859 0 \
860 -c "client hello, adding encrypt_then_mac extension" \
861 -s "found encrypt then mac extension" \
862 -S "server hello, adding encrypt then mac extension" \
863 -C "found encrypt_then_mac extension" \
864 -C "using encrypt then mac" \
865 -S "using encrypt then mac"
866
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100867run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100868 "$P_SRV debug_level=3 etm=1 \
869 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100870 "$P_CLI debug_level=3 etm=0" \
871 0 \
872 -C "client hello, adding encrypt_then_mac extension" \
873 -S "found encrypt then mac extension" \
874 -S "server hello, adding encrypt then mac extension" \
875 -C "found encrypt_then_mac extension" \
876 -C "using encrypt then mac" \
877 -S "using encrypt then mac"
878
Janos Follathe2681a42016-03-07 15:57:05 +0000879requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100880run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100881 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100882 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100883 "$P_CLI debug_level=3 force_version=ssl3" \
884 0 \
885 -C "client hello, adding encrypt_then_mac extension" \
886 -S "found encrypt then mac extension" \
887 -S "server hello, adding encrypt then mac extension" \
888 -C "found encrypt_then_mac extension" \
889 -C "using encrypt then mac" \
890 -S "using encrypt then mac"
891
Janos Follathe2681a42016-03-07 15:57:05 +0000892requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100893run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100894 "$P_SRV debug_level=3 force_version=ssl3 \
895 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100896 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100897 0 \
898 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100899 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100900 -S "server hello, adding encrypt then mac extension" \
901 -C "found encrypt_then_mac extension" \
902 -C "using encrypt then mac" \
903 -S "using encrypt then mac"
904
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200905# Tests for Extended Master Secret extension
906
907run_test "Extended Master Secret: default" \
908 "$P_SRV debug_level=3" \
909 "$P_CLI debug_level=3" \
910 0 \
911 -c "client hello, adding extended_master_secret extension" \
912 -s "found extended master secret extension" \
913 -s "server hello, adding extended master secret extension" \
914 -c "found extended_master_secret extension" \
915 -c "using extended master secret" \
916 -s "using extended master secret"
917
918run_test "Extended Master Secret: client enabled, server disabled" \
919 "$P_SRV debug_level=3 extended_ms=0" \
920 "$P_CLI debug_level=3 extended_ms=1" \
921 0 \
922 -c "client hello, adding extended_master_secret extension" \
923 -s "found extended master secret extension" \
924 -S "server hello, adding extended master secret extension" \
925 -C "found extended_master_secret extension" \
926 -C "using extended master secret" \
927 -S "using extended master secret"
928
929run_test "Extended Master Secret: client disabled, server enabled" \
930 "$P_SRV debug_level=3 extended_ms=1" \
931 "$P_CLI debug_level=3 extended_ms=0" \
932 0 \
933 -C "client hello, adding extended_master_secret extension" \
934 -S "found extended master secret extension" \
935 -S "server hello, adding extended master secret extension" \
936 -C "found extended_master_secret extension" \
937 -C "using extended master secret" \
938 -S "using extended master secret"
939
Janos Follathe2681a42016-03-07 15:57:05 +0000940requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200941run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100942 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200943 "$P_CLI debug_level=3 force_version=ssl3" \
944 0 \
945 -C "client hello, adding extended_master_secret extension" \
946 -S "found extended master secret extension" \
947 -S "server hello, adding extended master secret extension" \
948 -C "found extended_master_secret extension" \
949 -C "using extended master secret" \
950 -S "using extended master secret"
951
Janos Follathe2681a42016-03-07 15:57:05 +0000952requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200953run_test "Extended Master Secret: client enabled, server SSLv3" \
954 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100955 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200956 0 \
957 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100958 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200959 -S "server hello, adding extended master secret extension" \
960 -C "found extended_master_secret extension" \
961 -C "using extended master secret" \
962 -S "using extended master secret"
963
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200964# Tests for FALLBACK_SCSV
965
966run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200967 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200968 "$P_CLI debug_level=3 force_version=tls1_1" \
969 0 \
970 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200971 -S "received FALLBACK_SCSV" \
972 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200973 -C "is a fatal alert message (msg 86)"
974
975run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200976 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200977 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
978 0 \
979 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200980 -S "received FALLBACK_SCSV" \
981 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200982 -C "is a fatal alert message (msg 86)"
983
984run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200985 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200986 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200987 1 \
988 -c "adding FALLBACK_SCSV" \
989 -s "received FALLBACK_SCSV" \
990 -s "inapropriate fallback" \
991 -c "is a fatal alert message (msg 86)"
992
993run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200994 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200995 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200996 0 \
997 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200998 -s "received FALLBACK_SCSV" \
999 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001000 -C "is a fatal alert message (msg 86)"
1001
1002requires_openssl_with_fallback_scsv
1003run_test "Fallback SCSV: default, openssl server" \
1004 "$O_SRV" \
1005 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1006 0 \
1007 -C "adding FALLBACK_SCSV" \
1008 -C "is a fatal alert message (msg 86)"
1009
1010requires_openssl_with_fallback_scsv
1011run_test "Fallback SCSV: enabled, openssl server" \
1012 "$O_SRV" \
1013 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1014 1 \
1015 -c "adding FALLBACK_SCSV" \
1016 -c "is a fatal alert message (msg 86)"
1017
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001018requires_openssl_with_fallback_scsv
1019run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001020 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001021 "$O_CLI -tls1_1" \
1022 0 \
1023 -S "received FALLBACK_SCSV" \
1024 -S "inapropriate fallback"
1025
1026requires_openssl_with_fallback_scsv
1027run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001028 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001029 "$O_CLI -tls1_1 -fallback_scsv" \
1030 1 \
1031 -s "received FALLBACK_SCSV" \
1032 -s "inapropriate fallback"
1033
1034requires_openssl_with_fallback_scsv
1035run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001036 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001037 "$O_CLI -fallback_scsv" \
1038 0 \
1039 -s "received FALLBACK_SCSV" \
1040 -S "inapropriate fallback"
1041
Gilles Peskined50177f2017-05-16 17:53:03 +02001042## ClientHello generated with
1043## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1044## then manually twiddling the ciphersuite list.
1045## The ClientHello content is spelled out below as a hex string as
1046## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1047## The expected response is an inappropriate_fallback alert.
1048requires_openssl_with_fallback_scsv
1049run_test "Fallback SCSV: beginning of list" \
1050 "$P_SRV debug_level=2" \
1051 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1052 0 \
1053 -s "received FALLBACK_SCSV" \
1054 -s "inapropriate fallback"
1055
1056requires_openssl_with_fallback_scsv
1057run_test "Fallback SCSV: end of list" \
1058 "$P_SRV debug_level=2" \
1059 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1060 0 \
1061 -s "received FALLBACK_SCSV" \
1062 -s "inapropriate fallback"
1063
1064## Here the expected response is a valid ServerHello prefix, up to the random.
1065requires_openssl_with_fallback_scsv
1066run_test "Fallback SCSV: not in list" \
1067 "$P_SRV debug_level=2" \
1068 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1069 0 \
1070 -S "received FALLBACK_SCSV" \
1071 -S "inapropriate fallback"
1072
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001073# Tests for CBC 1/n-1 record splitting
1074
1075run_test "CBC Record splitting: TLS 1.2, no splitting" \
1076 "$P_SRV" \
1077 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1078 request_size=123 force_version=tls1_2" \
1079 0 \
1080 -s "Read from client: 123 bytes read" \
1081 -S "Read from client: 1 bytes read" \
1082 -S "122 bytes read"
1083
1084run_test "CBC Record splitting: TLS 1.1, no splitting" \
1085 "$P_SRV" \
1086 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1087 request_size=123 force_version=tls1_1" \
1088 0 \
1089 -s "Read from client: 123 bytes read" \
1090 -S "Read from client: 1 bytes read" \
1091 -S "122 bytes read"
1092
1093run_test "CBC Record splitting: TLS 1.0, splitting" \
1094 "$P_SRV" \
1095 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1096 request_size=123 force_version=tls1" \
1097 0 \
1098 -S "Read from client: 123 bytes read" \
1099 -s "Read from client: 1 bytes read" \
1100 -s "122 bytes read"
1101
Janos Follathe2681a42016-03-07 15:57:05 +00001102requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001103run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001104 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001105 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1106 request_size=123 force_version=ssl3" \
1107 0 \
1108 -S "Read from client: 123 bytes read" \
1109 -s "Read from client: 1 bytes read" \
1110 -s "122 bytes read"
1111
1112run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001113 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001114 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1115 request_size=123 force_version=tls1" \
1116 0 \
1117 -s "Read from client: 123 bytes read" \
1118 -S "Read from client: 1 bytes read" \
1119 -S "122 bytes read"
1120
1121run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1122 "$P_SRV" \
1123 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1124 request_size=123 force_version=tls1 recsplit=0" \
1125 0 \
1126 -s "Read from client: 123 bytes read" \
1127 -S "Read from client: 1 bytes read" \
1128 -S "122 bytes read"
1129
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001130run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1131 "$P_SRV nbio=2" \
1132 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1133 request_size=123 force_version=tls1" \
1134 0 \
1135 -S "Read from client: 123 bytes read" \
1136 -s "Read from client: 1 bytes read" \
1137 -s "122 bytes read"
1138
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001139# Tests for Session Tickets
1140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001141run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001142 "$P_SRV debug_level=3 tickets=1" \
1143 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001144 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001145 -c "client hello, adding session ticket extension" \
1146 -s "found session ticket extension" \
1147 -s "server hello, adding session ticket extension" \
1148 -c "found session_ticket extension" \
1149 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001150 -S "session successfully restored from cache" \
1151 -s "session successfully restored from ticket" \
1152 -s "a session has been resumed" \
1153 -c "a session has been resumed"
1154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001155run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001156 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1157 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001158 0 \
1159 -c "client hello, adding session ticket extension" \
1160 -s "found session ticket extension" \
1161 -s "server hello, adding session ticket extension" \
1162 -c "found session_ticket extension" \
1163 -c "parse new session ticket" \
1164 -S "session successfully restored from cache" \
1165 -s "session successfully restored from ticket" \
1166 -s "a session has been resumed" \
1167 -c "a session has been resumed"
1168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001169run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001170 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1171 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001172 0 \
1173 -c "client hello, adding session ticket extension" \
1174 -s "found session ticket extension" \
1175 -s "server hello, adding session ticket extension" \
1176 -c "found session_ticket extension" \
1177 -c "parse new session ticket" \
1178 -S "session successfully restored from cache" \
1179 -S "session successfully restored from ticket" \
1180 -S "a session has been resumed" \
1181 -C "a session has been resumed"
1182
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001183run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001184 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001185 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001186 0 \
1187 -c "client hello, adding session ticket extension" \
1188 -c "found session_ticket extension" \
1189 -c "parse new session ticket" \
1190 -c "a session has been resumed"
1191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001192run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001193 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001194 "( $O_CLI -sess_out $SESSION; \
1195 $O_CLI -sess_in $SESSION; \
1196 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001197 0 \
1198 -s "found session ticket extension" \
1199 -s "server hello, adding session ticket extension" \
1200 -S "session successfully restored from cache" \
1201 -s "session successfully restored from ticket" \
1202 -s "a session has been resumed"
1203
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001204# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001206run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001207 "$P_SRV debug_level=3 tickets=0" \
1208 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001209 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001210 -c "client hello, adding session ticket extension" \
1211 -s "found session ticket extension" \
1212 -S "server hello, adding session ticket extension" \
1213 -C "found session_ticket extension" \
1214 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001215 -s "session successfully restored from cache" \
1216 -S "session successfully restored from ticket" \
1217 -s "a session has been resumed" \
1218 -c "a session has been resumed"
1219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001220run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001221 "$P_SRV debug_level=3 tickets=1" \
1222 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001223 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001224 -C "client hello, adding session ticket extension" \
1225 -S "found session ticket extension" \
1226 -S "server hello, adding session ticket extension" \
1227 -C "found session_ticket extension" \
1228 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001229 -s "session successfully restored from cache" \
1230 -S "session successfully restored from ticket" \
1231 -s "a session has been resumed" \
1232 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001234run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001235 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1236 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001237 0 \
1238 -S "session successfully restored from cache" \
1239 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001240 -S "a session has been resumed" \
1241 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001243run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001244 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1245 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001246 0 \
1247 -s "session successfully restored from cache" \
1248 -S "session successfully restored from ticket" \
1249 -s "a session has been resumed" \
1250 -c "a session has been resumed"
1251
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001252run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001253 "$P_SRV debug_level=3 tickets=0" \
1254 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001255 0 \
1256 -s "session successfully restored from cache" \
1257 -S "session successfully restored from ticket" \
1258 -s "a session has been resumed" \
1259 -c "a session has been resumed"
1260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001261run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001262 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1263 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001264 0 \
1265 -S "session successfully restored from cache" \
1266 -S "session successfully restored from ticket" \
1267 -S "a session has been resumed" \
1268 -C "a session has been resumed"
1269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001270run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001271 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1272 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001273 0 \
1274 -s "session successfully restored from cache" \
1275 -S "session successfully restored from ticket" \
1276 -s "a session has been resumed" \
1277 -c "a session has been resumed"
1278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001279run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001280 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001281 "( $O_CLI -sess_out $SESSION; \
1282 $O_CLI -sess_in $SESSION; \
1283 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001284 0 \
1285 -s "found session ticket extension" \
1286 -S "server hello, adding session ticket extension" \
1287 -s "session successfully restored from cache" \
1288 -S "session successfully restored from ticket" \
1289 -s "a session has been resumed"
1290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001291run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001292 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001293 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001294 0 \
1295 -C "found session_ticket extension" \
1296 -C "parse new session ticket" \
1297 -c "a session has been resumed"
1298
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001299# Tests for Max Fragment Length extension
1300
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001301run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001302 "$P_SRV debug_level=3" \
1303 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001304 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001305 -c "Maximum fragment length is 16384" \
1306 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001307 -C "client hello, adding max_fragment_length extension" \
1308 -S "found max fragment length extension" \
1309 -S "server hello, max_fragment_length extension" \
1310 -C "found max_fragment_length extension"
1311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001312run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001313 "$P_SRV debug_level=3" \
1314 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001315 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001316 -c "Maximum fragment length is 4096" \
1317 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001318 -c "client hello, adding max_fragment_length extension" \
1319 -s "found max fragment length extension" \
1320 -s "server hello, max_fragment_length extension" \
1321 -c "found max_fragment_length extension"
1322
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001323run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001324 "$P_SRV debug_level=3 max_frag_len=4096" \
1325 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001326 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001327 -c "Maximum fragment length is 16384" \
1328 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001329 -C "client hello, adding max_fragment_length extension" \
1330 -S "found max fragment length extension" \
1331 -S "server hello, max_fragment_length extension" \
1332 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001333
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001334requires_gnutls
1335run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001336 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001337 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001338 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001339 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001340 -c "client hello, adding max_fragment_length extension" \
1341 -c "found max_fragment_length extension"
1342
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001343run_test "Max fragment length: client, message just fits" \
1344 "$P_SRV debug_level=3" \
1345 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1346 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001347 -c "Maximum fragment length is 2048" \
1348 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001349 -c "client hello, adding max_fragment_length extension" \
1350 -s "found max fragment length extension" \
1351 -s "server hello, max_fragment_length extension" \
1352 -c "found max_fragment_length extension" \
1353 -c "2048 bytes written in 1 fragments" \
1354 -s "2048 bytes read"
1355
1356run_test "Max fragment length: client, larger message" \
1357 "$P_SRV debug_level=3" \
1358 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1359 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001360 -c "Maximum fragment length is 2048" \
1361 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001362 -c "client hello, adding max_fragment_length extension" \
1363 -s "found max fragment length extension" \
1364 -s "server hello, max_fragment_length extension" \
1365 -c "found max_fragment_length extension" \
1366 -c "2345 bytes written in 2 fragments" \
1367 -s "2048 bytes read" \
1368 -s "297 bytes read"
1369
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001370run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001371 "$P_SRV debug_level=3 dtls=1" \
1372 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1373 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001374 -c "Maximum fragment length is 2048" \
1375 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001376 -c "client hello, adding max_fragment_length extension" \
1377 -s "found max fragment length extension" \
1378 -s "server hello, max_fragment_length extension" \
1379 -c "found max_fragment_length extension" \
1380 -c "fragment larger than.*maximum"
1381
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001382# Tests for renegotiation
1383
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001384run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001385 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001386 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001387 0 \
1388 -C "client hello, adding renegotiation extension" \
1389 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1390 -S "found renegotiation extension" \
1391 -s "server hello, secure renegotiation extension" \
1392 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001393 -C "=> renegotiate" \
1394 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001395 -S "write hello request"
1396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001397run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001398 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001399 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001400 0 \
1401 -c "client hello, adding renegotiation extension" \
1402 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1403 -s "found renegotiation extension" \
1404 -s "server hello, secure renegotiation extension" \
1405 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001406 -c "=> renegotiate" \
1407 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001408 -S "write hello request"
1409
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001410run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001411 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001412 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001413 0 \
1414 -c "client hello, adding renegotiation extension" \
1415 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1416 -s "found renegotiation extension" \
1417 -s "server hello, secure renegotiation extension" \
1418 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001419 -c "=> renegotiate" \
1420 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001421 -s "write hello request"
1422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001423run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001424 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001425 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001426 0 \
1427 -c "client hello, adding renegotiation extension" \
1428 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1429 -s "found renegotiation extension" \
1430 -s "server hello, secure renegotiation extension" \
1431 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001432 -c "=> renegotiate" \
1433 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001434 -s "write hello request"
1435
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001436run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001437 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001438 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001439 1 \
1440 -c "client hello, adding renegotiation extension" \
1441 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1442 -S "found renegotiation extension" \
1443 -s "server hello, secure renegotiation extension" \
1444 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001445 -c "=> renegotiate" \
1446 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001447 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001448 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001449 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001450
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001451run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001452 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001453 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001454 0 \
1455 -C "client hello, adding renegotiation extension" \
1456 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1457 -S "found renegotiation extension" \
1458 -s "server hello, secure renegotiation extension" \
1459 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001460 -C "=> renegotiate" \
1461 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001462 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001463 -S "SSL - An unexpected message was received from our peer" \
1464 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001466run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001467 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001468 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001469 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001470 0 \
1471 -C "client hello, adding renegotiation extension" \
1472 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1473 -S "found renegotiation extension" \
1474 -s "server hello, secure renegotiation extension" \
1475 -c "found renegotiation extension" \
1476 -C "=> renegotiate" \
1477 -S "=> renegotiate" \
1478 -s "write hello request" \
1479 -S "SSL - An unexpected message was received from our peer" \
1480 -S "failed"
1481
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001482# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001483run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001484 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001485 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001486 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001487 0 \
1488 -C "client hello, adding renegotiation extension" \
1489 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1490 -S "found renegotiation extension" \
1491 -s "server hello, secure renegotiation extension" \
1492 -c "found renegotiation extension" \
1493 -C "=> renegotiate" \
1494 -S "=> renegotiate" \
1495 -s "write hello request" \
1496 -S "SSL - An unexpected message was received from our peer" \
1497 -S "failed"
1498
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001499run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001500 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001501 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001502 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001503 0 \
1504 -C "client hello, adding renegotiation extension" \
1505 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1506 -S "found renegotiation extension" \
1507 -s "server hello, secure renegotiation extension" \
1508 -c "found renegotiation extension" \
1509 -C "=> renegotiate" \
1510 -S "=> renegotiate" \
1511 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001512 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001513
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001514run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001515 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001516 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001517 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001518 0 \
1519 -c "client hello, adding renegotiation extension" \
1520 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1521 -s "found renegotiation extension" \
1522 -s "server hello, secure renegotiation extension" \
1523 -c "found renegotiation extension" \
1524 -c "=> renegotiate" \
1525 -s "=> renegotiate" \
1526 -s "write hello request" \
1527 -S "SSL - An unexpected message was received from our peer" \
1528 -S "failed"
1529
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001530run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001531 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001532 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1533 0 \
1534 -C "client hello, adding renegotiation extension" \
1535 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1536 -S "found renegotiation extension" \
1537 -s "server hello, secure renegotiation extension" \
1538 -c "found renegotiation extension" \
1539 -S "record counter limit reached: renegotiate" \
1540 -C "=> renegotiate" \
1541 -S "=> renegotiate" \
1542 -S "write hello request" \
1543 -S "SSL - An unexpected message was received from our peer" \
1544 -S "failed"
1545
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001546# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001547run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001548 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001549 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001550 0 \
1551 -c "client hello, adding renegotiation extension" \
1552 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1553 -s "found renegotiation extension" \
1554 -s "server hello, secure renegotiation extension" \
1555 -c "found renegotiation extension" \
1556 -s "record counter limit reached: renegotiate" \
1557 -c "=> renegotiate" \
1558 -s "=> renegotiate" \
1559 -s "write hello request" \
1560 -S "SSL - An unexpected message was received from our peer" \
1561 -S "failed"
1562
1563run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001564 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001565 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001566 0 \
1567 -c "client hello, adding renegotiation extension" \
1568 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1569 -s "found renegotiation extension" \
1570 -s "server hello, secure renegotiation extension" \
1571 -c "found renegotiation extension" \
1572 -s "record counter limit reached: renegotiate" \
1573 -c "=> renegotiate" \
1574 -s "=> renegotiate" \
1575 -s "write hello request" \
1576 -S "SSL - An unexpected message was received from our peer" \
1577 -S "failed"
1578
1579run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001580 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001581 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1582 0 \
1583 -C "client hello, adding renegotiation extension" \
1584 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1585 -S "found renegotiation extension" \
1586 -s "server hello, secure renegotiation extension" \
1587 -c "found renegotiation extension" \
1588 -S "record counter limit reached: renegotiate" \
1589 -C "=> renegotiate" \
1590 -S "=> renegotiate" \
1591 -S "write hello request" \
1592 -S "SSL - An unexpected message was received from our peer" \
1593 -S "failed"
1594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001595run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001596 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001597 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001598 0 \
1599 -c "client hello, adding renegotiation extension" \
1600 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1601 -s "found renegotiation extension" \
1602 -s "server hello, secure renegotiation extension" \
1603 -c "found renegotiation extension" \
1604 -c "=> renegotiate" \
1605 -s "=> renegotiate" \
1606 -S "write hello request"
1607
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001608run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001609 "$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 +02001610 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001611 0 \
1612 -c "client hello, adding renegotiation extension" \
1613 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1614 -s "found renegotiation extension" \
1615 -s "server hello, secure renegotiation extension" \
1616 -c "found renegotiation extension" \
1617 -c "=> renegotiate" \
1618 -s "=> renegotiate" \
1619 -s "write hello request"
1620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001621run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001622 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001623 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001624 0 \
1625 -c "client hello, adding renegotiation extension" \
1626 -c "found renegotiation extension" \
1627 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001628 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001629 -C "error" \
1630 -c "HTTP/1.0 200 [Oo][Kk]"
1631
Paul Bakker539d9722015-02-08 16:18:35 +01001632requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001633run_test "Renegotiation: gnutls server strict, client-initiated" \
1634 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001635 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001636 0 \
1637 -c "client hello, adding renegotiation extension" \
1638 -c "found renegotiation extension" \
1639 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001640 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001641 -C "error" \
1642 -c "HTTP/1.0 200 [Oo][Kk]"
1643
Paul Bakker539d9722015-02-08 16:18:35 +01001644requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001645run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1646 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1647 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1648 1 \
1649 -c "client hello, adding renegotiation extension" \
1650 -C "found renegotiation extension" \
1651 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001652 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001653 -c "error" \
1654 -C "HTTP/1.0 200 [Oo][Kk]"
1655
Paul Bakker539d9722015-02-08 16:18:35 +01001656requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001657run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1658 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1659 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1660 allow_legacy=0" \
1661 1 \
1662 -c "client hello, adding renegotiation extension" \
1663 -C "found renegotiation extension" \
1664 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001665 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001666 -c "error" \
1667 -C "HTTP/1.0 200 [Oo][Kk]"
1668
Paul Bakker539d9722015-02-08 16:18:35 +01001669requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001670run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1671 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1672 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1673 allow_legacy=1" \
1674 0 \
1675 -c "client hello, adding renegotiation extension" \
1676 -C "found renegotiation extension" \
1677 -c "=> renegotiate" \
1678 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001679 -C "error" \
1680 -c "HTTP/1.0 200 [Oo][Kk]"
1681
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001682run_test "Renegotiation: DTLS, client-initiated" \
1683 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1684 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1685 0 \
1686 -c "client hello, adding renegotiation extension" \
1687 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1688 -s "found renegotiation extension" \
1689 -s "server hello, secure renegotiation extension" \
1690 -c "found renegotiation extension" \
1691 -c "=> renegotiate" \
1692 -s "=> renegotiate" \
1693 -S "write hello request"
1694
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001695run_test "Renegotiation: DTLS, server-initiated" \
1696 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001697 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1698 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001699 0 \
1700 -c "client hello, adding renegotiation extension" \
1701 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1702 -s "found renegotiation extension" \
1703 -s "server hello, secure renegotiation extension" \
1704 -c "found renegotiation extension" \
1705 -c "=> renegotiate" \
1706 -s "=> renegotiate" \
1707 -s "write hello request"
1708
Andres AG692ad842017-01-19 16:30:57 +00001709run_test "Renegotiation: DTLS, renego_period overflow" \
1710 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1711 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1712 0 \
1713 -c "client hello, adding renegotiation extension" \
1714 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1715 -s "found renegotiation extension" \
1716 -s "server hello, secure renegotiation extension" \
1717 -s "record counter limit reached: renegotiate" \
1718 -c "=> renegotiate" \
1719 -s "=> renegotiate" \
1720 -s "write hello request" \
1721
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001722requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001723run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1724 "$G_SRV -u --mtu 4096" \
1725 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1726 0 \
1727 -c "client hello, adding renegotiation extension" \
1728 -c "found renegotiation extension" \
1729 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001730 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001731 -C "error" \
1732 -s "Extra-header:"
1733
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001734# Test for the "secure renegotation" extension only (no actual renegotiation)
1735
Paul Bakker539d9722015-02-08 16:18:35 +01001736requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001737run_test "Renego ext: gnutls server strict, client default" \
1738 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1739 "$P_CLI debug_level=3" \
1740 0 \
1741 -c "found renegotiation extension" \
1742 -C "error" \
1743 -c "HTTP/1.0 200 [Oo][Kk]"
1744
Paul Bakker539d9722015-02-08 16:18:35 +01001745requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001746run_test "Renego ext: gnutls server unsafe, client default" \
1747 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1748 "$P_CLI debug_level=3" \
1749 0 \
1750 -C "found renegotiation extension" \
1751 -C "error" \
1752 -c "HTTP/1.0 200 [Oo][Kk]"
1753
Paul Bakker539d9722015-02-08 16:18:35 +01001754requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001755run_test "Renego ext: gnutls server unsafe, client break legacy" \
1756 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1757 "$P_CLI debug_level=3 allow_legacy=-1" \
1758 1 \
1759 -C "found renegotiation extension" \
1760 -c "error" \
1761 -C "HTTP/1.0 200 [Oo][Kk]"
1762
Paul Bakker539d9722015-02-08 16:18:35 +01001763requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001764run_test "Renego ext: gnutls client strict, server default" \
1765 "$P_SRV debug_level=3" \
1766 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1767 0 \
1768 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1769 -s "server hello, secure renegotiation extension"
1770
Paul Bakker539d9722015-02-08 16:18:35 +01001771requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001772run_test "Renego ext: gnutls client unsafe, server default" \
1773 "$P_SRV debug_level=3" \
1774 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1775 0 \
1776 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1777 -S "server hello, secure renegotiation extension"
1778
Paul Bakker539d9722015-02-08 16:18:35 +01001779requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001780run_test "Renego ext: gnutls client unsafe, server break legacy" \
1781 "$P_SRV debug_level=3 allow_legacy=-1" \
1782 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1783 1 \
1784 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1785 -S "server hello, secure renegotiation extension"
1786
Janos Follath0b242342016-02-17 10:11:21 +00001787# Tests for silently dropping trailing extra bytes in .der certificates
1788
1789requires_gnutls
1790run_test "DER format: no trailing bytes" \
1791 "$P_SRV crt_file=data_files/server5-der0.crt \
1792 key_file=data_files/server5.key" \
1793 "$G_CLI " \
1794 0 \
1795 -c "Handshake was completed" \
1796
1797requires_gnutls
1798run_test "DER format: with a trailing zero byte" \
1799 "$P_SRV crt_file=data_files/server5-der1a.crt \
1800 key_file=data_files/server5.key" \
1801 "$G_CLI " \
1802 0 \
1803 -c "Handshake was completed" \
1804
1805requires_gnutls
1806run_test "DER format: with a trailing random byte" \
1807 "$P_SRV crt_file=data_files/server5-der1b.crt \
1808 key_file=data_files/server5.key" \
1809 "$G_CLI " \
1810 0 \
1811 -c "Handshake was completed" \
1812
1813requires_gnutls
1814run_test "DER format: with 2 trailing random bytes" \
1815 "$P_SRV crt_file=data_files/server5-der2.crt \
1816 key_file=data_files/server5.key" \
1817 "$G_CLI " \
1818 0 \
1819 -c "Handshake was completed" \
1820
1821requires_gnutls
1822run_test "DER format: with 4 trailing random bytes" \
1823 "$P_SRV crt_file=data_files/server5-der4.crt \
1824 key_file=data_files/server5.key" \
1825 "$G_CLI " \
1826 0 \
1827 -c "Handshake was completed" \
1828
1829requires_gnutls
1830run_test "DER format: with 8 trailing random bytes" \
1831 "$P_SRV crt_file=data_files/server5-der8.crt \
1832 key_file=data_files/server5.key" \
1833 "$G_CLI " \
1834 0 \
1835 -c "Handshake was completed" \
1836
1837requires_gnutls
1838run_test "DER format: with 9 trailing random bytes" \
1839 "$P_SRV crt_file=data_files/server5-der9.crt \
1840 key_file=data_files/server5.key" \
1841 "$G_CLI " \
1842 0 \
1843 -c "Handshake was completed" \
1844
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001845# Tests for auth_mode
1846
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001847run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001848 "$P_SRV crt_file=data_files/server5-badsign.crt \
1849 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001850 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001851 1 \
1852 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001853 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001854 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001855 -c "X509 - Certificate verification failed"
1856
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001857run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001858 "$P_SRV crt_file=data_files/server5-badsign.crt \
1859 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001860 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001861 0 \
1862 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001863 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001864 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001865 -C "X509 - Certificate verification failed"
1866
Hanno Beckere6706e62017-05-15 16:05:15 +01001867run_test "Authentication: server goodcert, client optional, no trusted CA" \
1868 "$P_SRV" \
1869 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1870 0 \
1871 -c "x509_verify_cert() returned" \
1872 -c "! The certificate is not correctly signed by the trusted CA" \
1873 -c "! Certificate verification flags"\
1874 -C "! mbedtls_ssl_handshake returned" \
1875 -C "X509 - Certificate verification failed" \
1876 -C "SSL - No CA Chain is set, but required to operate"
1877
1878run_test "Authentication: server goodcert, client required, no trusted CA" \
1879 "$P_SRV" \
1880 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1881 1 \
1882 -c "x509_verify_cert() returned" \
1883 -c "! The certificate is not correctly signed by the trusted CA" \
1884 -c "! Certificate verification flags"\
1885 -c "! mbedtls_ssl_handshake returned" \
1886 -c "SSL - No CA Chain is set, but required to operate"
1887
1888# The purpose of the next two tests is to test the client's behaviour when receiving a server
1889# certificate with an unsupported elliptic curve. This should usually not happen because
1890# the client informs the server about the supported curves - it does, though, in the
1891# corner case of a static ECDH suite, because the server doesn't check the curve on that
1892# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1893# different means to have the server ignoring the client's supported curve list.
1894
1895requires_config_enabled MBEDTLS_ECP_C
1896run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1897 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1898 crt_file=data_files/server5.ku-ka.crt" \
1899 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1900 1 \
1901 -c "bad certificate (EC key curve)"\
1902 -c "! Certificate verification flags"\
1903 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1904
1905requires_config_enabled MBEDTLS_ECP_C
1906run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1907 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1908 crt_file=data_files/server5.ku-ka.crt" \
1909 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1910 1 \
1911 -c "bad certificate (EC key curve)"\
1912 -c "! Certificate verification flags"\
1913 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001915run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001916 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001917 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001918 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001919 0 \
1920 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001921 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001922 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001923 -C "X509 - Certificate verification failed"
1924
Simon Butcher99000142016-10-13 17:21:01 +01001925run_test "Authentication: client SHA256, server required" \
1926 "$P_SRV auth_mode=required" \
1927 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1928 key_file=data_files/server6.key \
1929 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1930 0 \
1931 -c "Supported Signature Algorithm found: 4," \
1932 -c "Supported Signature Algorithm found: 5,"
1933
1934run_test "Authentication: client SHA384, server required" \
1935 "$P_SRV auth_mode=required" \
1936 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1937 key_file=data_files/server6.key \
1938 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
1939 0 \
1940 -c "Supported Signature Algorithm found: 4," \
1941 -c "Supported Signature Algorithm found: 5,"
1942
Gilles Peskinefd8332e2017-05-03 16:25:07 +02001943requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
1944run_test "Authentication: client has no cert, server required (SSLv3)" \
1945 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
1946 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
1947 key_file=data_files/server5.key" \
1948 1 \
1949 -S "skip write certificate request" \
1950 -C "skip parse certificate request" \
1951 -c "got a certificate request" \
1952 -c "got no certificate to send" \
1953 -S "x509_verify_cert() returned" \
1954 -s "client has no certificate" \
1955 -s "! mbedtls_ssl_handshake returned" \
1956 -c "! mbedtls_ssl_handshake returned" \
1957 -s "No client certification received from the client, but required by the authentication mode"
1958
1959run_test "Authentication: client has no cert, server required (TLS)" \
1960 "$P_SRV debug_level=3 auth_mode=required" \
1961 "$P_CLI debug_level=3 crt_file=none \
1962 key_file=data_files/server5.key" \
1963 1 \
1964 -S "skip write certificate request" \
1965 -C "skip parse certificate request" \
1966 -c "got a certificate request" \
1967 -c "= write certificate$" \
1968 -C "skip write certificate$" \
1969 -S "x509_verify_cert() returned" \
1970 -s "client has no certificate" \
1971 -s "! mbedtls_ssl_handshake returned" \
1972 -c "! mbedtls_ssl_handshake returned" \
1973 -s "No client certification received from the client, but required by the authentication mode"
1974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001975run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001976 "$P_SRV debug_level=3 auth_mode=required" \
1977 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001978 key_file=data_files/server5.key" \
1979 1 \
1980 -S "skip write certificate request" \
1981 -C "skip parse certificate request" \
1982 -c "got a certificate request" \
1983 -C "skip write certificate" \
1984 -C "skip write certificate verify" \
1985 -S "skip parse certificate verify" \
1986 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001987 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001988 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02001989 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001990 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001991 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02001992# We don't check that the client receives the alert because it might
1993# detect that its write end of the connection is closed and abort
1994# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001995
Janos Follath89baba22017-04-10 14:34:35 +01001996run_test "Authentication: client cert not trusted, server required" \
1997 "$P_SRV debug_level=3 auth_mode=required" \
1998 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
1999 key_file=data_files/server5.key" \
2000 1 \
2001 -S "skip write certificate request" \
2002 -C "skip parse certificate request" \
2003 -c "got a certificate request" \
2004 -C "skip write certificate" \
2005 -C "skip write certificate verify" \
2006 -S "skip parse certificate verify" \
2007 -s "x509_verify_cert() returned" \
2008 -s "! The certificate is not correctly signed by the trusted CA" \
2009 -s "! mbedtls_ssl_handshake returned" \
2010 -c "! mbedtls_ssl_handshake returned" \
2011 -s "X509 - Certificate verification failed"
2012
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002013run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002014 "$P_SRV debug_level=3 auth_mode=optional" \
2015 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002016 key_file=data_files/server5.key" \
2017 0 \
2018 -S "skip write certificate request" \
2019 -C "skip parse certificate request" \
2020 -c "got a certificate request" \
2021 -C "skip write certificate" \
2022 -C "skip write certificate verify" \
2023 -S "skip parse certificate verify" \
2024 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002025 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002026 -S "! mbedtls_ssl_handshake returned" \
2027 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002028 -S "X509 - Certificate verification failed"
2029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002030run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002031 "$P_SRV debug_level=3 auth_mode=none" \
2032 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002033 key_file=data_files/server5.key" \
2034 0 \
2035 -s "skip write certificate request" \
2036 -C "skip parse certificate request" \
2037 -c "got no certificate request" \
2038 -c "skip write certificate" \
2039 -c "skip write certificate verify" \
2040 -s "skip parse certificate verify" \
2041 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002042 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002043 -S "! mbedtls_ssl_handshake returned" \
2044 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002045 -S "X509 - Certificate verification failed"
2046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002047run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002048 "$P_SRV debug_level=3 auth_mode=optional" \
2049 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002050 0 \
2051 -S "skip write certificate request" \
2052 -C "skip parse certificate request" \
2053 -c "got a certificate request" \
2054 -C "skip write certificate$" \
2055 -C "got no certificate to send" \
2056 -S "SSLv3 client has no certificate" \
2057 -c "skip write certificate verify" \
2058 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002059 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002060 -S "! mbedtls_ssl_handshake returned" \
2061 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002062 -S "X509 - Certificate verification failed"
2063
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002064run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002065 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002066 "$O_CLI" \
2067 0 \
2068 -S "skip write certificate request" \
2069 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002070 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002071 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002072 -S "X509 - Certificate verification failed"
2073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002074run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002075 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002076 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002077 0 \
2078 -C "skip parse certificate request" \
2079 -c "got a certificate request" \
2080 -C "skip write certificate$" \
2081 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002082 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002083
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002084run_test "Authentication: client no cert, openssl server required" \
2085 "$O_SRV -Verify 10" \
2086 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2087 1 \
2088 -C "skip parse certificate request" \
2089 -c "got a certificate request" \
2090 -C "skip write certificate$" \
2091 -c "skip write certificate verify" \
2092 -c "! mbedtls_ssl_handshake returned"
2093
Janos Follathe2681a42016-03-07 15:57:05 +00002094requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002095run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002096 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002097 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002098 0 \
2099 -S "skip write certificate request" \
2100 -C "skip parse certificate request" \
2101 -c "got a certificate request" \
2102 -C "skip write certificate$" \
2103 -c "skip write certificate verify" \
2104 -c "got no certificate to send" \
2105 -s "SSLv3 client has no certificate" \
2106 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002107 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002108 -S "! mbedtls_ssl_handshake returned" \
2109 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002110 -S "X509 - Certificate verification failed"
2111
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002112# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2113# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002114
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002115MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002116MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002117
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002118if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002119 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002120 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002121 printf "test value of ${MAX_IM_CA}. \n"
2122 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002123 printf "The tests assume this value and if it changes, the tests in this\n"
2124 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002125 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002126
2127 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002128fi
2129
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002130run_test "Authentication: server max_int chain, client default" \
2131 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2132 key_file=data_files/dir-maxpath/09.key" \
2133 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2134 0 \
2135 -C "X509 - A fatal error occured"
2136
2137run_test "Authentication: server max_int+1 chain, client default" \
2138 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2139 key_file=data_files/dir-maxpath/10.key" \
2140 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2141 1 \
2142 -c "X509 - A fatal error occured"
2143
2144run_test "Authentication: server max_int+1 chain, client optional" \
2145 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2146 key_file=data_files/dir-maxpath/10.key" \
2147 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2148 auth_mode=optional" \
2149 1 \
2150 -c "X509 - A fatal error occured"
2151
2152run_test "Authentication: server max_int+1 chain, client none" \
2153 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2154 key_file=data_files/dir-maxpath/10.key" \
2155 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2156 auth_mode=none" \
2157 0 \
2158 -C "X509 - A fatal error occured"
2159
2160run_test "Authentication: client max_int+1 chain, server default" \
2161 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2162 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2163 key_file=data_files/dir-maxpath/10.key" \
2164 0 \
2165 -S "X509 - A fatal error occured"
2166
2167run_test "Authentication: client max_int+1 chain, server optional" \
2168 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2169 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2170 key_file=data_files/dir-maxpath/10.key" \
2171 1 \
2172 -s "X509 - A fatal error occured"
2173
2174run_test "Authentication: client max_int+1 chain, server required" \
2175 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2176 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2177 key_file=data_files/dir-maxpath/10.key" \
2178 1 \
2179 -s "X509 - A fatal error occured"
2180
2181run_test "Authentication: client max_int chain, server required" \
2182 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2183 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2184 key_file=data_files/dir-maxpath/09.key" \
2185 0 \
2186 -S "X509 - A fatal error occured"
2187
Janos Follath89baba22017-04-10 14:34:35 +01002188# Tests for CA list in CertificateRequest messages
2189
2190run_test "Authentication: send CA list in CertificateRequest (default)" \
2191 "$P_SRV debug_level=3 auth_mode=required" \
2192 "$P_CLI crt_file=data_files/server6.crt \
2193 key_file=data_files/server6.key" \
2194 0 \
2195 -s "requested DN"
2196
2197run_test "Authentication: do not send CA list in CertificateRequest" \
2198 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2199 "$P_CLI crt_file=data_files/server6.crt \
2200 key_file=data_files/server6.key" \
2201 0 \
2202 -S "requested DN"
2203
2204run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2205 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2206 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2207 key_file=data_files/server5.key" \
2208 1 \
2209 -S "requested DN" \
2210 -s "x509_verify_cert() returned" \
2211 -s "! The certificate is not correctly signed by the trusted CA" \
2212 -s "! mbedtls_ssl_handshake returned" \
2213 -c "! mbedtls_ssl_handshake returned" \
2214 -s "X509 - Certificate verification failed"
2215
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002216# Tests for certificate selection based on SHA verson
2217
2218run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2219 "$P_SRV crt_file=data_files/server5.crt \
2220 key_file=data_files/server5.key \
2221 crt_file2=data_files/server5-sha1.crt \
2222 key_file2=data_files/server5.key" \
2223 "$P_CLI force_version=tls1_2" \
2224 0 \
2225 -c "signed using.*ECDSA with SHA256" \
2226 -C "signed using.*ECDSA with SHA1"
2227
2228run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2229 "$P_SRV crt_file=data_files/server5.crt \
2230 key_file=data_files/server5.key \
2231 crt_file2=data_files/server5-sha1.crt \
2232 key_file2=data_files/server5.key" \
2233 "$P_CLI force_version=tls1_1" \
2234 0 \
2235 -C "signed using.*ECDSA with SHA256" \
2236 -c "signed using.*ECDSA with SHA1"
2237
2238run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2239 "$P_SRV crt_file=data_files/server5.crt \
2240 key_file=data_files/server5.key \
2241 crt_file2=data_files/server5-sha1.crt \
2242 key_file2=data_files/server5.key" \
2243 "$P_CLI force_version=tls1" \
2244 0 \
2245 -C "signed using.*ECDSA with SHA256" \
2246 -c "signed using.*ECDSA with SHA1"
2247
2248run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2249 "$P_SRV crt_file=data_files/server5.crt \
2250 key_file=data_files/server5.key \
2251 crt_file2=data_files/server6.crt \
2252 key_file2=data_files/server6.key" \
2253 "$P_CLI force_version=tls1_1" \
2254 0 \
2255 -c "serial number.*09" \
2256 -c "signed using.*ECDSA with SHA256" \
2257 -C "signed using.*ECDSA with SHA1"
2258
2259run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2260 "$P_SRV crt_file=data_files/server6.crt \
2261 key_file=data_files/server6.key \
2262 crt_file2=data_files/server5.crt \
2263 key_file2=data_files/server5.key" \
2264 "$P_CLI force_version=tls1_1" \
2265 0 \
2266 -c "serial number.*0A" \
2267 -c "signed using.*ECDSA with SHA256" \
2268 -C "signed using.*ECDSA with SHA1"
2269
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002270# tests for SNI
2271
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002272run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002273 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002274 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002275 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002276 0 \
2277 -S "parse ServerName extension" \
2278 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2279 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002281run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002282 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002283 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002284 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 +02002285 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002286 0 \
2287 -s "parse ServerName extension" \
2288 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2289 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002291run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002292 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002293 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002294 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 +02002295 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002296 0 \
2297 -s "parse ServerName extension" \
2298 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2299 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002300
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002301run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002302 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002303 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002304 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 +02002305 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002306 1 \
2307 -s "parse ServerName extension" \
2308 -s "ssl_sni_wrapper() returned" \
2309 -s "mbedtls_ssl_handshake returned" \
2310 -c "mbedtls_ssl_handshake returned" \
2311 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002312
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002313run_test "SNI: client auth no override: optional" \
2314 "$P_SRV debug_level=3 auth_mode=optional \
2315 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2316 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2317 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002318 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002319 -S "skip write certificate request" \
2320 -C "skip parse certificate request" \
2321 -c "got a certificate request" \
2322 -C "skip write certificate" \
2323 -C "skip write certificate verify" \
2324 -S "skip parse certificate verify"
2325
2326run_test "SNI: client auth override: none -> optional" \
2327 "$P_SRV debug_level=3 auth_mode=none \
2328 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2329 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2330 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002331 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002332 -S "skip write certificate request" \
2333 -C "skip parse certificate request" \
2334 -c "got a certificate request" \
2335 -C "skip write certificate" \
2336 -C "skip write certificate verify" \
2337 -S "skip parse certificate verify"
2338
2339run_test "SNI: client auth override: optional -> none" \
2340 "$P_SRV debug_level=3 auth_mode=optional \
2341 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2342 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2343 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002344 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002345 -s "skip write certificate request" \
2346 -C "skip parse certificate request" \
2347 -c "got no certificate request" \
2348 -c "skip write certificate" \
2349 -c "skip write certificate verify" \
2350 -s "skip parse certificate verify"
2351
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002352run_test "SNI: CA no override" \
2353 "$P_SRV debug_level=3 auth_mode=optional \
2354 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2355 ca_file=data_files/test-ca.crt \
2356 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2357 "$P_CLI debug_level=3 server_name=localhost \
2358 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2359 1 \
2360 -S "skip write certificate request" \
2361 -C "skip parse certificate request" \
2362 -c "got a certificate request" \
2363 -C "skip write certificate" \
2364 -C "skip write certificate verify" \
2365 -S "skip parse certificate verify" \
2366 -s "x509_verify_cert() returned" \
2367 -s "! The certificate is not correctly signed by the trusted CA" \
2368 -S "The certificate has been revoked (is on a CRL)"
2369
2370run_test "SNI: CA override" \
2371 "$P_SRV debug_level=3 auth_mode=optional \
2372 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2373 ca_file=data_files/test-ca.crt \
2374 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2375 "$P_CLI debug_level=3 server_name=localhost \
2376 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2377 0 \
2378 -S "skip write certificate request" \
2379 -C "skip parse certificate request" \
2380 -c "got a certificate request" \
2381 -C "skip write certificate" \
2382 -C "skip write certificate verify" \
2383 -S "skip parse certificate verify" \
2384 -S "x509_verify_cert() returned" \
2385 -S "! The certificate is not correctly signed by the trusted CA" \
2386 -S "The certificate has been revoked (is on a CRL)"
2387
2388run_test "SNI: CA override with CRL" \
2389 "$P_SRV debug_level=3 auth_mode=optional \
2390 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2391 ca_file=data_files/test-ca.crt \
2392 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2393 "$P_CLI debug_level=3 server_name=localhost \
2394 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2395 1 \
2396 -S "skip write certificate request" \
2397 -C "skip parse certificate request" \
2398 -c "got a certificate request" \
2399 -C "skip write certificate" \
2400 -C "skip write certificate verify" \
2401 -S "skip parse certificate verify" \
2402 -s "x509_verify_cert() returned" \
2403 -S "! The certificate is not correctly signed by the trusted CA" \
2404 -s "The certificate has been revoked (is on a CRL)"
2405
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002406# Tests for non-blocking I/O: exercise a variety of handshake flows
2407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002408run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002409 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2410 "$P_CLI nbio=2 tickets=0" \
2411 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002412 -S "mbedtls_ssl_handshake returned" \
2413 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002414 -c "Read from server: .* bytes read"
2415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002416run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002417 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2418 "$P_CLI nbio=2 tickets=0" \
2419 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002420 -S "mbedtls_ssl_handshake returned" \
2421 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002422 -c "Read from server: .* bytes read"
2423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002424run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002425 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2426 "$P_CLI nbio=2 tickets=1" \
2427 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002428 -S "mbedtls_ssl_handshake returned" \
2429 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002430 -c "Read from server: .* bytes read"
2431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002432run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002433 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2434 "$P_CLI nbio=2 tickets=1" \
2435 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002436 -S "mbedtls_ssl_handshake returned" \
2437 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002438 -c "Read from server: .* bytes read"
2439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002440run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002441 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2442 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2443 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002444 -S "mbedtls_ssl_handshake returned" \
2445 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002446 -c "Read from server: .* bytes read"
2447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002448run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002449 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2450 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2451 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002452 -S "mbedtls_ssl_handshake returned" \
2453 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002454 -c "Read from server: .* bytes read"
2455
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002456run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002457 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2458 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2459 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002460 -S "mbedtls_ssl_handshake returned" \
2461 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002462 -c "Read from server: .* bytes read"
2463
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002464# Tests for version negotiation
2465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002466run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002467 "$P_SRV" \
2468 "$P_CLI" \
2469 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002470 -S "mbedtls_ssl_handshake returned" \
2471 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002472 -s "Protocol is TLSv1.2" \
2473 -c "Protocol is TLSv1.2"
2474
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002475run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002476 "$P_SRV" \
2477 "$P_CLI max_version=tls1_1" \
2478 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002479 -S "mbedtls_ssl_handshake returned" \
2480 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002481 -s "Protocol is TLSv1.1" \
2482 -c "Protocol is TLSv1.1"
2483
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002484run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002485 "$P_SRV max_version=tls1_1" \
2486 "$P_CLI" \
2487 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002488 -S "mbedtls_ssl_handshake returned" \
2489 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002490 -s "Protocol is TLSv1.1" \
2491 -c "Protocol is TLSv1.1"
2492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002493run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002494 "$P_SRV max_version=tls1_1" \
2495 "$P_CLI max_version=tls1_1" \
2496 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002497 -S "mbedtls_ssl_handshake returned" \
2498 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002499 -s "Protocol is TLSv1.1" \
2500 -c "Protocol is TLSv1.1"
2501
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002502run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002503 "$P_SRV min_version=tls1_1" \
2504 "$P_CLI max_version=tls1_1" \
2505 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002506 -S "mbedtls_ssl_handshake returned" \
2507 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002508 -s "Protocol is TLSv1.1" \
2509 -c "Protocol is TLSv1.1"
2510
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002511run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002512 "$P_SRV max_version=tls1_1" \
2513 "$P_CLI min_version=tls1_1" \
2514 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002515 -S "mbedtls_ssl_handshake returned" \
2516 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002517 -s "Protocol is TLSv1.1" \
2518 -c "Protocol is TLSv1.1"
2519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002520run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002521 "$P_SRV max_version=tls1_1" \
2522 "$P_CLI min_version=tls1_2" \
2523 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002524 -s "mbedtls_ssl_handshake returned" \
2525 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002526 -c "SSL - Handshake protocol not within min/max boundaries"
2527
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002528run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002529 "$P_SRV min_version=tls1_2" \
2530 "$P_CLI max_version=tls1_1" \
2531 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002532 -s "mbedtls_ssl_handshake returned" \
2533 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002534 -s "SSL - Handshake protocol not within min/max boundaries"
2535
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002536# Tests for ALPN extension
2537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002538run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002539 "$P_SRV debug_level=3" \
2540 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002541 0 \
2542 -C "client hello, adding alpn extension" \
2543 -S "found alpn extension" \
2544 -C "got an alert message, type: \\[2:120]" \
2545 -S "server hello, adding alpn extension" \
2546 -C "found alpn extension " \
2547 -C "Application Layer Protocol is" \
2548 -S "Application Layer Protocol is"
2549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002550run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002551 "$P_SRV debug_level=3" \
2552 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002553 0 \
2554 -c "client hello, adding alpn extension" \
2555 -s "found alpn extension" \
2556 -C "got an alert message, type: \\[2:120]" \
2557 -S "server hello, adding alpn extension" \
2558 -C "found alpn extension " \
2559 -c "Application Layer Protocol is (none)" \
2560 -S "Application Layer Protocol is"
2561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002562run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002563 "$P_SRV debug_level=3 alpn=abc,1234" \
2564 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002565 0 \
2566 -C "client hello, adding alpn extension" \
2567 -S "found alpn extension" \
2568 -C "got an alert message, type: \\[2:120]" \
2569 -S "server hello, adding alpn extension" \
2570 -C "found alpn extension " \
2571 -C "Application Layer Protocol is" \
2572 -s "Application Layer Protocol is (none)"
2573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002574run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002575 "$P_SRV debug_level=3 alpn=abc,1234" \
2576 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002577 0 \
2578 -c "client hello, adding alpn extension" \
2579 -s "found alpn extension" \
2580 -C "got an alert message, type: \\[2:120]" \
2581 -s "server hello, adding alpn extension" \
2582 -c "found alpn extension" \
2583 -c "Application Layer Protocol is abc" \
2584 -s "Application Layer Protocol is abc"
2585
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002586run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002587 "$P_SRV debug_level=3 alpn=abc,1234" \
2588 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002589 0 \
2590 -c "client hello, adding alpn extension" \
2591 -s "found alpn extension" \
2592 -C "got an alert message, type: \\[2:120]" \
2593 -s "server hello, adding alpn extension" \
2594 -c "found alpn extension" \
2595 -c "Application Layer Protocol is abc" \
2596 -s "Application Layer Protocol is abc"
2597
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002598run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002599 "$P_SRV debug_level=3 alpn=abc,1234" \
2600 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002601 0 \
2602 -c "client hello, adding alpn extension" \
2603 -s "found alpn extension" \
2604 -C "got an alert message, type: \\[2:120]" \
2605 -s "server hello, adding alpn extension" \
2606 -c "found alpn extension" \
2607 -c "Application Layer Protocol is 1234" \
2608 -s "Application Layer Protocol is 1234"
2609
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002610run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002611 "$P_SRV debug_level=3 alpn=abc,123" \
2612 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002613 1 \
2614 -c "client hello, adding alpn extension" \
2615 -s "found alpn extension" \
2616 -c "got an alert message, type: \\[2:120]" \
2617 -S "server hello, adding alpn extension" \
2618 -C "found alpn extension" \
2619 -C "Application Layer Protocol is 1234" \
2620 -S "Application Layer Protocol is 1234"
2621
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002622
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002623# Tests for keyUsage in leaf certificates, part 1:
2624# server-side certificate/suite selection
2625
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002626run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002627 "$P_SRV key_file=data_files/server2.key \
2628 crt_file=data_files/server2.ku-ds.crt" \
2629 "$P_CLI" \
2630 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002631 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002632
2633
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002634run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002635 "$P_SRV key_file=data_files/server2.key \
2636 crt_file=data_files/server2.ku-ke.crt" \
2637 "$P_CLI" \
2638 0 \
2639 -c "Ciphersuite is TLS-RSA-WITH-"
2640
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002641run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002642 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002643 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002644 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002645 1 \
2646 -C "Ciphersuite is "
2647
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002648run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002649 "$P_SRV key_file=data_files/server5.key \
2650 crt_file=data_files/server5.ku-ds.crt" \
2651 "$P_CLI" \
2652 0 \
2653 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2654
2655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002656run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002657 "$P_SRV key_file=data_files/server5.key \
2658 crt_file=data_files/server5.ku-ka.crt" \
2659 "$P_CLI" \
2660 0 \
2661 -c "Ciphersuite is TLS-ECDH-"
2662
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002663run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002664 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002665 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002666 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002667 1 \
2668 -C "Ciphersuite is "
2669
2670# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002671# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002672
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002673run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002674 "$O_SRV -key data_files/server2.key \
2675 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002676 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002677 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2678 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002679 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002680 -C "Processing of the Certificate handshake message failed" \
2681 -c "Ciphersuite is TLS-"
2682
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002683run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002684 "$O_SRV -key data_files/server2.key \
2685 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002686 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002687 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2688 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002689 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002690 -C "Processing of the Certificate handshake message failed" \
2691 -c "Ciphersuite is TLS-"
2692
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002693run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002694 "$O_SRV -key data_files/server2.key \
2695 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002696 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002697 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2698 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002699 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002700 -C "Processing of the Certificate handshake message failed" \
2701 -c "Ciphersuite is TLS-"
2702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002703run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002704 "$O_SRV -key data_files/server2.key \
2705 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002706 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002707 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2708 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002709 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002710 -c "Processing of the Certificate handshake message failed" \
2711 -C "Ciphersuite is TLS-"
2712
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002713run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2714 "$O_SRV -key data_files/server2.key \
2715 -cert data_files/server2.ku-ke.crt" \
2716 "$P_CLI debug_level=1 auth_mode=optional \
2717 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2718 0 \
2719 -c "bad certificate (usage extensions)" \
2720 -C "Processing of the Certificate handshake message failed" \
2721 -c "Ciphersuite is TLS-" \
2722 -c "! Usage does not match the keyUsage extension"
2723
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002724run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002725 "$O_SRV -key data_files/server2.key \
2726 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002727 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002728 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2729 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002730 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002731 -C "Processing of the Certificate handshake message failed" \
2732 -c "Ciphersuite is TLS-"
2733
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002734run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002735 "$O_SRV -key data_files/server2.key \
2736 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002737 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002738 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2739 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002740 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002741 -c "Processing of the Certificate handshake message failed" \
2742 -C "Ciphersuite is TLS-"
2743
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002744run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2745 "$O_SRV -key data_files/server2.key \
2746 -cert data_files/server2.ku-ds.crt" \
2747 "$P_CLI debug_level=1 auth_mode=optional \
2748 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2749 0 \
2750 -c "bad certificate (usage extensions)" \
2751 -C "Processing of the Certificate handshake message failed" \
2752 -c "Ciphersuite is TLS-" \
2753 -c "! Usage does not match the keyUsage extension"
2754
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002755# Tests for keyUsage in leaf certificates, part 3:
2756# server-side checking of client cert
2757
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002758run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002759 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002760 "$O_CLI -key data_files/server2.key \
2761 -cert data_files/server2.ku-ds.crt" \
2762 0 \
2763 -S "bad certificate (usage extensions)" \
2764 -S "Processing of the Certificate handshake message failed"
2765
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002766run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002767 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002768 "$O_CLI -key data_files/server2.key \
2769 -cert data_files/server2.ku-ke.crt" \
2770 0 \
2771 -s "bad certificate (usage extensions)" \
2772 -S "Processing of the Certificate handshake message failed"
2773
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002774run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002775 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002776 "$O_CLI -key data_files/server2.key \
2777 -cert data_files/server2.ku-ke.crt" \
2778 1 \
2779 -s "bad certificate (usage extensions)" \
2780 -s "Processing of the Certificate handshake message failed"
2781
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002782run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002783 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002784 "$O_CLI -key data_files/server5.key \
2785 -cert data_files/server5.ku-ds.crt" \
2786 0 \
2787 -S "bad certificate (usage extensions)" \
2788 -S "Processing of the Certificate handshake message failed"
2789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002790run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002791 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002792 "$O_CLI -key data_files/server5.key \
2793 -cert data_files/server5.ku-ka.crt" \
2794 0 \
2795 -s "bad certificate (usage extensions)" \
2796 -S "Processing of the Certificate handshake message failed"
2797
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002798# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002800run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002801 "$P_SRV key_file=data_files/server5.key \
2802 crt_file=data_files/server5.eku-srv.crt" \
2803 "$P_CLI" \
2804 0
2805
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002806run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002807 "$P_SRV key_file=data_files/server5.key \
2808 crt_file=data_files/server5.eku-srv.crt" \
2809 "$P_CLI" \
2810 0
2811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002812run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002813 "$P_SRV key_file=data_files/server5.key \
2814 crt_file=data_files/server5.eku-cs_any.crt" \
2815 "$P_CLI" \
2816 0
2817
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002818run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002819 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002820 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002821 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002822 1
2823
2824# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2825
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002826run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002827 "$O_SRV -key data_files/server5.key \
2828 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002829 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002830 0 \
2831 -C "bad certificate (usage extensions)" \
2832 -C "Processing of the Certificate handshake message failed" \
2833 -c "Ciphersuite is TLS-"
2834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002835run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002836 "$O_SRV -key data_files/server5.key \
2837 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002838 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002839 0 \
2840 -C "bad certificate (usage extensions)" \
2841 -C "Processing of the Certificate handshake message failed" \
2842 -c "Ciphersuite is TLS-"
2843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002844run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002845 "$O_SRV -key data_files/server5.key \
2846 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002847 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002848 0 \
2849 -C "bad certificate (usage extensions)" \
2850 -C "Processing of the Certificate handshake message failed" \
2851 -c "Ciphersuite is TLS-"
2852
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002853run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002854 "$O_SRV -key data_files/server5.key \
2855 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002856 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002857 1 \
2858 -c "bad certificate (usage extensions)" \
2859 -c "Processing of the Certificate handshake message failed" \
2860 -C "Ciphersuite is TLS-"
2861
2862# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002864run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002865 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002866 "$O_CLI -key data_files/server5.key \
2867 -cert data_files/server5.eku-cli.crt" \
2868 0 \
2869 -S "bad certificate (usage extensions)" \
2870 -S "Processing of the Certificate handshake message failed"
2871
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002872run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002873 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002874 "$O_CLI -key data_files/server5.key \
2875 -cert data_files/server5.eku-srv_cli.crt" \
2876 0 \
2877 -S "bad certificate (usage extensions)" \
2878 -S "Processing of the Certificate handshake message failed"
2879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002880run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002881 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002882 "$O_CLI -key data_files/server5.key \
2883 -cert data_files/server5.eku-cs_any.crt" \
2884 0 \
2885 -S "bad certificate (usage extensions)" \
2886 -S "Processing of the Certificate handshake message failed"
2887
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002888run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002889 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002890 "$O_CLI -key data_files/server5.key \
2891 -cert data_files/server5.eku-cs.crt" \
2892 0 \
2893 -s "bad certificate (usage extensions)" \
2894 -S "Processing of the Certificate handshake message failed"
2895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002896run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002897 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002898 "$O_CLI -key data_files/server5.key \
2899 -cert data_files/server5.eku-cs.crt" \
2900 1 \
2901 -s "bad certificate (usage extensions)" \
2902 -s "Processing of the Certificate handshake message failed"
2903
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002904# Tests for DHM parameters loading
2905
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002906run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002907 "$P_SRV" \
2908 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2909 debug_level=3" \
2910 0 \
2911 -c "value of 'DHM: P ' (2048 bits)" \
2912 -c "value of 'DHM: G ' (2048 bits)"
2913
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002914run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002915 "$P_SRV dhm_file=data_files/dhparams.pem" \
2916 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2917 debug_level=3" \
2918 0 \
2919 -c "value of 'DHM: P ' (1024 bits)" \
2920 -c "value of 'DHM: G ' (2 bits)"
2921
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002922# Tests for DHM client-side size checking
2923
2924run_test "DHM size: server default, client default, OK" \
2925 "$P_SRV" \
2926 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2927 debug_level=1" \
2928 0 \
2929 -C "DHM prime too short:"
2930
2931run_test "DHM size: server default, client 2048, OK" \
2932 "$P_SRV" \
2933 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2934 debug_level=1 dhmlen=2048" \
2935 0 \
2936 -C "DHM prime too short:"
2937
2938run_test "DHM size: server 1024, client default, OK" \
2939 "$P_SRV dhm_file=data_files/dhparams.pem" \
2940 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2941 debug_level=1" \
2942 0 \
2943 -C "DHM prime too short:"
2944
2945run_test "DHM size: server 1000, client default, rejected" \
2946 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2947 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2948 debug_level=1" \
2949 1 \
2950 -c "DHM prime too short:"
2951
2952run_test "DHM size: server default, client 2049, rejected" \
2953 "$P_SRV" \
2954 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2955 debug_level=1 dhmlen=2049" \
2956 1 \
2957 -c "DHM prime too short:"
2958
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002959# Tests for PSK callback
2960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002961run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002962 "$P_SRV psk=abc123 psk_identity=foo" \
2963 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2964 psk_identity=foo psk=abc123" \
2965 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002966 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002967 -S "SSL - Unknown identity received" \
2968 -S "SSL - Verification of the message MAC failed"
2969
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002970run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002971 "$P_SRV" \
2972 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2973 psk_identity=foo psk=abc123" \
2974 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002975 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002976 -S "SSL - Unknown identity received" \
2977 -S "SSL - Verification of the message MAC failed"
2978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002979run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002980 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2981 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2982 psk_identity=foo psk=abc123" \
2983 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002984 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002985 -s "SSL - Unknown identity received" \
2986 -S "SSL - Verification of the message MAC failed"
2987
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002988run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002989 "$P_SRV psk_list=abc,dead,def,beef" \
2990 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2991 psk_identity=abc psk=dead" \
2992 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002993 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002994 -S "SSL - Unknown identity received" \
2995 -S "SSL - Verification of the message MAC failed"
2996
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002997run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002998 "$P_SRV psk_list=abc,dead,def,beef" \
2999 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3000 psk_identity=def psk=beef" \
3001 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003002 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003003 -S "SSL - Unknown identity received" \
3004 -S "SSL - Verification of the message MAC failed"
3005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003006run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003007 "$P_SRV psk_list=abc,dead,def,beef" \
3008 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3009 psk_identity=ghi psk=beef" \
3010 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003011 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003012 -s "SSL - Unknown identity received" \
3013 -S "SSL - Verification of the message MAC failed"
3014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003015run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003016 "$P_SRV psk_list=abc,dead,def,beef" \
3017 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3018 psk_identity=abc psk=beef" \
3019 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003020 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003021 -S "SSL - Unknown identity received" \
3022 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003023
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003024# Tests for EC J-PAKE
3025
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003026requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003027run_test "ECJPAKE: client not configured" \
3028 "$P_SRV debug_level=3" \
3029 "$P_CLI debug_level=3" \
3030 0 \
3031 -C "add ciphersuite: c0ff" \
3032 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003033 -S "found ecjpake kkpp extension" \
3034 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003035 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003036 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003037 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003038 -S "None of the common ciphersuites is usable"
3039
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003040requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003041run_test "ECJPAKE: server not configured" \
3042 "$P_SRV debug_level=3" \
3043 "$P_CLI debug_level=3 ecjpake_pw=bla \
3044 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3045 1 \
3046 -c "add ciphersuite: c0ff" \
3047 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003048 -s "found ecjpake kkpp extension" \
3049 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003050 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003051 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003052 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003053 -s "None of the common ciphersuites is usable"
3054
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003055requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003056run_test "ECJPAKE: working, TLS" \
3057 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3058 "$P_CLI debug_level=3 ecjpake_pw=bla \
3059 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003060 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003061 -c "add ciphersuite: c0ff" \
3062 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003063 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003064 -s "found ecjpake kkpp extension" \
3065 -S "skip ecjpake kkpp extension" \
3066 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003067 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003068 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003069 -S "None of the common ciphersuites is usable" \
3070 -S "SSL - Verification of the message MAC failed"
3071
Janos Follath74537a62016-09-02 13:45:28 +01003072server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003073requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003074run_test "ECJPAKE: password mismatch, TLS" \
3075 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3076 "$P_CLI debug_level=3 ecjpake_pw=bad \
3077 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3078 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003079 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003080 -s "SSL - Verification of the message MAC failed"
3081
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003082requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003083run_test "ECJPAKE: working, DTLS" \
3084 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3085 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3086 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3087 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003088 -c "re-using cached ecjpake parameters" \
3089 -S "SSL - Verification of the message MAC failed"
3090
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003091requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003092run_test "ECJPAKE: working, DTLS, no cookie" \
3093 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3094 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3095 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3096 0 \
3097 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003098 -S "SSL - Verification of the message MAC failed"
3099
Janos Follath74537a62016-09-02 13:45:28 +01003100server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003101requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003102run_test "ECJPAKE: password mismatch, DTLS" \
3103 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3104 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3105 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3106 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003107 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003108 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003109
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003110# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003111requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003112run_test "ECJPAKE: working, DTLS, nolog" \
3113 "$P_SRV dtls=1 ecjpake_pw=bla" \
3114 "$P_CLI dtls=1 ecjpake_pw=bla \
3115 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3116 0
3117
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003118# Tests for ciphersuites per version
3119
Janos Follathe2681a42016-03-07 15:57:05 +00003120requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003121run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003122 "$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 +02003123 "$P_CLI force_version=ssl3" \
3124 0 \
3125 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003127run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003128 "$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 +01003129 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003130 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003131 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003132
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003133run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003134 "$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 +02003135 "$P_CLI force_version=tls1_1" \
3136 0 \
3137 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3138
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003139run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003140 "$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 +02003141 "$P_CLI force_version=tls1_2" \
3142 0 \
3143 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3144
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003145# Test for ClientHello without extensions
3146
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003147requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003148run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003149 "$P_SRV debug_level=3" \
3150 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3151 0 \
3152 -s "dumping 'client hello extensions' (0 bytes)"
3153
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003154requires_gnutls
3155run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3156 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3157 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3158 0 \
3159 -s "dumping 'client hello extensions' (0 bytes)"
3160
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003161# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003162
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003163run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003164 "$P_SRV" \
3165 "$P_CLI request_size=100" \
3166 0 \
3167 -s "Read from client: 100 bytes read$"
3168
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003169run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003170 "$P_SRV" \
3171 "$P_CLI request_size=500" \
3172 0 \
3173 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003174
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003175# Tests for small packets
3176
Janos Follathe2681a42016-03-07 15:57:05 +00003177requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003178run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003179 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003180 "$P_CLI request_size=1 force_version=ssl3 \
3181 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3182 0 \
3183 -s "Read from client: 1 bytes read"
3184
Janos Follathe2681a42016-03-07 15:57:05 +00003185requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003186run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003187 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003188 "$P_CLI request_size=1 force_version=ssl3 \
3189 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3190 0 \
3191 -s "Read from client: 1 bytes read"
3192
3193run_test "Small packet TLS 1.0 BlockCipher" \
3194 "$P_SRV" \
3195 "$P_CLI request_size=1 force_version=tls1 \
3196 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3197 0 \
3198 -s "Read from client: 1 bytes read"
3199
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003200run_test "Small packet TLS 1.0 BlockCipher without EtM" \
3201 "$P_SRV" \
3202 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3203 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3204 0 \
3205 -s "Read from client: 1 bytes read"
3206
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003207run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
3208 "$P_SRV" \
3209 "$P_CLI request_size=1 force_version=tls1 \
3210 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3211 trunc_hmac=1" \
3212 0 \
3213 -s "Read from client: 1 bytes read"
3214
3215run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003216 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003217 "$P_CLI request_size=1 force_version=tls1 \
3218 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3219 trunc_hmac=1" \
3220 0 \
3221 -s "Read from client: 1 bytes read"
3222
3223run_test "Small packet TLS 1.1 BlockCipher" \
3224 "$P_SRV" \
3225 "$P_CLI request_size=1 force_version=tls1_1 \
3226 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3227 0 \
3228 -s "Read from client: 1 bytes read"
3229
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003230run_test "Small packet TLS 1.1 BlockCipher without EtM" \
3231 "$P_SRV" \
3232 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
3233 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3234 0 \
3235 -s "Read from client: 1 bytes read"
3236
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003237run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003238 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003239 "$P_CLI request_size=1 force_version=tls1_1 \
3240 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3241 0 \
3242 -s "Read from client: 1 bytes read"
3243
3244run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3245 "$P_SRV" \
3246 "$P_CLI request_size=1 force_version=tls1_1 \
3247 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3248 trunc_hmac=1" \
3249 0 \
3250 -s "Read from client: 1 bytes read"
3251
3252run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003253 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003254 "$P_CLI request_size=1 force_version=tls1_1 \
3255 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3256 trunc_hmac=1" \
3257 0 \
3258 -s "Read from client: 1 bytes read"
3259
3260run_test "Small packet TLS 1.2 BlockCipher" \
3261 "$P_SRV" \
3262 "$P_CLI request_size=1 force_version=tls1_2 \
3263 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3264 0 \
3265 -s "Read from client: 1 bytes read"
3266
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003267run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3268 "$P_SRV" \
3269 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3270 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3271 0 \
3272 -s "Read from client: 1 bytes read"
3273
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003274run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3275 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003276 "$P_CLI request_size=1 force_version=tls1_2 \
3277 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003278 0 \
3279 -s "Read from client: 1 bytes read"
3280
3281run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3282 "$P_SRV" \
3283 "$P_CLI request_size=1 force_version=tls1_2 \
3284 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3285 trunc_hmac=1" \
3286 0 \
3287 -s "Read from client: 1 bytes read"
3288
3289run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003290 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003291 "$P_CLI request_size=1 force_version=tls1_2 \
3292 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3293 0 \
3294 -s "Read from client: 1 bytes read"
3295
3296run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003297 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003298 "$P_CLI request_size=1 force_version=tls1_2 \
3299 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3300 trunc_hmac=1" \
3301 0 \
3302 -s "Read from client: 1 bytes read"
3303
3304run_test "Small packet TLS 1.2 AEAD" \
3305 "$P_SRV" \
3306 "$P_CLI request_size=1 force_version=tls1_2 \
3307 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3308 0 \
3309 -s "Read from client: 1 bytes read"
3310
3311run_test "Small packet TLS 1.2 AEAD shorter tag" \
3312 "$P_SRV" \
3313 "$P_CLI request_size=1 force_version=tls1_2 \
3314 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3315 0 \
3316 -s "Read from client: 1 bytes read"
3317
Janos Follath00efff72016-05-06 13:48:23 +01003318# A test for extensions in SSLv3
3319
3320requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3321run_test "SSLv3 with extensions, server side" \
3322 "$P_SRV min_version=ssl3 debug_level=3" \
3323 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3324 0 \
3325 -S "dumping 'client hello extensions'" \
3326 -S "server hello, total extension length:"
3327
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003328# Test for large packets
3329
Janos Follathe2681a42016-03-07 15:57:05 +00003330requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003331run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003332 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003333 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003334 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3335 0 \
3336 -s "Read from client: 16384 bytes read"
3337
Janos Follathe2681a42016-03-07 15:57:05 +00003338requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003339run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003340 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003341 "$P_CLI request_size=16384 force_version=ssl3 \
3342 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3343 0 \
3344 -s "Read from client: 16384 bytes read"
3345
3346run_test "Large packet TLS 1.0 BlockCipher" \
3347 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003348 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003349 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3350 0 \
3351 -s "Read from client: 16384 bytes read"
3352
3353run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3354 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003355 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003356 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3357 trunc_hmac=1" \
3358 0 \
3359 -s "Read from client: 16384 bytes read"
3360
3361run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003362 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003363 "$P_CLI request_size=16384 force_version=tls1 \
3364 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3365 trunc_hmac=1" \
3366 0 \
3367 -s "Read from client: 16384 bytes read"
3368
3369run_test "Large packet TLS 1.1 BlockCipher" \
3370 "$P_SRV" \
3371 "$P_CLI request_size=16384 force_version=tls1_1 \
3372 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3373 0 \
3374 -s "Read from client: 16384 bytes read"
3375
3376run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003377 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003378 "$P_CLI request_size=16384 force_version=tls1_1 \
3379 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3380 0 \
3381 -s "Read from client: 16384 bytes read"
3382
3383run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3384 "$P_SRV" \
3385 "$P_CLI request_size=16384 force_version=tls1_1 \
3386 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3387 trunc_hmac=1" \
3388 0 \
3389 -s "Read from client: 16384 bytes read"
3390
3391run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003392 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003393 "$P_CLI request_size=16384 force_version=tls1_1 \
3394 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3395 trunc_hmac=1" \
3396 0 \
3397 -s "Read from client: 16384 bytes read"
3398
3399run_test "Large packet TLS 1.2 BlockCipher" \
3400 "$P_SRV" \
3401 "$P_CLI request_size=16384 force_version=tls1_2 \
3402 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3403 0 \
3404 -s "Read from client: 16384 bytes read"
3405
3406run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3407 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003408 "$P_CLI request_size=16384 force_version=tls1_2 \
3409 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003410 0 \
3411 -s "Read from client: 16384 bytes read"
3412
3413run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3414 "$P_SRV" \
3415 "$P_CLI request_size=16384 force_version=tls1_2 \
3416 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3417 trunc_hmac=1" \
3418 0 \
3419 -s "Read from client: 16384 bytes read"
3420
3421run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003422 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003423 "$P_CLI request_size=16384 force_version=tls1_2 \
3424 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3425 0 \
3426 -s "Read from client: 16384 bytes read"
3427
3428run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003429 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003430 "$P_CLI request_size=16384 force_version=tls1_2 \
3431 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3432 trunc_hmac=1" \
3433 0 \
3434 -s "Read from client: 16384 bytes read"
3435
3436run_test "Large packet TLS 1.2 AEAD" \
3437 "$P_SRV" \
3438 "$P_CLI request_size=16384 force_version=tls1_2 \
3439 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3440 0 \
3441 -s "Read from client: 16384 bytes read"
3442
3443run_test "Large packet TLS 1.2 AEAD shorter tag" \
3444 "$P_SRV" \
3445 "$P_CLI request_size=16384 force_version=tls1_2 \
3446 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3447 0 \
3448 -s "Read from client: 16384 bytes read"
3449
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003450# Tests for DTLS HelloVerifyRequest
3451
3452run_test "DTLS cookie: enabled" \
3453 "$P_SRV dtls=1 debug_level=2" \
3454 "$P_CLI dtls=1 debug_level=2" \
3455 0 \
3456 -s "cookie verification failed" \
3457 -s "cookie verification passed" \
3458 -S "cookie verification skipped" \
3459 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003460 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003461 -S "SSL - The requested feature is not available"
3462
3463run_test "DTLS cookie: disabled" \
3464 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3465 "$P_CLI dtls=1 debug_level=2" \
3466 0 \
3467 -S "cookie verification failed" \
3468 -S "cookie verification passed" \
3469 -s "cookie verification skipped" \
3470 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003471 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003472 -S "SSL - The requested feature is not available"
3473
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003474run_test "DTLS cookie: default (failing)" \
3475 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3476 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3477 1 \
3478 -s "cookie verification failed" \
3479 -S "cookie verification passed" \
3480 -S "cookie verification skipped" \
3481 -C "received hello verify request" \
3482 -S "hello verification requested" \
3483 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003484
3485requires_ipv6
3486run_test "DTLS cookie: enabled, IPv6" \
3487 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3488 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3489 0 \
3490 -s "cookie verification failed" \
3491 -s "cookie verification passed" \
3492 -S "cookie verification skipped" \
3493 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003494 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003495 -S "SSL - The requested feature is not available"
3496
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003497run_test "DTLS cookie: enabled, nbio" \
3498 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3499 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3500 0 \
3501 -s "cookie verification failed" \
3502 -s "cookie verification passed" \
3503 -S "cookie verification skipped" \
3504 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003505 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003506 -S "SSL - The requested feature is not available"
3507
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003508# Tests for client reconnecting from the same port with DTLS
3509
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003510not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003511run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003512 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3513 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003514 0 \
3515 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003516 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003517 -S "Client initiated reconnection from same port"
3518
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003519not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003520run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003521 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3522 "$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 +02003523 0 \
3524 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003525 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003526 -s "Client initiated reconnection from same port"
3527
Paul Bakker362689d2016-05-13 10:33:25 +01003528not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3529run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003530 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3531 "$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 +02003532 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003533 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003534 -s "Client initiated reconnection from same port"
3535
Paul Bakker362689d2016-05-13 10:33:25 +01003536only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3537run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3538 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3539 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3540 0 \
3541 -S "The operation timed out" \
3542 -s "Client initiated reconnection from same port"
3543
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003544run_test "DTLS client reconnect from same port: no cookies" \
3545 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003546 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3547 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003548 -s "The operation timed out" \
3549 -S "Client initiated reconnection from same port"
3550
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003551# Tests for various cases of client authentication with DTLS
3552# (focused on handshake flows and message parsing)
3553
3554run_test "DTLS client auth: required" \
3555 "$P_SRV dtls=1 auth_mode=required" \
3556 "$P_CLI dtls=1" \
3557 0 \
3558 -s "Verifying peer X.509 certificate... ok"
3559
3560run_test "DTLS client auth: optional, client has no cert" \
3561 "$P_SRV dtls=1 auth_mode=optional" \
3562 "$P_CLI dtls=1 crt_file=none key_file=none" \
3563 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003564 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003565
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003566run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003567 "$P_SRV dtls=1 auth_mode=none" \
3568 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3569 0 \
3570 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003571 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003572
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003573run_test "DTLS wrong PSK: badmac alert" \
3574 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3575 "$P_CLI dtls=1 psk=abc124" \
3576 1 \
3577 -s "SSL - Verification of the message MAC failed" \
3578 -c "SSL - A fatal alert message was received from our peer"
3579
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003580# Tests for receiving fragmented handshake messages with DTLS
3581
3582requires_gnutls
3583run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3584 "$G_SRV -u --mtu 2048 -a" \
3585 "$P_CLI dtls=1 debug_level=2" \
3586 0 \
3587 -C "found fragmented DTLS handshake message" \
3588 -C "error"
3589
3590requires_gnutls
3591run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3592 "$G_SRV -u --mtu 512" \
3593 "$P_CLI dtls=1 debug_level=2" \
3594 0 \
3595 -c "found fragmented DTLS handshake message" \
3596 -C "error"
3597
3598requires_gnutls
3599run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3600 "$G_SRV -u --mtu 128" \
3601 "$P_CLI dtls=1 debug_level=2" \
3602 0 \
3603 -c "found fragmented DTLS handshake message" \
3604 -C "error"
3605
3606requires_gnutls
3607run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3608 "$G_SRV -u --mtu 128" \
3609 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3610 0 \
3611 -c "found fragmented DTLS handshake message" \
3612 -C "error"
3613
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003614requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003615run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3616 "$G_SRV -u --mtu 256" \
3617 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3618 0 \
3619 -c "found fragmented DTLS handshake message" \
3620 -c "client hello, adding renegotiation extension" \
3621 -c "found renegotiation extension" \
3622 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003623 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003624 -C "error" \
3625 -s "Extra-header:"
3626
3627requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003628run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3629 "$G_SRV -u --mtu 256" \
3630 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3631 0 \
3632 -c "found fragmented DTLS handshake message" \
3633 -c "client hello, adding renegotiation extension" \
3634 -c "found renegotiation extension" \
3635 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003636 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003637 -C "error" \
3638 -s "Extra-header:"
3639
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003640run_test "DTLS reassembly: no fragmentation (openssl server)" \
3641 "$O_SRV -dtls1 -mtu 2048" \
3642 "$P_CLI dtls=1 debug_level=2" \
3643 0 \
3644 -C "found fragmented DTLS handshake message" \
3645 -C "error"
3646
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003647run_test "DTLS reassembly: some fragmentation (openssl server)" \
3648 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003649 "$P_CLI dtls=1 debug_level=2" \
3650 0 \
3651 -c "found fragmented DTLS handshake message" \
3652 -C "error"
3653
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003654run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003655 "$O_SRV -dtls1 -mtu 256" \
3656 "$P_CLI dtls=1 debug_level=2" \
3657 0 \
3658 -c "found fragmented DTLS handshake message" \
3659 -C "error"
3660
3661run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3662 "$O_SRV -dtls1 -mtu 256" \
3663 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3664 0 \
3665 -c "found fragmented DTLS handshake message" \
3666 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003667
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003668# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003669
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003670not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003671run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003672 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003673 "$P_SRV dtls=1 debug_level=2" \
3674 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003675 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003676 -C "replayed record" \
3677 -S "replayed record" \
3678 -C "record from another epoch" \
3679 -S "record from another epoch" \
3680 -C "discarding invalid record" \
3681 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003682 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003683 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003684 -c "HTTP/1.0 200 OK"
3685
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003686not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003687run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003688 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003689 "$P_SRV dtls=1 debug_level=2" \
3690 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003691 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003692 -c "replayed record" \
3693 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003694 -c "discarding invalid record" \
3695 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003696 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003697 -s "Extra-header:" \
3698 -c "HTTP/1.0 200 OK"
3699
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003700run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3701 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003702 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3703 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003704 0 \
3705 -c "replayed record" \
3706 -S "replayed record" \
3707 -c "discarding invalid record" \
3708 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003709 -c "resend" \
3710 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003711 -s "Extra-header:" \
3712 -c "HTTP/1.0 200 OK"
3713
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003714run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003715 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003716 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003717 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003718 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003719 -c "discarding invalid record (mac)" \
3720 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003721 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003722 -c "HTTP/1.0 200 OK" \
3723 -S "too many records with bad MAC" \
3724 -S "Verification of the message MAC failed"
3725
3726run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3727 -p "$P_PXY bad_ad=1" \
3728 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3729 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3730 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003731 -C "discarding invalid record (mac)" \
3732 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003733 -S "Extra-header:" \
3734 -C "HTTP/1.0 200 OK" \
3735 -s "too many records with bad MAC" \
3736 -s "Verification of the message MAC failed"
3737
3738run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3739 -p "$P_PXY bad_ad=1" \
3740 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3741 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3742 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003743 -c "discarding invalid record (mac)" \
3744 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003745 -s "Extra-header:" \
3746 -c "HTTP/1.0 200 OK" \
3747 -S "too many records with bad MAC" \
3748 -S "Verification of the message MAC failed"
3749
3750run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3751 -p "$P_PXY bad_ad=1" \
3752 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3753 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3754 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003755 -c "discarding invalid record (mac)" \
3756 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003757 -s "Extra-header:" \
3758 -c "HTTP/1.0 200 OK" \
3759 -s "too many records with bad MAC" \
3760 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003761
3762run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003763 -p "$P_PXY delay_ccs=1" \
3764 "$P_SRV dtls=1 debug_level=1" \
3765 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003766 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003767 -c "record from another epoch" \
3768 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003769 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003770 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003771 -s "Extra-header:" \
3772 -c "HTTP/1.0 200 OK"
3773
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003774# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003775
Janos Follath74537a62016-09-02 13:45:28 +01003776client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003777run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003778 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003779 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3780 psk=abc123" \
3781 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003782 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3783 0 \
3784 -s "Extra-header:" \
3785 -c "HTTP/1.0 200 OK"
3786
Janos Follath74537a62016-09-02 13:45:28 +01003787client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003788run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3789 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003790 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3791 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003792 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3793 0 \
3794 -s "Extra-header:" \
3795 -c "HTTP/1.0 200 OK"
3796
Janos Follath74537a62016-09-02 13:45:28 +01003797client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003798run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3799 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003800 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3801 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003802 0 \
3803 -s "Extra-header:" \
3804 -c "HTTP/1.0 200 OK"
3805
Janos Follath74537a62016-09-02 13:45:28 +01003806client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003807run_test "DTLS proxy: 3d, FS, client auth" \
3808 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003809 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3810 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003811 0 \
3812 -s "Extra-header:" \
3813 -c "HTTP/1.0 200 OK"
3814
Janos Follath74537a62016-09-02 13:45:28 +01003815client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003816run_test "DTLS proxy: 3d, FS, ticket" \
3817 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003818 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3819 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003820 0 \
3821 -s "Extra-header:" \
3822 -c "HTTP/1.0 200 OK"
3823
Janos Follath74537a62016-09-02 13:45:28 +01003824client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003825run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3826 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003827 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3828 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003829 0 \
3830 -s "Extra-header:" \
3831 -c "HTTP/1.0 200 OK"
3832
Janos Follath74537a62016-09-02 13:45:28 +01003833client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003834run_test "DTLS proxy: 3d, max handshake, nbio" \
3835 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003836 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3837 auth_mode=required" \
3838 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003839 0 \
3840 -s "Extra-header:" \
3841 -c "HTTP/1.0 200 OK"
3842
Janos Follath74537a62016-09-02 13:45:28 +01003843client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003844run_test "DTLS proxy: 3d, min handshake, resumption" \
3845 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3846 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3847 psk=abc123 debug_level=3" \
3848 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3849 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3850 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3851 0 \
3852 -s "a session has been resumed" \
3853 -c "a session has been resumed" \
3854 -s "Extra-header:" \
3855 -c "HTTP/1.0 200 OK"
3856
Janos Follath74537a62016-09-02 13:45:28 +01003857client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003858run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3859 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3860 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3861 psk=abc123 debug_level=3 nbio=2" \
3862 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3863 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3864 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3865 0 \
3866 -s "a session has been resumed" \
3867 -c "a session has been resumed" \
3868 -s "Extra-header:" \
3869 -c "HTTP/1.0 200 OK"
3870
Janos Follath74537a62016-09-02 13:45:28 +01003871client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003872run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003873 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003874 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3875 psk=abc123 renegotiation=1 debug_level=2" \
3876 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3877 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003878 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3879 0 \
3880 -c "=> renegotiate" \
3881 -s "=> renegotiate" \
3882 -s "Extra-header:" \
3883 -c "HTTP/1.0 200 OK"
3884
Janos Follath74537a62016-09-02 13:45:28 +01003885client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003886run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3887 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003888 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3889 psk=abc123 renegotiation=1 debug_level=2" \
3890 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3891 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003892 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3893 0 \
3894 -c "=> renegotiate" \
3895 -s "=> renegotiate" \
3896 -s "Extra-header:" \
3897 -c "HTTP/1.0 200 OK"
3898
Janos Follath74537a62016-09-02 13:45:28 +01003899client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003900run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003901 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003902 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003903 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003904 debug_level=2" \
3905 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003906 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003907 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3908 0 \
3909 -c "=> renegotiate" \
3910 -s "=> renegotiate" \
3911 -s "Extra-header:" \
3912 -c "HTTP/1.0 200 OK"
3913
Janos Follath74537a62016-09-02 13:45:28 +01003914client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003915run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003916 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003917 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003918 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003919 debug_level=2 nbio=2" \
3920 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003921 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003922 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3923 0 \
3924 -c "=> renegotiate" \
3925 -s "=> renegotiate" \
3926 -s "Extra-header:" \
3927 -c "HTTP/1.0 200 OK"
3928
Janos Follath74537a62016-09-02 13:45:28 +01003929client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003930not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003931run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003932 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3933 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003934 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003935 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003936 -c "HTTP/1.0 200 OK"
3937
Janos Follath74537a62016-09-02 13:45:28 +01003938client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003939not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003940run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3941 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3942 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003943 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003944 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003945 -c "HTTP/1.0 200 OK"
3946
Janos Follath74537a62016-09-02 13:45:28 +01003947client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003948not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003949run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3950 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3951 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003952 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003953 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003954 -c "HTTP/1.0 200 OK"
3955
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003956requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003957client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003958not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003959run_test "DTLS proxy: 3d, gnutls server" \
3960 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3961 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003962 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003963 0 \
3964 -s "Extra-header:" \
3965 -c "Extra-header:"
3966
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003967requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003968client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003969not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003970run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3971 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3972 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003973 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003974 0 \
3975 -s "Extra-header:" \
3976 -c "Extra-header:"
3977
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003978requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003979client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003980not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003981run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3982 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3983 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003984 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003985 0 \
3986 -s "Extra-header:" \
3987 -c "Extra-header:"
3988
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003989# Final report
3990
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003991echo "------------------------------------------------------------------------"
3992
3993if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003994 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003995else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003996 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003997fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003998PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003999echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004000
4001exit $FAILS