blob: 34aa43f99f7a59911140443befb377dcbbd165bf [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020031: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010032
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020033O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010034O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020035G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010036G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020037TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010038
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010039TESTS=0
40FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020041SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010042
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000043CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020044
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020047EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010048
Paul Bakkere20310a2016-05-10 11:18:17 +010049SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010050RUN_TEST_NUMBER=''
51
Paul Bakkeracaac852016-05-10 11:47:13 +010052PRESERVE_LOGS=0
53
Gilles Peskinef93c7d32017-04-14 17:55:28 +020054# Pick a "unique" server port in the range 10000-19999, and a proxy
55# port which is this plus 10000. Each port number may be independently
56# overridden by a command line option.
57SRV_PORT=$(($$ % 10000 + 10000))
58PXY_PORT=$((SRV_PORT + 10000))
59
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010060print_usage() {
61 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010062 printf " -h|--help\tPrint this help.\n"
63 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020064 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
65 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010066 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010067 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010068 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020069 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
70 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010071 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072}
73
74get_options() {
75 while [ $# -gt 0 ]; do
76 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010077 -f|--filter)
78 shift; FILTER=$1
79 ;;
80 -e|--exclude)
81 shift; EXCLUDE=$1
82 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010083 -m|--memcheck)
84 MEMCHECK=1
85 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010086 -n|--number)
87 shift; RUN_TEST_NUMBER=$1
88 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010089 -s|--show-numbers)
90 SHOW_TEST_NUMBER=1
91 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010092 -p|--preserve-logs)
93 PRESERVE_LOGS=1
94 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020095 --port)
96 shift; SRV_PORT=$1
97 ;;
98 --proxy-port)
99 shift; PXY_PORT=$1
100 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100101 --seed)
102 shift; SEED="$1"
103 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100104 -h|--help)
105 print_usage
106 exit 0
107 ;;
108 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200109 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100110 print_usage
111 exit 1
112 ;;
113 esac
114 shift
115 done
116}
117
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100118# skip next test if the flag is not enabled in config.h
119requires_config_enabled() {
120 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
121 SKIP_NEXT="YES"
122 fi
123}
124
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200125# skip next test if the flag is enabled in config.h
126requires_config_disabled() {
127 if grep "^#define $1" $CONFIG_H > /dev/null; then
128 SKIP_NEXT="YES"
129 fi
130}
131
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200132# skip next test if OpenSSL doesn't support FALLBACK_SCSV
133requires_openssl_with_fallback_scsv() {
134 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
135 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
136 then
137 OPENSSL_HAS_FBSCSV="YES"
138 else
139 OPENSSL_HAS_FBSCSV="NO"
140 fi
141 fi
142 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
143 SKIP_NEXT="YES"
144 fi
145}
146
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200147# skip next test if GnuTLS isn't available
148requires_gnutls() {
149 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200150 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200151 GNUTLS_AVAILABLE="YES"
152 else
153 GNUTLS_AVAILABLE="NO"
154 fi
155 fi
156 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200161# skip next test if IPv6 isn't available on this host
162requires_ipv6() {
163 if [ -z "${HAS_IPV6:-}" ]; then
164 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
165 SRV_PID=$!
166 sleep 1
167 kill $SRV_PID >/dev/null 2>&1
168 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
169 HAS_IPV6="NO"
170 else
171 HAS_IPV6="YES"
172 fi
173 rm -r $SRV_OUT
174 fi
175
176 if [ "$HAS_IPV6" = "NO" ]; then
177 SKIP_NEXT="YES"
178 fi
179}
180
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200181# skip the next test if valgrind is in use
182not_with_valgrind() {
183 if [ "$MEMCHECK" -gt 0 ]; then
184 SKIP_NEXT="YES"
185 fi
186}
187
Paul Bakker362689d2016-05-13 10:33:25 +0100188# skip the next test if valgrind is NOT in use
189only_with_valgrind() {
190 if [ "$MEMCHECK" -eq 0 ]; then
191 SKIP_NEXT="YES"
192 fi
193}
194
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200195# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100196client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200197 CLI_DELAY_FACTOR=$1
198}
199
Janos Follath74537a62016-09-02 13:45:28 +0100200# wait for the given seconds after the client finished in the next test
201server_needs_more_time() {
202 SRV_DELAY_SECONDS=$1
203}
204
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100205# print_name <name>
206print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100207 TESTS=$(( $TESTS + 1 ))
208 LINE=""
209
210 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
211 LINE="$TESTS "
212 fi
213
214 LINE="$LINE$1"
215 printf "$LINE "
216 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100217 for i in `seq 1 $LEN`; do printf '.'; done
218 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100219
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100220}
221
222# fail <message>
223fail() {
224 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100225 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100226
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200227 mv $SRV_OUT o-srv-${TESTS}.log
228 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200229 if [ -n "$PXY_CMD" ]; then
230 mv $PXY_OUT o-pxy-${TESTS}.log
231 fi
232 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100233
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200234 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
235 echo " ! server output:"
236 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200237 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200238 echo " ! client output:"
239 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200240 if [ -n "$PXY_CMD" ]; then
241 echo " ! ========================================================"
242 echo " ! proxy output:"
243 cat o-pxy-${TESTS}.log
244 fi
245 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200246 fi
247
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200248 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100249}
250
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100251# is_polar <cmd_line>
252is_polar() {
253 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
254}
255
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200256# openssl s_server doesn't have -www with DTLS
257check_osrv_dtls() {
258 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
259 NEEDS_INPUT=1
260 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
261 else
262 NEEDS_INPUT=0
263 fi
264}
265
266# provide input to commands that need it
267provide_input() {
268 if [ $NEEDS_INPUT -eq 0 ]; then
269 return
270 fi
271
272 while true; do
273 echo "HTTP/1.0 200 OK"
274 sleep 1
275 done
276}
277
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100278# has_mem_err <log_file_name>
279has_mem_err() {
280 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
281 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
282 then
283 return 1 # false: does not have errors
284 else
285 return 0 # true: has errors
286 fi
287}
288
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200289# wait for server to start: two versions depending on lsof availability
290wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200291 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200292 START_TIME=$( date +%s )
293 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200294
295 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200296 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200297 while [ $DONE -eq 0 ]; do
298 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
299 then
300 DONE=1
301 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
302 echo "SERVERSTART TIMEOUT"
303 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
304 DONE=1
305 fi
306 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200307 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200308 while [ $DONE -eq 0 ]; do
309 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
310 then
311 DONE=1
312 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
313 echo "SERVERSTART TIMEOUT"
314 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
315 DONE=1
316 fi
317 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200318 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200319 else
320 sleep "$START_DELAY"
321 fi
322}
323
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200324# wait for client to terminate and set CLI_EXIT
325# must be called right after starting the client
326wait_client_done() {
327 CLI_PID=$!
328
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200329 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
330 CLI_DELAY_FACTOR=1
331
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200332 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200333 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200334
335 wait $CLI_PID
336 CLI_EXIT=$?
337
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200338 kill $DOG_PID >/dev/null 2>&1
339 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200340
341 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100342
343 sleep $SRV_DELAY_SECONDS
344 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200345}
346
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200347# check if the given command uses dtls and sets global variable DTLS
348detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200349 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200350 DTLS=1
351 else
352 DTLS=0
353 fi
354}
355
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200356# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100357# Options: -s pattern pattern that must be present in server output
358# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100359# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100360# -S pattern pattern that must be absent in server output
361# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100362# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100363run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100364 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200365 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100366
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100367 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
368 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200369 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100370 return
371 fi
372
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100373 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100374
Paul Bakkerb7584a52016-05-10 10:50:43 +0100375 # Do we only run numbered tests?
376 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
377 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
378 else
379 SKIP_NEXT="YES"
380 fi
381
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200382 # should we skip?
383 if [ "X$SKIP_NEXT" = "XYES" ]; then
384 SKIP_NEXT="NO"
385 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200386 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200387 return
388 fi
389
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200390 # does this test use a proxy?
391 if [ "X$1" = "X-p" ]; then
392 PXY_CMD="$2"
393 shift 2
394 else
395 PXY_CMD=""
396 fi
397
398 # get commands and client output
399 SRV_CMD="$1"
400 CLI_CMD="$2"
401 CLI_EXPECT="$3"
402 shift 3
403
404 # fix client port
405 if [ -n "$PXY_CMD" ]; then
406 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
407 else
408 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
409 fi
410
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200411 # update DTLS variable
412 detect_dtls "$SRV_CMD"
413
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100414 # prepend valgrind to our commands if active
415 if [ "$MEMCHECK" -gt 0 ]; then
416 if is_polar "$SRV_CMD"; then
417 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
418 fi
419 if is_polar "$CLI_CMD"; then
420 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
421 fi
422 fi
423
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200424 TIMES_LEFT=2
425 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200426 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200427
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200428 # run the commands
429 if [ -n "$PXY_CMD" ]; then
430 echo "$PXY_CMD" > $PXY_OUT
431 $PXY_CMD >> $PXY_OUT 2>&1 &
432 PXY_PID=$!
433 # assume proxy starts faster than server
434 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200435
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200436 check_osrv_dtls
437 echo "$SRV_CMD" > $SRV_OUT
438 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
439 SRV_PID=$!
440 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200441
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200442 echo "$CLI_CMD" > $CLI_OUT
443 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
444 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100445
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100446 sleep 0.05
447
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200448 # terminate the server (and the proxy)
449 kill $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100450 sleep 0.01
451 if kill -0 $SRV_PID >/dev/null 2>&1; then
452 kill -KILL $SRV_PID
453 wait $SRV_PID
454 fi
455
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200456 if [ -n "$PXY_CMD" ]; then
457 kill $PXY_PID >/dev/null 2>&1
Hanno Beckerd82d8462017-05-29 21:37:46 +0100458 sleep 0.01
459 if kill -0 $PXY_PID >/dev/null 2>&1; then
Hanno Becker4ac73e72017-10-23 15:27:37 +0100460 kill -KILL $PXY_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100461 wait $PXY_PID
462 fi
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200463 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100464
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200465 # retry only on timeouts
466 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
467 printf "RETRY "
468 else
469 TIMES_LEFT=0
470 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200471 done
472
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100473 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200474 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100475 # expected client exit to incorrectly succeed in case of catastrophic
476 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100477 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200478 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100479 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100480 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100481 return
482 fi
483 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100484 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200485 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100486 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100487 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100488 return
489 fi
490 fi
491
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100492 # check server exit code
493 if [ $? != 0 ]; then
494 fail "server fail"
495 return
496 fi
497
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100498 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100499 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
500 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100501 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200502 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100503 return
504 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100505
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100506 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200507 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100508 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100509 while [ $# -gt 0 ]
510 do
511 case $1 in
512 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100513 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100514 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100515 return
516 fi
517 ;;
518
519 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100520 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100521 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100522 return
523 fi
524 ;;
525
526 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100527 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100528 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100529 return
530 fi
531 ;;
532
533 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100534 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100535 fail "pattern '$2' MUST NOT be present in the Client output"
536 return
537 fi
538 ;;
539
540 # The filtering in the following two options (-u and -U) do the following
541 # - ignore valgrind output
542 # - filter out everything but lines right after the pattern occurances
543 # - keep one of each non-unique line
544 # - count how many lines remain
545 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
546 # if there were no duplicates.
547 "-U")
548 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
549 fail "lines following pattern '$2' must be unique in Server output"
550 return
551 fi
552 ;;
553
554 "-u")
555 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
556 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100557 return
558 fi
559 ;;
560
561 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200562 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100563 exit 1
564 esac
565 shift 2
566 done
567
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100568 # check valgrind's results
569 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200570 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100571 fail "Server has memory errors"
572 return
573 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200574 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100575 fail "Client has memory errors"
576 return
577 fi
578 fi
579
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100580 # if we're here, everything is ok
581 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100582 if [ "$PRESERVE_LOGS" -gt 0 ]; then
583 mv $SRV_OUT o-srv-${TESTS}.log
584 mv $CLI_OUT o-cli-${TESTS}.log
585 fi
586
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200587 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100588}
589
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100590cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200591 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200592 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
593 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
594 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
595 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100596 exit 1
597}
598
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100599#
600# MAIN
601#
602
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000603if cd $( dirname $0 ); then :; else
604 echo "cd $( dirname $0 ) failed" >&2
605 exit 1
606fi
607
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100608get_options "$@"
609
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100610# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100611P_SRV_BIN="${P_SRV%%[ ]*}"
612P_CLI_BIN="${P_CLI%%[ ]*}"
613P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100614if [ ! -x "$P_SRV_BIN" ]; then
615 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100616 exit 1
617fi
Hanno Becker17c04932017-10-10 14:44:53 +0100618if [ ! -x "$P_CLI_BIN" ]; then
619 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100620 exit 1
621fi
Hanno Becker17c04932017-10-10 14:44:53 +0100622if [ ! -x "$P_PXY_BIN" ]; then
623 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200624 exit 1
625fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100626if [ "$MEMCHECK" -gt 0 ]; then
627 if which valgrind >/dev/null 2>&1; then :; else
628 echo "Memcheck not possible. Valgrind not found"
629 exit 1
630 fi
631fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100632if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
633 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100634 exit 1
635fi
636
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200637# used by watchdog
638MAIN_PID="$$"
639
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200640# be more patient with valgrind
641if [ "$MEMCHECK" -gt 0 ]; then
642 START_DELAY=3
643 DOG_DELAY=30
644else
645 START_DELAY=1
646 DOG_DELAY=10
647fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200648CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100649SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200650
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200651# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000652# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200653P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
654P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100655P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200656O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200657O_CLI="$O_CLI -connect localhost:+SRV_PORT"
658G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000659G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200660
Gilles Peskine62469d92017-05-10 10:13:59 +0200661# Allow SHA-1, because many of our test certificates use it
662P_SRV="$P_SRV allow_sha1=1"
663P_CLI="$P_CLI allow_sha1=1"
664
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200665# Also pick a unique name for intermediate files
666SRV_OUT="srv_out.$$"
667CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200668PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200669SESSION="session.$$"
670
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200671SKIP_NEXT="NO"
672
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100673trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100674
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200675# Basic test
676
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200677# Checks that:
678# - things work with all ciphersuites active (used with config-full in all.sh)
679# - the expected (highest security) parameters are selected
680# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200681run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200682 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200683 "$P_CLI" \
684 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200685 -s "Protocol is TLSv1.2" \
686 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
687 -s "client hello v3, signature_algorithm ext: 6" \
688 -s "ECDHE curve: secp521r1" \
689 -S "error" \
690 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200691
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000692run_test "Default, DTLS" \
693 "$P_SRV dtls=1" \
694 "$P_CLI dtls=1" \
695 0 \
696 -s "Protocol is DTLSv1.2" \
697 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
698
Simon Butcher8e004102016-10-14 00:48:33 +0100699# Test for uniqueness of IVs in AEAD ciphersuites
700run_test "Unique IV in GCM" \
701 "$P_SRV exchanges=20 debug_level=4" \
702 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
703 0 \
704 -u "IV used" \
705 -U "IV used"
706
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100707# Tests for rc4 option
708
Simon Butchera410af52016-05-19 22:12:18 +0100709requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100710run_test "RC4: server disabled, client enabled" \
711 "$P_SRV" \
712 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
713 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100714 -s "SSL - The server has no ciphersuites in common"
715
Simon Butchera410af52016-05-19 22:12:18 +0100716requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100717run_test "RC4: server half, client enabled" \
718 "$P_SRV arc4=1" \
719 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
720 1 \
721 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100722
723run_test "RC4: server enabled, client disabled" \
724 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
725 "$P_CLI" \
726 1 \
727 -s "SSL - The server has no ciphersuites in common"
728
729run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100730 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100731 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
732 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100733 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100734 -S "SSL - The server has no ciphersuites in common"
735
Gilles Peskinebc70a182017-05-09 15:59:24 +0200736# Tests for SHA-1 support
737
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200738requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200739run_test "SHA-1 forbidden by default in server certificate" \
740 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
741 "$P_CLI debug_level=2 allow_sha1=0" \
742 1 \
743 -c "The certificate is signed with an unacceptable hash"
744
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200745requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
746run_test "SHA-1 forbidden by default in server certificate" \
747 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
748 "$P_CLI debug_level=2 allow_sha1=0" \
749 0
750
Gilles Peskinebc70a182017-05-09 15:59:24 +0200751run_test "SHA-1 explicitly allowed in server certificate" \
752 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
753 "$P_CLI allow_sha1=1" \
754 0
755
756run_test "SHA-256 allowed by default in server certificate" \
757 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
758 "$P_CLI allow_sha1=0" \
759 0
760
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200761requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200762run_test "SHA-1 forbidden by default in client certificate" \
763 "$P_SRV auth_mode=required allow_sha1=0" \
764 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
765 1 \
766 -s "The certificate is signed with an unacceptable hash"
767
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200768requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
769run_test "SHA-1 forbidden by default in client certificate" \
770 "$P_SRV auth_mode=required allow_sha1=0" \
771 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
772 0
773
Gilles Peskinebc70a182017-05-09 15:59:24 +0200774run_test "SHA-1 explicitly allowed in client certificate" \
775 "$P_SRV auth_mode=required allow_sha1=1" \
776 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
777 0
778
779run_test "SHA-256 allowed by default in client certificate" \
780 "$P_SRV auth_mode=required allow_sha1=0" \
781 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
782 0
783
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100784# Tests for Truncated HMAC extension
785
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100786run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200787 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100788 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100789 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100790 -s "dumping 'computed mac' (20 bytes)" \
791 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100792
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100793run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200794 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100795 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
796 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100797 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100798 -s "dumping 'computed mac' (20 bytes)" \
799 -S "dumping 'computed mac' (10 bytes)"
800
801run_test "Truncated HMAC: client enabled, server default" \
802 "$P_SRV debug_level=4" \
803 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
804 trunc_hmac=1" \
805 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100806 -s "dumping 'computed mac' (20 bytes)" \
807 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100808
809run_test "Truncated HMAC: client enabled, server disabled" \
810 "$P_SRV debug_level=4 trunc_hmac=0" \
811 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
812 trunc_hmac=1" \
813 0 \
814 -s "dumping 'computed mac' (20 bytes)" \
815 -S "dumping 'computed mac' (10 bytes)"
816
817run_test "Truncated HMAC: client enabled, server enabled" \
818 "$P_SRV debug_level=4 trunc_hmac=1" \
819 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
820 trunc_hmac=1" \
821 0 \
822 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100823 -s "dumping 'computed mac' (10 bytes)"
824
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100825# Tests for Encrypt-then-MAC extension
826
827run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100828 "$P_SRV debug_level=3 \
829 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100830 "$P_CLI debug_level=3" \
831 0 \
832 -c "client hello, adding encrypt_then_mac extension" \
833 -s "found encrypt then mac extension" \
834 -s "server hello, adding encrypt then mac extension" \
835 -c "found encrypt_then_mac extension" \
836 -c "using encrypt then mac" \
837 -s "using encrypt then mac"
838
839run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100840 "$P_SRV debug_level=3 etm=0 \
841 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100842 "$P_CLI debug_level=3 etm=1" \
843 0 \
844 -c "client hello, adding encrypt_then_mac extension" \
845 -s "found encrypt then mac extension" \
846 -S "server hello, adding encrypt then mac extension" \
847 -C "found encrypt_then_mac extension" \
848 -C "using encrypt then mac" \
849 -S "using encrypt then mac"
850
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100851run_test "Encrypt then MAC: client enabled, aead cipher" \
852 "$P_SRV debug_level=3 etm=1 \
853 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
854 "$P_CLI debug_level=3 etm=1" \
855 0 \
856 -c "client hello, adding encrypt_then_mac extension" \
857 -s "found encrypt then mac extension" \
858 -S "server hello, adding encrypt then mac extension" \
859 -C "found encrypt_then_mac extension" \
860 -C "using encrypt then mac" \
861 -S "using encrypt then mac"
862
863run_test "Encrypt then MAC: client enabled, stream cipher" \
864 "$P_SRV debug_level=3 etm=1 \
865 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100866 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100867 0 \
868 -c "client hello, adding encrypt_then_mac extension" \
869 -s "found encrypt then mac extension" \
870 -S "server hello, adding encrypt then mac extension" \
871 -C "found encrypt_then_mac extension" \
872 -C "using encrypt then mac" \
873 -S "using encrypt then mac"
874
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100875run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100876 "$P_SRV debug_level=3 etm=1 \
877 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100878 "$P_CLI debug_level=3 etm=0" \
879 0 \
880 -C "client hello, adding encrypt_then_mac extension" \
881 -S "found encrypt then mac extension" \
882 -S "server hello, adding encrypt then mac extension" \
883 -C "found encrypt_then_mac extension" \
884 -C "using encrypt then mac" \
885 -S "using encrypt then mac"
886
Janos Follathe2681a42016-03-07 15:57:05 +0000887requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100888run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100889 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100890 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100891 "$P_CLI debug_level=3 force_version=ssl3" \
892 0 \
893 -C "client hello, adding encrypt_then_mac extension" \
894 -S "found encrypt then mac extension" \
895 -S "server hello, adding encrypt then mac extension" \
896 -C "found encrypt_then_mac extension" \
897 -C "using encrypt then mac" \
898 -S "using encrypt then mac"
899
Janos Follathe2681a42016-03-07 15:57:05 +0000900requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100901run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100902 "$P_SRV debug_level=3 force_version=ssl3 \
903 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100904 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100905 0 \
906 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100907 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100908 -S "server hello, adding encrypt then mac extension" \
909 -C "found encrypt_then_mac extension" \
910 -C "using encrypt then mac" \
911 -S "using encrypt then mac"
912
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200913# Tests for Extended Master Secret extension
914
915run_test "Extended Master Secret: default" \
916 "$P_SRV debug_level=3" \
917 "$P_CLI debug_level=3" \
918 0 \
919 -c "client hello, adding extended_master_secret extension" \
920 -s "found extended master secret extension" \
921 -s "server hello, adding extended master secret extension" \
922 -c "found extended_master_secret extension" \
923 -c "using extended master secret" \
924 -s "using extended master secret"
925
926run_test "Extended Master Secret: client enabled, server disabled" \
927 "$P_SRV debug_level=3 extended_ms=0" \
928 "$P_CLI debug_level=3 extended_ms=1" \
929 0 \
930 -c "client hello, adding extended_master_secret extension" \
931 -s "found extended master secret extension" \
932 -S "server hello, adding extended master secret extension" \
933 -C "found extended_master_secret extension" \
934 -C "using extended master secret" \
935 -S "using extended master secret"
936
937run_test "Extended Master Secret: client disabled, server enabled" \
938 "$P_SRV debug_level=3 extended_ms=1" \
939 "$P_CLI debug_level=3 extended_ms=0" \
940 0 \
941 -C "client hello, adding extended_master_secret extension" \
942 -S "found extended master secret extension" \
943 -S "server hello, adding extended master secret extension" \
944 -C "found extended_master_secret extension" \
945 -C "using extended master secret" \
946 -S "using extended master secret"
947
Janos Follathe2681a42016-03-07 15:57:05 +0000948requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200949run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100950 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200951 "$P_CLI debug_level=3 force_version=ssl3" \
952 0 \
953 -C "client hello, adding extended_master_secret extension" \
954 -S "found extended master secret extension" \
955 -S "server hello, adding extended master secret extension" \
956 -C "found extended_master_secret extension" \
957 -C "using extended master secret" \
958 -S "using extended master secret"
959
Janos Follathe2681a42016-03-07 15:57:05 +0000960requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200961run_test "Extended Master Secret: client enabled, server SSLv3" \
962 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100963 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200964 0 \
965 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100966 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200967 -S "server hello, adding extended master secret extension" \
968 -C "found extended_master_secret extension" \
969 -C "using extended master secret" \
970 -S "using extended master secret"
971
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200972# Tests for FALLBACK_SCSV
973
974run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200975 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200976 "$P_CLI debug_level=3 force_version=tls1_1" \
977 0 \
978 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200979 -S "received FALLBACK_SCSV" \
980 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200981 -C "is a fatal alert message (msg 86)"
982
983run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200984 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200985 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
986 0 \
987 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200988 -S "received FALLBACK_SCSV" \
989 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200990 -C "is a fatal alert message (msg 86)"
991
992run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200993 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200994 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200995 1 \
996 -c "adding FALLBACK_SCSV" \
997 -s "received FALLBACK_SCSV" \
998 -s "inapropriate fallback" \
999 -c "is a fatal alert message (msg 86)"
1000
1001run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001002 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001003 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001004 0 \
1005 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001006 -s "received FALLBACK_SCSV" \
1007 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001008 -C "is a fatal alert message (msg 86)"
1009
1010requires_openssl_with_fallback_scsv
1011run_test "Fallback SCSV: default, openssl server" \
1012 "$O_SRV" \
1013 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1014 0 \
1015 -C "adding FALLBACK_SCSV" \
1016 -C "is a fatal alert message (msg 86)"
1017
1018requires_openssl_with_fallback_scsv
1019run_test "Fallback SCSV: enabled, openssl server" \
1020 "$O_SRV" \
1021 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1022 1 \
1023 -c "adding FALLBACK_SCSV" \
1024 -c "is a fatal alert message (msg 86)"
1025
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001026requires_openssl_with_fallback_scsv
1027run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001028 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001029 "$O_CLI -tls1_1" \
1030 0 \
1031 -S "received FALLBACK_SCSV" \
1032 -S "inapropriate fallback"
1033
1034requires_openssl_with_fallback_scsv
1035run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001036 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001037 "$O_CLI -tls1_1 -fallback_scsv" \
1038 1 \
1039 -s "received FALLBACK_SCSV" \
1040 -s "inapropriate fallback"
1041
1042requires_openssl_with_fallback_scsv
1043run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001044 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001045 "$O_CLI -fallback_scsv" \
1046 0 \
1047 -s "received FALLBACK_SCSV" \
1048 -S "inapropriate fallback"
1049
Gilles Peskined50177f2017-05-16 17:53:03 +02001050## ClientHello generated with
1051## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1052## then manually twiddling the ciphersuite list.
1053## The ClientHello content is spelled out below as a hex string as
1054## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1055## The expected response is an inappropriate_fallback alert.
1056requires_openssl_with_fallback_scsv
1057run_test "Fallback SCSV: beginning of list" \
1058 "$P_SRV debug_level=2" \
1059 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1060 0 \
1061 -s "received FALLBACK_SCSV" \
1062 -s "inapropriate fallback"
1063
1064requires_openssl_with_fallback_scsv
1065run_test "Fallback SCSV: end of list" \
1066 "$P_SRV debug_level=2" \
1067 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1068 0 \
1069 -s "received FALLBACK_SCSV" \
1070 -s "inapropriate fallback"
1071
1072## Here the expected response is a valid ServerHello prefix, up to the random.
1073requires_openssl_with_fallback_scsv
1074run_test "Fallback SCSV: not in list" \
1075 "$P_SRV debug_level=2" \
1076 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1077 0 \
1078 -S "received FALLBACK_SCSV" \
1079 -S "inapropriate fallback"
1080
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001081# Tests for CBC 1/n-1 record splitting
1082
1083run_test "CBC Record splitting: TLS 1.2, no splitting" \
1084 "$P_SRV" \
1085 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1086 request_size=123 force_version=tls1_2" \
1087 0 \
1088 -s "Read from client: 123 bytes read" \
1089 -S "Read from client: 1 bytes read" \
1090 -S "122 bytes read"
1091
1092run_test "CBC Record splitting: TLS 1.1, no splitting" \
1093 "$P_SRV" \
1094 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1095 request_size=123 force_version=tls1_1" \
1096 0 \
1097 -s "Read from client: 123 bytes read" \
1098 -S "Read from client: 1 bytes read" \
1099 -S "122 bytes read"
1100
1101run_test "CBC Record splitting: TLS 1.0, splitting" \
1102 "$P_SRV" \
1103 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1104 request_size=123 force_version=tls1" \
1105 0 \
1106 -S "Read from client: 123 bytes read" \
1107 -s "Read from client: 1 bytes read" \
1108 -s "122 bytes read"
1109
Janos Follathe2681a42016-03-07 15:57:05 +00001110requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001111run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001112 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001113 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1114 request_size=123 force_version=ssl3" \
1115 0 \
1116 -S "Read from client: 123 bytes read" \
1117 -s "Read from client: 1 bytes read" \
1118 -s "122 bytes read"
1119
1120run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001121 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001122 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1123 request_size=123 force_version=tls1" \
1124 0 \
1125 -s "Read from client: 123 bytes read" \
1126 -S "Read from client: 1 bytes read" \
1127 -S "122 bytes read"
1128
1129run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1130 "$P_SRV" \
1131 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1132 request_size=123 force_version=tls1 recsplit=0" \
1133 0 \
1134 -s "Read from client: 123 bytes read" \
1135 -S "Read from client: 1 bytes read" \
1136 -S "122 bytes read"
1137
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001138run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1139 "$P_SRV nbio=2" \
1140 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1141 request_size=123 force_version=tls1" \
1142 0 \
1143 -S "Read from client: 123 bytes read" \
1144 -s "Read from client: 1 bytes read" \
1145 -s "122 bytes read"
1146
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001147# Tests for Session Tickets
1148
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001149run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001150 "$P_SRV debug_level=3 tickets=1" \
1151 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001152 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001153 -c "client hello, adding session ticket extension" \
1154 -s "found session ticket extension" \
1155 -s "server hello, adding session ticket extension" \
1156 -c "found session_ticket extension" \
1157 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001158 -S "session successfully restored from cache" \
1159 -s "session successfully restored from ticket" \
1160 -s "a session has been resumed" \
1161 -c "a session has been resumed"
1162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001163run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001164 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1165 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001166 0 \
1167 -c "client hello, adding session ticket extension" \
1168 -s "found session ticket extension" \
1169 -s "server hello, adding session ticket extension" \
1170 -c "found session_ticket extension" \
1171 -c "parse new session ticket" \
1172 -S "session successfully restored from cache" \
1173 -s "session successfully restored from ticket" \
1174 -s "a session has been resumed" \
1175 -c "a session has been resumed"
1176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001177run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001178 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1179 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001180 0 \
1181 -c "client hello, adding session ticket extension" \
1182 -s "found session ticket extension" \
1183 -s "server hello, adding session ticket extension" \
1184 -c "found session_ticket extension" \
1185 -c "parse new session ticket" \
1186 -S "session successfully restored from cache" \
1187 -S "session successfully restored from ticket" \
1188 -S "a session has been resumed" \
1189 -C "a session has been resumed"
1190
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001191run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001192 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001193 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001194 0 \
1195 -c "client hello, adding session ticket extension" \
1196 -c "found session_ticket extension" \
1197 -c "parse new session ticket" \
1198 -c "a session has been resumed"
1199
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001200run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001201 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001202 "( $O_CLI -sess_out $SESSION; \
1203 $O_CLI -sess_in $SESSION; \
1204 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001205 0 \
1206 -s "found session ticket extension" \
1207 -s "server hello, adding session ticket extension" \
1208 -S "session successfully restored from cache" \
1209 -s "session successfully restored from ticket" \
1210 -s "a session has been resumed"
1211
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001212# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001214run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001215 "$P_SRV debug_level=3 tickets=0" \
1216 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001217 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001218 -c "client hello, adding session ticket extension" \
1219 -s "found session ticket extension" \
1220 -S "server hello, adding session ticket extension" \
1221 -C "found session_ticket extension" \
1222 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001223 -s "session successfully restored from cache" \
1224 -S "session successfully restored from ticket" \
1225 -s "a session has been resumed" \
1226 -c "a session has been resumed"
1227
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001228run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001229 "$P_SRV debug_level=3 tickets=1" \
1230 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001231 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001232 -C "client hello, adding session ticket extension" \
1233 -S "found session ticket extension" \
1234 -S "server hello, adding session ticket extension" \
1235 -C "found session_ticket extension" \
1236 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001237 -s "session successfully restored from cache" \
1238 -S "session successfully restored from ticket" \
1239 -s "a session has been resumed" \
1240 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001242run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001243 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1244 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001245 0 \
1246 -S "session successfully restored from cache" \
1247 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001248 -S "a session has been resumed" \
1249 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001251run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001252 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1253 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001254 0 \
1255 -s "session successfully restored from cache" \
1256 -S "session successfully restored from ticket" \
1257 -s "a session has been resumed" \
1258 -c "a session has been resumed"
1259
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001260run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001261 "$P_SRV debug_level=3 tickets=0" \
1262 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001263 0 \
1264 -s "session successfully restored from cache" \
1265 -S "session successfully restored from ticket" \
1266 -s "a session has been resumed" \
1267 -c "a session has been resumed"
1268
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001269run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001270 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1271 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001272 0 \
1273 -S "session successfully restored from cache" \
1274 -S "session successfully restored from ticket" \
1275 -S "a session has been resumed" \
1276 -C "a session has been resumed"
1277
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001278run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001279 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1280 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001281 0 \
1282 -s "session successfully restored from cache" \
1283 -S "session successfully restored from ticket" \
1284 -s "a session has been resumed" \
1285 -c "a session has been resumed"
1286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001287run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001288 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001289 "( $O_CLI -sess_out $SESSION; \
1290 $O_CLI -sess_in $SESSION; \
1291 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001292 0 \
1293 -s "found session ticket extension" \
1294 -S "server hello, adding session ticket extension" \
1295 -s "session successfully restored from cache" \
1296 -S "session successfully restored from ticket" \
1297 -s "a session has been resumed"
1298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001299run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001300 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001301 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001302 0 \
1303 -C "found session_ticket extension" \
1304 -C "parse new session ticket" \
1305 -c "a session has been resumed"
1306
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001307# Tests for Max Fragment Length extension
1308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001309run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001310 "$P_SRV debug_level=3" \
1311 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001312 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001313 -c "Maximum fragment length is 16384" \
1314 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001315 -C "client hello, adding max_fragment_length extension" \
1316 -S "found max fragment length extension" \
1317 -S "server hello, max_fragment_length extension" \
1318 -C "found max_fragment_length extension"
1319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001320run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001321 "$P_SRV debug_level=3" \
1322 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001323 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001324 -c "Maximum fragment length is 4096" \
1325 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001326 -c "client hello, adding max_fragment_length extension" \
1327 -s "found max fragment length extension" \
1328 -s "server hello, max_fragment_length extension" \
1329 -c "found max_fragment_length extension"
1330
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001331run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001332 "$P_SRV debug_level=3 max_frag_len=4096" \
1333 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001334 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001335 -c "Maximum fragment length is 16384" \
1336 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001337 -C "client hello, adding max_fragment_length extension" \
1338 -S "found max fragment length extension" \
1339 -S "server hello, max_fragment_length extension" \
1340 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001341
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001342requires_gnutls
1343run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001344 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001345 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001346 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001347 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001348 -c "client hello, adding max_fragment_length extension" \
1349 -c "found max_fragment_length extension"
1350
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001351run_test "Max fragment length: client, message just fits" \
1352 "$P_SRV debug_level=3" \
1353 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1354 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001355 -c "Maximum fragment length is 2048" \
1356 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001357 -c "client hello, adding max_fragment_length extension" \
1358 -s "found max fragment length extension" \
1359 -s "server hello, max_fragment_length extension" \
1360 -c "found max_fragment_length extension" \
1361 -c "2048 bytes written in 1 fragments" \
1362 -s "2048 bytes read"
1363
1364run_test "Max fragment length: client, larger message" \
1365 "$P_SRV debug_level=3" \
1366 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1367 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001368 -c "Maximum fragment length is 2048" \
1369 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001370 -c "client hello, adding max_fragment_length extension" \
1371 -s "found max fragment length extension" \
1372 -s "server hello, max_fragment_length extension" \
1373 -c "found max_fragment_length extension" \
1374 -c "2345 bytes written in 2 fragments" \
1375 -s "2048 bytes read" \
1376 -s "297 bytes read"
1377
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001378run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001379 "$P_SRV debug_level=3 dtls=1" \
1380 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1381 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001382 -c "Maximum fragment length is 2048" \
1383 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001384 -c "client hello, adding max_fragment_length extension" \
1385 -s "found max fragment length extension" \
1386 -s "server hello, max_fragment_length extension" \
1387 -c "found max_fragment_length extension" \
1388 -c "fragment larger than.*maximum"
1389
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001390# Tests for renegotiation
1391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001392run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001393 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001394 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001395 0 \
1396 -C "client hello, adding renegotiation extension" \
1397 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1398 -S "found renegotiation extension" \
1399 -s "server hello, secure renegotiation extension" \
1400 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001401 -C "=> renegotiate" \
1402 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001403 -S "write hello request"
1404
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001405run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001406 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001407 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001408 0 \
1409 -c "client hello, adding renegotiation extension" \
1410 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1411 -s "found renegotiation extension" \
1412 -s "server hello, secure renegotiation extension" \
1413 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001414 -c "=> renegotiate" \
1415 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001416 -S "write hello request"
1417
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001418run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001419 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001420 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001421 0 \
1422 -c "client hello, adding renegotiation extension" \
1423 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1424 -s "found renegotiation extension" \
1425 -s "server hello, secure renegotiation extension" \
1426 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001427 -c "=> renegotiate" \
1428 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001429 -s "write hello request"
1430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001431run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001432 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001433 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001434 0 \
1435 -c "client hello, adding renegotiation extension" \
1436 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1437 -s "found renegotiation extension" \
1438 -s "server hello, secure renegotiation extension" \
1439 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001440 -c "=> renegotiate" \
1441 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001442 -s "write hello request"
1443
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001444run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001445 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001446 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001447 1 \
1448 -c "client hello, adding renegotiation extension" \
1449 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1450 -S "found renegotiation extension" \
1451 -s "server hello, secure renegotiation extension" \
1452 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001453 -c "=> renegotiate" \
1454 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001455 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001456 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001457 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001459run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001460 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001461 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001462 0 \
1463 -C "client hello, adding renegotiation extension" \
1464 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1465 -S "found renegotiation extension" \
1466 -s "server hello, secure renegotiation extension" \
1467 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001468 -C "=> renegotiate" \
1469 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001470 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001471 -S "SSL - An unexpected message was received from our peer" \
1472 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001474run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001475 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001476 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001477 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001478 0 \
1479 -C "client hello, adding renegotiation extension" \
1480 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1481 -S "found renegotiation extension" \
1482 -s "server hello, secure renegotiation extension" \
1483 -c "found renegotiation extension" \
1484 -C "=> renegotiate" \
1485 -S "=> renegotiate" \
1486 -s "write hello request" \
1487 -S "SSL - An unexpected message was received from our peer" \
1488 -S "failed"
1489
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001490# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001491run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001492 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001493 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001494 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001495 0 \
1496 -C "client hello, adding renegotiation extension" \
1497 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1498 -S "found renegotiation extension" \
1499 -s "server hello, secure renegotiation extension" \
1500 -c "found renegotiation extension" \
1501 -C "=> renegotiate" \
1502 -S "=> renegotiate" \
1503 -s "write hello request" \
1504 -S "SSL - An unexpected message was received from our peer" \
1505 -S "failed"
1506
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001507run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001508 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001509 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001510 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001511 0 \
1512 -C "client hello, adding renegotiation extension" \
1513 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1514 -S "found renegotiation extension" \
1515 -s "server hello, secure renegotiation extension" \
1516 -c "found renegotiation extension" \
1517 -C "=> renegotiate" \
1518 -S "=> renegotiate" \
1519 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001520 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001522run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001523 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001524 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001525 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001526 0 \
1527 -c "client hello, adding renegotiation extension" \
1528 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1529 -s "found renegotiation extension" \
1530 -s "server hello, secure renegotiation extension" \
1531 -c "found renegotiation extension" \
1532 -c "=> renegotiate" \
1533 -s "=> renegotiate" \
1534 -s "write hello request" \
1535 -S "SSL - An unexpected message was received from our peer" \
1536 -S "failed"
1537
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001538run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001539 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001540 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1541 0 \
1542 -C "client hello, adding renegotiation extension" \
1543 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1544 -S "found renegotiation extension" \
1545 -s "server hello, secure renegotiation extension" \
1546 -c "found renegotiation extension" \
1547 -S "record counter limit reached: renegotiate" \
1548 -C "=> renegotiate" \
1549 -S "=> renegotiate" \
1550 -S "write hello request" \
1551 -S "SSL - An unexpected message was received from our peer" \
1552 -S "failed"
1553
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001554# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001555run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001556 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001557 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001558 0 \
1559 -c "client hello, adding renegotiation extension" \
1560 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1561 -s "found renegotiation extension" \
1562 -s "server hello, secure renegotiation extension" \
1563 -c "found renegotiation extension" \
1564 -s "record counter limit reached: renegotiate" \
1565 -c "=> renegotiate" \
1566 -s "=> renegotiate" \
1567 -s "write hello request" \
1568 -S "SSL - An unexpected message was received from our peer" \
1569 -S "failed"
1570
1571run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001572 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001573 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001574 0 \
1575 -c "client hello, adding renegotiation extension" \
1576 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1577 -s "found renegotiation extension" \
1578 -s "server hello, secure renegotiation extension" \
1579 -c "found renegotiation extension" \
1580 -s "record counter limit reached: renegotiate" \
1581 -c "=> renegotiate" \
1582 -s "=> renegotiate" \
1583 -s "write hello request" \
1584 -S "SSL - An unexpected message was received from our peer" \
1585 -S "failed"
1586
1587run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001588 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001589 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1590 0 \
1591 -C "client hello, adding renegotiation extension" \
1592 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1593 -S "found renegotiation extension" \
1594 -s "server hello, secure renegotiation extension" \
1595 -c "found renegotiation extension" \
1596 -S "record counter limit reached: renegotiate" \
1597 -C "=> renegotiate" \
1598 -S "=> renegotiate" \
1599 -S "write hello request" \
1600 -S "SSL - An unexpected message was received from our peer" \
1601 -S "failed"
1602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001603run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001604 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001605 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001606 0 \
1607 -c "client hello, adding renegotiation extension" \
1608 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1609 -s "found renegotiation extension" \
1610 -s "server hello, secure renegotiation extension" \
1611 -c "found renegotiation extension" \
1612 -c "=> renegotiate" \
1613 -s "=> renegotiate" \
1614 -S "write hello request"
1615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001616run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001617 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001618 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001619 0 \
1620 -c "client hello, adding renegotiation extension" \
1621 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1622 -s "found renegotiation extension" \
1623 -s "server hello, secure renegotiation extension" \
1624 -c "found renegotiation extension" \
1625 -c "=> renegotiate" \
1626 -s "=> renegotiate" \
1627 -s "write hello request"
1628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001629run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001630 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001631 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001632 0 \
1633 -c "client hello, adding renegotiation extension" \
1634 -c "found renegotiation extension" \
1635 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001636 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001637 -C "error" \
1638 -c "HTTP/1.0 200 [Oo][Kk]"
1639
Paul Bakker539d9722015-02-08 16:18:35 +01001640requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001641run_test "Renegotiation: gnutls server strict, client-initiated" \
1642 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001643 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001644 0 \
1645 -c "client hello, adding renegotiation extension" \
1646 -c "found renegotiation extension" \
1647 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001648 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001649 -C "error" \
1650 -c "HTTP/1.0 200 [Oo][Kk]"
1651
Paul Bakker539d9722015-02-08 16:18:35 +01001652requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001653run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1654 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1655 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1656 1 \
1657 -c "client hello, adding renegotiation extension" \
1658 -C "found renegotiation extension" \
1659 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001660 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001661 -c "error" \
1662 -C "HTTP/1.0 200 [Oo][Kk]"
1663
Paul Bakker539d9722015-02-08 16:18:35 +01001664requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001665run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1666 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1667 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1668 allow_legacy=0" \
1669 1 \
1670 -c "client hello, adding renegotiation extension" \
1671 -C "found renegotiation extension" \
1672 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001673 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001674 -c "error" \
1675 -C "HTTP/1.0 200 [Oo][Kk]"
1676
Paul Bakker539d9722015-02-08 16:18:35 +01001677requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001678run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1679 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1680 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1681 allow_legacy=1" \
1682 0 \
1683 -c "client hello, adding renegotiation extension" \
1684 -C "found renegotiation extension" \
1685 -c "=> renegotiate" \
1686 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001687 -C "error" \
1688 -c "HTTP/1.0 200 [Oo][Kk]"
1689
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001690run_test "Renegotiation: DTLS, client-initiated" \
1691 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1692 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1693 0 \
1694 -c "client hello, adding renegotiation extension" \
1695 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1696 -s "found renegotiation extension" \
1697 -s "server hello, secure renegotiation extension" \
1698 -c "found renegotiation extension" \
1699 -c "=> renegotiate" \
1700 -s "=> renegotiate" \
1701 -S "write hello request"
1702
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001703run_test "Renegotiation: DTLS, server-initiated" \
1704 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001705 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1706 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001707 0 \
1708 -c "client hello, adding renegotiation extension" \
1709 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1710 -s "found renegotiation extension" \
1711 -s "server hello, secure renegotiation extension" \
1712 -c "found renegotiation extension" \
1713 -c "=> renegotiate" \
1714 -s "=> renegotiate" \
1715 -s "write hello request"
1716
Andres AG692ad842017-01-19 16:30:57 +00001717run_test "Renegotiation: DTLS, renego_period overflow" \
1718 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1719 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1720 0 \
1721 -c "client hello, adding renegotiation extension" \
1722 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1723 -s "found renegotiation extension" \
1724 -s "server hello, secure renegotiation extension" \
1725 -s "record counter limit reached: renegotiate" \
1726 -c "=> renegotiate" \
1727 -s "=> renegotiate" \
1728 -s "write hello request" \
1729
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001730requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001731run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1732 "$G_SRV -u --mtu 4096" \
1733 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1734 0 \
1735 -c "client hello, adding renegotiation extension" \
1736 -c "found renegotiation extension" \
1737 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001738 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001739 -C "error" \
1740 -s "Extra-header:"
1741
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001742# Test for the "secure renegotation" extension only (no actual renegotiation)
1743
Paul Bakker539d9722015-02-08 16:18:35 +01001744requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001745run_test "Renego ext: gnutls server strict, client default" \
1746 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1747 "$P_CLI debug_level=3" \
1748 0 \
1749 -c "found renegotiation extension" \
1750 -C "error" \
1751 -c "HTTP/1.0 200 [Oo][Kk]"
1752
Paul Bakker539d9722015-02-08 16:18:35 +01001753requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001754run_test "Renego ext: gnutls server unsafe, client default" \
1755 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1756 "$P_CLI debug_level=3" \
1757 0 \
1758 -C "found renegotiation extension" \
1759 -C "error" \
1760 -c "HTTP/1.0 200 [Oo][Kk]"
1761
Paul Bakker539d9722015-02-08 16:18:35 +01001762requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001763run_test "Renego ext: gnutls server unsafe, client break legacy" \
1764 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1765 "$P_CLI debug_level=3 allow_legacy=-1" \
1766 1 \
1767 -C "found renegotiation extension" \
1768 -c "error" \
1769 -C "HTTP/1.0 200 [Oo][Kk]"
1770
Paul Bakker539d9722015-02-08 16:18:35 +01001771requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001772run_test "Renego ext: gnutls client strict, server default" \
1773 "$P_SRV debug_level=3" \
1774 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1775 0 \
1776 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1777 -s "server hello, secure renegotiation extension"
1778
Paul Bakker539d9722015-02-08 16:18:35 +01001779requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001780run_test "Renego ext: gnutls client unsafe, server default" \
1781 "$P_SRV debug_level=3" \
1782 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1783 0 \
1784 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1785 -S "server hello, secure renegotiation extension"
1786
Paul Bakker539d9722015-02-08 16:18:35 +01001787requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001788run_test "Renego ext: gnutls client unsafe, server break legacy" \
1789 "$P_SRV debug_level=3 allow_legacy=-1" \
1790 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1791 1 \
1792 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1793 -S "server hello, secure renegotiation extension"
1794
Janos Follath0b242342016-02-17 10:11:21 +00001795# Tests for silently dropping trailing extra bytes in .der certificates
1796
1797requires_gnutls
1798run_test "DER format: no trailing bytes" \
1799 "$P_SRV crt_file=data_files/server5-der0.crt \
1800 key_file=data_files/server5.key" \
1801 "$G_CLI " \
1802 0 \
1803 -c "Handshake was completed" \
1804
1805requires_gnutls
1806run_test "DER format: with a trailing zero byte" \
1807 "$P_SRV crt_file=data_files/server5-der1a.crt \
1808 key_file=data_files/server5.key" \
1809 "$G_CLI " \
1810 0 \
1811 -c "Handshake was completed" \
1812
1813requires_gnutls
1814run_test "DER format: with a trailing random byte" \
1815 "$P_SRV crt_file=data_files/server5-der1b.crt \
1816 key_file=data_files/server5.key" \
1817 "$G_CLI " \
1818 0 \
1819 -c "Handshake was completed" \
1820
1821requires_gnutls
1822run_test "DER format: with 2 trailing random bytes" \
1823 "$P_SRV crt_file=data_files/server5-der2.crt \
1824 key_file=data_files/server5.key" \
1825 "$G_CLI " \
1826 0 \
1827 -c "Handshake was completed" \
1828
1829requires_gnutls
1830run_test "DER format: with 4 trailing random bytes" \
1831 "$P_SRV crt_file=data_files/server5-der4.crt \
1832 key_file=data_files/server5.key" \
1833 "$G_CLI " \
1834 0 \
1835 -c "Handshake was completed" \
1836
1837requires_gnutls
1838run_test "DER format: with 8 trailing random bytes" \
1839 "$P_SRV crt_file=data_files/server5-der8.crt \
1840 key_file=data_files/server5.key" \
1841 "$G_CLI " \
1842 0 \
1843 -c "Handshake was completed" \
1844
1845requires_gnutls
1846run_test "DER format: with 9 trailing random bytes" \
1847 "$P_SRV crt_file=data_files/server5-der9.crt \
1848 key_file=data_files/server5.key" \
1849 "$G_CLI " \
1850 0 \
1851 -c "Handshake was completed" \
1852
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001853# Tests for auth_mode
1854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001855run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001856 "$P_SRV crt_file=data_files/server5-badsign.crt \
1857 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001858 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001859 1 \
1860 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001861 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001862 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001863 -c "X509 - Certificate verification failed"
1864
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001865run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001866 "$P_SRV crt_file=data_files/server5-badsign.crt \
1867 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001868 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001869 0 \
1870 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001871 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001872 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001873 -C "X509 - Certificate verification failed"
1874
Hanno Beckere6706e62017-05-15 16:05:15 +01001875run_test "Authentication: server goodcert, client optional, no trusted CA" \
1876 "$P_SRV" \
1877 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1878 0 \
1879 -c "x509_verify_cert() returned" \
1880 -c "! The certificate is not correctly signed by the trusted CA" \
1881 -c "! Certificate verification flags"\
1882 -C "! mbedtls_ssl_handshake returned" \
1883 -C "X509 - Certificate verification failed" \
1884 -C "SSL - No CA Chain is set, but required to operate"
1885
1886run_test "Authentication: server goodcert, client required, no trusted CA" \
1887 "$P_SRV" \
1888 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1889 1 \
1890 -c "x509_verify_cert() returned" \
1891 -c "! The certificate is not correctly signed by the trusted CA" \
1892 -c "! Certificate verification flags"\
1893 -c "! mbedtls_ssl_handshake returned" \
1894 -c "SSL - No CA Chain is set, but required to operate"
1895
1896# The purpose of the next two tests is to test the client's behaviour when receiving a server
1897# certificate with an unsupported elliptic curve. This should usually not happen because
1898# the client informs the server about the supported curves - it does, though, in the
1899# corner case of a static ECDH suite, because the server doesn't check the curve on that
1900# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1901# different means to have the server ignoring the client's supported curve list.
1902
1903requires_config_enabled MBEDTLS_ECP_C
1904run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1905 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1906 crt_file=data_files/server5.ku-ka.crt" \
1907 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1908 1 \
1909 -c "bad certificate (EC key curve)"\
1910 -c "! Certificate verification flags"\
1911 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1912
1913requires_config_enabled MBEDTLS_ECP_C
1914run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1915 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1916 crt_file=data_files/server5.ku-ka.crt" \
1917 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1918 1 \
1919 -c "bad certificate (EC key curve)"\
1920 -c "! Certificate verification flags"\
1921 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001923run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001924 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001925 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001926 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001927 0 \
1928 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001929 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001930 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001931 -C "X509 - Certificate verification failed"
1932
Simon Butcher99000142016-10-13 17:21:01 +01001933run_test "Authentication: client SHA256, server required" \
1934 "$P_SRV auth_mode=required" \
1935 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1936 key_file=data_files/server6.key \
1937 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1938 0 \
1939 -c "Supported Signature Algorithm found: 4," \
1940 -c "Supported Signature Algorithm found: 5,"
1941
1942run_test "Authentication: client SHA384, server required" \
1943 "$P_SRV auth_mode=required" \
1944 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1945 key_file=data_files/server6.key \
1946 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
1947 0 \
1948 -c "Supported Signature Algorithm found: 4," \
1949 -c "Supported Signature Algorithm found: 5,"
1950
Gilles Peskinefd8332e2017-05-03 16:25:07 +02001951requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
1952run_test "Authentication: client has no cert, server required (SSLv3)" \
1953 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
1954 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
1955 key_file=data_files/server5.key" \
1956 1 \
1957 -S "skip write certificate request" \
1958 -C "skip parse certificate request" \
1959 -c "got a certificate request" \
1960 -c "got no certificate to send" \
1961 -S "x509_verify_cert() returned" \
1962 -s "client has no certificate" \
1963 -s "! mbedtls_ssl_handshake returned" \
1964 -c "! mbedtls_ssl_handshake returned" \
1965 -s "No client certification received from the client, but required by the authentication mode"
1966
1967run_test "Authentication: client has no cert, server required (TLS)" \
1968 "$P_SRV debug_level=3 auth_mode=required" \
1969 "$P_CLI debug_level=3 crt_file=none \
1970 key_file=data_files/server5.key" \
1971 1 \
1972 -S "skip write certificate request" \
1973 -C "skip parse certificate request" \
1974 -c "got a certificate request" \
1975 -c "= write certificate$" \
1976 -C "skip write certificate$" \
1977 -S "x509_verify_cert() returned" \
1978 -s "client has no certificate" \
1979 -s "! mbedtls_ssl_handshake returned" \
1980 -c "! mbedtls_ssl_handshake returned" \
1981 -s "No client certification received from the client, but required by the authentication mode"
1982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001983run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001984 "$P_SRV debug_level=3 auth_mode=required" \
1985 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001986 key_file=data_files/server5.key" \
1987 1 \
1988 -S "skip write certificate request" \
1989 -C "skip parse certificate request" \
1990 -c "got a certificate request" \
1991 -C "skip write certificate" \
1992 -C "skip write certificate verify" \
1993 -S "skip parse certificate verify" \
1994 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001995 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001996 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02001997 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001998 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001999 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002000# We don't check that the client receives the alert because it might
2001# detect that its write end of the connection is closed and abort
2002# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002003
Janos Follath89baba22017-04-10 14:34:35 +01002004run_test "Authentication: client cert not trusted, server required" \
2005 "$P_SRV debug_level=3 auth_mode=required" \
2006 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2007 key_file=data_files/server5.key" \
2008 1 \
2009 -S "skip write certificate request" \
2010 -C "skip parse certificate request" \
2011 -c "got a certificate request" \
2012 -C "skip write certificate" \
2013 -C "skip write certificate verify" \
2014 -S "skip parse certificate verify" \
2015 -s "x509_verify_cert() returned" \
2016 -s "! The certificate is not correctly signed by the trusted CA" \
2017 -s "! mbedtls_ssl_handshake returned" \
2018 -c "! mbedtls_ssl_handshake returned" \
2019 -s "X509 - Certificate verification failed"
2020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002021run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002022 "$P_SRV debug_level=3 auth_mode=optional" \
2023 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002024 key_file=data_files/server5.key" \
2025 0 \
2026 -S "skip write certificate request" \
2027 -C "skip parse certificate request" \
2028 -c "got a certificate request" \
2029 -C "skip write certificate" \
2030 -C "skip write certificate verify" \
2031 -S "skip parse certificate verify" \
2032 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002033 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002034 -S "! mbedtls_ssl_handshake returned" \
2035 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002036 -S "X509 - Certificate verification failed"
2037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002038run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002039 "$P_SRV debug_level=3 auth_mode=none" \
2040 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002041 key_file=data_files/server5.key" \
2042 0 \
2043 -s "skip write certificate request" \
2044 -C "skip parse certificate request" \
2045 -c "got no certificate request" \
2046 -c "skip write certificate" \
2047 -c "skip write certificate verify" \
2048 -s "skip parse certificate verify" \
2049 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002050 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002051 -S "! mbedtls_ssl_handshake returned" \
2052 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002053 -S "X509 - Certificate verification failed"
2054
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002055run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002056 "$P_SRV debug_level=3 auth_mode=optional" \
2057 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002058 0 \
2059 -S "skip write certificate request" \
2060 -C "skip parse certificate request" \
2061 -c "got a certificate request" \
2062 -C "skip write certificate$" \
2063 -C "got no certificate to send" \
2064 -S "SSLv3 client has no certificate" \
2065 -c "skip write certificate verify" \
2066 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002067 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002068 -S "! mbedtls_ssl_handshake returned" \
2069 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002070 -S "X509 - Certificate verification failed"
2071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002072run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002073 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002074 "$O_CLI" \
2075 0 \
2076 -S "skip write certificate request" \
2077 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002078 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002079 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002080 -S "X509 - Certificate verification failed"
2081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002082run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002083 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002084 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002085 0 \
2086 -C "skip parse certificate request" \
2087 -c "got a certificate request" \
2088 -C "skip write certificate$" \
2089 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002090 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002091
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002092run_test "Authentication: client no cert, openssl server required" \
2093 "$O_SRV -Verify 10" \
2094 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2095 1 \
2096 -C "skip parse certificate request" \
2097 -c "got a certificate request" \
2098 -C "skip write certificate$" \
2099 -c "skip write certificate verify" \
2100 -c "! mbedtls_ssl_handshake returned"
2101
Janos Follathe2681a42016-03-07 15:57:05 +00002102requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002103run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002104 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002105 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002106 0 \
2107 -S "skip write certificate request" \
2108 -C "skip parse certificate request" \
2109 -c "got a certificate request" \
2110 -C "skip write certificate$" \
2111 -c "skip write certificate verify" \
2112 -c "got no certificate to send" \
2113 -s "SSLv3 client has no certificate" \
2114 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002115 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002116 -S "! mbedtls_ssl_handshake returned" \
2117 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002118 -S "X509 - Certificate verification failed"
2119
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002120# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2121# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002122
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002123MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002124MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002125
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002126if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002127 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002128 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002129 printf "test value of ${MAX_IM_CA}. \n"
2130 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002131 printf "The tests assume this value and if it changes, the tests in this\n"
2132 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002133 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002134
2135 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002136fi
2137
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002138run_test "Authentication: server max_int chain, client default" \
2139 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2140 key_file=data_files/dir-maxpath/09.key" \
2141 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2142 0 \
2143 -C "X509 - A fatal error occured"
2144
2145run_test "Authentication: server max_int+1 chain, client default" \
2146 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2147 key_file=data_files/dir-maxpath/10.key" \
2148 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2149 1 \
2150 -c "X509 - A fatal error occured"
2151
2152run_test "Authentication: server max_int+1 chain, client optional" \
2153 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2154 key_file=data_files/dir-maxpath/10.key" \
2155 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2156 auth_mode=optional" \
2157 1 \
2158 -c "X509 - A fatal error occured"
2159
2160run_test "Authentication: server max_int+1 chain, client none" \
2161 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2162 key_file=data_files/dir-maxpath/10.key" \
2163 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2164 auth_mode=none" \
2165 0 \
2166 -C "X509 - A fatal error occured"
2167
2168run_test "Authentication: client max_int+1 chain, server default" \
2169 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2170 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2171 key_file=data_files/dir-maxpath/10.key" \
2172 0 \
2173 -S "X509 - A fatal error occured"
2174
2175run_test "Authentication: client max_int+1 chain, server optional" \
2176 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2177 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2178 key_file=data_files/dir-maxpath/10.key" \
2179 1 \
2180 -s "X509 - A fatal error occured"
2181
2182run_test "Authentication: client max_int+1 chain, server required" \
2183 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2184 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2185 key_file=data_files/dir-maxpath/10.key" \
2186 1 \
2187 -s "X509 - A fatal error occured"
2188
2189run_test "Authentication: client max_int chain, server required" \
2190 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2191 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2192 key_file=data_files/dir-maxpath/09.key" \
2193 0 \
2194 -S "X509 - A fatal error occured"
2195
Janos Follath89baba22017-04-10 14:34:35 +01002196# Tests for CA list in CertificateRequest messages
2197
2198run_test "Authentication: send CA list in CertificateRequest (default)" \
2199 "$P_SRV debug_level=3 auth_mode=required" \
2200 "$P_CLI crt_file=data_files/server6.crt \
2201 key_file=data_files/server6.key" \
2202 0 \
2203 -s "requested DN"
2204
2205run_test "Authentication: do not send CA list in CertificateRequest" \
2206 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2207 "$P_CLI crt_file=data_files/server6.crt \
2208 key_file=data_files/server6.key" \
2209 0 \
2210 -S "requested DN"
2211
2212run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2213 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2214 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2215 key_file=data_files/server5.key" \
2216 1 \
2217 -S "requested DN" \
2218 -s "x509_verify_cert() returned" \
2219 -s "! The certificate is not correctly signed by the trusted CA" \
2220 -s "! mbedtls_ssl_handshake returned" \
2221 -c "! mbedtls_ssl_handshake returned" \
2222 -s "X509 - Certificate verification failed"
2223
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002224# Tests for certificate selection based on SHA verson
2225
2226run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2227 "$P_SRV crt_file=data_files/server5.crt \
2228 key_file=data_files/server5.key \
2229 crt_file2=data_files/server5-sha1.crt \
2230 key_file2=data_files/server5.key" \
2231 "$P_CLI force_version=tls1_2" \
2232 0 \
2233 -c "signed using.*ECDSA with SHA256" \
2234 -C "signed using.*ECDSA with SHA1"
2235
2236run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2237 "$P_SRV crt_file=data_files/server5.crt \
2238 key_file=data_files/server5.key \
2239 crt_file2=data_files/server5-sha1.crt \
2240 key_file2=data_files/server5.key" \
2241 "$P_CLI force_version=tls1_1" \
2242 0 \
2243 -C "signed using.*ECDSA with SHA256" \
2244 -c "signed using.*ECDSA with SHA1"
2245
2246run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2247 "$P_SRV crt_file=data_files/server5.crt \
2248 key_file=data_files/server5.key \
2249 crt_file2=data_files/server5-sha1.crt \
2250 key_file2=data_files/server5.key" \
2251 "$P_CLI force_version=tls1" \
2252 0 \
2253 -C "signed using.*ECDSA with SHA256" \
2254 -c "signed using.*ECDSA with SHA1"
2255
2256run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2257 "$P_SRV crt_file=data_files/server5.crt \
2258 key_file=data_files/server5.key \
2259 crt_file2=data_files/server6.crt \
2260 key_file2=data_files/server6.key" \
2261 "$P_CLI force_version=tls1_1" \
2262 0 \
2263 -c "serial number.*09" \
2264 -c "signed using.*ECDSA with SHA256" \
2265 -C "signed using.*ECDSA with SHA1"
2266
2267run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2268 "$P_SRV crt_file=data_files/server6.crt \
2269 key_file=data_files/server6.key \
2270 crt_file2=data_files/server5.crt \
2271 key_file2=data_files/server5.key" \
2272 "$P_CLI force_version=tls1_1" \
2273 0 \
2274 -c "serial number.*0A" \
2275 -c "signed using.*ECDSA with SHA256" \
2276 -C "signed using.*ECDSA with SHA1"
2277
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002278# tests for SNI
2279
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002280run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002281 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002282 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002283 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002284 0 \
2285 -S "parse ServerName extension" \
2286 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2287 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002288
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002289run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002290 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002291 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002292 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002293 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002294 0 \
2295 -s "parse ServerName extension" \
2296 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2297 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002299run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002300 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002301 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002302 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002303 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002304 0 \
2305 -s "parse ServerName extension" \
2306 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2307 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002309run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002310 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002311 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002312 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002313 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002314 1 \
2315 -s "parse ServerName extension" \
2316 -s "ssl_sni_wrapper() returned" \
2317 -s "mbedtls_ssl_handshake returned" \
2318 -c "mbedtls_ssl_handshake returned" \
2319 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002320
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002321run_test "SNI: client auth no override: optional" \
2322 "$P_SRV debug_level=3 auth_mode=optional \
2323 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2324 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2325 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002326 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002327 -S "skip write certificate request" \
2328 -C "skip parse certificate request" \
2329 -c "got a certificate request" \
2330 -C "skip write certificate" \
2331 -C "skip write certificate verify" \
2332 -S "skip parse certificate verify"
2333
2334run_test "SNI: client auth override: none -> optional" \
2335 "$P_SRV debug_level=3 auth_mode=none \
2336 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2337 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2338 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002339 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002340 -S "skip write certificate request" \
2341 -C "skip parse certificate request" \
2342 -c "got a certificate request" \
2343 -C "skip write certificate" \
2344 -C "skip write certificate verify" \
2345 -S "skip parse certificate verify"
2346
2347run_test "SNI: client auth override: optional -> none" \
2348 "$P_SRV debug_level=3 auth_mode=optional \
2349 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2350 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2351 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002352 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002353 -s "skip write certificate request" \
2354 -C "skip parse certificate request" \
2355 -c "got no certificate request" \
2356 -c "skip write certificate" \
2357 -c "skip write certificate verify" \
2358 -s "skip parse certificate verify"
2359
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002360run_test "SNI: CA no override" \
2361 "$P_SRV debug_level=3 auth_mode=optional \
2362 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2363 ca_file=data_files/test-ca.crt \
2364 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2365 "$P_CLI debug_level=3 server_name=localhost \
2366 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2367 1 \
2368 -S "skip write certificate request" \
2369 -C "skip parse certificate request" \
2370 -c "got a certificate request" \
2371 -C "skip write certificate" \
2372 -C "skip write certificate verify" \
2373 -S "skip parse certificate verify" \
2374 -s "x509_verify_cert() returned" \
2375 -s "! The certificate is not correctly signed by the trusted CA" \
2376 -S "The certificate has been revoked (is on a CRL)"
2377
2378run_test "SNI: CA override" \
2379 "$P_SRV debug_level=3 auth_mode=optional \
2380 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2381 ca_file=data_files/test-ca.crt \
2382 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2383 "$P_CLI debug_level=3 server_name=localhost \
2384 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2385 0 \
2386 -S "skip write certificate request" \
2387 -C "skip parse certificate request" \
2388 -c "got a certificate request" \
2389 -C "skip write certificate" \
2390 -C "skip write certificate verify" \
2391 -S "skip parse certificate verify" \
2392 -S "x509_verify_cert() returned" \
2393 -S "! The certificate is not correctly signed by the trusted CA" \
2394 -S "The certificate has been revoked (is on a CRL)"
2395
2396run_test "SNI: CA override with CRL" \
2397 "$P_SRV debug_level=3 auth_mode=optional \
2398 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2399 ca_file=data_files/test-ca.crt \
2400 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2401 "$P_CLI debug_level=3 server_name=localhost \
2402 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2403 1 \
2404 -S "skip write certificate request" \
2405 -C "skip parse certificate request" \
2406 -c "got a certificate request" \
2407 -C "skip write certificate" \
2408 -C "skip write certificate verify" \
2409 -S "skip parse certificate verify" \
2410 -s "x509_verify_cert() returned" \
2411 -S "! The certificate is not correctly signed by the trusted CA" \
2412 -s "The certificate has been revoked (is on a CRL)"
2413
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002414# Tests for non-blocking I/O: exercise a variety of handshake flows
2415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002416run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002417 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2418 "$P_CLI nbio=2 tickets=0" \
2419 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002420 -S "mbedtls_ssl_handshake returned" \
2421 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002422 -c "Read from server: .* bytes read"
2423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002424run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002425 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2426 "$P_CLI nbio=2 tickets=0" \
2427 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002428 -S "mbedtls_ssl_handshake returned" \
2429 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002430 -c "Read from server: .* bytes read"
2431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002432run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002433 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2434 "$P_CLI nbio=2 tickets=1" \
2435 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002436 -S "mbedtls_ssl_handshake returned" \
2437 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002438 -c "Read from server: .* bytes read"
2439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002440run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002441 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2442 "$P_CLI nbio=2 tickets=1" \
2443 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002444 -S "mbedtls_ssl_handshake returned" \
2445 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002446 -c "Read from server: .* bytes read"
2447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002448run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002449 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2450 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2451 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002452 -S "mbedtls_ssl_handshake returned" \
2453 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002454 -c "Read from server: .* bytes read"
2455
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002456run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002457 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2458 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2459 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002460 -S "mbedtls_ssl_handshake returned" \
2461 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002462 -c "Read from server: .* bytes read"
2463
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002464run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002465 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2466 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2467 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002468 -S "mbedtls_ssl_handshake returned" \
2469 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002470 -c "Read from server: .* bytes read"
2471
Hanno Becker00076712017-11-15 16:39:08 +00002472# Tests for event-driven I/O: exercise a variety of handshake flows
2473
2474run_test "Event-driven I/O: basic handshake" \
2475 "$P_SRV event=1 tickets=0 auth_mode=none" \
2476 "$P_CLI event=1 tickets=0" \
2477 0 \
2478 -S "mbedtls_ssl_handshake returned" \
2479 -C "mbedtls_ssl_handshake returned" \
2480 -c "Read from server: .* bytes read"
2481
2482run_test "Event-driven I/O: client auth" \
2483 "$P_SRV event=1 tickets=0 auth_mode=required" \
2484 "$P_CLI event=1 tickets=0" \
2485 0 \
2486 -S "mbedtls_ssl_handshake returned" \
2487 -C "mbedtls_ssl_handshake returned" \
2488 -c "Read from server: .* bytes read"
2489
2490run_test "Event-driven I/O: ticket" \
2491 "$P_SRV event=1 tickets=1 auth_mode=none" \
2492 "$P_CLI event=1 tickets=1" \
2493 0 \
2494 -S "mbedtls_ssl_handshake returned" \
2495 -C "mbedtls_ssl_handshake returned" \
2496 -c "Read from server: .* bytes read"
2497
2498run_test "Event-driven I/O: ticket + client auth" \
2499 "$P_SRV event=1 tickets=1 auth_mode=required" \
2500 "$P_CLI event=1 tickets=1" \
2501 0 \
2502 -S "mbedtls_ssl_handshake returned" \
2503 -C "mbedtls_ssl_handshake returned" \
2504 -c "Read from server: .* bytes read"
2505
2506run_test "Event-driven I/O: ticket + client auth + resume" \
2507 "$P_SRV event=1 tickets=1 auth_mode=required" \
2508 "$P_CLI event=1 tickets=1 reconnect=1" \
2509 0 \
2510 -S "mbedtls_ssl_handshake returned" \
2511 -C "mbedtls_ssl_handshake returned" \
2512 -c "Read from server: .* bytes read"
2513
2514run_test "Event-driven I/O: ticket + resume" \
2515 "$P_SRV event=1 tickets=1 auth_mode=none" \
2516 "$P_CLI event=1 tickets=1 reconnect=1" \
2517 0 \
2518 -S "mbedtls_ssl_handshake returned" \
2519 -C "mbedtls_ssl_handshake returned" \
2520 -c "Read from server: .* bytes read"
2521
2522run_test "Event-driven I/O: session-id resume" \
2523 "$P_SRV event=1 tickets=0 auth_mode=none" \
2524 "$P_CLI event=1 tickets=0 reconnect=1" \
2525 0 \
2526 -S "mbedtls_ssl_handshake returned" \
2527 -C "mbedtls_ssl_handshake returned" \
2528 -c "Read from server: .* bytes read"
2529
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002530# Tests for version negotiation
2531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002532run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002533 "$P_SRV" \
2534 "$P_CLI" \
2535 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002536 -S "mbedtls_ssl_handshake returned" \
2537 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002538 -s "Protocol is TLSv1.2" \
2539 -c "Protocol is TLSv1.2"
2540
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002541run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002542 "$P_SRV" \
2543 "$P_CLI max_version=tls1_1" \
2544 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002545 -S "mbedtls_ssl_handshake returned" \
2546 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002547 -s "Protocol is TLSv1.1" \
2548 -c "Protocol is TLSv1.1"
2549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002550run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002551 "$P_SRV max_version=tls1_1" \
2552 "$P_CLI" \
2553 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002554 -S "mbedtls_ssl_handshake returned" \
2555 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002556 -s "Protocol is TLSv1.1" \
2557 -c "Protocol is TLSv1.1"
2558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002559run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002560 "$P_SRV max_version=tls1_1" \
2561 "$P_CLI max_version=tls1_1" \
2562 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002563 -S "mbedtls_ssl_handshake returned" \
2564 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002565 -s "Protocol is TLSv1.1" \
2566 -c "Protocol is TLSv1.1"
2567
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002568run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002569 "$P_SRV min_version=tls1_1" \
2570 "$P_CLI max_version=tls1_1" \
2571 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002572 -S "mbedtls_ssl_handshake returned" \
2573 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002574 -s "Protocol is TLSv1.1" \
2575 -c "Protocol is TLSv1.1"
2576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002577run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002578 "$P_SRV max_version=tls1_1" \
2579 "$P_CLI min_version=tls1_1" \
2580 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002581 -S "mbedtls_ssl_handshake returned" \
2582 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002583 -s "Protocol is TLSv1.1" \
2584 -c "Protocol is TLSv1.1"
2585
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002586run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002587 "$P_SRV max_version=tls1_1" \
2588 "$P_CLI min_version=tls1_2" \
2589 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002590 -s "mbedtls_ssl_handshake returned" \
2591 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002592 -c "SSL - Handshake protocol not within min/max boundaries"
2593
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002594run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002595 "$P_SRV min_version=tls1_2" \
2596 "$P_CLI max_version=tls1_1" \
2597 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002598 -s "mbedtls_ssl_handshake returned" \
2599 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002600 -s "SSL - Handshake protocol not within min/max boundaries"
2601
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002602# Tests for ALPN extension
2603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002604run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002605 "$P_SRV debug_level=3" \
2606 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002607 0 \
2608 -C "client hello, adding alpn extension" \
2609 -S "found alpn extension" \
2610 -C "got an alert message, type: \\[2:120]" \
2611 -S "server hello, adding alpn extension" \
2612 -C "found alpn extension " \
2613 -C "Application Layer Protocol is" \
2614 -S "Application Layer Protocol is"
2615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002616run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002617 "$P_SRV debug_level=3" \
2618 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002619 0 \
2620 -c "client hello, adding alpn extension" \
2621 -s "found alpn extension" \
2622 -C "got an alert message, type: \\[2:120]" \
2623 -S "server hello, adding alpn extension" \
2624 -C "found alpn extension " \
2625 -c "Application Layer Protocol is (none)" \
2626 -S "Application Layer Protocol is"
2627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002628run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002629 "$P_SRV debug_level=3 alpn=abc,1234" \
2630 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002631 0 \
2632 -C "client hello, adding alpn extension" \
2633 -S "found alpn extension" \
2634 -C "got an alert message, type: \\[2:120]" \
2635 -S "server hello, adding alpn extension" \
2636 -C "found alpn extension " \
2637 -C "Application Layer Protocol is" \
2638 -s "Application Layer Protocol is (none)"
2639
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002640run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002641 "$P_SRV debug_level=3 alpn=abc,1234" \
2642 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002643 0 \
2644 -c "client hello, adding alpn extension" \
2645 -s "found alpn extension" \
2646 -C "got an alert message, type: \\[2:120]" \
2647 -s "server hello, adding alpn extension" \
2648 -c "found alpn extension" \
2649 -c "Application Layer Protocol is abc" \
2650 -s "Application Layer Protocol is abc"
2651
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002652run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002653 "$P_SRV debug_level=3 alpn=abc,1234" \
2654 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002655 0 \
2656 -c "client hello, adding alpn extension" \
2657 -s "found alpn extension" \
2658 -C "got an alert message, type: \\[2:120]" \
2659 -s "server hello, adding alpn extension" \
2660 -c "found alpn extension" \
2661 -c "Application Layer Protocol is abc" \
2662 -s "Application Layer Protocol is abc"
2663
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002664run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002665 "$P_SRV debug_level=3 alpn=abc,1234" \
2666 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002667 0 \
2668 -c "client hello, adding alpn extension" \
2669 -s "found alpn extension" \
2670 -C "got an alert message, type: \\[2:120]" \
2671 -s "server hello, adding alpn extension" \
2672 -c "found alpn extension" \
2673 -c "Application Layer Protocol is 1234" \
2674 -s "Application Layer Protocol is 1234"
2675
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002676run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002677 "$P_SRV debug_level=3 alpn=abc,123" \
2678 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002679 1 \
2680 -c "client hello, adding alpn extension" \
2681 -s "found alpn extension" \
2682 -c "got an alert message, type: \\[2:120]" \
2683 -S "server hello, adding alpn extension" \
2684 -C "found alpn extension" \
2685 -C "Application Layer Protocol is 1234" \
2686 -S "Application Layer Protocol is 1234"
2687
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002688
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002689# Tests for keyUsage in leaf certificates, part 1:
2690# server-side certificate/suite selection
2691
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002692run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002693 "$P_SRV key_file=data_files/server2.key \
2694 crt_file=data_files/server2.ku-ds.crt" \
2695 "$P_CLI" \
2696 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002697 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002698
2699
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002700run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002701 "$P_SRV key_file=data_files/server2.key \
2702 crt_file=data_files/server2.ku-ke.crt" \
2703 "$P_CLI" \
2704 0 \
2705 -c "Ciphersuite is TLS-RSA-WITH-"
2706
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002707run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002708 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002709 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002710 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002711 1 \
2712 -C "Ciphersuite is "
2713
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002714run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002715 "$P_SRV key_file=data_files/server5.key \
2716 crt_file=data_files/server5.ku-ds.crt" \
2717 "$P_CLI" \
2718 0 \
2719 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2720
2721
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002722run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002723 "$P_SRV key_file=data_files/server5.key \
2724 crt_file=data_files/server5.ku-ka.crt" \
2725 "$P_CLI" \
2726 0 \
2727 -c "Ciphersuite is TLS-ECDH-"
2728
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002729run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002730 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002731 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002732 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002733 1 \
2734 -C "Ciphersuite is "
2735
2736# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002737# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002738
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002739run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002740 "$O_SRV -key data_files/server2.key \
2741 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002742 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002743 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2744 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002745 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002746 -C "Processing of the Certificate handshake message failed" \
2747 -c "Ciphersuite is TLS-"
2748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002749run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002750 "$O_SRV -key data_files/server2.key \
2751 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002752 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002753 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2754 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002755 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002756 -C "Processing of the Certificate handshake message failed" \
2757 -c "Ciphersuite is TLS-"
2758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002759run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002760 "$O_SRV -key data_files/server2.key \
2761 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002762 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002763 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2764 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002765 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002766 -C "Processing of the Certificate handshake message failed" \
2767 -c "Ciphersuite is TLS-"
2768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002769run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002770 "$O_SRV -key data_files/server2.key \
2771 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002772 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002773 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2774 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002775 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002776 -c "Processing of the Certificate handshake message failed" \
2777 -C "Ciphersuite is TLS-"
2778
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002779run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2780 "$O_SRV -key data_files/server2.key \
2781 -cert data_files/server2.ku-ke.crt" \
2782 "$P_CLI debug_level=1 auth_mode=optional \
2783 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2784 0 \
2785 -c "bad certificate (usage extensions)" \
2786 -C "Processing of the Certificate handshake message failed" \
2787 -c "Ciphersuite is TLS-" \
2788 -c "! Usage does not match the keyUsage extension"
2789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002790run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002791 "$O_SRV -key data_files/server2.key \
2792 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002793 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002794 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2795 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002796 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002797 -C "Processing of the Certificate handshake message failed" \
2798 -c "Ciphersuite is TLS-"
2799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002800run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002801 "$O_SRV -key data_files/server2.key \
2802 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002803 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002804 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2805 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002806 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002807 -c "Processing of the Certificate handshake message failed" \
2808 -C "Ciphersuite is TLS-"
2809
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002810run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2811 "$O_SRV -key data_files/server2.key \
2812 -cert data_files/server2.ku-ds.crt" \
2813 "$P_CLI debug_level=1 auth_mode=optional \
2814 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2815 0 \
2816 -c "bad certificate (usage extensions)" \
2817 -C "Processing of the Certificate handshake message failed" \
2818 -c "Ciphersuite is TLS-" \
2819 -c "! Usage does not match the keyUsage extension"
2820
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002821# Tests for keyUsage in leaf certificates, part 3:
2822# server-side checking of client cert
2823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002824run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002825 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002826 "$O_CLI -key data_files/server2.key \
2827 -cert data_files/server2.ku-ds.crt" \
2828 0 \
2829 -S "bad certificate (usage extensions)" \
2830 -S "Processing of the Certificate handshake message failed"
2831
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002832run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002833 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002834 "$O_CLI -key data_files/server2.key \
2835 -cert data_files/server2.ku-ke.crt" \
2836 0 \
2837 -s "bad certificate (usage extensions)" \
2838 -S "Processing of the Certificate handshake message failed"
2839
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002840run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002841 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002842 "$O_CLI -key data_files/server2.key \
2843 -cert data_files/server2.ku-ke.crt" \
2844 1 \
2845 -s "bad certificate (usage extensions)" \
2846 -s "Processing of the Certificate handshake message failed"
2847
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002848run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002849 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002850 "$O_CLI -key data_files/server5.key \
2851 -cert data_files/server5.ku-ds.crt" \
2852 0 \
2853 -S "bad certificate (usage extensions)" \
2854 -S "Processing of the Certificate handshake message failed"
2855
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002856run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002857 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002858 "$O_CLI -key data_files/server5.key \
2859 -cert data_files/server5.ku-ka.crt" \
2860 0 \
2861 -s "bad certificate (usage extensions)" \
2862 -S "Processing of the Certificate handshake message failed"
2863
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002864# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002866run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002867 "$P_SRV key_file=data_files/server5.key \
2868 crt_file=data_files/server5.eku-srv.crt" \
2869 "$P_CLI" \
2870 0
2871
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002872run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002873 "$P_SRV key_file=data_files/server5.key \
2874 crt_file=data_files/server5.eku-srv.crt" \
2875 "$P_CLI" \
2876 0
2877
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002878run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002879 "$P_SRV key_file=data_files/server5.key \
2880 crt_file=data_files/server5.eku-cs_any.crt" \
2881 "$P_CLI" \
2882 0
2883
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002884run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002885 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002886 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002887 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002888 1
2889
2890# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002892run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002893 "$O_SRV -key data_files/server5.key \
2894 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002895 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002896 0 \
2897 -C "bad certificate (usage extensions)" \
2898 -C "Processing of the Certificate handshake message failed" \
2899 -c "Ciphersuite is TLS-"
2900
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002901run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002902 "$O_SRV -key data_files/server5.key \
2903 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002904 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002905 0 \
2906 -C "bad certificate (usage extensions)" \
2907 -C "Processing of the Certificate handshake message failed" \
2908 -c "Ciphersuite is TLS-"
2909
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002910run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002911 "$O_SRV -key data_files/server5.key \
2912 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002913 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002914 0 \
2915 -C "bad certificate (usage extensions)" \
2916 -C "Processing of the Certificate handshake message failed" \
2917 -c "Ciphersuite is TLS-"
2918
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002919run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002920 "$O_SRV -key data_files/server5.key \
2921 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002922 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002923 1 \
2924 -c "bad certificate (usage extensions)" \
2925 -c "Processing of the Certificate handshake message failed" \
2926 -C "Ciphersuite is TLS-"
2927
2928# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002930run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002931 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002932 "$O_CLI -key data_files/server5.key \
2933 -cert data_files/server5.eku-cli.crt" \
2934 0 \
2935 -S "bad certificate (usage extensions)" \
2936 -S "Processing of the Certificate handshake message failed"
2937
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002938run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002939 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002940 "$O_CLI -key data_files/server5.key \
2941 -cert data_files/server5.eku-srv_cli.crt" \
2942 0 \
2943 -S "bad certificate (usage extensions)" \
2944 -S "Processing of the Certificate handshake message failed"
2945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002946run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002947 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002948 "$O_CLI -key data_files/server5.key \
2949 -cert data_files/server5.eku-cs_any.crt" \
2950 0 \
2951 -S "bad certificate (usage extensions)" \
2952 -S "Processing of the Certificate handshake message failed"
2953
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002954run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002955 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002956 "$O_CLI -key data_files/server5.key \
2957 -cert data_files/server5.eku-cs.crt" \
2958 0 \
2959 -s "bad certificate (usage extensions)" \
2960 -S "Processing of the Certificate handshake message failed"
2961
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002962run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002963 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002964 "$O_CLI -key data_files/server5.key \
2965 -cert data_files/server5.eku-cs.crt" \
2966 1 \
2967 -s "bad certificate (usage extensions)" \
2968 -s "Processing of the Certificate handshake message failed"
2969
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002970# Tests for DHM parameters loading
2971
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002972run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002973 "$P_SRV" \
2974 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2975 debug_level=3" \
2976 0 \
2977 -c "value of 'DHM: P ' (2048 bits)" \
2978 -c "value of 'DHM: G ' (2048 bits)"
2979
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002980run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002981 "$P_SRV dhm_file=data_files/dhparams.pem" \
2982 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2983 debug_level=3" \
2984 0 \
2985 -c "value of 'DHM: P ' (1024 bits)" \
2986 -c "value of 'DHM: G ' (2 bits)"
2987
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002988# Tests for DHM client-side size checking
2989
2990run_test "DHM size: server default, client default, OK" \
2991 "$P_SRV" \
2992 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2993 debug_level=1" \
2994 0 \
2995 -C "DHM prime too short:"
2996
2997run_test "DHM size: server default, client 2048, OK" \
2998 "$P_SRV" \
2999 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3000 debug_level=1 dhmlen=2048" \
3001 0 \
3002 -C "DHM prime too short:"
3003
3004run_test "DHM size: server 1024, client default, OK" \
3005 "$P_SRV dhm_file=data_files/dhparams.pem" \
3006 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3007 debug_level=1" \
3008 0 \
3009 -C "DHM prime too short:"
3010
3011run_test "DHM size: server 1000, client default, rejected" \
3012 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3013 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3014 debug_level=1" \
3015 1 \
3016 -c "DHM prime too short:"
3017
3018run_test "DHM size: server default, client 2049, rejected" \
3019 "$P_SRV" \
3020 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3021 debug_level=1 dhmlen=2049" \
3022 1 \
3023 -c "DHM prime too short:"
3024
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003025# Tests for PSK callback
3026
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003027run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003028 "$P_SRV psk=abc123 psk_identity=foo" \
3029 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3030 psk_identity=foo psk=abc123" \
3031 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003032 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003033 -S "SSL - Unknown identity received" \
3034 -S "SSL - Verification of the message MAC failed"
3035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003036run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003037 "$P_SRV" \
3038 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3039 psk_identity=foo psk=abc123" \
3040 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003041 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003042 -S "SSL - Unknown identity received" \
3043 -S "SSL - Verification of the message MAC failed"
3044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003045run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003046 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3047 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3048 psk_identity=foo psk=abc123" \
3049 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003050 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003051 -s "SSL - Unknown identity received" \
3052 -S "SSL - Verification of the message MAC failed"
3053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003054run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003055 "$P_SRV psk_list=abc,dead,def,beef" \
3056 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3057 psk_identity=abc psk=dead" \
3058 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003059 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003060 -S "SSL - Unknown identity received" \
3061 -S "SSL - Verification of the message MAC failed"
3062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003063run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003064 "$P_SRV psk_list=abc,dead,def,beef" \
3065 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3066 psk_identity=def psk=beef" \
3067 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003068 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003069 -S "SSL - Unknown identity received" \
3070 -S "SSL - Verification of the message MAC failed"
3071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003072run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003073 "$P_SRV psk_list=abc,dead,def,beef" \
3074 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3075 psk_identity=ghi psk=beef" \
3076 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003077 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003078 -s "SSL - Unknown identity received" \
3079 -S "SSL - Verification of the message MAC failed"
3080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003081run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003082 "$P_SRV psk_list=abc,dead,def,beef" \
3083 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3084 psk_identity=abc psk=beef" \
3085 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003086 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003087 -S "SSL - Unknown identity received" \
3088 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003089
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003090# Tests for EC J-PAKE
3091
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003092requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003093run_test "ECJPAKE: client not configured" \
3094 "$P_SRV debug_level=3" \
3095 "$P_CLI debug_level=3" \
3096 0 \
3097 -C "add ciphersuite: c0ff" \
3098 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003099 -S "found ecjpake kkpp extension" \
3100 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003101 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003102 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003103 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003104 -S "None of the common ciphersuites is usable"
3105
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003106requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003107run_test "ECJPAKE: server not configured" \
3108 "$P_SRV debug_level=3" \
3109 "$P_CLI debug_level=3 ecjpake_pw=bla \
3110 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3111 1 \
3112 -c "add ciphersuite: c0ff" \
3113 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003114 -s "found ecjpake kkpp extension" \
3115 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003116 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003117 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003118 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003119 -s "None of the common ciphersuites is usable"
3120
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003121requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003122run_test "ECJPAKE: working, TLS" \
3123 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3124 "$P_CLI debug_level=3 ecjpake_pw=bla \
3125 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003126 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003127 -c "add ciphersuite: c0ff" \
3128 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003129 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003130 -s "found ecjpake kkpp extension" \
3131 -S "skip ecjpake kkpp extension" \
3132 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003133 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003134 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003135 -S "None of the common ciphersuites is usable" \
3136 -S "SSL - Verification of the message MAC failed"
3137
Janos Follath74537a62016-09-02 13:45:28 +01003138server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003139requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003140run_test "ECJPAKE: password mismatch, TLS" \
3141 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3142 "$P_CLI debug_level=3 ecjpake_pw=bad \
3143 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3144 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003145 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003146 -s "SSL - Verification of the message MAC failed"
3147
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003148requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003149run_test "ECJPAKE: working, DTLS" \
3150 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3151 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3152 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3153 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003154 -c "re-using cached ecjpake parameters" \
3155 -S "SSL - Verification of the message MAC failed"
3156
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003157requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003158run_test "ECJPAKE: working, DTLS, no cookie" \
3159 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3160 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3161 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3162 0 \
3163 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003164 -S "SSL - Verification of the message MAC failed"
3165
Janos Follath74537a62016-09-02 13:45:28 +01003166server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003167requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003168run_test "ECJPAKE: password mismatch, DTLS" \
3169 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3170 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3171 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3172 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003173 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003174 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003175
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003176# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003177requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003178run_test "ECJPAKE: working, DTLS, nolog" \
3179 "$P_SRV dtls=1 ecjpake_pw=bla" \
3180 "$P_CLI dtls=1 ecjpake_pw=bla \
3181 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3182 0
3183
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003184# Tests for ciphersuites per version
3185
Janos Follathe2681a42016-03-07 15:57:05 +00003186requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003187run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003188 "$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 +02003189 "$P_CLI force_version=ssl3" \
3190 0 \
3191 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003193run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003194 "$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 +01003195 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003196 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003197 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003199run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003200 "$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 +02003201 "$P_CLI force_version=tls1_1" \
3202 0 \
3203 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3204
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003205run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003206 "$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 +02003207 "$P_CLI force_version=tls1_2" \
3208 0 \
3209 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3210
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003211# Test for ClientHello without extensions
3212
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003213requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003214run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003215 "$P_SRV debug_level=3" \
3216 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3217 0 \
3218 -s "dumping 'client hello extensions' (0 bytes)"
3219
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003220requires_gnutls
3221run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3222 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3223 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3224 0 \
3225 -s "dumping 'client hello extensions' (0 bytes)"
3226
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003227# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003228
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003229run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003230 "$P_SRV" \
3231 "$P_CLI request_size=100" \
3232 0 \
3233 -s "Read from client: 100 bytes read$"
3234
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003235run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003236 "$P_SRV" \
3237 "$P_CLI request_size=500" \
3238 0 \
3239 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003240
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003241# Tests for small packets
3242
Janos Follathe2681a42016-03-07 15:57:05 +00003243requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003244run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003245 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003246 "$P_CLI request_size=1 force_version=ssl3 \
3247 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3248 0 \
3249 -s "Read from client: 1 bytes read"
3250
Janos Follathe2681a42016-03-07 15:57:05 +00003251requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003252run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003253 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003254 "$P_CLI request_size=1 force_version=ssl3 \
3255 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3256 0 \
3257 -s "Read from client: 1 bytes read"
3258
3259run_test "Small packet TLS 1.0 BlockCipher" \
3260 "$P_SRV" \
3261 "$P_CLI request_size=1 force_version=tls1 \
3262 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3263 0 \
3264 -s "Read from client: 1 bytes read"
3265
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003266run_test "Small packet TLS 1.0 BlockCipher without EtM" \
3267 "$P_SRV" \
3268 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3269 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3270 0 \
3271 -s "Read from client: 1 bytes read"
3272
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003273run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
3274 "$P_SRV" \
3275 "$P_CLI request_size=1 force_version=tls1 \
3276 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3277 trunc_hmac=1" \
3278 0 \
3279 -s "Read from client: 1 bytes read"
3280
3281run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003282 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003283 "$P_CLI request_size=1 force_version=tls1 \
3284 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3285 trunc_hmac=1" \
3286 0 \
3287 -s "Read from client: 1 bytes read"
3288
3289run_test "Small packet TLS 1.1 BlockCipher" \
3290 "$P_SRV" \
3291 "$P_CLI request_size=1 force_version=tls1_1 \
3292 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3293 0 \
3294 -s "Read from client: 1 bytes read"
3295
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003296run_test "Small packet TLS 1.1 BlockCipher without EtM" \
3297 "$P_SRV" \
3298 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
3299 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3300 0 \
3301 -s "Read from client: 1 bytes read"
3302
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003303run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003304 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003305 "$P_CLI request_size=1 force_version=tls1_1 \
3306 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3307 0 \
3308 -s "Read from client: 1 bytes read"
3309
3310run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3311 "$P_SRV" \
3312 "$P_CLI request_size=1 force_version=tls1_1 \
3313 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3314 trunc_hmac=1" \
3315 0 \
3316 -s "Read from client: 1 bytes read"
3317
3318run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003319 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003320 "$P_CLI request_size=1 force_version=tls1_1 \
3321 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3322 trunc_hmac=1" \
3323 0 \
3324 -s "Read from client: 1 bytes read"
3325
3326run_test "Small packet TLS 1.2 BlockCipher" \
3327 "$P_SRV" \
3328 "$P_CLI request_size=1 force_version=tls1_2 \
3329 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3330 0 \
3331 -s "Read from client: 1 bytes read"
3332
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003333run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3334 "$P_SRV" \
3335 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3336 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3337 0 \
3338 -s "Read from client: 1 bytes read"
3339
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003340run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3341 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003342 "$P_CLI request_size=1 force_version=tls1_2 \
3343 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003344 0 \
3345 -s "Read from client: 1 bytes read"
3346
3347run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3348 "$P_SRV" \
3349 "$P_CLI request_size=1 force_version=tls1_2 \
3350 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3351 trunc_hmac=1" \
3352 0 \
3353 -s "Read from client: 1 bytes read"
3354
3355run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003356 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003357 "$P_CLI request_size=1 force_version=tls1_2 \
3358 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3359 0 \
3360 -s "Read from client: 1 bytes read"
3361
3362run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003363 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003364 "$P_CLI request_size=1 force_version=tls1_2 \
3365 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3366 trunc_hmac=1" \
3367 0 \
3368 -s "Read from client: 1 bytes read"
3369
3370run_test "Small packet TLS 1.2 AEAD" \
3371 "$P_SRV" \
3372 "$P_CLI request_size=1 force_version=tls1_2 \
3373 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3374 0 \
3375 -s "Read from client: 1 bytes read"
3376
3377run_test "Small packet TLS 1.2 AEAD shorter tag" \
3378 "$P_SRV" \
3379 "$P_CLI request_size=1 force_version=tls1_2 \
3380 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3381 0 \
3382 -s "Read from client: 1 bytes read"
3383
Janos Follath00efff72016-05-06 13:48:23 +01003384# A test for extensions in SSLv3
3385
3386requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3387run_test "SSLv3 with extensions, server side" \
3388 "$P_SRV min_version=ssl3 debug_level=3" \
3389 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3390 0 \
3391 -S "dumping 'client hello extensions'" \
3392 -S "server hello, total extension length:"
3393
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003394# Test for large packets
3395
Janos Follathe2681a42016-03-07 15:57:05 +00003396requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003397run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003398 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003399 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003400 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3401 0 \
3402 -s "Read from client: 16384 bytes read"
3403
Janos Follathe2681a42016-03-07 15:57:05 +00003404requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003405run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003406 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003407 "$P_CLI request_size=16384 force_version=ssl3 \
3408 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3409 0 \
3410 -s "Read from client: 16384 bytes read"
3411
3412run_test "Large packet TLS 1.0 BlockCipher" \
3413 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003414 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003415 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3416 0 \
3417 -s "Read from client: 16384 bytes read"
3418
3419run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3420 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003421 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003422 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3423 trunc_hmac=1" \
3424 0 \
3425 -s "Read from client: 16384 bytes read"
3426
3427run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003428 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003429 "$P_CLI request_size=16384 force_version=tls1 \
3430 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3431 trunc_hmac=1" \
3432 0 \
3433 -s "Read from client: 16384 bytes read"
3434
3435run_test "Large packet TLS 1.1 BlockCipher" \
3436 "$P_SRV" \
3437 "$P_CLI request_size=16384 force_version=tls1_1 \
3438 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3439 0 \
3440 -s "Read from client: 16384 bytes read"
3441
3442run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003443 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003444 "$P_CLI request_size=16384 force_version=tls1_1 \
3445 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3446 0 \
3447 -s "Read from client: 16384 bytes read"
3448
3449run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3450 "$P_SRV" \
3451 "$P_CLI request_size=16384 force_version=tls1_1 \
3452 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3453 trunc_hmac=1" \
3454 0 \
3455 -s "Read from client: 16384 bytes read"
3456
3457run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003458 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003459 "$P_CLI request_size=16384 force_version=tls1_1 \
3460 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3461 trunc_hmac=1" \
3462 0 \
3463 -s "Read from client: 16384 bytes read"
3464
3465run_test "Large packet TLS 1.2 BlockCipher" \
3466 "$P_SRV" \
3467 "$P_CLI request_size=16384 force_version=tls1_2 \
3468 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3469 0 \
3470 -s "Read from client: 16384 bytes read"
3471
3472run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3473 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003474 "$P_CLI request_size=16384 force_version=tls1_2 \
3475 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003476 0 \
3477 -s "Read from client: 16384 bytes read"
3478
3479run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3480 "$P_SRV" \
3481 "$P_CLI request_size=16384 force_version=tls1_2 \
3482 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3483 trunc_hmac=1" \
3484 0 \
3485 -s "Read from client: 16384 bytes read"
3486
3487run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003488 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003489 "$P_CLI request_size=16384 force_version=tls1_2 \
3490 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3491 0 \
3492 -s "Read from client: 16384 bytes read"
3493
3494run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003495 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003496 "$P_CLI request_size=16384 force_version=tls1_2 \
3497 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3498 trunc_hmac=1" \
3499 0 \
3500 -s "Read from client: 16384 bytes read"
3501
3502run_test "Large packet TLS 1.2 AEAD" \
3503 "$P_SRV" \
3504 "$P_CLI request_size=16384 force_version=tls1_2 \
3505 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3506 0 \
3507 -s "Read from client: 16384 bytes read"
3508
3509run_test "Large packet TLS 1.2 AEAD shorter tag" \
3510 "$P_SRV" \
3511 "$P_CLI request_size=16384 force_version=tls1_2 \
3512 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3513 0 \
3514 -s "Read from client: 16384 bytes read"
3515
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003516# Tests for DTLS HelloVerifyRequest
3517
3518run_test "DTLS cookie: enabled" \
3519 "$P_SRV dtls=1 debug_level=2" \
3520 "$P_CLI dtls=1 debug_level=2" \
3521 0 \
3522 -s "cookie verification failed" \
3523 -s "cookie verification passed" \
3524 -S "cookie verification skipped" \
3525 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003526 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003527 -S "SSL - The requested feature is not available"
3528
3529run_test "DTLS cookie: disabled" \
3530 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3531 "$P_CLI dtls=1 debug_level=2" \
3532 0 \
3533 -S "cookie verification failed" \
3534 -S "cookie verification passed" \
3535 -s "cookie verification skipped" \
3536 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003537 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003538 -S "SSL - The requested feature is not available"
3539
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003540run_test "DTLS cookie: default (failing)" \
3541 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3542 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3543 1 \
3544 -s "cookie verification failed" \
3545 -S "cookie verification passed" \
3546 -S "cookie verification skipped" \
3547 -C "received hello verify request" \
3548 -S "hello verification requested" \
3549 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003550
3551requires_ipv6
3552run_test "DTLS cookie: enabled, IPv6" \
3553 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3554 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3555 0 \
3556 -s "cookie verification failed" \
3557 -s "cookie verification passed" \
3558 -S "cookie verification skipped" \
3559 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003560 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003561 -S "SSL - The requested feature is not available"
3562
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003563run_test "DTLS cookie: enabled, nbio" \
3564 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3565 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3566 0 \
3567 -s "cookie verification failed" \
3568 -s "cookie verification passed" \
3569 -S "cookie verification skipped" \
3570 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003571 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003572 -S "SSL - The requested feature is not available"
3573
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003574# Tests for client reconnecting from the same port with DTLS
3575
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003576not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003577run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003578 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3579 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003580 0 \
3581 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003582 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003583 -S "Client initiated reconnection from same port"
3584
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003585not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003586run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003587 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3588 "$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 +02003589 0 \
3590 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003591 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003592 -s "Client initiated reconnection from same port"
3593
Paul Bakker362689d2016-05-13 10:33:25 +01003594not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3595run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003596 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3597 "$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 +02003598 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003599 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003600 -s "Client initiated reconnection from same port"
3601
Paul Bakker362689d2016-05-13 10:33:25 +01003602only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3603run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3604 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3605 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3606 0 \
3607 -S "The operation timed out" \
3608 -s "Client initiated reconnection from same port"
3609
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003610run_test "DTLS client reconnect from same port: no cookies" \
3611 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003612 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3613 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003614 -s "The operation timed out" \
3615 -S "Client initiated reconnection from same port"
3616
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003617# Tests for various cases of client authentication with DTLS
3618# (focused on handshake flows and message parsing)
3619
3620run_test "DTLS client auth: required" \
3621 "$P_SRV dtls=1 auth_mode=required" \
3622 "$P_CLI dtls=1" \
3623 0 \
3624 -s "Verifying peer X.509 certificate... ok"
3625
3626run_test "DTLS client auth: optional, client has no cert" \
3627 "$P_SRV dtls=1 auth_mode=optional" \
3628 "$P_CLI dtls=1 crt_file=none key_file=none" \
3629 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003630 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003631
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003632run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003633 "$P_SRV dtls=1 auth_mode=none" \
3634 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3635 0 \
3636 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003637 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003638
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003639run_test "DTLS wrong PSK: badmac alert" \
3640 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3641 "$P_CLI dtls=1 psk=abc124" \
3642 1 \
3643 -s "SSL - Verification of the message MAC failed" \
3644 -c "SSL - A fatal alert message was received from our peer"
3645
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003646# Tests for receiving fragmented handshake messages with DTLS
3647
3648requires_gnutls
3649run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3650 "$G_SRV -u --mtu 2048 -a" \
3651 "$P_CLI dtls=1 debug_level=2" \
3652 0 \
3653 -C "found fragmented DTLS handshake message" \
3654 -C "error"
3655
3656requires_gnutls
3657run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3658 "$G_SRV -u --mtu 512" \
3659 "$P_CLI dtls=1 debug_level=2" \
3660 0 \
3661 -c "found fragmented DTLS handshake message" \
3662 -C "error"
3663
3664requires_gnutls
3665run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3666 "$G_SRV -u --mtu 128" \
3667 "$P_CLI dtls=1 debug_level=2" \
3668 0 \
3669 -c "found fragmented DTLS handshake message" \
3670 -C "error"
3671
3672requires_gnutls
3673run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3674 "$G_SRV -u --mtu 128" \
3675 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3676 0 \
3677 -c "found fragmented DTLS handshake message" \
3678 -C "error"
3679
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003680requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003681run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3682 "$G_SRV -u --mtu 256" \
3683 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3684 0 \
3685 -c "found fragmented DTLS handshake message" \
3686 -c "client hello, adding renegotiation extension" \
3687 -c "found renegotiation extension" \
3688 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003689 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003690 -C "error" \
3691 -s "Extra-header:"
3692
3693requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003694run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3695 "$G_SRV -u --mtu 256" \
3696 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3697 0 \
3698 -c "found fragmented DTLS handshake message" \
3699 -c "client hello, adding renegotiation extension" \
3700 -c "found renegotiation extension" \
3701 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003702 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003703 -C "error" \
3704 -s "Extra-header:"
3705
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003706run_test "DTLS reassembly: no fragmentation (openssl server)" \
3707 "$O_SRV -dtls1 -mtu 2048" \
3708 "$P_CLI dtls=1 debug_level=2" \
3709 0 \
3710 -C "found fragmented DTLS handshake message" \
3711 -C "error"
3712
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003713run_test "DTLS reassembly: some fragmentation (openssl server)" \
3714 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003715 "$P_CLI dtls=1 debug_level=2" \
3716 0 \
3717 -c "found fragmented DTLS handshake message" \
3718 -C "error"
3719
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003720run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003721 "$O_SRV -dtls1 -mtu 256" \
3722 "$P_CLI dtls=1 debug_level=2" \
3723 0 \
3724 -c "found fragmented DTLS handshake message" \
3725 -C "error"
3726
3727run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3728 "$O_SRV -dtls1 -mtu 256" \
3729 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3730 0 \
3731 -c "found fragmented DTLS handshake message" \
3732 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003733
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003734# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003735
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003736not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003737run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003738 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003739 "$P_SRV dtls=1 debug_level=2" \
3740 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003741 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003742 -C "replayed record" \
3743 -S "replayed record" \
3744 -C "record from another epoch" \
3745 -S "record from another epoch" \
3746 -C "discarding invalid record" \
3747 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003748 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003749 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003750 -c "HTTP/1.0 200 OK"
3751
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003752not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003753run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003754 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003755 "$P_SRV dtls=1 debug_level=2" \
3756 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003757 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003758 -c "replayed record" \
3759 -s "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01003760 -c "record from another epoch" \
3761 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003762 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003763 -s "Extra-header:" \
3764 -c "HTTP/1.0 200 OK"
3765
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003766run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3767 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003768 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3769 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003770 0 \
3771 -c "replayed record" \
3772 -S "replayed record" \
Hanno Becker52c6dc62017-05-26 16:07:36 +01003773 -c "record from another epoch" \
3774 -s "record from another epoch" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003775 -c "resend" \
3776 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003777 -s "Extra-header:" \
3778 -c "HTTP/1.0 200 OK"
3779
Hanno Becker72a4f032017-11-15 16:39:20 +00003780run_test "DTLS proxy: multiple records in same datagram" \
3781 -p "$P_PXY pack=10" \
3782 "$P_SRV dtls=1 debug_level=2" \
3783 "$P_CLI dtls=1 debug_level=2" \
3784 0 \
3785 -c "next record in same datagram" \
3786 -s "next record in same datagram"
3787
3788run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
3789 -p "$P_PXY pack=10 duplicate=1" \
3790 "$P_SRV dtls=1 debug_level=2" \
3791 "$P_CLI dtls=1 debug_level=2" \
3792 0 \
3793 -c "next record in same datagram" \
3794 -s "next record in same datagram"
3795
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003796run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003797 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003798 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003799 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003800 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003801 -c "discarding invalid record (mac)" \
3802 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003803 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003804 -c "HTTP/1.0 200 OK" \
3805 -S "too many records with bad MAC" \
3806 -S "Verification of the message MAC failed"
3807
3808run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3809 -p "$P_PXY bad_ad=1" \
3810 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3811 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3812 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003813 -C "discarding invalid record (mac)" \
3814 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003815 -S "Extra-header:" \
3816 -C "HTTP/1.0 200 OK" \
3817 -s "too many records with bad MAC" \
3818 -s "Verification of the message MAC failed"
3819
3820run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3821 -p "$P_PXY bad_ad=1" \
3822 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3823 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3824 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003825 -c "discarding invalid record (mac)" \
3826 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003827 -s "Extra-header:" \
3828 -c "HTTP/1.0 200 OK" \
3829 -S "too many records with bad MAC" \
3830 -S "Verification of the message MAC failed"
3831
3832run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3833 -p "$P_PXY bad_ad=1" \
3834 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3835 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3836 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003837 -c "discarding invalid record (mac)" \
3838 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003839 -s "Extra-header:" \
3840 -c "HTTP/1.0 200 OK" \
3841 -s "too many records with bad MAC" \
3842 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003843
3844run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003845 -p "$P_PXY delay_ccs=1" \
3846 "$P_SRV dtls=1 debug_level=1" \
3847 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003848 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003849 -c "record from another epoch" \
3850 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003851 -s "Extra-header:" \
3852 -c "HTTP/1.0 200 OK"
3853
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003854# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003855
Janos Follath74537a62016-09-02 13:45:28 +01003856client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003857run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003858 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003859 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3860 psk=abc123" \
3861 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003862 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3863 0 \
3864 -s "Extra-header:" \
3865 -c "HTTP/1.0 200 OK"
3866
Janos Follath74537a62016-09-02 13:45:28 +01003867client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003868run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3869 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003870 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3871 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003872 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3873 0 \
3874 -s "Extra-header:" \
3875 -c "HTTP/1.0 200 OK"
3876
Janos Follath74537a62016-09-02 13:45:28 +01003877client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003878run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3879 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003880 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3881 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003882 0 \
3883 -s "Extra-header:" \
3884 -c "HTTP/1.0 200 OK"
3885
Janos Follath74537a62016-09-02 13:45:28 +01003886client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003887run_test "DTLS proxy: 3d, FS, client auth" \
3888 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003889 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3890 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003891 0 \
3892 -s "Extra-header:" \
3893 -c "HTTP/1.0 200 OK"
3894
Janos Follath74537a62016-09-02 13:45:28 +01003895client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003896run_test "DTLS proxy: 3d, FS, ticket" \
3897 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003898 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3899 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003900 0 \
3901 -s "Extra-header:" \
3902 -c "HTTP/1.0 200 OK"
3903
Janos Follath74537a62016-09-02 13:45:28 +01003904client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003905run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3906 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003907 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3908 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003909 0 \
3910 -s "Extra-header:" \
3911 -c "HTTP/1.0 200 OK"
3912
Janos Follath74537a62016-09-02 13:45:28 +01003913client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003914run_test "DTLS proxy: 3d, max handshake, nbio" \
3915 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003916 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3917 auth_mode=required" \
3918 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003919 0 \
3920 -s "Extra-header:" \
3921 -c "HTTP/1.0 200 OK"
3922
Janos Follath74537a62016-09-02 13:45:28 +01003923client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003924run_test "DTLS proxy: 3d, min handshake, resumption" \
3925 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3926 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3927 psk=abc123 debug_level=3" \
3928 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3929 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3930 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3931 0 \
3932 -s "a session has been resumed" \
3933 -c "a session has been resumed" \
3934 -s "Extra-header:" \
3935 -c "HTTP/1.0 200 OK"
3936
Janos Follath74537a62016-09-02 13:45:28 +01003937client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003938run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3939 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3940 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3941 psk=abc123 debug_level=3 nbio=2" \
3942 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3943 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3944 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3945 0 \
3946 -s "a session has been resumed" \
3947 -c "a session has been resumed" \
3948 -s "Extra-header:" \
3949 -c "HTTP/1.0 200 OK"
3950
Janos Follath74537a62016-09-02 13:45:28 +01003951client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003952run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003953 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003954 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3955 psk=abc123 renegotiation=1 debug_level=2" \
3956 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3957 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003958 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3959 0 \
3960 -c "=> renegotiate" \
3961 -s "=> renegotiate" \
3962 -s "Extra-header:" \
3963 -c "HTTP/1.0 200 OK"
3964
Janos Follath74537a62016-09-02 13:45:28 +01003965client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003966run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3967 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003968 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3969 psk=abc123 renegotiation=1 debug_level=2" \
3970 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3971 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003972 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3973 0 \
3974 -c "=> renegotiate" \
3975 -s "=> renegotiate" \
3976 -s "Extra-header:" \
3977 -c "HTTP/1.0 200 OK"
3978
Janos Follath74537a62016-09-02 13:45:28 +01003979client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003980run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003981 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003982 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003983 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003984 debug_level=2" \
3985 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003986 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003987 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3988 0 \
3989 -c "=> renegotiate" \
3990 -s "=> renegotiate" \
3991 -s "Extra-header:" \
3992 -c "HTTP/1.0 200 OK"
3993
Janos Follath74537a62016-09-02 13:45:28 +01003994client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003995run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003996 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003997 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003998 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003999 debug_level=2 nbio=2" \
4000 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004001 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004002 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4003 0 \
4004 -c "=> renegotiate" \
4005 -s "=> renegotiate" \
4006 -s "Extra-header:" \
4007 -c "HTTP/1.0 200 OK"
4008
Janos Follath74537a62016-09-02 13:45:28 +01004009client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004010not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004011run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004012 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4013 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004014 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004015 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004016 -c "HTTP/1.0 200 OK"
4017
Janos Follath74537a62016-09-02 13:45:28 +01004018client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004019not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004020run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4021 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4022 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004023 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004024 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004025 -c "HTTP/1.0 200 OK"
4026
Janos Follath74537a62016-09-02 13:45:28 +01004027client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004028not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004029run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4030 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4031 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004032 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004033 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004034 -c "HTTP/1.0 200 OK"
4035
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004036requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004037client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004038not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004039run_test "DTLS proxy: 3d, gnutls server" \
4040 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4041 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004042 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004043 0 \
4044 -s "Extra-header:" \
4045 -c "Extra-header:"
4046
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004047requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004048client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004049not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004050run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4051 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4052 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004053 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004054 0 \
4055 -s "Extra-header:" \
4056 -c "Extra-header:"
4057
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004058requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004059client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004060not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004061run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4062 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4063 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004064 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004065 0 \
4066 -s "Extra-header:" \
4067 -c "Extra-header:"
4068
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004069# Final report
4070
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004071echo "------------------------------------------------------------------------"
4072
4073if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004074 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004075else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004076 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004077fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004078PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004079echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004080
4081exit $FAILS