blob: b349512cc4d2672d27ac6a1141a9204eba83e2f3 [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
Andres Amaya Garciaa46a58a2017-09-06 15:38:07 +0100360# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100361# -S pattern pattern that must be absent in server output
362# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100363# -U pattern lines after pattern must be unique in server output
Andres Amaya Garciaa46a58a2017-09-06 15:38:07 +0100364# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100365run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100366 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200367 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100368
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100369 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
370 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200371 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100372 return
373 fi
374
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100375 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100376
Paul Bakkerb7584a52016-05-10 10:50:43 +0100377 # Do we only run numbered tests?
378 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
379 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
380 else
381 SKIP_NEXT="YES"
382 fi
383
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200384 # should we skip?
385 if [ "X$SKIP_NEXT" = "XYES" ]; then
386 SKIP_NEXT="NO"
387 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200388 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200389 return
390 fi
391
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200392 # does this test use a proxy?
393 if [ "X$1" = "X-p" ]; then
394 PXY_CMD="$2"
395 shift 2
396 else
397 PXY_CMD=""
398 fi
399
400 # get commands and client output
401 SRV_CMD="$1"
402 CLI_CMD="$2"
403 CLI_EXPECT="$3"
404 shift 3
405
406 # fix client port
407 if [ -n "$PXY_CMD" ]; then
408 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
409 else
410 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
411 fi
412
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200413 # update DTLS variable
414 detect_dtls "$SRV_CMD"
415
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100416 # prepend valgrind to our commands if active
417 if [ "$MEMCHECK" -gt 0 ]; then
418 if is_polar "$SRV_CMD"; then
419 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
420 fi
421 if is_polar "$CLI_CMD"; then
422 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
423 fi
424 fi
425
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200426 TIMES_LEFT=2
427 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200428 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200429
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200430 # run the commands
431 if [ -n "$PXY_CMD" ]; then
432 echo "$PXY_CMD" > $PXY_OUT
433 $PXY_CMD >> $PXY_OUT 2>&1 &
434 PXY_PID=$!
435 # assume proxy starts faster than server
436 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200437
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200438 check_osrv_dtls
439 echo "$SRV_CMD" > $SRV_OUT
440 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
441 SRV_PID=$!
442 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200443
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200444 echo "$CLI_CMD" > $CLI_OUT
445 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
446 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100447
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200448 # terminate the server (and the proxy)
449 kill $SRV_PID
450 wait $SRV_PID
451 if [ -n "$PXY_CMD" ]; then
452 kill $PXY_PID >/dev/null 2>&1
453 wait $PXY_PID
454 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100455
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200456 # retry only on timeouts
457 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
458 printf "RETRY "
459 else
460 TIMES_LEFT=0
461 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200462 done
463
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100464 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200465 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100466 # expected client exit to incorrectly succeed in case of catastrophic
467 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100468 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200469 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100470 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100471 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100472 return
473 fi
474 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100475 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200476 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100477 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100478 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100479 return
480 fi
481 fi
482
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100483 # check server exit code
484 if [ $? != 0 ]; then
485 fail "server fail"
486 return
487 fi
488
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100489 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100490 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
491 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100492 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200493 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100494 return
495 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100496
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100497 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200498 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100499 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100500 while [ $# -gt 0 ]
501 do
502 case $1 in
503 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100504 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100505 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100506 return
507 fi
508 ;;
509
510 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100511 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100512 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100513 return
514 fi
515 ;;
516
517 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100518 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100519 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100520 return
521 fi
522 ;;
523
524 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100525 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100526 fail "pattern '$2' MUST NOT be present in the Client output"
527 return
528 fi
529 ;;
530
531 # The filtering in the following two options (-u and -U) do the following
532 # - ignore valgrind output
533 # - filter out everything but lines right after the pattern occurances
534 # - keep one of each non-unique line
535 # - count how many lines remain
536 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
537 # if there were no duplicates.
538 "-U")
539 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
540 fail "lines following pattern '$2' must be unique in Server output"
541 return
542 fi
543 ;;
544
545 "-u")
546 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
547 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100548 return
549 fi
550 ;;
Andres Amaya Garciaa46a58a2017-09-06 15:38:07 +0100551 "-F")
552 if ! $2 "$SRV_OUT"; then
553 fail "function call to '$2' failed on Server output"
554 return
555 fi
556 ;;
557 "-f")
558 if ! $2 "$CLI_OUT"; then
559 fail "function call to '$2' failed on Client output"
560 return
561 fi
562 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100563
564 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200565 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100566 exit 1
567 esac
568 shift 2
569 done
570
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100571 # check valgrind's results
572 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200573 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100574 fail "Server has memory errors"
575 return
576 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200577 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100578 fail "Client has memory errors"
579 return
580 fi
581 fi
582
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100583 # if we're here, everything is ok
584 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100585 if [ "$PRESERVE_LOGS" -gt 0 ]; then
586 mv $SRV_OUT o-srv-${TESTS}.log
587 mv $CLI_OUT o-cli-${TESTS}.log
588 fi
589
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200590 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100591}
592
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100593cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200594 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200595 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
596 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
597 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
598 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100599 exit 1
600}
601
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100602#
603# MAIN
604#
605
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000606if cd $( dirname $0 ); then :; else
607 echo "cd $( dirname $0 ) failed" >&2
608 exit 1
609fi
610
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100611get_options "$@"
612
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100613# sanity checks, avoid an avalanche of errors
614if [ ! -x "$P_SRV" ]; then
615 echo "Command '$P_SRV' is not an executable file"
616 exit 1
617fi
618if [ ! -x "$P_CLI" ]; then
619 echo "Command '$P_CLI' is not an executable file"
620 exit 1
621fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200622if [ ! -x "$P_PXY" ]; then
623 echo "Command '$P_PXY' is not an executable file"
624 exit 1
625fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100626if [ "$MEMCHECK" -gt 0 ]; then
627 if which valgrind >/dev/null 2>&1; then :; else
628 echo "Memcheck not possible. Valgrind not found"
629 exit 1
630 fi
631fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100632if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
633 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100634 exit 1
635fi
636
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200637# used by watchdog
638MAIN_PID="$$"
639
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200640# be more patient with valgrind
641if [ "$MEMCHECK" -gt 0 ]; then
642 START_DELAY=3
643 DOG_DELAY=30
644else
645 START_DELAY=1
646 DOG_DELAY=10
647fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200648CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100649SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200650
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200651# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000652# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200653P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
654P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100655P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200656O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200657O_CLI="$O_CLI -connect localhost:+SRV_PORT"
658G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000659G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200660
Gilles Peskine62469d92017-05-10 10:13:59 +0200661# Allow SHA-1, because many of our test certificates use it
662P_SRV="$P_SRV allow_sha1=1"
663P_CLI="$P_CLI allow_sha1=1"
664
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200665# Also pick a unique name for intermediate files
666SRV_OUT="srv_out.$$"
667CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200668PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200669SESSION="session.$$"
670
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200671SKIP_NEXT="NO"
672
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100673trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100674
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200675# Basic test
676
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200677# Checks that:
678# - things work with all ciphersuites active (used with config-full in all.sh)
679# - the expected (highest security) parameters are selected
680# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200681run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200682 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200683 "$P_CLI" \
684 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200685 -s "Protocol is TLSv1.2" \
686 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
687 -s "client hello v3, signature_algorithm ext: 6" \
688 -s "ECDHE curve: secp521r1" \
689 -S "error" \
690 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200691
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000692run_test "Default, DTLS" \
693 "$P_SRV dtls=1" \
694 "$P_CLI dtls=1" \
695 0 \
696 -s "Protocol is DTLSv1.2" \
697 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
698
Simon Butcher8e004102016-10-14 00:48:33 +0100699# Test for uniqueness of IVs in AEAD ciphersuites
700run_test "Unique IV in GCM" \
701 "$P_SRV exchanges=20 debug_level=4" \
702 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
703 0 \
704 -u "IV used" \
705 -U "IV used"
706
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100707# Tests for rc4 option
708
Simon Butchera410af52016-05-19 22:12:18 +0100709requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100710run_test "RC4: server disabled, client enabled" \
711 "$P_SRV" \
712 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
713 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100714 -s "SSL - The server has no ciphersuites in common"
715
Simon Butchera410af52016-05-19 22:12:18 +0100716requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100717run_test "RC4: server half, client enabled" \
718 "$P_SRV arc4=1" \
719 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
720 1 \
721 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100722
723run_test "RC4: server enabled, client disabled" \
724 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
725 "$P_CLI" \
726 1 \
727 -s "SSL - The server has no ciphersuites in common"
728
729run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100730 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100731 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
732 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100733 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100734 -S "SSL - The server has no ciphersuites in common"
735
Gilles Peskinebc70a182017-05-09 15:59:24 +0200736# Tests for SHA-1 support
737
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200738requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200739run_test "SHA-1 forbidden by default in server certificate" \
740 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
741 "$P_CLI debug_level=2 allow_sha1=0" \
742 1 \
743 -c "The certificate is signed with an unacceptable hash"
744
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200745requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
746run_test "SHA-1 forbidden by default in server certificate" \
747 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
748 "$P_CLI debug_level=2 allow_sha1=0" \
749 0
750
Gilles Peskinebc70a182017-05-09 15:59:24 +0200751run_test "SHA-1 explicitly allowed in server certificate" \
752 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
753 "$P_CLI allow_sha1=1" \
754 0
755
756run_test "SHA-256 allowed by default in server certificate" \
757 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
758 "$P_CLI allow_sha1=0" \
759 0
760
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200761requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200762run_test "SHA-1 forbidden by default in client certificate" \
763 "$P_SRV auth_mode=required allow_sha1=0" \
764 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
765 1 \
766 -s "The certificate is signed with an unacceptable hash"
767
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200768requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
769run_test "SHA-1 forbidden by default in client certificate" \
770 "$P_SRV auth_mode=required allow_sha1=0" \
771 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
772 0
773
Gilles Peskinebc70a182017-05-09 15:59:24 +0200774run_test "SHA-1 explicitly allowed in client certificate" \
775 "$P_SRV auth_mode=required allow_sha1=1" \
776 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
777 0
778
779run_test "SHA-256 allowed by default in client certificate" \
780 "$P_SRV auth_mode=required allow_sha1=0" \
781 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
782 0
783
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100784# Tests for Truncated HMAC extension
785
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100786run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200787 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100788 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100789 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100790 -s "dumping 'computed mac' (20 bytes)" \
791 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100792
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100793run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200794 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100795 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
796 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100797 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100798 -s "dumping 'computed mac' (20 bytes)" \
799 -S "dumping 'computed mac' (10 bytes)"
800
801run_test "Truncated HMAC: client enabled, server default" \
802 "$P_SRV debug_level=4" \
803 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
804 trunc_hmac=1" \
805 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100806 -s "dumping 'computed mac' (20 bytes)" \
807 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100808
809run_test "Truncated HMAC: client enabled, server disabled" \
810 "$P_SRV debug_level=4 trunc_hmac=0" \
811 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
812 trunc_hmac=1" \
813 0 \
814 -s "dumping 'computed mac' (20 bytes)" \
815 -S "dumping 'computed mac' (10 bytes)"
816
817run_test "Truncated HMAC: client enabled, server enabled" \
818 "$P_SRV debug_level=4 trunc_hmac=1" \
819 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
820 trunc_hmac=1" \
821 0 \
822 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100823 -s "dumping 'computed mac' (10 bytes)"
824
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100825# Tests for Encrypt-then-MAC extension
826
827run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100828 "$P_SRV debug_level=3 \
829 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100830 "$P_CLI debug_level=3" \
831 0 \
832 -c "client hello, adding encrypt_then_mac extension" \
833 -s "found encrypt then mac extension" \
834 -s "server hello, adding encrypt then mac extension" \
835 -c "found encrypt_then_mac extension" \
836 -c "using encrypt then mac" \
837 -s "using encrypt then mac"
838
839run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100840 "$P_SRV debug_level=3 etm=0 \
841 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100842 "$P_CLI debug_level=3 etm=1" \
843 0 \
844 -c "client hello, adding encrypt_then_mac extension" \
845 -s "found encrypt then mac extension" \
846 -S "server hello, adding encrypt then mac extension" \
847 -C "found encrypt_then_mac extension" \
848 -C "using encrypt then mac" \
849 -S "using encrypt then mac"
850
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100851run_test "Encrypt then MAC: client enabled, aead cipher" \
852 "$P_SRV debug_level=3 etm=1 \
853 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
854 "$P_CLI debug_level=3 etm=1" \
855 0 \
856 -c "client hello, adding encrypt_then_mac extension" \
857 -s "found encrypt then mac extension" \
858 -S "server hello, adding encrypt then mac extension" \
859 -C "found encrypt_then_mac extension" \
860 -C "using encrypt then mac" \
861 -S "using encrypt then mac"
862
863run_test "Encrypt then MAC: client enabled, stream cipher" \
864 "$P_SRV debug_level=3 etm=1 \
865 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100866 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100867 0 \
868 -c "client hello, adding encrypt_then_mac extension" \
869 -s "found encrypt then mac extension" \
870 -S "server hello, adding encrypt then mac extension" \
871 -C "found encrypt_then_mac extension" \
872 -C "using encrypt then mac" \
873 -S "using encrypt then mac"
874
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100875run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100876 "$P_SRV debug_level=3 etm=1 \
877 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100878 "$P_CLI debug_level=3 etm=0" \
879 0 \
880 -C "client hello, adding encrypt_then_mac extension" \
881 -S "found encrypt then mac extension" \
882 -S "server hello, adding encrypt then mac extension" \
883 -C "found encrypt_then_mac extension" \
884 -C "using encrypt then mac" \
885 -S "using encrypt then mac"
886
Janos Follathe2681a42016-03-07 15:57:05 +0000887requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100888run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100889 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100890 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100891 "$P_CLI debug_level=3 force_version=ssl3" \
892 0 \
893 -C "client hello, adding encrypt_then_mac extension" \
894 -S "found encrypt then mac extension" \
895 -S "server hello, adding encrypt then mac extension" \
896 -C "found encrypt_then_mac extension" \
897 -C "using encrypt then mac" \
898 -S "using encrypt then mac"
899
Janos Follathe2681a42016-03-07 15:57:05 +0000900requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100901run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100902 "$P_SRV debug_level=3 force_version=ssl3 \
903 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100904 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100905 0 \
906 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100907 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100908 -S "server hello, adding encrypt then mac extension" \
909 -C "found encrypt_then_mac extension" \
910 -C "using encrypt then mac" \
911 -S "using encrypt then mac"
912
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200913# Tests for Extended Master Secret extension
914
915run_test "Extended Master Secret: default" \
916 "$P_SRV debug_level=3" \
917 "$P_CLI debug_level=3" \
918 0 \
919 -c "client hello, adding extended_master_secret extension" \
920 -s "found extended master secret extension" \
921 -s "server hello, adding extended master secret extension" \
922 -c "found extended_master_secret extension" \
923 -c "using extended master secret" \
924 -s "using extended master secret"
925
926run_test "Extended Master Secret: client enabled, server disabled" \
927 "$P_SRV debug_level=3 extended_ms=0" \
928 "$P_CLI debug_level=3 extended_ms=1" \
929 0 \
930 -c "client hello, adding extended_master_secret extension" \
931 -s "found extended master secret extension" \
932 -S "server hello, adding extended master secret extension" \
933 -C "found extended_master_secret extension" \
934 -C "using extended master secret" \
935 -S "using extended master secret"
936
937run_test "Extended Master Secret: client disabled, server enabled" \
938 "$P_SRV debug_level=3 extended_ms=1" \
939 "$P_CLI debug_level=3 extended_ms=0" \
940 0 \
941 -C "client hello, adding extended_master_secret extension" \
942 -S "found extended master secret extension" \
943 -S "server hello, adding extended master secret extension" \
944 -C "found extended_master_secret extension" \
945 -C "using extended master secret" \
946 -S "using extended master secret"
947
Janos Follathe2681a42016-03-07 15:57:05 +0000948requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200949run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100950 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200951 "$P_CLI debug_level=3 force_version=ssl3" \
952 0 \
953 -C "client hello, adding extended_master_secret extension" \
954 -S "found extended master secret extension" \
955 -S "server hello, adding extended master secret extension" \
956 -C "found extended_master_secret extension" \
957 -C "using extended master secret" \
958 -S "using extended master secret"
959
Janos Follathe2681a42016-03-07 15:57:05 +0000960requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200961run_test "Extended Master Secret: client enabled, server SSLv3" \
962 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100963 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200964 0 \
965 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100966 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200967 -S "server hello, adding extended master secret extension" \
968 -C "found extended_master_secret extension" \
969 -C "using extended master secret" \
970 -S "using extended master secret"
971
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200972# Tests for FALLBACK_SCSV
973
974run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200975 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200976 "$P_CLI debug_level=3 force_version=tls1_1" \
977 0 \
978 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200979 -S "received FALLBACK_SCSV" \
980 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200981 -C "is a fatal alert message (msg 86)"
982
983run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200984 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200985 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
986 0 \
987 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200988 -S "received FALLBACK_SCSV" \
989 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200990 -C "is a fatal alert message (msg 86)"
991
992run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200993 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200994 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200995 1 \
996 -c "adding FALLBACK_SCSV" \
997 -s "received FALLBACK_SCSV" \
998 -s "inapropriate fallback" \
999 -c "is a fatal alert message (msg 86)"
1000
1001run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001002 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001003 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001004 0 \
1005 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001006 -s "received FALLBACK_SCSV" \
1007 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001008 -C "is a fatal alert message (msg 86)"
1009
1010requires_openssl_with_fallback_scsv
1011run_test "Fallback SCSV: default, openssl server" \
1012 "$O_SRV" \
1013 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1014 0 \
1015 -C "adding FALLBACK_SCSV" \
1016 -C "is a fatal alert message (msg 86)"
1017
1018requires_openssl_with_fallback_scsv
1019run_test "Fallback SCSV: enabled, openssl server" \
1020 "$O_SRV" \
1021 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1022 1 \
1023 -c "adding FALLBACK_SCSV" \
1024 -c "is a fatal alert message (msg 86)"
1025
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001026requires_openssl_with_fallback_scsv
1027run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001028 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001029 "$O_CLI -tls1_1" \
1030 0 \
1031 -S "received FALLBACK_SCSV" \
1032 -S "inapropriate fallback"
1033
1034requires_openssl_with_fallback_scsv
1035run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001036 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001037 "$O_CLI -tls1_1 -fallback_scsv" \
1038 1 \
1039 -s "received FALLBACK_SCSV" \
1040 -s "inapropriate fallback"
1041
1042requires_openssl_with_fallback_scsv
1043run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001044 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001045 "$O_CLI -fallback_scsv" \
1046 0 \
1047 -s "received FALLBACK_SCSV" \
1048 -S "inapropriate fallback"
1049
Gilles Peskined50177f2017-05-16 17:53:03 +02001050## ClientHello generated with
1051## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1052## then manually twiddling the ciphersuite list.
1053## The ClientHello content is spelled out below as a hex string as
1054## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1055## The expected response is an inappropriate_fallback alert.
1056requires_openssl_with_fallback_scsv
1057run_test "Fallback SCSV: beginning of list" \
1058 "$P_SRV debug_level=2" \
1059 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1060 0 \
1061 -s "received FALLBACK_SCSV" \
1062 -s "inapropriate fallback"
1063
1064requires_openssl_with_fallback_scsv
1065run_test "Fallback SCSV: end of list" \
1066 "$P_SRV debug_level=2" \
1067 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1068 0 \
1069 -s "received FALLBACK_SCSV" \
1070 -s "inapropriate fallback"
1071
1072## Here the expected response is a valid ServerHello prefix, up to the random.
1073requires_openssl_with_fallback_scsv
1074run_test "Fallback SCSV: not in list" \
1075 "$P_SRV debug_level=2" \
1076 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1077 0 \
1078 -S "received FALLBACK_SCSV" \
1079 -S "inapropriate fallback"
1080
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001081# Tests for CBC 1/n-1 record splitting
1082
1083run_test "CBC Record splitting: TLS 1.2, no splitting" \
1084 "$P_SRV" \
1085 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1086 request_size=123 force_version=tls1_2" \
1087 0 \
1088 -s "Read from client: 123 bytes read" \
1089 -S "Read from client: 1 bytes read" \
1090 -S "122 bytes read"
1091
1092run_test "CBC Record splitting: TLS 1.1, no splitting" \
1093 "$P_SRV" \
1094 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1095 request_size=123 force_version=tls1_1" \
1096 0 \
1097 -s "Read from client: 123 bytes read" \
1098 -S "Read from client: 1 bytes read" \
1099 -S "122 bytes read"
1100
1101run_test "CBC Record splitting: TLS 1.0, splitting" \
1102 "$P_SRV" \
1103 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1104 request_size=123 force_version=tls1" \
1105 0 \
1106 -S "Read from client: 123 bytes read" \
1107 -s "Read from client: 1 bytes read" \
1108 -s "122 bytes read"
1109
Janos Follathe2681a42016-03-07 15:57:05 +00001110requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001111run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001112 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001113 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1114 request_size=123 force_version=ssl3" \
1115 0 \
1116 -S "Read from client: 123 bytes read" \
1117 -s "Read from client: 1 bytes read" \
1118 -s "122 bytes read"
1119
1120run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001121 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001122 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1123 request_size=123 force_version=tls1" \
1124 0 \
1125 -s "Read from client: 123 bytes read" \
1126 -S "Read from client: 1 bytes read" \
1127 -S "122 bytes read"
1128
1129run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1130 "$P_SRV" \
1131 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1132 request_size=123 force_version=tls1 recsplit=0" \
1133 0 \
1134 -s "Read from client: 123 bytes read" \
1135 -S "Read from client: 1 bytes read" \
1136 -S "122 bytes read"
1137
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001138run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1139 "$P_SRV nbio=2" \
1140 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1141 request_size=123 force_version=tls1" \
1142 0 \
1143 -S "Read from client: 123 bytes read" \
1144 -s "Read from client: 1 bytes read" \
1145 -s "122 bytes read"
1146
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001147# Tests for Session Tickets
1148
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001149run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001150 "$P_SRV debug_level=3 tickets=1" \
1151 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001152 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001153 -c "client hello, adding session ticket extension" \
1154 -s "found session ticket extension" \
1155 -s "server hello, adding session ticket extension" \
1156 -c "found session_ticket extension" \
1157 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001158 -S "session successfully restored from cache" \
1159 -s "session successfully restored from ticket" \
1160 -s "a session has been resumed" \
1161 -c "a session has been resumed"
1162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001163run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001164 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1165 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001166 0 \
1167 -c "client hello, adding session ticket extension" \
1168 -s "found session ticket extension" \
1169 -s "server hello, adding session ticket extension" \
1170 -c "found session_ticket extension" \
1171 -c "parse new session ticket" \
1172 -S "session successfully restored from cache" \
1173 -s "session successfully restored from ticket" \
1174 -s "a session has been resumed" \
1175 -c "a session has been resumed"
1176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001177run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001178 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1179 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001180 0 \
1181 -c "client hello, adding session ticket extension" \
1182 -s "found session ticket extension" \
1183 -s "server hello, adding session ticket extension" \
1184 -c "found session_ticket extension" \
1185 -c "parse new session ticket" \
1186 -S "session successfully restored from cache" \
1187 -S "session successfully restored from ticket" \
1188 -S "a session has been resumed" \
1189 -C "a session has been resumed"
1190
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001191run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001192 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001193 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001194 0 \
1195 -c "client hello, adding session ticket extension" \
1196 -c "found session_ticket extension" \
1197 -c "parse new session ticket" \
1198 -c "a session has been resumed"
1199
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001200run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001201 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001202 "( $O_CLI -sess_out $SESSION; \
1203 $O_CLI -sess_in $SESSION; \
1204 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001205 0 \
1206 -s "found session ticket extension" \
1207 -s "server hello, adding session ticket extension" \
1208 -S "session successfully restored from cache" \
1209 -s "session successfully restored from ticket" \
1210 -s "a session has been resumed"
1211
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001212# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001214run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001215 "$P_SRV debug_level=3 tickets=0" \
1216 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001217 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001218 -c "client hello, adding session ticket extension" \
1219 -s "found session ticket extension" \
1220 -S "server hello, adding session ticket extension" \
1221 -C "found session_ticket extension" \
1222 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001223 -s "session successfully restored from cache" \
1224 -S "session successfully restored from ticket" \
1225 -s "a session has been resumed" \
1226 -c "a session has been resumed"
1227
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001228run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001229 "$P_SRV debug_level=3 tickets=1" \
1230 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001231 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001232 -C "client hello, adding session ticket extension" \
1233 -S "found session ticket extension" \
1234 -S "server hello, adding session ticket extension" \
1235 -C "found session_ticket extension" \
1236 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001237 -s "session successfully restored from cache" \
1238 -S "session successfully restored from ticket" \
1239 -s "a session has been resumed" \
1240 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001242run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001243 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1244 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001245 0 \
1246 -S "session successfully restored from cache" \
1247 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001248 -S "a session has been resumed" \
1249 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001251run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001252 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1253 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001254 0 \
1255 -s "session successfully restored from cache" \
1256 -S "session successfully restored from ticket" \
1257 -s "a session has been resumed" \
1258 -c "a session has been resumed"
1259
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001260run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001261 "$P_SRV debug_level=3 tickets=0" \
1262 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001263 0 \
1264 -s "session successfully restored from cache" \
1265 -S "session successfully restored from ticket" \
1266 -s "a session has been resumed" \
1267 -c "a session has been resumed"
1268
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001269run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001270 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1271 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001272 0 \
1273 -S "session successfully restored from cache" \
1274 -S "session successfully restored from ticket" \
1275 -S "a session has been resumed" \
1276 -C "a session has been resumed"
1277
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001278run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001279 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1280 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001281 0 \
1282 -s "session successfully restored from cache" \
1283 -S "session successfully restored from ticket" \
1284 -s "a session has been resumed" \
1285 -c "a session has been resumed"
1286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001287run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001288 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001289 "( $O_CLI -sess_out $SESSION; \
1290 $O_CLI -sess_in $SESSION; \
1291 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001292 0 \
1293 -s "found session ticket extension" \
1294 -S "server hello, adding session ticket extension" \
1295 -s "session successfully restored from cache" \
1296 -S "session successfully restored from ticket" \
1297 -s "a session has been resumed"
1298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001299run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001300 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001301 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001302 0 \
1303 -C "found session_ticket extension" \
1304 -C "parse new session ticket" \
1305 -c "a session has been resumed"
1306
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001307# Tests for Max Fragment Length extension
1308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001309run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001310 "$P_SRV debug_level=3" \
1311 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001312 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001313 -c "Maximum fragment length is 16384" \
1314 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001315 -C "client hello, adding max_fragment_length extension" \
1316 -S "found max fragment length extension" \
1317 -S "server hello, max_fragment_length extension" \
1318 -C "found max_fragment_length extension"
1319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001320run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001321 "$P_SRV debug_level=3" \
1322 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001323 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001324 -c "Maximum fragment length is 4096" \
1325 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001326 -c "client hello, adding max_fragment_length extension" \
1327 -s "found max fragment length extension" \
1328 -s "server hello, max_fragment_length extension" \
1329 -c "found max_fragment_length extension"
1330
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001331run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001332 "$P_SRV debug_level=3 max_frag_len=4096" \
1333 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001334 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001335 -c "Maximum fragment length is 16384" \
1336 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001337 -C "client hello, adding max_fragment_length extension" \
1338 -S "found max fragment length extension" \
1339 -S "server hello, max_fragment_length extension" \
1340 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001341
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001342requires_gnutls
1343run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001344 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001345 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001346 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001347 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001348 -c "client hello, adding max_fragment_length extension" \
1349 -c "found max_fragment_length extension"
1350
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001351run_test "Max fragment length: client, message just fits" \
1352 "$P_SRV debug_level=3" \
1353 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1354 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001355 -c "Maximum fragment length is 2048" \
1356 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001357 -c "client hello, adding max_fragment_length extension" \
1358 -s "found max fragment length extension" \
1359 -s "server hello, max_fragment_length extension" \
1360 -c "found max_fragment_length extension" \
1361 -c "2048 bytes written in 1 fragments" \
1362 -s "2048 bytes read"
1363
1364run_test "Max fragment length: client, larger message" \
1365 "$P_SRV debug_level=3" \
1366 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1367 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001368 -c "Maximum fragment length is 2048" \
1369 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001370 -c "client hello, adding max_fragment_length extension" \
1371 -s "found max fragment length extension" \
1372 -s "server hello, max_fragment_length extension" \
1373 -c "found max_fragment_length extension" \
1374 -c "2345 bytes written in 2 fragments" \
1375 -s "2048 bytes read" \
1376 -s "297 bytes read"
1377
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001378run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001379 "$P_SRV debug_level=3 dtls=1" \
1380 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1381 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001382 -c "Maximum fragment length is 2048" \
1383 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001384 -c "client hello, adding max_fragment_length extension" \
1385 -s "found max fragment length extension" \
1386 -s "server hello, max_fragment_length extension" \
1387 -c "found max_fragment_length extension" \
1388 -c "fragment larger than.*maximum"
1389
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001390# Tests for renegotiation
1391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001392run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001393 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001394 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001395 0 \
1396 -C "client hello, adding renegotiation extension" \
1397 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1398 -S "found renegotiation extension" \
1399 -s "server hello, secure renegotiation extension" \
1400 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001401 -C "=> renegotiate" \
1402 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001403 -S "write hello request"
1404
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001405run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001406 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001407 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001408 0 \
1409 -c "client hello, adding renegotiation extension" \
1410 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1411 -s "found renegotiation extension" \
1412 -s "server hello, secure renegotiation extension" \
1413 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001414 -c "=> renegotiate" \
1415 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001416 -S "write hello request"
1417
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001418run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001419 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001420 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001421 0 \
1422 -c "client hello, adding renegotiation extension" \
1423 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1424 -s "found renegotiation extension" \
1425 -s "server hello, secure renegotiation extension" \
1426 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001427 -c "=> renegotiate" \
1428 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001429 -s "write hello request"
1430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001431run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001432 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001433 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001434 0 \
1435 -c "client hello, adding renegotiation extension" \
1436 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1437 -s "found renegotiation extension" \
1438 -s "server hello, secure renegotiation extension" \
1439 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001440 -c "=> renegotiate" \
1441 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001442 -s "write hello request"
1443
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001444run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001445 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001446 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001447 1 \
1448 -c "client hello, adding renegotiation extension" \
1449 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1450 -S "found renegotiation extension" \
1451 -s "server hello, secure renegotiation extension" \
1452 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001453 -c "=> renegotiate" \
1454 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001455 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001456 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001457 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001459run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001460 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001461 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001462 0 \
1463 -C "client hello, adding renegotiation extension" \
1464 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1465 -S "found renegotiation extension" \
1466 -s "server hello, secure renegotiation extension" \
1467 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001468 -C "=> renegotiate" \
1469 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001470 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001471 -S "SSL - An unexpected message was received from our peer" \
1472 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001474run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001475 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001476 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001477 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001478 0 \
1479 -C "client hello, adding renegotiation extension" \
1480 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1481 -S "found renegotiation extension" \
1482 -s "server hello, secure renegotiation extension" \
1483 -c "found renegotiation extension" \
1484 -C "=> renegotiate" \
1485 -S "=> renegotiate" \
1486 -s "write hello request" \
1487 -S "SSL - An unexpected message was received from our peer" \
1488 -S "failed"
1489
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001490# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001491run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001492 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001493 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001494 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001495 0 \
1496 -C "client hello, adding renegotiation extension" \
1497 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1498 -S "found renegotiation extension" \
1499 -s "server hello, secure renegotiation extension" \
1500 -c "found renegotiation extension" \
1501 -C "=> renegotiate" \
1502 -S "=> renegotiate" \
1503 -s "write hello request" \
1504 -S "SSL - An unexpected message was received from our peer" \
1505 -S "failed"
1506
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001507run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001508 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001509 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001510 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001511 0 \
1512 -C "client hello, adding renegotiation extension" \
1513 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1514 -S "found renegotiation extension" \
1515 -s "server hello, secure renegotiation extension" \
1516 -c "found renegotiation extension" \
1517 -C "=> renegotiate" \
1518 -S "=> renegotiate" \
1519 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001520 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001522run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001523 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001524 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001525 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001526 0 \
1527 -c "client hello, adding renegotiation extension" \
1528 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1529 -s "found renegotiation extension" \
1530 -s "server hello, secure renegotiation extension" \
1531 -c "found renegotiation extension" \
1532 -c "=> renegotiate" \
1533 -s "=> renegotiate" \
1534 -s "write hello request" \
1535 -S "SSL - An unexpected message was received from our peer" \
1536 -S "failed"
1537
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001538run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001539 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001540 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1541 0 \
1542 -C "client hello, adding renegotiation extension" \
1543 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1544 -S "found renegotiation extension" \
1545 -s "server hello, secure renegotiation extension" \
1546 -c "found renegotiation extension" \
1547 -S "record counter limit reached: renegotiate" \
1548 -C "=> renegotiate" \
1549 -S "=> renegotiate" \
1550 -S "write hello request" \
1551 -S "SSL - An unexpected message was received from our peer" \
1552 -S "failed"
1553
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001554# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001555run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001556 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001557 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001558 0 \
1559 -c "client hello, adding renegotiation extension" \
1560 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1561 -s "found renegotiation extension" \
1562 -s "server hello, secure renegotiation extension" \
1563 -c "found renegotiation extension" \
1564 -s "record counter limit reached: renegotiate" \
1565 -c "=> renegotiate" \
1566 -s "=> renegotiate" \
1567 -s "write hello request" \
1568 -S "SSL - An unexpected message was received from our peer" \
1569 -S "failed"
1570
1571run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001572 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001573 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001574 0 \
1575 -c "client hello, adding renegotiation extension" \
1576 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1577 -s "found renegotiation extension" \
1578 -s "server hello, secure renegotiation extension" \
1579 -c "found renegotiation extension" \
1580 -s "record counter limit reached: renegotiate" \
1581 -c "=> renegotiate" \
1582 -s "=> renegotiate" \
1583 -s "write hello request" \
1584 -S "SSL - An unexpected message was received from our peer" \
1585 -S "failed"
1586
1587run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001588 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001589 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1590 0 \
1591 -C "client hello, adding renegotiation extension" \
1592 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1593 -S "found renegotiation extension" \
1594 -s "server hello, secure renegotiation extension" \
1595 -c "found renegotiation extension" \
1596 -S "record counter limit reached: renegotiate" \
1597 -C "=> renegotiate" \
1598 -S "=> renegotiate" \
1599 -S "write hello request" \
1600 -S "SSL - An unexpected message was received from our peer" \
1601 -S "failed"
1602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001603run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001604 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001605 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001606 0 \
1607 -c "client hello, adding renegotiation extension" \
1608 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1609 -s "found renegotiation extension" \
1610 -s "server hello, secure renegotiation extension" \
1611 -c "found renegotiation extension" \
1612 -c "=> renegotiate" \
1613 -s "=> renegotiate" \
1614 -S "write hello request"
1615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001616run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001617 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001618 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001619 0 \
1620 -c "client hello, adding renegotiation extension" \
1621 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1622 -s "found renegotiation extension" \
1623 -s "server hello, secure renegotiation extension" \
1624 -c "found renegotiation extension" \
1625 -c "=> renegotiate" \
1626 -s "=> renegotiate" \
1627 -s "write hello request"
1628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001629run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001630 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001631 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001632 0 \
1633 -c "client hello, adding renegotiation extension" \
1634 -c "found renegotiation extension" \
1635 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001636 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001637 -C "error" \
1638 -c "HTTP/1.0 200 [Oo][Kk]"
1639
Paul Bakker539d9722015-02-08 16:18:35 +01001640requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001641run_test "Renegotiation: gnutls server strict, client-initiated" \
1642 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001643 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001644 0 \
1645 -c "client hello, adding renegotiation extension" \
1646 -c "found renegotiation extension" \
1647 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001648 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001649 -C "error" \
1650 -c "HTTP/1.0 200 [Oo][Kk]"
1651
Paul Bakker539d9722015-02-08 16:18:35 +01001652requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001653run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1654 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1655 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1656 1 \
1657 -c "client hello, adding renegotiation extension" \
1658 -C "found renegotiation extension" \
1659 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001660 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001661 -c "error" \
1662 -C "HTTP/1.0 200 [Oo][Kk]"
1663
Paul Bakker539d9722015-02-08 16:18:35 +01001664requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001665run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1666 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1667 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1668 allow_legacy=0" \
1669 1 \
1670 -c "client hello, adding renegotiation extension" \
1671 -C "found renegotiation extension" \
1672 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001673 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001674 -c "error" \
1675 -C "HTTP/1.0 200 [Oo][Kk]"
1676
Paul Bakker539d9722015-02-08 16:18:35 +01001677requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001678run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1679 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1680 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1681 allow_legacy=1" \
1682 0 \
1683 -c "client hello, adding renegotiation extension" \
1684 -C "found renegotiation extension" \
1685 -c "=> renegotiate" \
1686 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001687 -C "error" \
1688 -c "HTTP/1.0 200 [Oo][Kk]"
1689
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001690run_test "Renegotiation: DTLS, client-initiated" \
1691 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1692 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1693 0 \
1694 -c "client hello, adding renegotiation extension" \
1695 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1696 -s "found renegotiation extension" \
1697 -s "server hello, secure renegotiation extension" \
1698 -c "found renegotiation extension" \
1699 -c "=> renegotiate" \
1700 -s "=> renegotiate" \
1701 -S "write hello request"
1702
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001703run_test "Renegotiation: DTLS, server-initiated" \
1704 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001705 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1706 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001707 0 \
1708 -c "client hello, adding renegotiation extension" \
1709 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1710 -s "found renegotiation extension" \
1711 -s "server hello, secure renegotiation extension" \
1712 -c "found renegotiation extension" \
1713 -c "=> renegotiate" \
1714 -s "=> renegotiate" \
1715 -s "write hello request"
1716
Andres AG692ad842017-01-19 16:30:57 +00001717run_test "Renegotiation: DTLS, renego_period overflow" \
1718 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1719 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1720 0 \
1721 -c "client hello, adding renegotiation extension" \
1722 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1723 -s "found renegotiation extension" \
1724 -s "server hello, secure renegotiation extension" \
1725 -s "record counter limit reached: renegotiate" \
1726 -c "=> renegotiate" \
1727 -s "=> renegotiate" \
1728 -s "write hello request" \
1729
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001730requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001731run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1732 "$G_SRV -u --mtu 4096" \
1733 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1734 0 \
1735 -c "client hello, adding renegotiation extension" \
1736 -c "found renegotiation extension" \
1737 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001738 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001739 -C "error" \
1740 -s "Extra-header:"
1741
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001742# Test for the "secure renegotation" extension only (no actual renegotiation)
1743
Paul Bakker539d9722015-02-08 16:18:35 +01001744requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001745run_test "Renego ext: gnutls server strict, client default" \
1746 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1747 "$P_CLI debug_level=3" \
1748 0 \
1749 -c "found renegotiation extension" \
1750 -C "error" \
1751 -c "HTTP/1.0 200 [Oo][Kk]"
1752
Paul Bakker539d9722015-02-08 16:18:35 +01001753requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001754run_test "Renego ext: gnutls server unsafe, client default" \
1755 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1756 "$P_CLI debug_level=3" \
1757 0 \
1758 -C "found renegotiation extension" \
1759 -C "error" \
1760 -c "HTTP/1.0 200 [Oo][Kk]"
1761
Paul Bakker539d9722015-02-08 16:18:35 +01001762requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001763run_test "Renego ext: gnutls server unsafe, client break legacy" \
1764 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1765 "$P_CLI debug_level=3 allow_legacy=-1" \
1766 1 \
1767 -C "found renegotiation extension" \
1768 -c "error" \
1769 -C "HTTP/1.0 200 [Oo][Kk]"
1770
Paul Bakker539d9722015-02-08 16:18:35 +01001771requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001772run_test "Renego ext: gnutls client strict, server default" \
1773 "$P_SRV debug_level=3" \
1774 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1775 0 \
1776 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1777 -s "server hello, secure renegotiation extension"
1778
Paul Bakker539d9722015-02-08 16:18:35 +01001779requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001780run_test "Renego ext: gnutls client unsafe, server default" \
1781 "$P_SRV debug_level=3" \
1782 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1783 0 \
1784 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1785 -S "server hello, secure renegotiation extension"
1786
Paul Bakker539d9722015-02-08 16:18:35 +01001787requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001788run_test "Renego ext: gnutls client unsafe, server break legacy" \
1789 "$P_SRV debug_level=3 allow_legacy=-1" \
1790 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1791 1 \
1792 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1793 -S "server hello, secure renegotiation extension"
1794
Janos Follath0b242342016-02-17 10:11:21 +00001795# Tests for silently dropping trailing extra bytes in .der certificates
1796
1797requires_gnutls
1798run_test "DER format: no trailing bytes" \
1799 "$P_SRV crt_file=data_files/server5-der0.crt \
1800 key_file=data_files/server5.key" \
1801 "$G_CLI " \
1802 0 \
1803 -c "Handshake was completed" \
1804
1805requires_gnutls
1806run_test "DER format: with a trailing zero byte" \
1807 "$P_SRV crt_file=data_files/server5-der1a.crt \
1808 key_file=data_files/server5.key" \
1809 "$G_CLI " \
1810 0 \
1811 -c "Handshake was completed" \
1812
1813requires_gnutls
1814run_test "DER format: with a trailing random byte" \
1815 "$P_SRV crt_file=data_files/server5-der1b.crt \
1816 key_file=data_files/server5.key" \
1817 "$G_CLI " \
1818 0 \
1819 -c "Handshake was completed" \
1820
1821requires_gnutls
1822run_test "DER format: with 2 trailing random bytes" \
1823 "$P_SRV crt_file=data_files/server5-der2.crt \
1824 key_file=data_files/server5.key" \
1825 "$G_CLI " \
1826 0 \
1827 -c "Handshake was completed" \
1828
1829requires_gnutls
1830run_test "DER format: with 4 trailing random bytes" \
1831 "$P_SRV crt_file=data_files/server5-der4.crt \
1832 key_file=data_files/server5.key" \
1833 "$G_CLI " \
1834 0 \
1835 -c "Handshake was completed" \
1836
1837requires_gnutls
1838run_test "DER format: with 8 trailing random bytes" \
1839 "$P_SRV crt_file=data_files/server5-der8.crt \
1840 key_file=data_files/server5.key" \
1841 "$G_CLI " \
1842 0 \
1843 -c "Handshake was completed" \
1844
1845requires_gnutls
1846run_test "DER format: with 9 trailing random bytes" \
1847 "$P_SRV crt_file=data_files/server5-der9.crt \
1848 key_file=data_files/server5.key" \
1849 "$G_CLI " \
1850 0 \
1851 -c "Handshake was completed" \
1852
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001853# Tests for auth_mode
1854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001855run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001856 "$P_SRV crt_file=data_files/server5-badsign.crt \
1857 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001858 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001859 1 \
1860 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001861 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001862 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001863 -c "X509 - Certificate verification failed"
1864
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001865run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001866 "$P_SRV crt_file=data_files/server5-badsign.crt \
1867 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001868 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001869 0 \
1870 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001871 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001872 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001873 -C "X509 - Certificate verification failed"
1874
Hanno Beckere6706e62017-05-15 16:05:15 +01001875run_test "Authentication: server goodcert, client optional, no trusted CA" \
1876 "$P_SRV" \
1877 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1878 0 \
1879 -c "x509_verify_cert() returned" \
1880 -c "! The certificate is not correctly signed by the trusted CA" \
1881 -c "! Certificate verification flags"\
1882 -C "! mbedtls_ssl_handshake returned" \
1883 -C "X509 - Certificate verification failed" \
1884 -C "SSL - No CA Chain is set, but required to operate"
1885
1886run_test "Authentication: server goodcert, client required, no trusted CA" \
1887 "$P_SRV" \
1888 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1889 1 \
1890 -c "x509_verify_cert() returned" \
1891 -c "! The certificate is not correctly signed by the trusted CA" \
1892 -c "! Certificate verification flags"\
1893 -c "! mbedtls_ssl_handshake returned" \
1894 -c "SSL - No CA Chain is set, but required to operate"
1895
1896# The purpose of the next two tests is to test the client's behaviour when receiving a server
1897# certificate with an unsupported elliptic curve. This should usually not happen because
1898# the client informs the server about the supported curves - it does, though, in the
1899# corner case of a static ECDH suite, because the server doesn't check the curve on that
1900# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1901# different means to have the server ignoring the client's supported curve list.
1902
1903requires_config_enabled MBEDTLS_ECP_C
1904run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1905 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1906 crt_file=data_files/server5.ku-ka.crt" \
1907 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1908 1 \
1909 -c "bad certificate (EC key curve)"\
1910 -c "! Certificate verification flags"\
1911 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1912
1913requires_config_enabled MBEDTLS_ECP_C
1914run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1915 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1916 crt_file=data_files/server5.ku-ka.crt" \
1917 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1918 1 \
1919 -c "bad certificate (EC key curve)"\
1920 -c "! Certificate verification flags"\
1921 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001923run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001924 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001925 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001926 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001927 0 \
1928 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001929 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001930 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001931 -C "X509 - Certificate verification failed"
1932
Simon Butcher99000142016-10-13 17:21:01 +01001933run_test "Authentication: client SHA256, server required" \
1934 "$P_SRV auth_mode=required" \
1935 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1936 key_file=data_files/server6.key \
1937 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1938 0 \
1939 -c "Supported Signature Algorithm found: 4," \
1940 -c "Supported Signature Algorithm found: 5,"
1941
1942run_test "Authentication: client SHA384, server required" \
1943 "$P_SRV auth_mode=required" \
1944 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1945 key_file=data_files/server6.key \
1946 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
1947 0 \
1948 -c "Supported Signature Algorithm found: 4," \
1949 -c "Supported Signature Algorithm found: 5,"
1950
Gilles Peskinefd8332e2017-05-03 16:25:07 +02001951requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
1952run_test "Authentication: client has no cert, server required (SSLv3)" \
1953 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
1954 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
1955 key_file=data_files/server5.key" \
1956 1 \
1957 -S "skip write certificate request" \
1958 -C "skip parse certificate request" \
1959 -c "got a certificate request" \
1960 -c "got no certificate to send" \
1961 -S "x509_verify_cert() returned" \
1962 -s "client has no certificate" \
1963 -s "! mbedtls_ssl_handshake returned" \
1964 -c "! mbedtls_ssl_handshake returned" \
1965 -s "No client certification received from the client, but required by the authentication mode"
1966
1967run_test "Authentication: client has no cert, server required (TLS)" \
1968 "$P_SRV debug_level=3 auth_mode=required" \
1969 "$P_CLI debug_level=3 crt_file=none \
1970 key_file=data_files/server5.key" \
1971 1 \
1972 -S "skip write certificate request" \
1973 -C "skip parse certificate request" \
1974 -c "got a certificate request" \
1975 -c "= write certificate$" \
1976 -C "skip write certificate$" \
1977 -S "x509_verify_cert() returned" \
1978 -s "client has no certificate" \
1979 -s "! mbedtls_ssl_handshake returned" \
1980 -c "! mbedtls_ssl_handshake returned" \
1981 -s "No client certification received from the client, but required by the authentication mode"
1982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001983run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001984 "$P_SRV debug_level=3 auth_mode=required" \
1985 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001986 key_file=data_files/server5.key" \
1987 1 \
1988 -S "skip write certificate request" \
1989 -C "skip parse certificate request" \
1990 -c "got a certificate request" \
1991 -C "skip write certificate" \
1992 -C "skip write certificate verify" \
1993 -S "skip parse certificate verify" \
1994 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001995 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001996 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02001997 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001998 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001999 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002000# We don't check that the client receives the alert because it might
2001# detect that its write end of the connection is closed and abort
2002# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002003
Janos Follath89baba22017-04-10 14:34:35 +01002004run_test "Authentication: client cert not trusted, server required" \
2005 "$P_SRV debug_level=3 auth_mode=required" \
2006 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2007 key_file=data_files/server5.key" \
2008 1 \
2009 -S "skip write certificate request" \
2010 -C "skip parse certificate request" \
2011 -c "got a certificate request" \
2012 -C "skip write certificate" \
2013 -C "skip write certificate verify" \
2014 -S "skip parse certificate verify" \
2015 -s "x509_verify_cert() returned" \
2016 -s "! The certificate is not correctly signed by the trusted CA" \
2017 -s "! mbedtls_ssl_handshake returned" \
2018 -c "! mbedtls_ssl_handshake returned" \
2019 -s "X509 - Certificate verification failed"
2020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002021run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002022 "$P_SRV debug_level=3 auth_mode=optional" \
2023 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002024 key_file=data_files/server5.key" \
2025 0 \
2026 -S "skip write certificate request" \
2027 -C "skip parse certificate request" \
2028 -c "got a certificate request" \
2029 -C "skip write certificate" \
2030 -C "skip write certificate verify" \
2031 -S "skip parse certificate verify" \
2032 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002033 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002034 -S "! mbedtls_ssl_handshake returned" \
2035 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002036 -S "X509 - Certificate verification failed"
2037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002038run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002039 "$P_SRV debug_level=3 auth_mode=none" \
2040 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002041 key_file=data_files/server5.key" \
2042 0 \
2043 -s "skip write certificate request" \
2044 -C "skip parse certificate request" \
2045 -c "got no certificate request" \
2046 -c "skip write certificate" \
2047 -c "skip write certificate verify" \
2048 -s "skip parse certificate verify" \
2049 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002050 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002051 -S "! mbedtls_ssl_handshake returned" \
2052 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002053 -S "X509 - Certificate verification failed"
2054
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002055run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002056 "$P_SRV debug_level=3 auth_mode=optional" \
2057 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002058 0 \
2059 -S "skip write certificate request" \
2060 -C "skip parse certificate request" \
2061 -c "got a certificate request" \
2062 -C "skip write certificate$" \
2063 -C "got no certificate to send" \
2064 -S "SSLv3 client has no certificate" \
2065 -c "skip write certificate verify" \
2066 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002067 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002068 -S "! mbedtls_ssl_handshake returned" \
2069 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002070 -S "X509 - Certificate verification failed"
2071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002072run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002073 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002074 "$O_CLI" \
2075 0 \
2076 -S "skip write certificate request" \
2077 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002078 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002079 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002080 -S "X509 - Certificate verification failed"
2081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002082run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002083 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002084 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002085 0 \
2086 -C "skip parse certificate request" \
2087 -c "got a certificate request" \
2088 -C "skip write certificate$" \
2089 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002090 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002091
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002092run_test "Authentication: client no cert, openssl server required" \
2093 "$O_SRV -Verify 10" \
2094 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2095 1 \
2096 -C "skip parse certificate request" \
2097 -c "got a certificate request" \
2098 -C "skip write certificate$" \
2099 -c "skip write certificate verify" \
2100 -c "! mbedtls_ssl_handshake returned"
2101
Janos Follathe2681a42016-03-07 15:57:05 +00002102requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002103run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002104 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002105 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002106 0 \
2107 -S "skip write certificate request" \
2108 -C "skip parse certificate request" \
2109 -c "got a certificate request" \
2110 -C "skip write certificate$" \
2111 -c "skip write certificate verify" \
2112 -c "got no certificate to send" \
2113 -s "SSLv3 client has no certificate" \
2114 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002115 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002116 -S "! mbedtls_ssl_handshake returned" \
2117 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002118 -S "X509 - Certificate verification failed"
2119
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002120# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2121# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002122
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002123MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002124MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002125
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002126if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002127 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002128 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002129 printf "test value of ${MAX_IM_CA}. \n"
2130 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002131 printf "The tests assume this value and if it changes, the tests in this\n"
2132 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002133 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002134
2135 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002136fi
2137
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002138run_test "Authentication: server max_int chain, client default" \
2139 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2140 key_file=data_files/dir-maxpath/09.key" \
2141 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2142 0 \
2143 -C "X509 - A fatal error occured"
2144
2145run_test "Authentication: server max_int+1 chain, client default" \
2146 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2147 key_file=data_files/dir-maxpath/10.key" \
2148 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2149 1 \
2150 -c "X509 - A fatal error occured"
2151
2152run_test "Authentication: server max_int+1 chain, client optional" \
2153 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2154 key_file=data_files/dir-maxpath/10.key" \
2155 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2156 auth_mode=optional" \
2157 1 \
2158 -c "X509 - A fatal error occured"
2159
2160run_test "Authentication: server max_int+1 chain, client none" \
2161 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2162 key_file=data_files/dir-maxpath/10.key" \
2163 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2164 auth_mode=none" \
2165 0 \
2166 -C "X509 - A fatal error occured"
2167
2168run_test "Authentication: client max_int+1 chain, server default" \
2169 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2170 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2171 key_file=data_files/dir-maxpath/10.key" \
2172 0 \
2173 -S "X509 - A fatal error occured"
2174
2175run_test "Authentication: client max_int+1 chain, server optional" \
2176 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2177 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2178 key_file=data_files/dir-maxpath/10.key" \
2179 1 \
2180 -s "X509 - A fatal error occured"
2181
2182run_test "Authentication: client max_int+1 chain, server required" \
2183 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2184 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2185 key_file=data_files/dir-maxpath/10.key" \
2186 1 \
2187 -s "X509 - A fatal error occured"
2188
2189run_test "Authentication: client max_int chain, server required" \
2190 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2191 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2192 key_file=data_files/dir-maxpath/09.key" \
2193 0 \
2194 -S "X509 - A fatal error occured"
2195
Janos Follath89baba22017-04-10 14:34:35 +01002196# Tests for CA list in CertificateRequest messages
2197
2198run_test "Authentication: send CA list in CertificateRequest (default)" \
2199 "$P_SRV debug_level=3 auth_mode=required" \
2200 "$P_CLI crt_file=data_files/server6.crt \
2201 key_file=data_files/server6.key" \
2202 0 \
2203 -s "requested DN"
2204
2205run_test "Authentication: do not send CA list in CertificateRequest" \
2206 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2207 "$P_CLI crt_file=data_files/server6.crt \
2208 key_file=data_files/server6.key" \
2209 0 \
2210 -S "requested DN"
2211
2212run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2213 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2214 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2215 key_file=data_files/server5.key" \
2216 1 \
2217 -S "requested DN" \
2218 -s "x509_verify_cert() returned" \
2219 -s "! The certificate is not correctly signed by the trusted CA" \
2220 -s "! mbedtls_ssl_handshake returned" \
2221 -c "! mbedtls_ssl_handshake returned" \
2222 -s "X509 - Certificate verification failed"
2223
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002224# Tests for certificate selection based on SHA verson
2225
2226run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2227 "$P_SRV crt_file=data_files/server5.crt \
2228 key_file=data_files/server5.key \
2229 crt_file2=data_files/server5-sha1.crt \
2230 key_file2=data_files/server5.key" \
2231 "$P_CLI force_version=tls1_2" \
2232 0 \
2233 -c "signed using.*ECDSA with SHA256" \
2234 -C "signed using.*ECDSA with SHA1"
2235
2236run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2237 "$P_SRV crt_file=data_files/server5.crt \
2238 key_file=data_files/server5.key \
2239 crt_file2=data_files/server5-sha1.crt \
2240 key_file2=data_files/server5.key" \
2241 "$P_CLI force_version=tls1_1" \
2242 0 \
2243 -C "signed using.*ECDSA with SHA256" \
2244 -c "signed using.*ECDSA with SHA1"
2245
2246run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2247 "$P_SRV crt_file=data_files/server5.crt \
2248 key_file=data_files/server5.key \
2249 crt_file2=data_files/server5-sha1.crt \
2250 key_file2=data_files/server5.key" \
2251 "$P_CLI force_version=tls1" \
2252 0 \
2253 -C "signed using.*ECDSA with SHA256" \
2254 -c "signed using.*ECDSA with SHA1"
2255
2256run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2257 "$P_SRV crt_file=data_files/server5.crt \
2258 key_file=data_files/server5.key \
2259 crt_file2=data_files/server6.crt \
2260 key_file2=data_files/server6.key" \
2261 "$P_CLI force_version=tls1_1" \
2262 0 \
2263 -c "serial number.*09" \
2264 -c "signed using.*ECDSA with SHA256" \
2265 -C "signed using.*ECDSA with SHA1"
2266
2267run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2268 "$P_SRV crt_file=data_files/server6.crt \
2269 key_file=data_files/server6.key \
2270 crt_file2=data_files/server5.crt \
2271 key_file2=data_files/server5.key" \
2272 "$P_CLI force_version=tls1_1" \
2273 0 \
2274 -c "serial number.*0A" \
2275 -c "signed using.*ECDSA with SHA256" \
2276 -C "signed using.*ECDSA with SHA1"
2277
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002278# tests for SNI
2279
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002280run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002281 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002282 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002283 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002284 0 \
2285 -S "parse ServerName extension" \
2286 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2287 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002288
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002289run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002290 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002291 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002292 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002293 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002294 0 \
2295 -s "parse ServerName extension" \
2296 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2297 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002299run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002300 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002301 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002302 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002303 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002304 0 \
2305 -s "parse ServerName extension" \
2306 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2307 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002309run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002310 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002311 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002312 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002313 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002314 1 \
2315 -s "parse ServerName extension" \
2316 -s "ssl_sni_wrapper() returned" \
2317 -s "mbedtls_ssl_handshake returned" \
2318 -c "mbedtls_ssl_handshake returned" \
2319 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002320
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002321run_test "SNI: client auth no override: optional" \
2322 "$P_SRV debug_level=3 auth_mode=optional \
2323 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2324 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2325 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002326 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002327 -S "skip write certificate request" \
2328 -C "skip parse certificate request" \
2329 -c "got a certificate request" \
2330 -C "skip write certificate" \
2331 -C "skip write certificate verify" \
2332 -S "skip parse certificate verify"
2333
2334run_test "SNI: client auth override: none -> optional" \
2335 "$P_SRV debug_level=3 auth_mode=none \
2336 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2337 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2338 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002339 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002340 -S "skip write certificate request" \
2341 -C "skip parse certificate request" \
2342 -c "got a certificate request" \
2343 -C "skip write certificate" \
2344 -C "skip write certificate verify" \
2345 -S "skip parse certificate verify"
2346
2347run_test "SNI: client auth override: optional -> none" \
2348 "$P_SRV debug_level=3 auth_mode=optional \
2349 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2350 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2351 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002352 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002353 -s "skip write certificate request" \
2354 -C "skip parse certificate request" \
2355 -c "got no certificate request" \
2356 -c "skip write certificate" \
2357 -c "skip write certificate verify" \
2358 -s "skip parse certificate verify"
2359
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002360run_test "SNI: CA no override" \
2361 "$P_SRV debug_level=3 auth_mode=optional \
2362 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2363 ca_file=data_files/test-ca.crt \
2364 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2365 "$P_CLI debug_level=3 server_name=localhost \
2366 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2367 1 \
2368 -S "skip write certificate request" \
2369 -C "skip parse certificate request" \
2370 -c "got a certificate request" \
2371 -C "skip write certificate" \
2372 -C "skip write certificate verify" \
2373 -S "skip parse certificate verify" \
2374 -s "x509_verify_cert() returned" \
2375 -s "! The certificate is not correctly signed by the trusted CA" \
2376 -S "The certificate has been revoked (is on a CRL)"
2377
2378run_test "SNI: CA override" \
2379 "$P_SRV debug_level=3 auth_mode=optional \
2380 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2381 ca_file=data_files/test-ca.crt \
2382 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2383 "$P_CLI debug_level=3 server_name=localhost \
2384 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2385 0 \
2386 -S "skip write certificate request" \
2387 -C "skip parse certificate request" \
2388 -c "got a certificate request" \
2389 -C "skip write certificate" \
2390 -C "skip write certificate verify" \
2391 -S "skip parse certificate verify" \
2392 -S "x509_verify_cert() returned" \
2393 -S "! The certificate is not correctly signed by the trusted CA" \
2394 -S "The certificate has been revoked (is on a CRL)"
2395
2396run_test "SNI: CA override with CRL" \
2397 "$P_SRV debug_level=3 auth_mode=optional \
2398 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2399 ca_file=data_files/test-ca.crt \
2400 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2401 "$P_CLI debug_level=3 server_name=localhost \
2402 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2403 1 \
2404 -S "skip write certificate request" \
2405 -C "skip parse certificate request" \
2406 -c "got a certificate request" \
2407 -C "skip write certificate" \
2408 -C "skip write certificate verify" \
2409 -S "skip parse certificate verify" \
2410 -s "x509_verify_cert() returned" \
2411 -S "! The certificate is not correctly signed by the trusted CA" \
2412 -s "The certificate has been revoked (is on a CRL)"
2413
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002414# Tests for non-blocking I/O: exercise a variety of handshake flows
2415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002416run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002417 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2418 "$P_CLI nbio=2 tickets=0" \
2419 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002420 -S "mbedtls_ssl_handshake returned" \
2421 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002422 -c "Read from server: .* bytes read"
2423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002424run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002425 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2426 "$P_CLI nbio=2 tickets=0" \
2427 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002428 -S "mbedtls_ssl_handshake returned" \
2429 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002430 -c "Read from server: .* bytes read"
2431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002432run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002433 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2434 "$P_CLI nbio=2 tickets=1" \
2435 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002436 -S "mbedtls_ssl_handshake returned" \
2437 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002438 -c "Read from server: .* bytes read"
2439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002440run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002441 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2442 "$P_CLI nbio=2 tickets=1" \
2443 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002444 -S "mbedtls_ssl_handshake returned" \
2445 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002446 -c "Read from server: .* bytes read"
2447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002448run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002449 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2450 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2451 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002452 -S "mbedtls_ssl_handshake returned" \
2453 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002454 -c "Read from server: .* bytes read"
2455
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002456run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002457 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2458 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2459 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002460 -S "mbedtls_ssl_handshake returned" \
2461 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002462 -c "Read from server: .* bytes read"
2463
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002464run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002465 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2466 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2467 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002468 -S "mbedtls_ssl_handshake returned" \
2469 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002470 -c "Read from server: .* bytes read"
2471
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002472# Tests for version negotiation
2473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002474run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002475 "$P_SRV" \
2476 "$P_CLI" \
2477 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002478 -S "mbedtls_ssl_handshake returned" \
2479 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002480 -s "Protocol is TLSv1.2" \
2481 -c "Protocol is TLSv1.2"
2482
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002483run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002484 "$P_SRV" \
2485 "$P_CLI max_version=tls1_1" \
2486 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002487 -S "mbedtls_ssl_handshake returned" \
2488 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002489 -s "Protocol is TLSv1.1" \
2490 -c "Protocol is TLSv1.1"
2491
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002492run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002493 "$P_SRV max_version=tls1_1" \
2494 "$P_CLI" \
2495 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002496 -S "mbedtls_ssl_handshake returned" \
2497 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002498 -s "Protocol is TLSv1.1" \
2499 -c "Protocol is TLSv1.1"
2500
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002501run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002502 "$P_SRV max_version=tls1_1" \
2503 "$P_CLI max_version=tls1_1" \
2504 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002505 -S "mbedtls_ssl_handshake returned" \
2506 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002507 -s "Protocol is TLSv1.1" \
2508 -c "Protocol is TLSv1.1"
2509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002510run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002511 "$P_SRV min_version=tls1_1" \
2512 "$P_CLI max_version=tls1_1" \
2513 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002514 -S "mbedtls_ssl_handshake returned" \
2515 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002516 -s "Protocol is TLSv1.1" \
2517 -c "Protocol is TLSv1.1"
2518
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002519run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002520 "$P_SRV max_version=tls1_1" \
2521 "$P_CLI min_version=tls1_1" \
2522 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002523 -S "mbedtls_ssl_handshake returned" \
2524 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002525 -s "Protocol is TLSv1.1" \
2526 -c "Protocol is TLSv1.1"
2527
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002528run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002529 "$P_SRV max_version=tls1_1" \
2530 "$P_CLI min_version=tls1_2" \
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 -c "SSL - Handshake protocol not within min/max boundaries"
2535
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002536run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002537 "$P_SRV min_version=tls1_2" \
2538 "$P_CLI max_version=tls1_1" \
2539 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002540 -s "mbedtls_ssl_handshake returned" \
2541 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002542 -s "SSL - Handshake protocol not within min/max boundaries"
2543
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002544# Tests for ALPN extension
2545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002546run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002547 "$P_SRV debug_level=3" \
2548 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002549 0 \
2550 -C "client hello, adding alpn extension" \
2551 -S "found alpn extension" \
2552 -C "got an alert message, type: \\[2:120]" \
2553 -S "server hello, adding alpn extension" \
2554 -C "found alpn extension " \
2555 -C "Application Layer Protocol is" \
2556 -S "Application Layer Protocol is"
2557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002558run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002559 "$P_SRV debug_level=3" \
2560 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002561 0 \
2562 -c "client hello, adding alpn extension" \
2563 -s "found alpn extension" \
2564 -C "got an alert message, type: \\[2:120]" \
2565 -S "server hello, adding alpn extension" \
2566 -C "found alpn extension " \
2567 -c "Application Layer Protocol is (none)" \
2568 -S "Application Layer Protocol is"
2569
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002570run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002571 "$P_SRV debug_level=3 alpn=abc,1234" \
2572 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002573 0 \
2574 -C "client hello, adding alpn extension" \
2575 -S "found alpn extension" \
2576 -C "got an alert message, type: \\[2:120]" \
2577 -S "server hello, adding alpn extension" \
2578 -C "found alpn extension " \
2579 -C "Application Layer Protocol is" \
2580 -s "Application Layer Protocol is (none)"
2581
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002582run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002583 "$P_SRV debug_level=3 alpn=abc,1234" \
2584 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002585 0 \
2586 -c "client hello, adding alpn extension" \
2587 -s "found alpn extension" \
2588 -C "got an alert message, type: \\[2:120]" \
2589 -s "server hello, adding alpn extension" \
2590 -c "found alpn extension" \
2591 -c "Application Layer Protocol is abc" \
2592 -s "Application Layer Protocol is abc"
2593
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002594run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002595 "$P_SRV debug_level=3 alpn=abc,1234" \
2596 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002597 0 \
2598 -c "client hello, adding alpn extension" \
2599 -s "found alpn extension" \
2600 -C "got an alert message, type: \\[2:120]" \
2601 -s "server hello, adding alpn extension" \
2602 -c "found alpn extension" \
2603 -c "Application Layer Protocol is abc" \
2604 -s "Application Layer Protocol is abc"
2605
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002606run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002607 "$P_SRV debug_level=3 alpn=abc,1234" \
2608 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002609 0 \
2610 -c "client hello, adding alpn extension" \
2611 -s "found alpn extension" \
2612 -C "got an alert message, type: \\[2:120]" \
2613 -s "server hello, adding alpn extension" \
2614 -c "found alpn extension" \
2615 -c "Application Layer Protocol is 1234" \
2616 -s "Application Layer Protocol is 1234"
2617
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002618run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002619 "$P_SRV debug_level=3 alpn=abc,123" \
2620 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002621 1 \
2622 -c "client hello, adding alpn extension" \
2623 -s "found alpn extension" \
2624 -c "got an alert message, type: \\[2:120]" \
2625 -S "server hello, adding alpn extension" \
2626 -C "found alpn extension" \
2627 -C "Application Layer Protocol is 1234" \
2628 -S "Application Layer Protocol is 1234"
2629
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002630
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002631# Tests for keyUsage in leaf certificates, part 1:
2632# server-side certificate/suite selection
2633
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002634run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-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-ds.crt" \
2637 "$P_CLI" \
2638 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002639 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002640
2641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002642run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002643 "$P_SRV key_file=data_files/server2.key \
2644 crt_file=data_files/server2.ku-ke.crt" \
2645 "$P_CLI" \
2646 0 \
2647 -c "Ciphersuite is TLS-RSA-WITH-"
2648
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002649run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002650 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002651 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002652 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002653 1 \
2654 -C "Ciphersuite is "
2655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002656run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
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-ds.crt" \
2659 "$P_CLI" \
2660 0 \
2661 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2662
2663
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002664run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002665 "$P_SRV key_file=data_files/server5.key \
2666 crt_file=data_files/server5.ku-ka.crt" \
2667 "$P_CLI" \
2668 0 \
2669 -c "Ciphersuite is TLS-ECDH-"
2670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002671run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002672 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002673 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002674 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002675 1 \
2676 -C "Ciphersuite is "
2677
2678# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002679# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002681run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002682 "$O_SRV -key data_files/server2.key \
2683 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002684 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002685 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2686 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002687 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002688 -C "Processing of the Certificate handshake message failed" \
2689 -c "Ciphersuite is TLS-"
2690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002691run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002692 "$O_SRV -key data_files/server2.key \
2693 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002694 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002695 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2696 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002697 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002698 -C "Processing of the Certificate handshake message failed" \
2699 -c "Ciphersuite is TLS-"
2700
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002701run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002702 "$O_SRV -key data_files/server2.key \
2703 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002704 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002705 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2706 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002707 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002708 -C "Processing of the Certificate handshake message failed" \
2709 -c "Ciphersuite is TLS-"
2710
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002711run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002712 "$O_SRV -key data_files/server2.key \
2713 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002714 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002715 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2716 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002717 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002718 -c "Processing of the Certificate handshake message failed" \
2719 -C "Ciphersuite is TLS-"
2720
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002721run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2722 "$O_SRV -key data_files/server2.key \
2723 -cert data_files/server2.ku-ke.crt" \
2724 "$P_CLI debug_level=1 auth_mode=optional \
2725 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2726 0 \
2727 -c "bad certificate (usage extensions)" \
2728 -C "Processing of the Certificate handshake message failed" \
2729 -c "Ciphersuite is TLS-" \
2730 -c "! Usage does not match the keyUsage extension"
2731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002732run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002733 "$O_SRV -key data_files/server2.key \
2734 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002735 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002736 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2737 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002738 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002739 -C "Processing of the Certificate handshake message failed" \
2740 -c "Ciphersuite is TLS-"
2741
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002742run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002743 "$O_SRV -key data_files/server2.key \
2744 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002745 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002746 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2747 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002748 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002749 -c "Processing of the Certificate handshake message failed" \
2750 -C "Ciphersuite is TLS-"
2751
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002752run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2753 "$O_SRV -key data_files/server2.key \
2754 -cert data_files/server2.ku-ds.crt" \
2755 "$P_CLI debug_level=1 auth_mode=optional \
2756 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2757 0 \
2758 -c "bad certificate (usage extensions)" \
2759 -C "Processing of the Certificate handshake message failed" \
2760 -c "Ciphersuite is TLS-" \
2761 -c "! Usage does not match the keyUsage extension"
2762
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002763# Tests for keyUsage in leaf certificates, part 3:
2764# server-side checking of client cert
2765
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002766run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
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-ds.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 (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002775 "$P_SRV debug_level=1 auth_mode=optional" \
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 0 \
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: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002783 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002784 "$O_CLI -key data_files/server2.key \
2785 -cert data_files/server2.ku-ke.crt" \
2786 1 \
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, DigitalSignature: OK" \
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-ds.crt" \
2794 0 \
2795 -S "bad certificate (usage extensions)" \
2796 -S "Processing of the Certificate handshake message failed"
2797
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002798run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002799 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002800 "$O_CLI -key data_files/server5.key \
2801 -cert data_files/server5.ku-ka.crt" \
2802 0 \
2803 -s "bad certificate (usage extensions)" \
2804 -S "Processing of the Certificate handshake message failed"
2805
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002806# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002808run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002809 "$P_SRV key_file=data_files/server5.key \
2810 crt_file=data_files/server5.eku-srv.crt" \
2811 "$P_CLI" \
2812 0
2813
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002814run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002815 "$P_SRV key_file=data_files/server5.key \
2816 crt_file=data_files/server5.eku-srv.crt" \
2817 "$P_CLI" \
2818 0
2819
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002820run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002821 "$P_SRV key_file=data_files/server5.key \
2822 crt_file=data_files/server5.eku-cs_any.crt" \
2823 "$P_CLI" \
2824 0
2825
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002826run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002827 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002828 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002829 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002830 1
2831
2832# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2833
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002834run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002835 "$O_SRV -key data_files/server5.key \
2836 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002837 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002838 0 \
2839 -C "bad certificate (usage extensions)" \
2840 -C "Processing of the Certificate handshake message failed" \
2841 -c "Ciphersuite is TLS-"
2842
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002843run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002844 "$O_SRV -key data_files/server5.key \
2845 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002846 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002847 0 \
2848 -C "bad certificate (usage extensions)" \
2849 -C "Processing of the Certificate handshake message failed" \
2850 -c "Ciphersuite is TLS-"
2851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002852run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002853 "$O_SRV -key data_files/server5.key \
2854 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002855 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002856 0 \
2857 -C "bad certificate (usage extensions)" \
2858 -C "Processing of the Certificate handshake message failed" \
2859 -c "Ciphersuite is TLS-"
2860
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002861run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002862 "$O_SRV -key data_files/server5.key \
2863 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002864 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002865 1 \
2866 -c "bad certificate (usage extensions)" \
2867 -c "Processing of the Certificate handshake message failed" \
2868 -C "Ciphersuite is TLS-"
2869
2870# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2871
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002872run_test "extKeyUsage cli-auth: 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-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: serverAuth,clientAuth -> 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-srv_cli.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,anyEKU -> OK" \
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_any.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 (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002897 "$P_SRV debug_level=1 auth_mode=optional" \
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 0 \
2901 -s "bad certificate (usage extensions)" \
2902 -S "Processing of the Certificate handshake message failed"
2903
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002904run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002905 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002906 "$O_CLI -key data_files/server5.key \
2907 -cert data_files/server5.eku-cs.crt" \
2908 1 \
2909 -s "bad certificate (usage extensions)" \
2910 -s "Processing of the Certificate handshake message failed"
2911
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002912# Tests for DHM parameters loading
2913
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002914run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002915 "$P_SRV" \
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 ' (2048 bits)" \
2920 -c "value of 'DHM: G ' (2048 bits)"
2921
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002922run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002923 "$P_SRV dhm_file=data_files/dhparams.pem" \
2924 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2925 debug_level=3" \
2926 0 \
2927 -c "value of 'DHM: P ' (1024 bits)" \
2928 -c "value of 'DHM: G ' (2 bits)"
2929
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002930# Tests for DHM client-side size checking
2931
2932run_test "DHM size: server default, client default, OK" \
2933 "$P_SRV" \
2934 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2935 debug_level=1" \
2936 0 \
2937 -C "DHM prime too short:"
2938
2939run_test "DHM size: server default, client 2048, OK" \
2940 "$P_SRV" \
2941 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2942 debug_level=1 dhmlen=2048" \
2943 0 \
2944 -C "DHM prime too short:"
2945
2946run_test "DHM size: server 1024, client default, OK" \
2947 "$P_SRV dhm_file=data_files/dhparams.pem" \
2948 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2949 debug_level=1" \
2950 0 \
2951 -C "DHM prime too short:"
2952
2953run_test "DHM size: server 1000, client default, rejected" \
2954 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2955 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2956 debug_level=1" \
2957 1 \
2958 -c "DHM prime too short:"
2959
2960run_test "DHM size: server default, client 2049, rejected" \
2961 "$P_SRV" \
2962 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2963 debug_level=1 dhmlen=2049" \
2964 1 \
2965 -c "DHM prime too short:"
2966
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002967# Tests for PSK callback
2968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002969run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002970 "$P_SRV psk=abc123 psk_identity=foo" \
2971 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2972 psk_identity=foo psk=abc123" \
2973 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002974 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002975 -S "SSL - Unknown identity received" \
2976 -S "SSL - Verification of the message MAC failed"
2977
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002978run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002979 "$P_SRV" \
2980 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2981 psk_identity=foo psk=abc123" \
2982 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002983 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002984 -S "SSL - Unknown identity received" \
2985 -S "SSL - Verification of the message MAC failed"
2986
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002987run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002988 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2989 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2990 psk_identity=foo psk=abc123" \
2991 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002992 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002993 -s "SSL - Unknown identity received" \
2994 -S "SSL - Verification of the message MAC failed"
2995
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002996run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002997 "$P_SRV psk_list=abc,dead,def,beef" \
2998 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2999 psk_identity=abc psk=dead" \
3000 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003001 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003002 -S "SSL - Unknown identity received" \
3003 -S "SSL - Verification of the message MAC failed"
3004
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003005run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003006 "$P_SRV psk_list=abc,dead,def,beef" \
3007 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3008 psk_identity=def psk=beef" \
3009 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003010 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003011 -S "SSL - Unknown identity received" \
3012 -S "SSL - Verification of the message MAC failed"
3013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003014run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003015 "$P_SRV psk_list=abc,dead,def,beef" \
3016 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3017 psk_identity=ghi psk=beef" \
3018 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003019 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003020 -s "SSL - Unknown identity received" \
3021 -S "SSL - Verification of the message MAC failed"
3022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003023run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003024 "$P_SRV psk_list=abc,dead,def,beef" \
3025 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3026 psk_identity=abc psk=beef" \
3027 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003028 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003029 -S "SSL - Unknown identity received" \
3030 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003031
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003032# Tests for EC J-PAKE
3033
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003034requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003035run_test "ECJPAKE: client not configured" \
3036 "$P_SRV debug_level=3" \
3037 "$P_CLI debug_level=3" \
3038 0 \
3039 -C "add ciphersuite: c0ff" \
3040 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003041 -S "found ecjpake kkpp extension" \
3042 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003043 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003044 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003045 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003046 -S "None of the common ciphersuites is usable"
3047
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003048requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003049run_test "ECJPAKE: server not configured" \
3050 "$P_SRV debug_level=3" \
3051 "$P_CLI debug_level=3 ecjpake_pw=bla \
3052 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3053 1 \
3054 -c "add ciphersuite: c0ff" \
3055 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003056 -s "found ecjpake kkpp extension" \
3057 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003058 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003059 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003060 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003061 -s "None of the common ciphersuites is usable"
3062
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003063requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003064run_test "ECJPAKE: working, TLS" \
3065 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3066 "$P_CLI debug_level=3 ecjpake_pw=bla \
3067 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003068 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003069 -c "add ciphersuite: c0ff" \
3070 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003071 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003072 -s "found ecjpake kkpp extension" \
3073 -S "skip ecjpake kkpp extension" \
3074 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003075 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003076 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003077 -S "None of the common ciphersuites is usable" \
3078 -S "SSL - Verification of the message MAC failed"
3079
Janos Follath74537a62016-09-02 13:45:28 +01003080server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003081requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003082run_test "ECJPAKE: password mismatch, TLS" \
3083 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3084 "$P_CLI debug_level=3 ecjpake_pw=bad \
3085 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3086 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003087 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003088 -s "SSL - Verification of the message MAC failed"
3089
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003090requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003091run_test "ECJPAKE: working, DTLS" \
3092 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3093 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3094 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3095 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003096 -c "re-using cached ecjpake parameters" \
3097 -S "SSL - Verification of the message MAC failed"
3098
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003099requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003100run_test "ECJPAKE: working, DTLS, no cookie" \
3101 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3102 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3103 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3104 0 \
3105 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003106 -S "SSL - Verification of the message MAC failed"
3107
Janos Follath74537a62016-09-02 13:45:28 +01003108server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003109requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003110run_test "ECJPAKE: password mismatch, DTLS" \
3111 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3112 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3113 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3114 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003115 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003116 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003117
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003118# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003119requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003120run_test "ECJPAKE: working, DTLS, nolog" \
3121 "$P_SRV dtls=1 ecjpake_pw=bla" \
3122 "$P_CLI dtls=1 ecjpake_pw=bla \
3123 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3124 0
3125
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003126# Tests for ciphersuites per version
3127
Janos Follathe2681a42016-03-07 15:57:05 +00003128requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003129run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003130 "$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 +02003131 "$P_CLI force_version=ssl3" \
3132 0 \
3133 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3134
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003135run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003136 "$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 +01003137 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003138 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003139 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003141run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003142 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003143 "$P_CLI force_version=tls1_1" \
3144 0 \
3145 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3146
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003147run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003148 "$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 +02003149 "$P_CLI force_version=tls1_2" \
3150 0 \
3151 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3152
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003153# Test for ClientHello without extensions
3154
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003155requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003156run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003157 "$P_SRV debug_level=3" \
3158 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3159 0 \
3160 -s "dumping 'client hello extensions' (0 bytes)"
3161
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003162requires_gnutls
3163run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3164 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3165 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3166 0 \
3167 -s "dumping 'client hello extensions' (0 bytes)"
3168
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003169# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003170
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003171run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003172 "$P_SRV" \
3173 "$P_CLI request_size=100" \
3174 0 \
3175 -s "Read from client: 100 bytes read$"
3176
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003177run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003178 "$P_SRV" \
3179 "$P_CLI request_size=500" \
3180 0 \
3181 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003182
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003183# Tests for small packets
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 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003187 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003188 "$P_CLI request_size=1 force_version=ssl3 \
3189 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3190 0 \
3191 -s "Read from client: 1 bytes read"
3192
Janos Follathe2681a42016-03-07 15:57:05 +00003193requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003194run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003195 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003196 "$P_CLI request_size=1 force_version=ssl3 \
3197 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3198 0 \
3199 -s "Read from client: 1 bytes read"
3200
3201run_test "Small packet TLS 1.0 BlockCipher" \
3202 "$P_SRV" \
3203 "$P_CLI request_size=1 force_version=tls1 \
3204 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3205 0 \
3206 -s "Read from client: 1 bytes read"
3207
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003208run_test "Small packet TLS 1.0 BlockCipher without EtM" \
3209 "$P_SRV" \
3210 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3211 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3212 0 \
3213 -s "Read from client: 1 bytes read"
3214
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003215run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
3216 "$P_SRV" \
3217 "$P_CLI request_size=1 force_version=tls1 \
3218 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3219 trunc_hmac=1" \
3220 0 \
3221 -s "Read from client: 1 bytes read"
3222
3223run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003224 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003225 "$P_CLI request_size=1 force_version=tls1 \
3226 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3227 trunc_hmac=1" \
3228 0 \
3229 -s "Read from client: 1 bytes read"
3230
3231run_test "Small packet TLS 1.1 BlockCipher" \
3232 "$P_SRV" \
3233 "$P_CLI request_size=1 force_version=tls1_1 \
3234 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3235 0 \
3236 -s "Read from client: 1 bytes read"
3237
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003238run_test "Small packet TLS 1.1 BlockCipher without EtM" \
3239 "$P_SRV" \
3240 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
3241 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3242 0 \
3243 -s "Read from client: 1 bytes read"
3244
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003245run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003246 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003247 "$P_CLI request_size=1 force_version=tls1_1 \
3248 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3249 0 \
3250 -s "Read from client: 1 bytes read"
3251
3252run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3253 "$P_SRV" \
3254 "$P_CLI request_size=1 force_version=tls1_1 \
3255 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3256 trunc_hmac=1" \
3257 0 \
3258 -s "Read from client: 1 bytes read"
3259
3260run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003261 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003262 "$P_CLI request_size=1 force_version=tls1_1 \
3263 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3264 trunc_hmac=1" \
3265 0 \
3266 -s "Read from client: 1 bytes read"
3267
3268run_test "Small packet TLS 1.2 BlockCipher" \
3269 "$P_SRV" \
3270 "$P_CLI request_size=1 force_version=tls1_2 \
3271 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3272 0 \
3273 -s "Read from client: 1 bytes read"
3274
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003275run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3276 "$P_SRV" \
3277 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3278 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3279 0 \
3280 -s "Read from client: 1 bytes read"
3281
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003282run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3283 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003284 "$P_CLI request_size=1 force_version=tls1_2 \
3285 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003286 0 \
3287 -s "Read from client: 1 bytes read"
3288
3289run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3290 "$P_SRV" \
3291 "$P_CLI request_size=1 force_version=tls1_2 \
3292 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3293 trunc_hmac=1" \
3294 0 \
3295 -s "Read from client: 1 bytes read"
3296
3297run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003298 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003299 "$P_CLI request_size=1 force_version=tls1_2 \
3300 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3301 0 \
3302 -s "Read from client: 1 bytes read"
3303
3304run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003305 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003306 "$P_CLI request_size=1 force_version=tls1_2 \
3307 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3308 trunc_hmac=1" \
3309 0 \
3310 -s "Read from client: 1 bytes read"
3311
3312run_test "Small packet TLS 1.2 AEAD" \
3313 "$P_SRV" \
3314 "$P_CLI request_size=1 force_version=tls1_2 \
3315 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3316 0 \
3317 -s "Read from client: 1 bytes read"
3318
3319run_test "Small packet TLS 1.2 AEAD shorter tag" \
3320 "$P_SRV" \
3321 "$P_CLI request_size=1 force_version=tls1_2 \
3322 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3323 0 \
3324 -s "Read from client: 1 bytes read"
3325
Janos Follath00efff72016-05-06 13:48:23 +01003326# A test for extensions in SSLv3
3327
3328requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3329run_test "SSLv3 with extensions, server side" \
3330 "$P_SRV min_version=ssl3 debug_level=3" \
3331 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3332 0 \
3333 -S "dumping 'client hello extensions'" \
3334 -S "server hello, total extension length:"
3335
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003336# Test for large packets
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 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003340 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003341 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003342 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3343 0 \
3344 -s "Read from client: 16384 bytes read"
3345
Janos Follathe2681a42016-03-07 15:57:05 +00003346requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003347run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003348 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003349 "$P_CLI request_size=16384 force_version=ssl3 \
3350 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3351 0 \
3352 -s "Read from client: 16384 bytes read"
3353
3354run_test "Large packet TLS 1.0 BlockCipher" \
3355 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003356 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003357 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3358 0 \
3359 -s "Read from client: 16384 bytes read"
3360
3361run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3362 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003363 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003364 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3365 trunc_hmac=1" \
3366 0 \
3367 -s "Read from client: 16384 bytes read"
3368
3369run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003370 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003371 "$P_CLI request_size=16384 force_version=tls1 \
3372 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3373 trunc_hmac=1" \
3374 0 \
3375 -s "Read from client: 16384 bytes read"
3376
3377run_test "Large packet TLS 1.1 BlockCipher" \
3378 "$P_SRV" \
3379 "$P_CLI request_size=16384 force_version=tls1_1 \
3380 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3381 0 \
3382 -s "Read from client: 16384 bytes read"
3383
3384run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003385 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003386 "$P_CLI request_size=16384 force_version=tls1_1 \
3387 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3388 0 \
3389 -s "Read from client: 16384 bytes read"
3390
3391run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3392 "$P_SRV" \
3393 "$P_CLI request_size=16384 force_version=tls1_1 \
3394 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3395 trunc_hmac=1" \
3396 0 \
3397 -s "Read from client: 16384 bytes read"
3398
3399run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003400 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003401 "$P_CLI request_size=16384 force_version=tls1_1 \
3402 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3403 trunc_hmac=1" \
3404 0 \
3405 -s "Read from client: 16384 bytes read"
3406
3407run_test "Large packet TLS 1.2 BlockCipher" \
3408 "$P_SRV" \
3409 "$P_CLI request_size=16384 force_version=tls1_2 \
3410 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3411 0 \
3412 -s "Read from client: 16384 bytes read"
3413
3414run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3415 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003416 "$P_CLI request_size=16384 force_version=tls1_2 \
3417 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003418 0 \
3419 -s "Read from client: 16384 bytes read"
3420
3421run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3422 "$P_SRV" \
3423 "$P_CLI request_size=16384 force_version=tls1_2 \
3424 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3425 trunc_hmac=1" \
3426 0 \
3427 -s "Read from client: 16384 bytes read"
3428
3429run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003430 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003431 "$P_CLI request_size=16384 force_version=tls1_2 \
3432 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3433 0 \
3434 -s "Read from client: 16384 bytes read"
3435
3436run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003437 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003438 "$P_CLI request_size=16384 force_version=tls1_2 \
3439 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3440 trunc_hmac=1" \
3441 0 \
3442 -s "Read from client: 16384 bytes read"
3443
3444run_test "Large packet TLS 1.2 AEAD" \
3445 "$P_SRV" \
3446 "$P_CLI request_size=16384 force_version=tls1_2 \
3447 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3448 0 \
3449 -s "Read from client: 16384 bytes read"
3450
3451run_test "Large packet TLS 1.2 AEAD shorter tag" \
3452 "$P_SRV" \
3453 "$P_CLI request_size=16384 force_version=tls1_2 \
3454 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3455 0 \
3456 -s "Read from client: 16384 bytes read"
3457
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003458# Tests for DTLS HelloVerifyRequest
3459
3460run_test "DTLS cookie: enabled" \
3461 "$P_SRV dtls=1 debug_level=2" \
3462 "$P_CLI dtls=1 debug_level=2" \
3463 0 \
3464 -s "cookie verification failed" \
3465 -s "cookie verification passed" \
3466 -S "cookie verification skipped" \
3467 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003468 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003469 -S "SSL - The requested feature is not available"
3470
3471run_test "DTLS cookie: disabled" \
3472 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3473 "$P_CLI dtls=1 debug_level=2" \
3474 0 \
3475 -S "cookie verification failed" \
3476 -S "cookie verification passed" \
3477 -s "cookie verification skipped" \
3478 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003479 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003480 -S "SSL - The requested feature is not available"
3481
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003482run_test "DTLS cookie: default (failing)" \
3483 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3484 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3485 1 \
3486 -s "cookie verification failed" \
3487 -S "cookie verification passed" \
3488 -S "cookie verification skipped" \
3489 -C "received hello verify request" \
3490 -S "hello verification requested" \
3491 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003492
3493requires_ipv6
3494run_test "DTLS cookie: enabled, IPv6" \
3495 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3496 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3497 0 \
3498 -s "cookie verification failed" \
3499 -s "cookie verification passed" \
3500 -S "cookie verification skipped" \
3501 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003502 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003503 -S "SSL - The requested feature is not available"
3504
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003505run_test "DTLS cookie: enabled, nbio" \
3506 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3507 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3508 0 \
3509 -s "cookie verification failed" \
3510 -s "cookie verification passed" \
3511 -S "cookie verification skipped" \
3512 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003513 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003514 -S "SSL - The requested feature is not available"
3515
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003516# Tests for client reconnecting from the same port with DTLS
3517
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003518not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003519run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003520 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3521 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003522 0 \
3523 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003524 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003525 -S "Client initiated reconnection from same port"
3526
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003527not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003528run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003529 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3530 "$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 +02003531 0 \
3532 -C "resend" \
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 +01003536not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3537run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003538 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3539 "$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 +02003540 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003541 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003542 -s "Client initiated reconnection from same port"
3543
Paul Bakker362689d2016-05-13 10:33:25 +01003544only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3545run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3546 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3547 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3548 0 \
3549 -S "The operation timed out" \
3550 -s "Client initiated reconnection from same port"
3551
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003552run_test "DTLS client reconnect from same port: no cookies" \
3553 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003554 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3555 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003556 -s "The operation timed out" \
3557 -S "Client initiated reconnection from same port"
3558
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003559# Tests for various cases of client authentication with DTLS
3560# (focused on handshake flows and message parsing)
3561
3562run_test "DTLS client auth: required" \
3563 "$P_SRV dtls=1 auth_mode=required" \
3564 "$P_CLI dtls=1" \
3565 0 \
3566 -s "Verifying peer X.509 certificate... ok"
3567
3568run_test "DTLS client auth: optional, client has no cert" \
3569 "$P_SRV dtls=1 auth_mode=optional" \
3570 "$P_CLI dtls=1 crt_file=none key_file=none" \
3571 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003572 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003573
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003574run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003575 "$P_SRV dtls=1 auth_mode=none" \
3576 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3577 0 \
3578 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003579 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003580
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003581run_test "DTLS wrong PSK: badmac alert" \
3582 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3583 "$P_CLI dtls=1 psk=abc124" \
3584 1 \
3585 -s "SSL - Verification of the message MAC failed" \
3586 -c "SSL - A fatal alert message was received from our peer"
3587
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003588# Tests for receiving fragmented handshake messages with DTLS
3589
3590requires_gnutls
3591run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3592 "$G_SRV -u --mtu 2048 -a" \
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: some fragmentation (gnutls server)" \
3600 "$G_SRV -u --mtu 512" \
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 (gnutls server)" \
3608 "$G_SRV -u --mtu 128" \
3609 "$P_CLI dtls=1 debug_level=2" \
3610 0 \
3611 -c "found fragmented DTLS handshake message" \
3612 -C "error"
3613
3614requires_gnutls
3615run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3616 "$G_SRV -u --mtu 128" \
3617 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3618 0 \
3619 -c "found fragmented DTLS handshake message" \
3620 -C "error"
3621
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003622requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003623run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3624 "$G_SRV -u --mtu 256" \
3625 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3626 0 \
3627 -c "found fragmented DTLS handshake message" \
3628 -c "client hello, adding renegotiation extension" \
3629 -c "found renegotiation extension" \
3630 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003631 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003632 -C "error" \
3633 -s "Extra-header:"
3634
3635requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003636run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3637 "$G_SRV -u --mtu 256" \
3638 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3639 0 \
3640 -c "found fragmented DTLS handshake message" \
3641 -c "client hello, adding renegotiation extension" \
3642 -c "found renegotiation extension" \
3643 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003644 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003645 -C "error" \
3646 -s "Extra-header:"
3647
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003648run_test "DTLS reassembly: no fragmentation (openssl server)" \
3649 "$O_SRV -dtls1 -mtu 2048" \
3650 "$P_CLI dtls=1 debug_level=2" \
3651 0 \
3652 -C "found fragmented DTLS handshake message" \
3653 -C "error"
3654
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003655run_test "DTLS reassembly: some fragmentation (openssl server)" \
3656 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003657 "$P_CLI dtls=1 debug_level=2" \
3658 0 \
3659 -c "found fragmented DTLS handshake message" \
3660 -C "error"
3661
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003662run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003663 "$O_SRV -dtls1 -mtu 256" \
3664 "$P_CLI dtls=1 debug_level=2" \
3665 0 \
3666 -c "found fragmented DTLS handshake message" \
3667 -C "error"
3668
3669run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3670 "$O_SRV -dtls1 -mtu 256" \
3671 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3672 0 \
3673 -c "found fragmented DTLS handshake message" \
3674 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003675
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003676# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003677
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003678not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003679run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003680 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003681 "$P_SRV dtls=1 debug_level=2" \
3682 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003683 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003684 -C "replayed record" \
3685 -S "replayed record" \
3686 -C "record from another epoch" \
3687 -S "record from another epoch" \
3688 -C "discarding invalid record" \
3689 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003690 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003691 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003692 -c "HTTP/1.0 200 OK"
3693
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003694not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003695run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003696 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003697 "$P_SRV dtls=1 debug_level=2" \
3698 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003699 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003700 -c "replayed record" \
3701 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003702 -c "discarding invalid record" \
3703 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003704 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003705 -s "Extra-header:" \
3706 -c "HTTP/1.0 200 OK"
3707
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003708run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3709 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003710 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3711 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003712 0 \
3713 -c "replayed record" \
3714 -S "replayed record" \
3715 -c "discarding invalid record" \
3716 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003717 -c "resend" \
3718 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003719 -s "Extra-header:" \
3720 -c "HTTP/1.0 200 OK"
3721
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003722run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003723 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003724 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003725 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003726 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003727 -c "discarding invalid record (mac)" \
3728 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003729 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003730 -c "HTTP/1.0 200 OK" \
3731 -S "too many records with bad MAC" \
3732 -S "Verification of the message MAC failed"
3733
3734run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3735 -p "$P_PXY bad_ad=1" \
3736 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3737 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3738 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003739 -C "discarding invalid record (mac)" \
3740 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003741 -S "Extra-header:" \
3742 -C "HTTP/1.0 200 OK" \
3743 -s "too many records with bad MAC" \
3744 -s "Verification of the message MAC failed"
3745
3746run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3747 -p "$P_PXY bad_ad=1" \
3748 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3749 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3750 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003751 -c "discarding invalid record (mac)" \
3752 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003753 -s "Extra-header:" \
3754 -c "HTTP/1.0 200 OK" \
3755 -S "too many records with bad MAC" \
3756 -S "Verification of the message MAC failed"
3757
3758run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3759 -p "$P_PXY bad_ad=1" \
3760 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3761 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3762 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003763 -c "discarding invalid record (mac)" \
3764 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003765 -s "Extra-header:" \
3766 -c "HTTP/1.0 200 OK" \
3767 -s "too many records with bad MAC" \
3768 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003769
3770run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003771 -p "$P_PXY delay_ccs=1" \
3772 "$P_SRV dtls=1 debug_level=1" \
3773 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003774 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003775 -c "record from another epoch" \
3776 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003777 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003778 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003779 -s "Extra-header:" \
3780 -c "HTTP/1.0 200 OK"
3781
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003782# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003783
Janos Follath74537a62016-09-02 13:45:28 +01003784client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003785run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003786 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003787 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3788 psk=abc123" \
3789 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003790 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3791 0 \
3792 -s "Extra-header:" \
3793 -c "HTTP/1.0 200 OK"
3794
Janos Follath74537a62016-09-02 13:45:28 +01003795client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003796run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3797 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003798 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3799 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003800 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3801 0 \
3802 -s "Extra-header:" \
3803 -c "HTTP/1.0 200 OK"
3804
Janos Follath74537a62016-09-02 13:45:28 +01003805client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003806run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3807 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003808 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3809 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003810 0 \
3811 -s "Extra-header:" \
3812 -c "HTTP/1.0 200 OK"
3813
Janos Follath74537a62016-09-02 13:45:28 +01003814client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003815run_test "DTLS proxy: 3d, FS, client auth" \
3816 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003817 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3818 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003819 0 \
3820 -s "Extra-header:" \
3821 -c "HTTP/1.0 200 OK"
3822
Janos Follath74537a62016-09-02 13:45:28 +01003823client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003824run_test "DTLS proxy: 3d, FS, ticket" \
3825 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003826 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3827 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003828 0 \
3829 -s "Extra-header:" \
3830 -c "HTTP/1.0 200 OK"
3831
Janos Follath74537a62016-09-02 13:45:28 +01003832client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003833run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3834 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003835 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3836 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003837 0 \
3838 -s "Extra-header:" \
3839 -c "HTTP/1.0 200 OK"
3840
Janos Follath74537a62016-09-02 13:45:28 +01003841client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003842run_test "DTLS proxy: 3d, max handshake, nbio" \
3843 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003844 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3845 auth_mode=required" \
3846 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003847 0 \
3848 -s "Extra-header:" \
3849 -c "HTTP/1.0 200 OK"
3850
Janos Follath74537a62016-09-02 13:45:28 +01003851client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003852run_test "DTLS proxy: 3d, min handshake, resumption" \
3853 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3854 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3855 psk=abc123 debug_level=3" \
3856 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3857 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3858 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3859 0 \
3860 -s "a session has been resumed" \
3861 -c "a session has been resumed" \
3862 -s "Extra-header:" \
3863 -c "HTTP/1.0 200 OK"
3864
Janos Follath74537a62016-09-02 13:45:28 +01003865client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003866run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3867 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3868 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3869 psk=abc123 debug_level=3 nbio=2" \
3870 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3871 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3872 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3873 0 \
3874 -s "a session has been resumed" \
3875 -c "a session has been resumed" \
3876 -s "Extra-header:" \
3877 -c "HTTP/1.0 200 OK"
3878
Janos Follath74537a62016-09-02 13:45:28 +01003879client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003880run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003881 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003882 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3883 psk=abc123 renegotiation=1 debug_level=2" \
3884 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3885 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003886 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3887 0 \
3888 -c "=> renegotiate" \
3889 -s "=> renegotiate" \
3890 -s "Extra-header:" \
3891 -c "HTTP/1.0 200 OK"
3892
Janos Follath74537a62016-09-02 13:45:28 +01003893client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003894run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3895 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003896 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3897 psk=abc123 renegotiation=1 debug_level=2" \
3898 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3899 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003900 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3901 0 \
3902 -c "=> renegotiate" \
3903 -s "=> renegotiate" \
3904 -s "Extra-header:" \
3905 -c "HTTP/1.0 200 OK"
3906
Janos Follath74537a62016-09-02 13:45:28 +01003907client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003908run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003909 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003910 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003911 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003912 debug_level=2" \
3913 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003914 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003915 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3916 0 \
3917 -c "=> renegotiate" \
3918 -s "=> renegotiate" \
3919 -s "Extra-header:" \
3920 -c "HTTP/1.0 200 OK"
3921
Janos Follath74537a62016-09-02 13:45:28 +01003922client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003923run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003924 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003925 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003926 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003927 debug_level=2 nbio=2" \
3928 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003929 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003930 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3931 0 \
3932 -c "=> renegotiate" \
3933 -s "=> renegotiate" \
3934 -s "Extra-header:" \
3935 -c "HTTP/1.0 200 OK"
3936
Janos Follath74537a62016-09-02 13:45:28 +01003937client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003938not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003939run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003940 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3941 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003942 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003943 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003944 -c "HTTP/1.0 200 OK"
3945
Janos Follath74537a62016-09-02 13:45:28 +01003946client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003947not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003948run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3949 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3950 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003951 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003952 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003953 -c "HTTP/1.0 200 OK"
3954
Janos Follath74537a62016-09-02 13:45:28 +01003955client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003956not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003957run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3958 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3959 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003960 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003961 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003962 -c "HTTP/1.0 200 OK"
3963
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003964requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003965client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003966not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003967run_test "DTLS proxy: 3d, gnutls server" \
3968 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3969 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003970 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003971 0 \
3972 -s "Extra-header:" \
3973 -c "Extra-header:"
3974
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003975requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003976client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003977not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003978run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3979 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3980 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003981 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003982 0 \
3983 -s "Extra-header:" \
3984 -c "Extra-header:"
3985
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003986requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003987client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003988not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003989run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3990 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3991 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003992 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003993 0 \
3994 -s "Extra-header:" \
3995 -c "Extra-header:"
3996
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003997# Final report
3998
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003999echo "------------------------------------------------------------------------"
4000
4001if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004002 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004003else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004004 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004005fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004006PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004007echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004008
4009exit $FAILS