blob: 280fc63486ba7154e81924a2c318dc3af2a8ebb9 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020031: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010032
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020033O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010034O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020035G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010036G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020037TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010038
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010039TESTS=0
40FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020041SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010042
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000043CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020044
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020047EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010048
Paul Bakkere20310a2016-05-10 11:18:17 +010049SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010050RUN_TEST_NUMBER=''
51
Paul Bakkeracaac852016-05-10 11:47:13 +010052PRESERVE_LOGS=0
53
Gilles Peskinef93c7d32017-04-14 17:55:28 +020054# Pick a "unique" server port in the range 10000-19999, and a proxy
55# port which is this plus 10000. Each port number may be independently
56# overridden by a command line option.
57SRV_PORT=$(($$ % 10000 + 10000))
58PXY_PORT=$((SRV_PORT + 10000))
59
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010060print_usage() {
61 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010062 printf " -h|--help\tPrint this help.\n"
63 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020064 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
65 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010066 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010067 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010068 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020069 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
70 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010071 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072}
73
74get_options() {
75 while [ $# -gt 0 ]; do
76 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010077 -f|--filter)
78 shift; FILTER=$1
79 ;;
80 -e|--exclude)
81 shift; EXCLUDE=$1
82 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010083 -m|--memcheck)
84 MEMCHECK=1
85 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010086 -n|--number)
87 shift; RUN_TEST_NUMBER=$1
88 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010089 -s|--show-numbers)
90 SHOW_TEST_NUMBER=1
91 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010092 -p|--preserve-logs)
93 PRESERVE_LOGS=1
94 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020095 --port)
96 shift; SRV_PORT=$1
97 ;;
98 --proxy-port)
99 shift; PXY_PORT=$1
100 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100101 --seed)
102 shift; SEED="$1"
103 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100104 -h|--help)
105 print_usage
106 exit 0
107 ;;
108 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200109 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100110 print_usage
111 exit 1
112 ;;
113 esac
114 shift
115 done
116}
117
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100118# skip next test if the flag is not enabled in config.h
119requires_config_enabled() {
120 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
121 SKIP_NEXT="YES"
122 fi
123}
124
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200125# skip next test if the flag is enabled in config.h
126requires_config_disabled() {
127 if grep "^#define $1" $CONFIG_H > /dev/null; then
128 SKIP_NEXT="YES"
129 fi
130}
131
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200132# skip next test if OpenSSL doesn't support FALLBACK_SCSV
133requires_openssl_with_fallback_scsv() {
134 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
135 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
136 then
137 OPENSSL_HAS_FBSCSV="YES"
138 else
139 OPENSSL_HAS_FBSCSV="NO"
140 fi
141 fi
142 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
143 SKIP_NEXT="YES"
144 fi
145}
146
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200147# skip next test if GnuTLS isn't available
148requires_gnutls() {
149 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200150 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200151 GNUTLS_AVAILABLE="YES"
152 else
153 GNUTLS_AVAILABLE="NO"
154 fi
155 fi
156 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200161# skip next test if IPv6 isn't available on this host
162requires_ipv6() {
163 if [ -z "${HAS_IPV6:-}" ]; then
164 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
165 SRV_PID=$!
166 sleep 1
167 kill $SRV_PID >/dev/null 2>&1
168 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
169 HAS_IPV6="NO"
170 else
171 HAS_IPV6="YES"
172 fi
173 rm -r $SRV_OUT
174 fi
175
176 if [ "$HAS_IPV6" = "NO" ]; then
177 SKIP_NEXT="YES"
178 fi
179}
180
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200181# skip the next test if valgrind is in use
182not_with_valgrind() {
183 if [ "$MEMCHECK" -gt 0 ]; then
184 SKIP_NEXT="YES"
185 fi
186}
187
Paul Bakker362689d2016-05-13 10:33:25 +0100188# skip the next test if valgrind is NOT in use
189only_with_valgrind() {
190 if [ "$MEMCHECK" -eq 0 ]; then
191 SKIP_NEXT="YES"
192 fi
193}
194
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200195# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100196client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200197 CLI_DELAY_FACTOR=$1
198}
199
Janos Follath74537a62016-09-02 13:45:28 +0100200# wait for the given seconds after the client finished in the next test
201server_needs_more_time() {
202 SRV_DELAY_SECONDS=$1
203}
204
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100205# print_name <name>
206print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100207 TESTS=$(( $TESTS + 1 ))
208 LINE=""
209
210 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
211 LINE="$TESTS "
212 fi
213
214 LINE="$LINE$1"
215 printf "$LINE "
216 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100217 for i in `seq 1 $LEN`; do printf '.'; done
218 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100219
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100220}
221
222# fail <message>
223fail() {
224 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100225 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100226
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200227 mv $SRV_OUT o-srv-${TESTS}.log
228 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200229 if [ -n "$PXY_CMD" ]; then
230 mv $PXY_OUT o-pxy-${TESTS}.log
231 fi
232 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100233
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200234 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
235 echo " ! server output:"
236 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200237 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200238 echo " ! client output:"
239 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200240 if [ -n "$PXY_CMD" ]; then
241 echo " ! ========================================================"
242 echo " ! proxy output:"
243 cat o-pxy-${TESTS}.log
244 fi
245 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200246 fi
247
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200248 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100249}
250
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100251# is_polar <cmd_line>
252is_polar() {
253 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
254}
255
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200256# openssl s_server doesn't have -www with DTLS
257check_osrv_dtls() {
258 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
259 NEEDS_INPUT=1
260 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
261 else
262 NEEDS_INPUT=0
263 fi
264}
265
266# provide input to commands that need it
267provide_input() {
268 if [ $NEEDS_INPUT -eq 0 ]; then
269 return
270 fi
271
272 while true; do
273 echo "HTTP/1.0 200 OK"
274 sleep 1
275 done
276}
277
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100278# has_mem_err <log_file_name>
279has_mem_err() {
280 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
281 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
282 then
283 return 1 # false: does not have errors
284 else
285 return 0 # true: has errors
286 fi
287}
288
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200289# wait for server to start: two versions depending on lsof availability
290wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200291 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200292 START_TIME=$( date +%s )
293 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200294
295 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200296 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200297 while [ $DONE -eq 0 ]; do
298 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
299 then
300 DONE=1
301 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
302 echo "SERVERSTART TIMEOUT"
303 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
304 DONE=1
305 fi
306 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200307 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200308 while [ $DONE -eq 0 ]; do
309 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
310 then
311 DONE=1
312 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
313 echo "SERVERSTART TIMEOUT"
314 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
315 DONE=1
316 fi
317 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200318 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200319 else
320 sleep "$START_DELAY"
321 fi
322}
323
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200324# wait for client to terminate and set CLI_EXIT
325# must be called right after starting the client
326wait_client_done() {
327 CLI_PID=$!
328
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200329 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
330 CLI_DELAY_FACTOR=1
331
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200332 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200333 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200334
335 wait $CLI_PID
336 CLI_EXIT=$?
337
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200338 kill $DOG_PID >/dev/null 2>&1
339 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200340
341 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100342
343 sleep $SRV_DELAY_SECONDS
344 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200345}
346
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200347# check if the given command uses dtls and sets global variable DTLS
348detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200349 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200350 DTLS=1
351 else
352 DTLS=0
353 fi
354}
355
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200356# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100357# Options: -s pattern pattern that must be present in server output
358# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100359# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100360# -S pattern pattern that must be absent in server output
361# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100362# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100363run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100364 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200365 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100366
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100367 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
368 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200369 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100370 return
371 fi
372
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100373 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100374
Paul Bakkerb7584a52016-05-10 10:50:43 +0100375 # Do we only run numbered tests?
376 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
377 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
378 else
379 SKIP_NEXT="YES"
380 fi
381
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200382 # should we skip?
383 if [ "X$SKIP_NEXT" = "XYES" ]; then
384 SKIP_NEXT="NO"
385 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200386 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200387 return
388 fi
389
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200390 # does this test use a proxy?
391 if [ "X$1" = "X-p" ]; then
392 PXY_CMD="$2"
393 shift 2
394 else
395 PXY_CMD=""
396 fi
397
398 # get commands and client output
399 SRV_CMD="$1"
400 CLI_CMD="$2"
401 CLI_EXPECT="$3"
402 shift 3
403
404 # fix client port
405 if [ -n "$PXY_CMD" ]; then
406 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
407 else
408 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
409 fi
410
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200411 # update DTLS variable
412 detect_dtls "$SRV_CMD"
413
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100414 # prepend valgrind to our commands if active
415 if [ "$MEMCHECK" -gt 0 ]; then
416 if is_polar "$SRV_CMD"; then
417 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
418 fi
419 if is_polar "$CLI_CMD"; then
420 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
421 fi
422 fi
423
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200424 TIMES_LEFT=2
425 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200426 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200427
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200428 # run the commands
429 if [ -n "$PXY_CMD" ]; then
430 echo "$PXY_CMD" > $PXY_OUT
431 $PXY_CMD >> $PXY_OUT 2>&1 &
432 PXY_PID=$!
433 # assume proxy starts faster than server
434 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200435
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200436 check_osrv_dtls
437 echo "$SRV_CMD" > $SRV_OUT
438 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
439 SRV_PID=$!
440 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200441
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200442 echo "$CLI_CMD" > $CLI_OUT
443 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
444 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100445
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200446 # terminate the server (and the proxy)
447 kill $SRV_PID
448 wait $SRV_PID
449 if [ -n "$PXY_CMD" ]; then
450 kill $PXY_PID >/dev/null 2>&1
451 wait $PXY_PID
452 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100453
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200454 # retry only on timeouts
455 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
456 printf "RETRY "
457 else
458 TIMES_LEFT=0
459 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200460 done
461
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100462 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200463 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100464 # expected client exit to incorrectly succeed in case of catastrophic
465 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100466 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200467 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100468 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100469 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100470 return
471 fi
472 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100473 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200474 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100475 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100476 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100477 return
478 fi
479 fi
480
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100481 # check server exit code
482 if [ $? != 0 ]; then
483 fail "server fail"
484 return
485 fi
486
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100487 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100488 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
489 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100490 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200491 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100492 return
493 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100494
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100495 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200496 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100497 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100498 while [ $# -gt 0 ]
499 do
500 case $1 in
501 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100502 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100503 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100504 return
505 fi
506 ;;
507
508 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100509 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100510 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100511 return
512 fi
513 ;;
514
515 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100516 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100517 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100518 return
519 fi
520 ;;
521
522 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100523 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100524 fail "pattern '$2' MUST NOT be present in the Client output"
525 return
526 fi
527 ;;
528
529 # The filtering in the following two options (-u and -U) do the following
530 # - ignore valgrind output
531 # - filter out everything but lines right after the pattern occurances
532 # - keep one of each non-unique line
533 # - count how many lines remain
534 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
535 # if there were no duplicates.
536 "-U")
537 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
538 fail "lines following pattern '$2' must be unique in Server output"
539 return
540 fi
541 ;;
542
543 "-u")
544 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
545 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100546 return
547 fi
548 ;;
549
550 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200551 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100552 exit 1
553 esac
554 shift 2
555 done
556
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100557 # check valgrind's results
558 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200559 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100560 fail "Server has memory errors"
561 return
562 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200563 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100564 fail "Client has memory errors"
565 return
566 fi
567 fi
568
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100569 # if we're here, everything is ok
570 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100571 if [ "$PRESERVE_LOGS" -gt 0 ]; then
572 mv $SRV_OUT o-srv-${TESTS}.log
573 mv $CLI_OUT o-cli-${TESTS}.log
574 fi
575
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200576 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100577}
578
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100579cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200580 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200581 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
582 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
583 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
584 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100585 exit 1
586}
587
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100588#
589# MAIN
590#
591
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000592if cd $( dirname $0 ); then :; else
593 echo "cd $( dirname $0 ) failed" >&2
594 exit 1
595fi
596
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100597get_options "$@"
598
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100599# sanity checks, avoid an avalanche of errors
600if [ ! -x "$P_SRV" ]; then
601 echo "Command '$P_SRV' is not an executable file"
602 exit 1
603fi
604if [ ! -x "$P_CLI" ]; then
605 echo "Command '$P_CLI' is not an executable file"
606 exit 1
607fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200608if [ ! -x "$P_PXY" ]; then
609 echo "Command '$P_PXY' is not an executable file"
610 exit 1
611fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100612if [ "$MEMCHECK" -gt 0 ]; then
613 if which valgrind >/dev/null 2>&1; then :; else
614 echo "Memcheck not possible. Valgrind not found"
615 exit 1
616 fi
617fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100618if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
619 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100620 exit 1
621fi
622
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200623# used by watchdog
624MAIN_PID="$$"
625
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200626# be more patient with valgrind
627if [ "$MEMCHECK" -gt 0 ]; then
628 START_DELAY=3
629 DOG_DELAY=30
630else
631 START_DELAY=1
632 DOG_DELAY=10
633fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200634CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100635SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200636
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200637# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000638# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200639P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
640P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100641P_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 +0200642O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200643O_CLI="$O_CLI -connect localhost:+SRV_PORT"
644G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000645G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200646
Gilles Peskine62469d92017-05-10 10:13:59 +0200647# Allow SHA-1, because many of our test certificates use it
648P_SRV="$P_SRV allow_sha1=1"
649P_CLI="$P_CLI allow_sha1=1"
650
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200651# Also pick a unique name for intermediate files
652SRV_OUT="srv_out.$$"
653CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200654PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200655SESSION="session.$$"
656
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200657SKIP_NEXT="NO"
658
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100659trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100660
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200661# Basic test
662
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200663# Checks that:
664# - things work with all ciphersuites active (used with config-full in all.sh)
665# - the expected (highest security) parameters are selected
666# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200667run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200668 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200669 "$P_CLI" \
670 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200671 -s "Protocol is TLSv1.2" \
672 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
673 -s "client hello v3, signature_algorithm ext: 6" \
674 -s "ECDHE curve: secp521r1" \
675 -S "error" \
676 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200677
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000678run_test "Default, DTLS" \
679 "$P_SRV dtls=1" \
680 "$P_CLI dtls=1" \
681 0 \
682 -s "Protocol is DTLSv1.2" \
683 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
684
Simon Butcher8e004102016-10-14 00:48:33 +0100685# Test for uniqueness of IVs in AEAD ciphersuites
686run_test "Unique IV in GCM" \
687 "$P_SRV exchanges=20 debug_level=4" \
688 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
689 0 \
690 -u "IV used" \
691 -U "IV used"
692
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100693# Tests for rc4 option
694
Simon Butchera410af52016-05-19 22:12:18 +0100695requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100696run_test "RC4: server disabled, client enabled" \
697 "$P_SRV" \
698 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
699 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100700 -s "SSL - The server has no ciphersuites in common"
701
Simon Butchera410af52016-05-19 22:12:18 +0100702requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100703run_test "RC4: server half, client enabled" \
704 "$P_SRV arc4=1" \
705 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
706 1 \
707 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100708
709run_test "RC4: server enabled, client disabled" \
710 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
711 "$P_CLI" \
712 1 \
713 -s "SSL - The server has no ciphersuites in common"
714
715run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100716 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100717 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
718 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100719 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100720 -S "SSL - The server has no ciphersuites in common"
721
Gilles Peskinebc70a182017-05-09 15:59:24 +0200722# Tests for SHA-1 support
723
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200724requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200725run_test "SHA-1 forbidden by default in server certificate" \
726 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
727 "$P_CLI debug_level=2 allow_sha1=0" \
728 1 \
729 -c "The certificate is signed with an unacceptable hash"
730
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200731requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
732run_test "SHA-1 forbidden by default in server certificate" \
733 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
734 "$P_CLI debug_level=2 allow_sha1=0" \
735 0
736
Gilles Peskinebc70a182017-05-09 15:59:24 +0200737run_test "SHA-1 explicitly allowed in server certificate" \
738 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
739 "$P_CLI allow_sha1=1" \
740 0
741
742run_test "SHA-256 allowed by default in server certificate" \
743 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
744 "$P_CLI allow_sha1=0" \
745 0
746
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200747requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200748run_test "SHA-1 forbidden by default in client certificate" \
749 "$P_SRV auth_mode=required allow_sha1=0" \
750 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
751 1 \
752 -s "The certificate is signed with an unacceptable hash"
753
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200754requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
755run_test "SHA-1 forbidden by default in client certificate" \
756 "$P_SRV auth_mode=required allow_sha1=0" \
757 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
758 0
759
Gilles Peskinebc70a182017-05-09 15:59:24 +0200760run_test "SHA-1 explicitly allowed in client certificate" \
761 "$P_SRV auth_mode=required allow_sha1=1" \
762 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
763 0
764
765run_test "SHA-256 allowed by default in client certificate" \
766 "$P_SRV auth_mode=required allow_sha1=0" \
767 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
768 0
769
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100770# Tests for Truncated HMAC extension
771
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100772run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200773 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100774 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100775 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100776 -s "dumping 'computed mac' (20 bytes)" \
777 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100778
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100779run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200780 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100781 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
782 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100783 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100784 -s "dumping 'computed mac' (20 bytes)" \
785 -S "dumping 'computed mac' (10 bytes)"
786
787run_test "Truncated HMAC: client enabled, server default" \
788 "$P_SRV debug_level=4" \
789 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
790 trunc_hmac=1" \
791 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100792 -s "dumping 'computed mac' (20 bytes)" \
793 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100794
795run_test "Truncated HMAC: client enabled, server disabled" \
796 "$P_SRV debug_level=4 trunc_hmac=0" \
797 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
798 trunc_hmac=1" \
799 0 \
800 -s "dumping 'computed mac' (20 bytes)" \
801 -S "dumping 'computed mac' (10 bytes)"
802
803run_test "Truncated HMAC: client enabled, server enabled" \
804 "$P_SRV debug_level=4 trunc_hmac=1" \
805 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
806 trunc_hmac=1" \
807 0 \
808 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100809 -s "dumping 'computed mac' (10 bytes)"
810
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100811# Tests for Encrypt-then-MAC extension
812
813run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100814 "$P_SRV debug_level=3 \
815 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100816 "$P_CLI debug_level=3" \
817 0 \
818 -c "client hello, adding encrypt_then_mac extension" \
819 -s "found encrypt then mac extension" \
820 -s "server hello, adding encrypt then mac extension" \
821 -c "found encrypt_then_mac extension" \
822 -c "using encrypt then mac" \
823 -s "using encrypt then mac"
824
825run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100826 "$P_SRV debug_level=3 etm=0 \
827 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100828 "$P_CLI debug_level=3 etm=1" \
829 0 \
830 -c "client hello, adding encrypt_then_mac extension" \
831 -s "found encrypt then mac extension" \
832 -S "server hello, adding encrypt then mac extension" \
833 -C "found encrypt_then_mac extension" \
834 -C "using encrypt then mac" \
835 -S "using encrypt then mac"
836
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100837run_test "Encrypt then MAC: client enabled, aead cipher" \
838 "$P_SRV debug_level=3 etm=1 \
839 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
840 "$P_CLI debug_level=3 etm=1" \
841 0 \
842 -c "client hello, adding encrypt_then_mac extension" \
843 -s "found encrypt then mac extension" \
844 -S "server hello, adding encrypt then mac extension" \
845 -C "found encrypt_then_mac extension" \
846 -C "using encrypt then mac" \
847 -S "using encrypt then mac"
848
849run_test "Encrypt then MAC: client enabled, stream cipher" \
850 "$P_SRV debug_level=3 etm=1 \
851 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100852 "$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 +0100853 0 \
854 -c "client hello, adding encrypt_then_mac extension" \
855 -s "found encrypt then mac extension" \
856 -S "server hello, adding encrypt then mac extension" \
857 -C "found encrypt_then_mac extension" \
858 -C "using encrypt then mac" \
859 -S "using encrypt then mac"
860
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100861run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100862 "$P_SRV debug_level=3 etm=1 \
863 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100864 "$P_CLI debug_level=3 etm=0" \
865 0 \
866 -C "client hello, adding encrypt_then_mac extension" \
867 -S "found encrypt then mac extension" \
868 -S "server hello, adding encrypt then mac extension" \
869 -C "found encrypt_then_mac extension" \
870 -C "using encrypt then mac" \
871 -S "using encrypt then mac"
872
Janos Follathe2681a42016-03-07 15:57:05 +0000873requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100874run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100875 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100876 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100877 "$P_CLI debug_level=3 force_version=ssl3" \
878 0 \
879 -C "client hello, adding encrypt_then_mac extension" \
880 -S "found encrypt then mac extension" \
881 -S "server hello, adding encrypt then mac extension" \
882 -C "found encrypt_then_mac extension" \
883 -C "using encrypt then mac" \
884 -S "using encrypt then mac"
885
Janos Follathe2681a42016-03-07 15:57:05 +0000886requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100887run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100888 "$P_SRV debug_level=3 force_version=ssl3 \
889 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100890 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100891 0 \
892 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100893 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100894 -S "server hello, adding encrypt then mac extension" \
895 -C "found encrypt_then_mac extension" \
896 -C "using encrypt then mac" \
897 -S "using encrypt then mac"
898
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200899# Tests for Extended Master Secret extension
900
901run_test "Extended Master Secret: default" \
902 "$P_SRV debug_level=3" \
903 "$P_CLI debug_level=3" \
904 0 \
905 -c "client hello, adding extended_master_secret extension" \
906 -s "found extended master secret extension" \
907 -s "server hello, adding extended master secret extension" \
908 -c "found extended_master_secret extension" \
909 -c "using extended master secret" \
910 -s "using extended master secret"
911
912run_test "Extended Master Secret: client enabled, server disabled" \
913 "$P_SRV debug_level=3 extended_ms=0" \
914 "$P_CLI debug_level=3 extended_ms=1" \
915 0 \
916 -c "client hello, adding extended_master_secret extension" \
917 -s "found extended master secret extension" \
918 -S "server hello, adding extended master secret extension" \
919 -C "found extended_master_secret extension" \
920 -C "using extended master secret" \
921 -S "using extended master secret"
922
923run_test "Extended Master Secret: client disabled, server enabled" \
924 "$P_SRV debug_level=3 extended_ms=1" \
925 "$P_CLI debug_level=3 extended_ms=0" \
926 0 \
927 -C "client hello, adding extended_master_secret extension" \
928 -S "found extended master secret extension" \
929 -S "server hello, adding extended master secret extension" \
930 -C "found extended_master_secret extension" \
931 -C "using extended master secret" \
932 -S "using extended master secret"
933
Janos Follathe2681a42016-03-07 15:57:05 +0000934requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200935run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100936 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200937 "$P_CLI debug_level=3 force_version=ssl3" \
938 0 \
939 -C "client hello, adding extended_master_secret extension" \
940 -S "found extended master secret extension" \
941 -S "server hello, adding extended master secret extension" \
942 -C "found extended_master_secret extension" \
943 -C "using extended master secret" \
944 -S "using extended master secret"
945
Janos Follathe2681a42016-03-07 15:57:05 +0000946requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200947run_test "Extended Master Secret: client enabled, server SSLv3" \
948 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100949 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200950 0 \
951 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100952 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200953 -S "server hello, adding extended master secret extension" \
954 -C "found extended_master_secret extension" \
955 -C "using extended master secret" \
956 -S "using extended master secret"
957
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200958# Tests for FALLBACK_SCSV
959
960run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200961 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200962 "$P_CLI debug_level=3 force_version=tls1_1" \
963 0 \
964 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200965 -S "received FALLBACK_SCSV" \
966 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200967 -C "is a fatal alert message (msg 86)"
968
969run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200970 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200971 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
972 0 \
973 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200974 -S "received FALLBACK_SCSV" \
975 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200976 -C "is a fatal alert message (msg 86)"
977
978run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200979 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200980 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200981 1 \
982 -c "adding FALLBACK_SCSV" \
983 -s "received FALLBACK_SCSV" \
984 -s "inapropriate fallback" \
985 -c "is a fatal alert message (msg 86)"
986
987run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200988 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200989 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200990 0 \
991 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200992 -s "received FALLBACK_SCSV" \
993 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200994 -C "is a fatal alert message (msg 86)"
995
996requires_openssl_with_fallback_scsv
997run_test "Fallback SCSV: default, openssl server" \
998 "$O_SRV" \
999 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1000 0 \
1001 -C "adding FALLBACK_SCSV" \
1002 -C "is a fatal alert message (msg 86)"
1003
1004requires_openssl_with_fallback_scsv
1005run_test "Fallback SCSV: enabled, openssl server" \
1006 "$O_SRV" \
1007 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1008 1 \
1009 -c "adding FALLBACK_SCSV" \
1010 -c "is a fatal alert message (msg 86)"
1011
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001012requires_openssl_with_fallback_scsv
1013run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001014 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001015 "$O_CLI -tls1_1" \
1016 0 \
1017 -S "received FALLBACK_SCSV" \
1018 -S "inapropriate fallback"
1019
1020requires_openssl_with_fallback_scsv
1021run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001022 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001023 "$O_CLI -tls1_1 -fallback_scsv" \
1024 1 \
1025 -s "received FALLBACK_SCSV" \
1026 -s "inapropriate fallback"
1027
1028requires_openssl_with_fallback_scsv
1029run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001030 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001031 "$O_CLI -fallback_scsv" \
1032 0 \
1033 -s "received FALLBACK_SCSV" \
1034 -S "inapropriate fallback"
1035
Gilles Peskined50177f2017-05-16 17:53:03 +02001036## ClientHello generated with
1037## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1038## then manually twiddling the ciphersuite list.
1039## The ClientHello content is spelled out below as a hex string as
1040## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1041## The expected response is an inappropriate_fallback alert.
1042requires_openssl_with_fallback_scsv
1043run_test "Fallback SCSV: beginning of list" \
1044 "$P_SRV debug_level=2" \
1045 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1046 0 \
1047 -s "received FALLBACK_SCSV" \
1048 -s "inapropriate fallback"
1049
1050requires_openssl_with_fallback_scsv
1051run_test "Fallback SCSV: end of list" \
1052 "$P_SRV debug_level=2" \
1053 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1054 0 \
1055 -s "received FALLBACK_SCSV" \
1056 -s "inapropriate fallback"
1057
1058## Here the expected response is a valid ServerHello prefix, up to the random.
1059requires_openssl_with_fallback_scsv
1060run_test "Fallback SCSV: not in list" \
1061 "$P_SRV debug_level=2" \
1062 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1063 0 \
1064 -S "received FALLBACK_SCSV" \
1065 -S "inapropriate fallback"
1066
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001067# Tests for CBC 1/n-1 record splitting
1068
1069run_test "CBC Record splitting: TLS 1.2, no splitting" \
1070 "$P_SRV" \
1071 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1072 request_size=123 force_version=tls1_2" \
1073 0 \
1074 -s "Read from client: 123 bytes read" \
1075 -S "Read from client: 1 bytes read" \
1076 -S "122 bytes read"
1077
1078run_test "CBC Record splitting: TLS 1.1, no splitting" \
1079 "$P_SRV" \
1080 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1081 request_size=123 force_version=tls1_1" \
1082 0 \
1083 -s "Read from client: 123 bytes read" \
1084 -S "Read from client: 1 bytes read" \
1085 -S "122 bytes read"
1086
1087run_test "CBC Record splitting: TLS 1.0, splitting" \
1088 "$P_SRV" \
1089 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1090 request_size=123 force_version=tls1" \
1091 0 \
1092 -S "Read from client: 123 bytes read" \
1093 -s "Read from client: 1 bytes read" \
1094 -s "122 bytes read"
1095
Janos Follathe2681a42016-03-07 15:57:05 +00001096requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001097run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001098 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001099 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1100 request_size=123 force_version=ssl3" \
1101 0 \
1102 -S "Read from client: 123 bytes read" \
1103 -s "Read from client: 1 bytes read" \
1104 -s "122 bytes read"
1105
1106run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001107 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001108 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1109 request_size=123 force_version=tls1" \
1110 0 \
1111 -s "Read from client: 123 bytes read" \
1112 -S "Read from client: 1 bytes read" \
1113 -S "122 bytes read"
1114
1115run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1116 "$P_SRV" \
1117 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1118 request_size=123 force_version=tls1 recsplit=0" \
1119 0 \
1120 -s "Read from client: 123 bytes read" \
1121 -S "Read from client: 1 bytes read" \
1122 -S "122 bytes read"
1123
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001124run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1125 "$P_SRV nbio=2" \
1126 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1127 request_size=123 force_version=tls1" \
1128 0 \
1129 -S "Read from client: 123 bytes read" \
1130 -s "Read from client: 1 bytes read" \
1131 -s "122 bytes read"
1132
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001133# Tests for Session Tickets
1134
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001135run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001136 "$P_SRV debug_level=3 tickets=1" \
1137 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001138 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001139 -c "client hello, adding session ticket extension" \
1140 -s "found session ticket extension" \
1141 -s "server hello, adding session ticket extension" \
1142 -c "found session_ticket extension" \
1143 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001144 -S "session successfully restored from cache" \
1145 -s "session successfully restored from ticket" \
1146 -s "a session has been resumed" \
1147 -c "a session has been resumed"
1148
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001149run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001150 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1151 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001152 0 \
1153 -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" \
1158 -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: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001164 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1165 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
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: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001178 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001179 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001180 0 \
1181 -c "client hello, adding session ticket extension" \
1182 -c "found session_ticket extension" \
1183 -c "parse new session ticket" \
1184 -c "a session has been resumed"
1185
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001186run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001187 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001188 "( $O_CLI -sess_out $SESSION; \
1189 $O_CLI -sess_in $SESSION; \
1190 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001191 0 \
1192 -s "found session ticket extension" \
1193 -s "server hello, adding session ticket extension" \
1194 -S "session successfully restored from cache" \
1195 -s "session successfully restored from ticket" \
1196 -s "a session has been resumed"
1197
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001198# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001199
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001200run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001201 "$P_SRV debug_level=3 tickets=0" \
1202 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001203 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001204 -c "client hello, adding session ticket extension" \
1205 -s "found session ticket extension" \
1206 -S "server hello, adding session ticket extension" \
1207 -C "found session_ticket extension" \
1208 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001209 -s "session successfully restored from cache" \
1210 -S "session successfully restored from ticket" \
1211 -s "a session has been resumed" \
1212 -c "a session has been resumed"
1213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001214run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001215 "$P_SRV debug_level=3 tickets=1" \
1216 "$P_CLI debug_level=3 tickets=0 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"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001227
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001228run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001229 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1230 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001231 0 \
1232 -S "session successfully restored from cache" \
1233 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001234 -S "a session has been resumed" \
1235 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001236
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001237run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001238 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1239 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001240 0 \
1241 -s "session successfully restored from cache" \
1242 -S "session successfully restored from ticket" \
1243 -s "a session has been resumed" \
1244 -c "a session has been resumed"
1245
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001246run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001247 "$P_SRV debug_level=3 tickets=0" \
1248 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001249 0 \
1250 -s "session successfully restored from cache" \
1251 -S "session successfully restored from ticket" \
1252 -s "a session has been resumed" \
1253 -c "a session has been resumed"
1254
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001255run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001256 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1257 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001258 0 \
1259 -S "session successfully restored from cache" \
1260 -S "session successfully restored from ticket" \
1261 -S "a session has been resumed" \
1262 -C "a session has been resumed"
1263
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001264run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001265 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1266 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001267 0 \
1268 -s "session successfully restored from cache" \
1269 -S "session successfully restored from ticket" \
1270 -s "a session has been resumed" \
1271 -c "a session has been resumed"
1272
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001273run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001274 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001275 "( $O_CLI -sess_out $SESSION; \
1276 $O_CLI -sess_in $SESSION; \
1277 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001278 0 \
1279 -s "found session ticket extension" \
1280 -S "server hello, adding session ticket extension" \
1281 -s "session successfully restored from cache" \
1282 -S "session successfully restored from ticket" \
1283 -s "a session has been resumed"
1284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001285run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001286 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001287 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001288 0 \
1289 -C "found session_ticket extension" \
1290 -C "parse new session ticket" \
1291 -c "a session has been resumed"
1292
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001293# Tests for Max Fragment Length extension
1294
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001295run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001296 "$P_SRV debug_level=3" \
1297 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001298 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001299 -c "Maximum fragment length is 16384" \
1300 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001301 -C "client hello, adding max_fragment_length extension" \
1302 -S "found max fragment length extension" \
1303 -S "server hello, max_fragment_length extension" \
1304 -C "found max_fragment_length extension"
1305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001306run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001307 "$P_SRV debug_level=3" \
1308 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001309 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001310 -c "Maximum fragment length is 4096" \
1311 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001312 -c "client hello, adding max_fragment_length extension" \
1313 -s "found max fragment length extension" \
1314 -s "server hello, max_fragment_length extension" \
1315 -c "found max_fragment_length extension"
1316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001317run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001318 "$P_SRV debug_level=3 max_frag_len=4096" \
1319 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001320 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001321 -c "Maximum fragment length is 16384" \
1322 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001323 -C "client hello, adding max_fragment_length extension" \
1324 -S "found max fragment length extension" \
1325 -S "server hello, max_fragment_length extension" \
1326 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001327
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001328requires_gnutls
1329run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001330 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001331 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001332 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001333 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001334 -c "client hello, adding max_fragment_length extension" \
1335 -c "found max_fragment_length extension"
1336
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001337run_test "Max fragment length: client, message just fits" \
1338 "$P_SRV debug_level=3" \
1339 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1340 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001341 -c "Maximum fragment length is 2048" \
1342 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001343 -c "client hello, adding max_fragment_length extension" \
1344 -s "found max fragment length extension" \
1345 -s "server hello, max_fragment_length extension" \
1346 -c "found max_fragment_length extension" \
1347 -c "2048 bytes written in 1 fragments" \
1348 -s "2048 bytes read"
1349
1350run_test "Max fragment length: client, larger message" \
1351 "$P_SRV debug_level=3" \
1352 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1353 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001354 -c "Maximum fragment length is 2048" \
1355 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001356 -c "client hello, adding max_fragment_length extension" \
1357 -s "found max fragment length extension" \
1358 -s "server hello, max_fragment_length extension" \
1359 -c "found max_fragment_length extension" \
1360 -c "2345 bytes written in 2 fragments" \
1361 -s "2048 bytes read" \
1362 -s "297 bytes read"
1363
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001364run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001365 "$P_SRV debug_level=3 dtls=1" \
1366 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1367 1 \
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 "fragment larger than.*maximum"
1375
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001376# Tests for renegotiation
1377
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001378run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001379 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001380 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001381 0 \
1382 -C "client hello, adding renegotiation extension" \
1383 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1384 -S "found renegotiation extension" \
1385 -s "server hello, secure renegotiation extension" \
1386 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001387 -C "=> renegotiate" \
1388 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001389 -S "write hello request"
1390
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001391run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001392 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001393 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001394 0 \
1395 -c "client hello, adding renegotiation extension" \
1396 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1397 -s "found renegotiation extension" \
1398 -s "server hello, secure renegotiation extension" \
1399 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001400 -c "=> renegotiate" \
1401 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001402 -S "write hello request"
1403
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001404run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001405 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001406 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001407 0 \
1408 -c "client hello, adding renegotiation extension" \
1409 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1410 -s "found renegotiation extension" \
1411 -s "server hello, secure renegotiation extension" \
1412 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001413 -c "=> renegotiate" \
1414 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001415 -s "write hello request"
1416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001417run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001418 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001419 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001420 0 \
1421 -c "client hello, adding renegotiation extension" \
1422 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1423 -s "found renegotiation extension" \
1424 -s "server hello, secure renegotiation extension" \
1425 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001426 -c "=> renegotiate" \
1427 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001428 -s "write hello request"
1429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001430run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001431 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001432 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001433 1 \
1434 -c "client hello, adding renegotiation extension" \
1435 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1436 -S "found renegotiation extension" \
1437 -s "server hello, secure renegotiation extension" \
1438 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001439 -c "=> renegotiate" \
1440 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001441 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001442 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001443 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001445run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001446 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001447 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001448 0 \
1449 -C "client hello, adding renegotiation extension" \
1450 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1451 -S "found renegotiation extension" \
1452 -s "server hello, secure renegotiation extension" \
1453 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001454 -C "=> renegotiate" \
1455 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001456 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001457 -S "SSL - An unexpected message was received from our peer" \
1458 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001459
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001460run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001461 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001462 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001463 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001464 0 \
1465 -C "client hello, adding renegotiation extension" \
1466 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1467 -S "found renegotiation extension" \
1468 -s "server hello, secure renegotiation extension" \
1469 -c "found renegotiation extension" \
1470 -C "=> renegotiate" \
1471 -S "=> renegotiate" \
1472 -s "write hello request" \
1473 -S "SSL - An unexpected message was received from our peer" \
1474 -S "failed"
1475
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001476# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001477run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001478 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001479 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001480 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001481 0 \
1482 -C "client hello, adding renegotiation extension" \
1483 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1484 -S "found renegotiation extension" \
1485 -s "server hello, secure renegotiation extension" \
1486 -c "found renegotiation extension" \
1487 -C "=> renegotiate" \
1488 -S "=> renegotiate" \
1489 -s "write hello request" \
1490 -S "SSL - An unexpected message was received from our peer" \
1491 -S "failed"
1492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001493run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001494 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001495 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001496 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001497 0 \
1498 -C "client hello, adding renegotiation extension" \
1499 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1500 -S "found renegotiation extension" \
1501 -s "server hello, secure renegotiation extension" \
1502 -c "found renegotiation extension" \
1503 -C "=> renegotiate" \
1504 -S "=> renegotiate" \
1505 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001506 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001507
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001508run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001509 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001510 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001511 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001512 0 \
1513 -c "client hello, adding renegotiation extension" \
1514 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1515 -s "found renegotiation extension" \
1516 -s "server hello, secure renegotiation extension" \
1517 -c "found renegotiation extension" \
1518 -c "=> renegotiate" \
1519 -s "=> renegotiate" \
1520 -s "write hello request" \
1521 -S "SSL - An unexpected message was received from our peer" \
1522 -S "failed"
1523
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001524run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001525 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001526 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1527 0 \
1528 -C "client hello, adding renegotiation extension" \
1529 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1530 -S "found renegotiation extension" \
1531 -s "server hello, secure renegotiation extension" \
1532 -c "found renegotiation extension" \
1533 -S "record counter limit reached: renegotiate" \
1534 -C "=> renegotiate" \
1535 -S "=> renegotiate" \
1536 -S "write hello request" \
1537 -S "SSL - An unexpected message was received from our peer" \
1538 -S "failed"
1539
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001540# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001541run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001542 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001543 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001544 0 \
1545 -c "client hello, adding renegotiation extension" \
1546 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1547 -s "found renegotiation extension" \
1548 -s "server hello, secure renegotiation extension" \
1549 -c "found renegotiation extension" \
1550 -s "record counter limit reached: renegotiate" \
1551 -c "=> renegotiate" \
1552 -s "=> renegotiate" \
1553 -s "write hello request" \
1554 -S "SSL - An unexpected message was received from our peer" \
1555 -S "failed"
1556
1557run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001558 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001559 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001560 0 \
1561 -c "client hello, adding renegotiation extension" \
1562 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1563 -s "found renegotiation extension" \
1564 -s "server hello, secure renegotiation extension" \
1565 -c "found renegotiation extension" \
1566 -s "record counter limit reached: renegotiate" \
1567 -c "=> renegotiate" \
1568 -s "=> renegotiate" \
1569 -s "write hello request" \
1570 -S "SSL - An unexpected message was received from our peer" \
1571 -S "failed"
1572
1573run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001574 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001575 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1576 0 \
1577 -C "client hello, adding renegotiation extension" \
1578 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1579 -S "found renegotiation extension" \
1580 -s "server hello, secure renegotiation extension" \
1581 -c "found renegotiation extension" \
1582 -S "record counter limit reached: renegotiate" \
1583 -C "=> renegotiate" \
1584 -S "=> renegotiate" \
1585 -S "write hello request" \
1586 -S "SSL - An unexpected message was received from our peer" \
1587 -S "failed"
1588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001589run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001590 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001591 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001592 0 \
1593 -c "client hello, adding renegotiation extension" \
1594 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1595 -s "found renegotiation extension" \
1596 -s "server hello, secure renegotiation extension" \
1597 -c "found renegotiation extension" \
1598 -c "=> renegotiate" \
1599 -s "=> renegotiate" \
1600 -S "write hello request"
1601
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001602run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001603 "$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 +02001604 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001605 0 \
1606 -c "client hello, adding renegotiation extension" \
1607 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1608 -s "found renegotiation extension" \
1609 -s "server hello, secure renegotiation extension" \
1610 -c "found renegotiation extension" \
1611 -c "=> renegotiate" \
1612 -s "=> renegotiate" \
1613 -s "write hello request"
1614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001615run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001616 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001617 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001618 0 \
1619 -c "client hello, adding renegotiation extension" \
1620 -c "found renegotiation extension" \
1621 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001622 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001623 -C "error" \
1624 -c "HTTP/1.0 200 [Oo][Kk]"
1625
Paul Bakker539d9722015-02-08 16:18:35 +01001626requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001627run_test "Renegotiation: gnutls server strict, client-initiated" \
1628 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001629 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001630 0 \
1631 -c "client hello, adding renegotiation extension" \
1632 -c "found renegotiation extension" \
1633 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001634 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001635 -C "error" \
1636 -c "HTTP/1.0 200 [Oo][Kk]"
1637
Paul Bakker539d9722015-02-08 16:18:35 +01001638requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001639run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1640 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1641 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1642 1 \
1643 -c "client hello, adding renegotiation extension" \
1644 -C "found renegotiation extension" \
1645 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001646 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001647 -c "error" \
1648 -C "HTTP/1.0 200 [Oo][Kk]"
1649
Paul Bakker539d9722015-02-08 16:18:35 +01001650requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001651run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1652 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1653 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1654 allow_legacy=0" \
1655 1 \
1656 -c "client hello, adding renegotiation extension" \
1657 -C "found renegotiation extension" \
1658 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001659 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001660 -c "error" \
1661 -C "HTTP/1.0 200 [Oo][Kk]"
1662
Paul Bakker539d9722015-02-08 16:18:35 +01001663requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001664run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1665 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1666 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1667 allow_legacy=1" \
1668 0 \
1669 -c "client hello, adding renegotiation extension" \
1670 -C "found renegotiation extension" \
1671 -c "=> renegotiate" \
1672 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001673 -C "error" \
1674 -c "HTTP/1.0 200 [Oo][Kk]"
1675
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001676run_test "Renegotiation: DTLS, client-initiated" \
1677 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1678 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1679 0 \
1680 -c "client hello, adding renegotiation extension" \
1681 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1682 -s "found renegotiation extension" \
1683 -s "server hello, secure renegotiation extension" \
1684 -c "found renegotiation extension" \
1685 -c "=> renegotiate" \
1686 -s "=> renegotiate" \
1687 -S "write hello request"
1688
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001689run_test "Renegotiation: DTLS, server-initiated" \
1690 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001691 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1692 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001693 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
Andres AG692ad842017-01-19 16:30:57 +00001703run_test "Renegotiation: DTLS, renego_period overflow" \
1704 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1705 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1706 0 \
1707 -c "client hello, adding renegotiation extension" \
1708 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1709 -s "found renegotiation extension" \
1710 -s "server hello, secure renegotiation extension" \
1711 -s "record counter limit reached: renegotiate" \
1712 -c "=> renegotiate" \
1713 -s "=> renegotiate" \
1714 -s "write hello request" \
1715
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001716requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001717run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1718 "$G_SRV -u --mtu 4096" \
1719 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1720 0 \
1721 -c "client hello, adding renegotiation extension" \
1722 -c "found renegotiation extension" \
1723 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001724 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001725 -C "error" \
1726 -s "Extra-header:"
1727
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001728# Test for the "secure renegotation" extension only (no actual renegotiation)
1729
Paul Bakker539d9722015-02-08 16:18:35 +01001730requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001731run_test "Renego ext: gnutls server strict, client default" \
1732 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1733 "$P_CLI debug_level=3" \
1734 0 \
1735 -c "found renegotiation extension" \
1736 -C "error" \
1737 -c "HTTP/1.0 200 [Oo][Kk]"
1738
Paul Bakker539d9722015-02-08 16:18:35 +01001739requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001740run_test "Renego ext: gnutls server unsafe, client default" \
1741 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1742 "$P_CLI debug_level=3" \
1743 0 \
1744 -C "found renegotiation extension" \
1745 -C "error" \
1746 -c "HTTP/1.0 200 [Oo][Kk]"
1747
Paul Bakker539d9722015-02-08 16:18:35 +01001748requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001749run_test "Renego ext: gnutls server unsafe, client break legacy" \
1750 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1751 "$P_CLI debug_level=3 allow_legacy=-1" \
1752 1 \
1753 -C "found renegotiation extension" \
1754 -c "error" \
1755 -C "HTTP/1.0 200 [Oo][Kk]"
1756
Paul Bakker539d9722015-02-08 16:18:35 +01001757requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001758run_test "Renego ext: gnutls client strict, server default" \
1759 "$P_SRV debug_level=3" \
1760 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1761 0 \
1762 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1763 -s "server hello, secure renegotiation extension"
1764
Paul Bakker539d9722015-02-08 16:18:35 +01001765requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001766run_test "Renego ext: gnutls client unsafe, server default" \
1767 "$P_SRV debug_level=3" \
1768 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1769 0 \
1770 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1771 -S "server hello, secure renegotiation extension"
1772
Paul Bakker539d9722015-02-08 16:18:35 +01001773requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001774run_test "Renego ext: gnutls client unsafe, server break legacy" \
1775 "$P_SRV debug_level=3 allow_legacy=-1" \
1776 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1777 1 \
1778 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1779 -S "server hello, secure renegotiation extension"
1780
Janos Follath0b242342016-02-17 10:11:21 +00001781# Tests for silently dropping trailing extra bytes in .der certificates
1782
1783requires_gnutls
1784run_test "DER format: no trailing bytes" \
1785 "$P_SRV crt_file=data_files/server5-der0.crt \
1786 key_file=data_files/server5.key" \
1787 "$G_CLI " \
1788 0 \
1789 -c "Handshake was completed" \
1790
1791requires_gnutls
1792run_test "DER format: with a trailing zero byte" \
1793 "$P_SRV crt_file=data_files/server5-der1a.crt \
1794 key_file=data_files/server5.key" \
1795 "$G_CLI " \
1796 0 \
1797 -c "Handshake was completed" \
1798
1799requires_gnutls
1800run_test "DER format: with a trailing random byte" \
1801 "$P_SRV crt_file=data_files/server5-der1b.crt \
1802 key_file=data_files/server5.key" \
1803 "$G_CLI " \
1804 0 \
1805 -c "Handshake was completed" \
1806
1807requires_gnutls
1808run_test "DER format: with 2 trailing random bytes" \
1809 "$P_SRV crt_file=data_files/server5-der2.crt \
1810 key_file=data_files/server5.key" \
1811 "$G_CLI " \
1812 0 \
1813 -c "Handshake was completed" \
1814
1815requires_gnutls
1816run_test "DER format: with 4 trailing random bytes" \
1817 "$P_SRV crt_file=data_files/server5-der4.crt \
1818 key_file=data_files/server5.key" \
1819 "$G_CLI " \
1820 0 \
1821 -c "Handshake was completed" \
1822
1823requires_gnutls
1824run_test "DER format: with 8 trailing random bytes" \
1825 "$P_SRV crt_file=data_files/server5-der8.crt \
1826 key_file=data_files/server5.key" \
1827 "$G_CLI " \
1828 0 \
1829 -c "Handshake was completed" \
1830
1831requires_gnutls
1832run_test "DER format: with 9 trailing random bytes" \
1833 "$P_SRV crt_file=data_files/server5-der9.crt \
1834 key_file=data_files/server5.key" \
1835 "$G_CLI " \
1836 0 \
1837 -c "Handshake was completed" \
1838
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001839# Tests for auth_mode
1840
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001841run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001842 "$P_SRV crt_file=data_files/server5-badsign.crt \
1843 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001844 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001845 1 \
1846 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001847 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001848 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001849 -c "X509 - Certificate verification failed"
1850
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001851run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001852 "$P_SRV crt_file=data_files/server5-badsign.crt \
1853 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001854 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001855 0 \
1856 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001857 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001858 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001859 -C "X509 - Certificate verification failed"
1860
Hanno Beckere6706e62017-05-15 16:05:15 +01001861run_test "Authentication: server goodcert, client optional, no trusted CA" \
1862 "$P_SRV" \
1863 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1864 0 \
1865 -c "x509_verify_cert() returned" \
1866 -c "! The certificate is not correctly signed by the trusted CA" \
1867 -c "! Certificate verification flags"\
1868 -C "! mbedtls_ssl_handshake returned" \
1869 -C "X509 - Certificate verification failed" \
1870 -C "SSL - No CA Chain is set, but required to operate"
1871
1872run_test "Authentication: server goodcert, client required, no trusted CA" \
1873 "$P_SRV" \
1874 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1875 1 \
1876 -c "x509_verify_cert() returned" \
1877 -c "! The certificate is not correctly signed by the trusted CA" \
1878 -c "! Certificate verification flags"\
1879 -c "! mbedtls_ssl_handshake returned" \
1880 -c "SSL - No CA Chain is set, but required to operate"
1881
1882# The purpose of the next two tests is to test the client's behaviour when receiving a server
1883# certificate with an unsupported elliptic curve. This should usually not happen because
1884# the client informs the server about the supported curves - it does, though, in the
1885# corner case of a static ECDH suite, because the server doesn't check the curve on that
1886# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1887# different means to have the server ignoring the client's supported curve list.
1888
1889requires_config_enabled MBEDTLS_ECP_C
1890run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1891 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1892 crt_file=data_files/server5.ku-ka.crt" \
1893 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1894 1 \
1895 -c "bad certificate (EC key curve)"\
1896 -c "! Certificate verification flags"\
1897 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1898
1899requires_config_enabled MBEDTLS_ECP_C
1900run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1901 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1902 crt_file=data_files/server5.ku-ka.crt" \
1903 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1904 1 \
1905 -c "bad certificate (EC key curve)"\
1906 -c "! Certificate verification flags"\
1907 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001909run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001910 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001911 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001912 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001913 0 \
1914 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001915 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001916 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001917 -C "X509 - Certificate verification failed"
1918
Simon Butcher99000142016-10-13 17:21:01 +01001919run_test "Authentication: client SHA256, server required" \
1920 "$P_SRV auth_mode=required" \
1921 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1922 key_file=data_files/server6.key \
1923 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1924 0 \
1925 -c "Supported Signature Algorithm found: 4," \
1926 -c "Supported Signature Algorithm found: 5,"
1927
1928run_test "Authentication: client SHA384, server required" \
1929 "$P_SRV auth_mode=required" \
1930 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1931 key_file=data_files/server6.key \
1932 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
1933 0 \
1934 -c "Supported Signature Algorithm found: 4," \
1935 -c "Supported Signature Algorithm found: 5,"
1936
Gilles Peskinefd8332e2017-05-03 16:25:07 +02001937requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
1938run_test "Authentication: client has no cert, server required (SSLv3)" \
1939 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
1940 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
1941 key_file=data_files/server5.key" \
1942 1 \
1943 -S "skip write certificate request" \
1944 -C "skip parse certificate request" \
1945 -c "got a certificate request" \
1946 -c "got no certificate to send" \
1947 -S "x509_verify_cert() returned" \
1948 -s "client has no certificate" \
1949 -s "! mbedtls_ssl_handshake returned" \
1950 -c "! mbedtls_ssl_handshake returned" \
1951 -s "No client certification received from the client, but required by the authentication mode"
1952
1953run_test "Authentication: client has no cert, server required (TLS)" \
1954 "$P_SRV debug_level=3 auth_mode=required" \
1955 "$P_CLI debug_level=3 crt_file=none \
1956 key_file=data_files/server5.key" \
1957 1 \
1958 -S "skip write certificate request" \
1959 -C "skip parse certificate request" \
1960 -c "got a certificate request" \
1961 -c "= write certificate$" \
1962 -C "skip write certificate$" \
1963 -S "x509_verify_cert() returned" \
1964 -s "client has no certificate" \
1965 -s "! mbedtls_ssl_handshake returned" \
1966 -c "! mbedtls_ssl_handshake returned" \
1967 -s "No client certification received from the client, but required by the authentication mode"
1968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001969run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001970 "$P_SRV debug_level=3 auth_mode=required" \
1971 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001972 key_file=data_files/server5.key" \
1973 1 \
1974 -S "skip write certificate request" \
1975 -C "skip parse certificate request" \
1976 -c "got a certificate request" \
1977 -C "skip write certificate" \
1978 -C "skip write certificate verify" \
1979 -S "skip parse certificate verify" \
1980 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001981 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001982 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02001983 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001984 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001985 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02001986# We don't check that the client receives the alert because it might
1987# detect that its write end of the connection is closed and abort
1988# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001989
Janos Follath89baba22017-04-10 14:34:35 +01001990run_test "Authentication: client cert not trusted, server required" \
1991 "$P_SRV debug_level=3 auth_mode=required" \
1992 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
1993 key_file=data_files/server5.key" \
1994 1 \
1995 -S "skip write certificate request" \
1996 -C "skip parse certificate request" \
1997 -c "got a certificate request" \
1998 -C "skip write certificate" \
1999 -C "skip write certificate verify" \
2000 -S "skip parse certificate verify" \
2001 -s "x509_verify_cert() returned" \
2002 -s "! The certificate is not correctly signed by the trusted CA" \
2003 -s "! mbedtls_ssl_handshake returned" \
2004 -c "! mbedtls_ssl_handshake returned" \
2005 -s "X509 - Certificate verification failed"
2006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002007run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002008 "$P_SRV debug_level=3 auth_mode=optional" \
2009 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002010 key_file=data_files/server5.key" \
2011 0 \
2012 -S "skip write certificate request" \
2013 -C "skip parse certificate request" \
2014 -c "got a certificate request" \
2015 -C "skip write certificate" \
2016 -C "skip write certificate verify" \
2017 -S "skip parse certificate verify" \
2018 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002019 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002020 -S "! mbedtls_ssl_handshake returned" \
2021 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002022 -S "X509 - Certificate verification failed"
2023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002024run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002025 "$P_SRV debug_level=3 auth_mode=none" \
2026 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002027 key_file=data_files/server5.key" \
2028 0 \
2029 -s "skip write certificate request" \
2030 -C "skip parse certificate request" \
2031 -c "got no certificate request" \
2032 -c "skip write certificate" \
2033 -c "skip write certificate verify" \
2034 -s "skip parse certificate verify" \
2035 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002036 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002037 -S "! mbedtls_ssl_handshake returned" \
2038 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002039 -S "X509 - Certificate verification failed"
2040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002041run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002042 "$P_SRV debug_level=3 auth_mode=optional" \
2043 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002044 0 \
2045 -S "skip write certificate request" \
2046 -C "skip parse certificate request" \
2047 -c "got a certificate request" \
2048 -C "skip write certificate$" \
2049 -C "got no certificate to send" \
2050 -S "SSLv3 client has no certificate" \
2051 -c "skip write certificate verify" \
2052 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002053 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002054 -S "! mbedtls_ssl_handshake returned" \
2055 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002056 -S "X509 - Certificate verification failed"
2057
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002058run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002059 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002060 "$O_CLI" \
2061 0 \
2062 -S "skip write certificate request" \
2063 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002064 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002065 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002066 -S "X509 - Certificate verification failed"
2067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002068run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002069 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002070 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002071 0 \
2072 -C "skip parse certificate request" \
2073 -c "got a certificate request" \
2074 -C "skip write certificate$" \
2075 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002076 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002077
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002078run_test "Authentication: client no cert, openssl server required" \
2079 "$O_SRV -Verify 10" \
2080 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2081 1 \
2082 -C "skip parse certificate request" \
2083 -c "got a certificate request" \
2084 -C "skip write certificate$" \
2085 -c "skip write certificate verify" \
2086 -c "! mbedtls_ssl_handshake returned"
2087
Janos Follathe2681a42016-03-07 15:57:05 +00002088requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002089run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002090 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002091 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002092 0 \
2093 -S "skip write certificate request" \
2094 -C "skip parse certificate request" \
2095 -c "got a certificate request" \
2096 -C "skip write certificate$" \
2097 -c "skip write certificate verify" \
2098 -c "got no certificate to send" \
2099 -s "SSLv3 client has no certificate" \
2100 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002101 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002102 -S "! mbedtls_ssl_handshake returned" \
2103 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002104 -S "X509 - Certificate verification failed"
2105
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002106# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2107# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002108
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002109MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002110MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002111
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002112if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002113 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002114 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002115 printf "test value of ${MAX_IM_CA}. \n"
2116 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002117 printf "The tests assume this value and if it changes, the tests in this\n"
2118 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002119 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002120
2121 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002122fi
2123
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002124run_test "Authentication: server max_int chain, client default" \
2125 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2126 key_file=data_files/dir-maxpath/09.key" \
2127 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2128 0 \
2129 -C "X509 - A fatal error occured"
2130
2131run_test "Authentication: server max_int+1 chain, client default" \
2132 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2133 key_file=data_files/dir-maxpath/10.key" \
2134 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2135 1 \
2136 -c "X509 - A fatal error occured"
2137
2138run_test "Authentication: server max_int+1 chain, client optional" \
2139 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2140 key_file=data_files/dir-maxpath/10.key" \
2141 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2142 auth_mode=optional" \
2143 1 \
2144 -c "X509 - A fatal error occured"
2145
2146run_test "Authentication: server max_int+1 chain, client none" \
2147 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2148 key_file=data_files/dir-maxpath/10.key" \
2149 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2150 auth_mode=none" \
2151 0 \
2152 -C "X509 - A fatal error occured"
2153
2154run_test "Authentication: client max_int+1 chain, server default" \
2155 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2156 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2157 key_file=data_files/dir-maxpath/10.key" \
2158 0 \
2159 -S "X509 - A fatal error occured"
2160
2161run_test "Authentication: client max_int+1 chain, server optional" \
2162 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2163 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2164 key_file=data_files/dir-maxpath/10.key" \
2165 1 \
2166 -s "X509 - A fatal error occured"
2167
2168run_test "Authentication: client max_int+1 chain, server required" \
2169 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2170 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2171 key_file=data_files/dir-maxpath/10.key" \
2172 1 \
2173 -s "X509 - A fatal error occured"
2174
2175run_test "Authentication: client max_int chain, server required" \
2176 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2177 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2178 key_file=data_files/dir-maxpath/09.key" \
2179 0 \
2180 -S "X509 - A fatal error occured"
2181
Janos Follath89baba22017-04-10 14:34:35 +01002182# Tests for CA list in CertificateRequest messages
2183
2184run_test "Authentication: send CA list in CertificateRequest (default)" \
2185 "$P_SRV debug_level=3 auth_mode=required" \
2186 "$P_CLI crt_file=data_files/server6.crt \
2187 key_file=data_files/server6.key" \
2188 0 \
2189 -s "requested DN"
2190
2191run_test "Authentication: do not send CA list in CertificateRequest" \
2192 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2193 "$P_CLI crt_file=data_files/server6.crt \
2194 key_file=data_files/server6.key" \
2195 0 \
2196 -S "requested DN"
2197
2198run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2199 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2200 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2201 key_file=data_files/server5.key" \
2202 1 \
2203 -S "requested DN" \
2204 -s "x509_verify_cert() returned" \
2205 -s "! The certificate is not correctly signed by the trusted CA" \
2206 -s "! mbedtls_ssl_handshake returned" \
2207 -c "! mbedtls_ssl_handshake returned" \
2208 -s "X509 - Certificate verification failed"
2209
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002210# Tests for certificate selection based on SHA verson
2211
2212run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2213 "$P_SRV crt_file=data_files/server5.crt \
2214 key_file=data_files/server5.key \
2215 crt_file2=data_files/server5-sha1.crt \
2216 key_file2=data_files/server5.key" \
2217 "$P_CLI force_version=tls1_2" \
2218 0 \
2219 -c "signed using.*ECDSA with SHA256" \
2220 -C "signed using.*ECDSA with SHA1"
2221
2222run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2223 "$P_SRV crt_file=data_files/server5.crt \
2224 key_file=data_files/server5.key \
2225 crt_file2=data_files/server5-sha1.crt \
2226 key_file2=data_files/server5.key" \
2227 "$P_CLI force_version=tls1_1" \
2228 0 \
2229 -C "signed using.*ECDSA with SHA256" \
2230 -c "signed using.*ECDSA with SHA1"
2231
2232run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2233 "$P_SRV crt_file=data_files/server5.crt \
2234 key_file=data_files/server5.key \
2235 crt_file2=data_files/server5-sha1.crt \
2236 key_file2=data_files/server5.key" \
2237 "$P_CLI force_version=tls1" \
2238 0 \
2239 -C "signed using.*ECDSA with SHA256" \
2240 -c "signed using.*ECDSA with SHA1"
2241
2242run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2243 "$P_SRV crt_file=data_files/server5.crt \
2244 key_file=data_files/server5.key \
2245 crt_file2=data_files/server6.crt \
2246 key_file2=data_files/server6.key" \
2247 "$P_CLI force_version=tls1_1" \
2248 0 \
2249 -c "serial number.*09" \
2250 -c "signed using.*ECDSA with SHA256" \
2251 -C "signed using.*ECDSA with SHA1"
2252
2253run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2254 "$P_SRV crt_file=data_files/server6.crt \
2255 key_file=data_files/server6.key \
2256 crt_file2=data_files/server5.crt \
2257 key_file2=data_files/server5.key" \
2258 "$P_CLI force_version=tls1_1" \
2259 0 \
2260 -c "serial number.*0A" \
2261 -c "signed using.*ECDSA with SHA256" \
2262 -C "signed using.*ECDSA with SHA1"
2263
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002264# tests for SNI
2265
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002266run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002267 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002268 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002269 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002270 0 \
2271 -S "parse ServerName extension" \
2272 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2273 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002274
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002275run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002276 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002277 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002278 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 +02002279 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002280 0 \
2281 -s "parse ServerName extension" \
2282 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2283 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002285run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002286 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002287 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002288 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 +02002289 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002290 0 \
2291 -s "parse ServerName extension" \
2292 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2293 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002294
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002295run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002296 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002297 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002298 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 +02002299 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002300 1 \
2301 -s "parse ServerName extension" \
2302 -s "ssl_sni_wrapper() returned" \
2303 -s "mbedtls_ssl_handshake returned" \
2304 -c "mbedtls_ssl_handshake returned" \
2305 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002306
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002307run_test "SNI: client auth no override: optional" \
2308 "$P_SRV debug_level=3 auth_mode=optional \
2309 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2310 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2311 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002312 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002313 -S "skip write certificate request" \
2314 -C "skip parse certificate request" \
2315 -c "got a certificate request" \
2316 -C "skip write certificate" \
2317 -C "skip write certificate verify" \
2318 -S "skip parse certificate verify"
2319
2320run_test "SNI: client auth override: none -> optional" \
2321 "$P_SRV debug_level=3 auth_mode=none \
2322 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2323 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2324 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002325 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002326 -S "skip write certificate request" \
2327 -C "skip parse certificate request" \
2328 -c "got a certificate request" \
2329 -C "skip write certificate" \
2330 -C "skip write certificate verify" \
2331 -S "skip parse certificate verify"
2332
2333run_test "SNI: client auth override: optional -> none" \
2334 "$P_SRV debug_level=3 auth_mode=optional \
2335 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2336 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2337 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002338 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002339 -s "skip write certificate request" \
2340 -C "skip parse certificate request" \
2341 -c "got no certificate request" \
2342 -c "skip write certificate" \
2343 -c "skip write certificate verify" \
2344 -s "skip parse certificate verify"
2345
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002346run_test "SNI: CA no override" \
2347 "$P_SRV debug_level=3 auth_mode=optional \
2348 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2349 ca_file=data_files/test-ca.crt \
2350 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2351 "$P_CLI debug_level=3 server_name=localhost \
2352 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2353 1 \
2354 -S "skip write certificate request" \
2355 -C "skip parse certificate request" \
2356 -c "got a certificate request" \
2357 -C "skip write certificate" \
2358 -C "skip write certificate verify" \
2359 -S "skip parse certificate verify" \
2360 -s "x509_verify_cert() returned" \
2361 -s "! The certificate is not correctly signed by the trusted CA" \
2362 -S "The certificate has been revoked (is on a CRL)"
2363
2364run_test "SNI: CA override" \
2365 "$P_SRV debug_level=3 auth_mode=optional \
2366 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2367 ca_file=data_files/test-ca.crt \
2368 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2369 "$P_CLI debug_level=3 server_name=localhost \
2370 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2371 0 \
2372 -S "skip write certificate request" \
2373 -C "skip parse certificate request" \
2374 -c "got a certificate request" \
2375 -C "skip write certificate" \
2376 -C "skip write certificate verify" \
2377 -S "skip parse certificate verify" \
2378 -S "x509_verify_cert() returned" \
2379 -S "! The certificate is not correctly signed by the trusted CA" \
2380 -S "The certificate has been revoked (is on a CRL)"
2381
2382run_test "SNI: CA override with CRL" \
2383 "$P_SRV debug_level=3 auth_mode=optional \
2384 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2385 ca_file=data_files/test-ca.crt \
2386 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2387 "$P_CLI debug_level=3 server_name=localhost \
2388 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2389 1 \
2390 -S "skip write certificate request" \
2391 -C "skip parse certificate request" \
2392 -c "got a certificate request" \
2393 -C "skip write certificate" \
2394 -C "skip write certificate verify" \
2395 -S "skip parse certificate verify" \
2396 -s "x509_verify_cert() returned" \
2397 -S "! The certificate is not correctly signed by the trusted CA" \
2398 -s "The certificate has been revoked (is on a CRL)"
2399
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002400# Tests for non-blocking I/O: exercise a variety of handshake flows
2401
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002402run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002403 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2404 "$P_CLI nbio=2 tickets=0" \
2405 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002406 -S "mbedtls_ssl_handshake returned" \
2407 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002408 -c "Read from server: .* bytes read"
2409
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002410run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002411 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2412 "$P_CLI nbio=2 tickets=0" \
2413 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002414 -S "mbedtls_ssl_handshake returned" \
2415 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002416 -c "Read from server: .* bytes read"
2417
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002418run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002419 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2420 "$P_CLI nbio=2 tickets=1" \
2421 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002422 -S "mbedtls_ssl_handshake returned" \
2423 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002424 -c "Read from server: .* bytes read"
2425
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002426run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002427 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2428 "$P_CLI nbio=2 tickets=1" \
2429 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002430 -S "mbedtls_ssl_handshake returned" \
2431 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002432 -c "Read from server: .* bytes read"
2433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002434run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002435 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2436 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2437 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002438 -S "mbedtls_ssl_handshake returned" \
2439 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002440 -c "Read from server: .* bytes read"
2441
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002442run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002443 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2444 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2445 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002446 -S "mbedtls_ssl_handshake returned" \
2447 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002448 -c "Read from server: .* bytes read"
2449
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002450run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002451 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2452 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2453 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002454 -S "mbedtls_ssl_handshake returned" \
2455 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002456 -c "Read from server: .* bytes read"
2457
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002458# Tests for version negotiation
2459
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002460run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002461 "$P_SRV" \
2462 "$P_CLI" \
2463 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002464 -S "mbedtls_ssl_handshake returned" \
2465 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002466 -s "Protocol is TLSv1.2" \
2467 -c "Protocol is TLSv1.2"
2468
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002469run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002470 "$P_SRV" \
2471 "$P_CLI max_version=tls1_1" \
2472 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002473 -S "mbedtls_ssl_handshake returned" \
2474 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002475 -s "Protocol is TLSv1.1" \
2476 -c "Protocol is TLSv1.1"
2477
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002478run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002479 "$P_SRV max_version=tls1_1" \
2480 "$P_CLI" \
2481 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002482 -S "mbedtls_ssl_handshake returned" \
2483 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002484 -s "Protocol is TLSv1.1" \
2485 -c "Protocol is TLSv1.1"
2486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002487run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002488 "$P_SRV max_version=tls1_1" \
2489 "$P_CLI max_version=tls1_1" \
2490 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002491 -S "mbedtls_ssl_handshake returned" \
2492 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002493 -s "Protocol is TLSv1.1" \
2494 -c "Protocol is TLSv1.1"
2495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002496run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002497 "$P_SRV min_version=tls1_1" \
2498 "$P_CLI max_version=tls1_1" \
2499 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002500 -S "mbedtls_ssl_handshake returned" \
2501 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002502 -s "Protocol is TLSv1.1" \
2503 -c "Protocol is TLSv1.1"
2504
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002505run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002506 "$P_SRV max_version=tls1_1" \
2507 "$P_CLI min_version=tls1_1" \
2508 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002509 -S "mbedtls_ssl_handshake returned" \
2510 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002511 -s "Protocol is TLSv1.1" \
2512 -c "Protocol is TLSv1.1"
2513
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002514run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002515 "$P_SRV max_version=tls1_1" \
2516 "$P_CLI min_version=tls1_2" \
2517 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002518 -s "mbedtls_ssl_handshake returned" \
2519 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002520 -c "SSL - Handshake protocol not within min/max boundaries"
2521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002522run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002523 "$P_SRV min_version=tls1_2" \
2524 "$P_CLI max_version=tls1_1" \
2525 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002526 -s "mbedtls_ssl_handshake returned" \
2527 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002528 -s "SSL - Handshake protocol not within min/max boundaries"
2529
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002530# Tests for ALPN extension
2531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002532run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002533 "$P_SRV debug_level=3" \
2534 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002535 0 \
2536 -C "client hello, adding alpn extension" \
2537 -S "found alpn extension" \
2538 -C "got an alert message, type: \\[2:120]" \
2539 -S "server hello, adding alpn extension" \
2540 -C "found alpn extension " \
2541 -C "Application Layer Protocol is" \
2542 -S "Application Layer Protocol is"
2543
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002544run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002545 "$P_SRV debug_level=3" \
2546 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002547 0 \
2548 -c "client hello, adding alpn extension" \
2549 -s "found alpn extension" \
2550 -C "got an alert message, type: \\[2:120]" \
2551 -S "server hello, adding alpn extension" \
2552 -C "found alpn extension " \
2553 -c "Application Layer Protocol is (none)" \
2554 -S "Application Layer Protocol is"
2555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002556run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002557 "$P_SRV debug_level=3 alpn=abc,1234" \
2558 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002559 0 \
2560 -C "client hello, adding alpn extension" \
2561 -S "found alpn extension" \
2562 -C "got an alert message, type: \\[2:120]" \
2563 -S "server hello, adding alpn extension" \
2564 -C "found alpn extension " \
2565 -C "Application Layer Protocol is" \
2566 -s "Application Layer Protocol is (none)"
2567
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002568run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002569 "$P_SRV debug_level=3 alpn=abc,1234" \
2570 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002571 0 \
2572 -c "client hello, adding alpn extension" \
2573 -s "found alpn extension" \
2574 -C "got an alert message, type: \\[2:120]" \
2575 -s "server hello, adding alpn extension" \
2576 -c "found alpn extension" \
2577 -c "Application Layer Protocol is abc" \
2578 -s "Application Layer Protocol is abc"
2579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002580run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002581 "$P_SRV debug_level=3 alpn=abc,1234" \
2582 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002583 0 \
2584 -c "client hello, adding alpn extension" \
2585 -s "found alpn extension" \
2586 -C "got an alert message, type: \\[2:120]" \
2587 -s "server hello, adding alpn extension" \
2588 -c "found alpn extension" \
2589 -c "Application Layer Protocol is abc" \
2590 -s "Application Layer Protocol is abc"
2591
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002592run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002593 "$P_SRV debug_level=3 alpn=abc,1234" \
2594 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002595 0 \
2596 -c "client hello, adding alpn extension" \
2597 -s "found alpn extension" \
2598 -C "got an alert message, type: \\[2:120]" \
2599 -s "server hello, adding alpn extension" \
2600 -c "found alpn extension" \
2601 -c "Application Layer Protocol is 1234" \
2602 -s "Application Layer Protocol is 1234"
2603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002604run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002605 "$P_SRV debug_level=3 alpn=abc,123" \
2606 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002607 1 \
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 1234" \
2614 -S "Application Layer Protocol is 1234"
2615
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002616
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002617# Tests for keyUsage in leaf certificates, part 1:
2618# server-side certificate/suite selection
2619
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002620run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002621 "$P_SRV key_file=data_files/server2.key \
2622 crt_file=data_files/server2.ku-ds.crt" \
2623 "$P_CLI" \
2624 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002625 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002626
2627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002628run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002629 "$P_SRV key_file=data_files/server2.key \
2630 crt_file=data_files/server2.ku-ke.crt" \
2631 "$P_CLI" \
2632 0 \
2633 -c "Ciphersuite is TLS-RSA-WITH-"
2634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002635run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002636 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002637 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002638 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002639 1 \
2640 -C "Ciphersuite is "
2641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002642run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002643 "$P_SRV key_file=data_files/server5.key \
2644 crt_file=data_files/server5.ku-ds.crt" \
2645 "$P_CLI" \
2646 0 \
2647 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2648
2649
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002650run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002651 "$P_SRV key_file=data_files/server5.key \
2652 crt_file=data_files/server5.ku-ka.crt" \
2653 "$P_CLI" \
2654 0 \
2655 -c "Ciphersuite is TLS-ECDH-"
2656
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002657run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002658 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002659 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002660 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002661 1 \
2662 -C "Ciphersuite is "
2663
2664# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002665# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002667run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002668 "$O_SRV -key data_files/server2.key \
2669 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002670 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002671 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2672 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002673 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002674 -C "Processing of the Certificate handshake message failed" \
2675 -c "Ciphersuite is TLS-"
2676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002677run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002678 "$O_SRV -key data_files/server2.key \
2679 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002680 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002681 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2682 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002683 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002684 -C "Processing of the Certificate handshake message failed" \
2685 -c "Ciphersuite is TLS-"
2686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002687run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002688 "$O_SRV -key data_files/server2.key \
2689 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002690 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002691 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2692 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002693 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002694 -C "Processing of the Certificate handshake message failed" \
2695 -c "Ciphersuite is TLS-"
2696
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002697run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002698 "$O_SRV -key data_files/server2.key \
2699 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002700 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002701 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2702 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002703 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002704 -c "Processing of the Certificate handshake message failed" \
2705 -C "Ciphersuite is TLS-"
2706
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002707run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2708 "$O_SRV -key data_files/server2.key \
2709 -cert data_files/server2.ku-ke.crt" \
2710 "$P_CLI debug_level=1 auth_mode=optional \
2711 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2712 0 \
2713 -c "bad certificate (usage extensions)" \
2714 -C "Processing of the Certificate handshake message failed" \
2715 -c "Ciphersuite is TLS-" \
2716 -c "! Usage does not match the keyUsage extension"
2717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002718run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002719 "$O_SRV -key data_files/server2.key \
2720 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002721 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002722 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2723 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002724 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002725 -C "Processing of the Certificate handshake message failed" \
2726 -c "Ciphersuite is TLS-"
2727
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002728run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002729 "$O_SRV -key data_files/server2.key \
2730 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002731 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002732 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2733 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002734 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002735 -c "Processing of the Certificate handshake message failed" \
2736 -C "Ciphersuite is TLS-"
2737
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002738run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2739 "$O_SRV -key data_files/server2.key \
2740 -cert data_files/server2.ku-ds.crt" \
2741 "$P_CLI debug_level=1 auth_mode=optional \
2742 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2743 0 \
2744 -c "bad certificate (usage extensions)" \
2745 -C "Processing of the Certificate handshake message failed" \
2746 -c "Ciphersuite is TLS-" \
2747 -c "! Usage does not match the keyUsage extension"
2748
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002749# Tests for keyUsage in leaf certificates, part 3:
2750# server-side checking of client cert
2751
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002752run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002753 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002754 "$O_CLI -key data_files/server2.key \
2755 -cert data_files/server2.ku-ds.crt" \
2756 0 \
2757 -S "bad certificate (usage extensions)" \
2758 -S "Processing of the Certificate handshake message failed"
2759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002760run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002761 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002762 "$O_CLI -key data_files/server2.key \
2763 -cert data_files/server2.ku-ke.crt" \
2764 0 \
2765 -s "bad certificate (usage extensions)" \
2766 -S "Processing of the Certificate handshake message failed"
2767
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002768run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002769 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002770 "$O_CLI -key data_files/server2.key \
2771 -cert data_files/server2.ku-ke.crt" \
2772 1 \
2773 -s "bad certificate (usage extensions)" \
2774 -s "Processing of the Certificate handshake message failed"
2775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002776run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002777 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002778 "$O_CLI -key data_files/server5.key \
2779 -cert data_files/server5.ku-ds.crt" \
2780 0 \
2781 -S "bad certificate (usage extensions)" \
2782 -S "Processing of the Certificate handshake message failed"
2783
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002784run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002785 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002786 "$O_CLI -key data_files/server5.key \
2787 -cert data_files/server5.ku-ka.crt" \
2788 0 \
2789 -s "bad certificate (usage extensions)" \
2790 -S "Processing of the Certificate handshake message failed"
2791
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002792# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002794run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002795 "$P_SRV key_file=data_files/server5.key \
2796 crt_file=data_files/server5.eku-srv.crt" \
2797 "$P_CLI" \
2798 0
2799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002800run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002801 "$P_SRV key_file=data_files/server5.key \
2802 crt_file=data_files/server5.eku-srv.crt" \
2803 "$P_CLI" \
2804 0
2805
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002806run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002807 "$P_SRV key_file=data_files/server5.key \
2808 crt_file=data_files/server5.eku-cs_any.crt" \
2809 "$P_CLI" \
2810 0
2811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002812run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002813 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002814 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002815 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002816 1
2817
2818# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2819
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002820run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002821 "$O_SRV -key data_files/server5.key \
2822 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002823 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002824 0 \
2825 -C "bad certificate (usage extensions)" \
2826 -C "Processing of the Certificate handshake message failed" \
2827 -c "Ciphersuite is TLS-"
2828
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002829run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002830 "$O_SRV -key data_files/server5.key \
2831 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002832 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002833 0 \
2834 -C "bad certificate (usage extensions)" \
2835 -C "Processing of the Certificate handshake message failed" \
2836 -c "Ciphersuite is TLS-"
2837
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002838run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002839 "$O_SRV -key data_files/server5.key \
2840 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002841 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002842 0 \
2843 -C "bad certificate (usage extensions)" \
2844 -C "Processing of the Certificate handshake message failed" \
2845 -c "Ciphersuite is TLS-"
2846
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002847run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002848 "$O_SRV -key data_files/server5.key \
2849 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002850 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002851 1 \
2852 -c "bad certificate (usage extensions)" \
2853 -c "Processing of the Certificate handshake message failed" \
2854 -C "Ciphersuite is TLS-"
2855
2856# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002858run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002859 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002860 "$O_CLI -key data_files/server5.key \
2861 -cert data_files/server5.eku-cli.crt" \
2862 0 \
2863 -S "bad certificate (usage extensions)" \
2864 -S "Processing of the Certificate handshake message failed"
2865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002866run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002867 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002868 "$O_CLI -key data_files/server5.key \
2869 -cert data_files/server5.eku-srv_cli.crt" \
2870 0 \
2871 -S "bad certificate (usage extensions)" \
2872 -S "Processing of the Certificate handshake message failed"
2873
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002874run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002875 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002876 "$O_CLI -key data_files/server5.key \
2877 -cert data_files/server5.eku-cs_any.crt" \
2878 0 \
2879 -S "bad certificate (usage extensions)" \
2880 -S "Processing of the Certificate handshake message failed"
2881
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002882run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002883 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002884 "$O_CLI -key data_files/server5.key \
2885 -cert data_files/server5.eku-cs.crt" \
2886 0 \
2887 -s "bad certificate (usage extensions)" \
2888 -S "Processing of the Certificate handshake message failed"
2889
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002890run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002891 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002892 "$O_CLI -key data_files/server5.key \
2893 -cert data_files/server5.eku-cs.crt" \
2894 1 \
2895 -s "bad certificate (usage extensions)" \
2896 -s "Processing of the Certificate handshake message failed"
2897
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002898# Tests for DHM parameters loading
2899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002900run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002901 "$P_SRV" \
2902 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2903 debug_level=3" \
2904 0 \
2905 -c "value of 'DHM: P ' (2048 bits)" \
2906 -c "value of 'DHM: G ' (2048 bits)"
2907
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002908run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002909 "$P_SRV dhm_file=data_files/dhparams.pem" \
2910 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2911 debug_level=3" \
2912 0 \
2913 -c "value of 'DHM: P ' (1024 bits)" \
2914 -c "value of 'DHM: G ' (2 bits)"
2915
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002916# Tests for DHM client-side size checking
2917
2918run_test "DHM size: server default, client default, OK" \
2919 "$P_SRV" \
2920 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2921 debug_level=1" \
2922 0 \
2923 -C "DHM prime too short:"
2924
2925run_test "DHM size: server default, client 2048, OK" \
2926 "$P_SRV" \
2927 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2928 debug_level=1 dhmlen=2048" \
2929 0 \
2930 -C "DHM prime too short:"
2931
2932run_test "DHM size: server 1024, client default, OK" \
2933 "$P_SRV dhm_file=data_files/dhparams.pem" \
2934 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2935 debug_level=1" \
2936 0 \
2937 -C "DHM prime too short:"
2938
2939run_test "DHM size: server 1000, client default, rejected" \
2940 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2941 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2942 debug_level=1" \
2943 1 \
2944 -c "DHM prime too short:"
2945
2946run_test "DHM size: server default, client 2049, rejected" \
2947 "$P_SRV" \
2948 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2949 debug_level=1 dhmlen=2049" \
2950 1 \
2951 -c "DHM prime too short:"
2952
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002953# Tests for PSK callback
2954
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002955run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002956 "$P_SRV psk=abc123 psk_identity=foo" \
2957 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2958 psk_identity=foo psk=abc123" \
2959 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002960 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002961 -S "SSL - Unknown identity received" \
2962 -S "SSL - Verification of the message MAC failed"
2963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002964run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002965 "$P_SRV" \
2966 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2967 psk_identity=foo psk=abc123" \
2968 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002969 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002970 -S "SSL - Unknown identity received" \
2971 -S "SSL - Verification of the message MAC failed"
2972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002973run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002974 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2975 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2976 psk_identity=foo psk=abc123" \
2977 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002978 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002979 -s "SSL - Unknown identity received" \
2980 -S "SSL - Verification of the message MAC failed"
2981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002982run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002983 "$P_SRV psk_list=abc,dead,def,beef" \
2984 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2985 psk_identity=abc psk=dead" \
2986 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002987 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002988 -S "SSL - Unknown identity received" \
2989 -S "SSL - Verification of the message MAC failed"
2990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002991run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002992 "$P_SRV psk_list=abc,dead,def,beef" \
2993 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2994 psk_identity=def psk=beef" \
2995 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002996 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002997 -S "SSL - Unknown identity received" \
2998 -S "SSL - Verification of the message MAC failed"
2999
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003000run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003001 "$P_SRV psk_list=abc,dead,def,beef" \
3002 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3003 psk_identity=ghi psk=beef" \
3004 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003005 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003006 -s "SSL - Unknown identity received" \
3007 -S "SSL - Verification of the message MAC failed"
3008
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003009run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003010 "$P_SRV psk_list=abc,dead,def,beef" \
3011 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3012 psk_identity=abc psk=beef" \
3013 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003014 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003015 -S "SSL - Unknown identity received" \
3016 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003017
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003018# Tests for EC J-PAKE
3019
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003020requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003021run_test "ECJPAKE: client not configured" \
3022 "$P_SRV debug_level=3" \
3023 "$P_CLI debug_level=3" \
3024 0 \
3025 -C "add ciphersuite: c0ff" \
3026 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003027 -S "found ecjpake kkpp extension" \
3028 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003029 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003030 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003031 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003032 -S "None of the common ciphersuites is usable"
3033
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003034requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003035run_test "ECJPAKE: server not configured" \
3036 "$P_SRV debug_level=3" \
3037 "$P_CLI debug_level=3 ecjpake_pw=bla \
3038 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3039 1 \
3040 -c "add ciphersuite: c0ff" \
3041 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003042 -s "found ecjpake kkpp extension" \
3043 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003044 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003045 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003046 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003047 -s "None of the common ciphersuites is usable"
3048
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003049requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003050run_test "ECJPAKE: working, TLS" \
3051 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3052 "$P_CLI debug_level=3 ecjpake_pw=bla \
3053 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003054 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003055 -c "add ciphersuite: c0ff" \
3056 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003057 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003058 -s "found ecjpake kkpp extension" \
3059 -S "skip ecjpake kkpp extension" \
3060 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003061 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003062 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003063 -S "None of the common ciphersuites is usable" \
3064 -S "SSL - Verification of the message MAC failed"
3065
Janos Follath74537a62016-09-02 13:45:28 +01003066server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003067requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003068run_test "ECJPAKE: password mismatch, TLS" \
3069 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3070 "$P_CLI debug_level=3 ecjpake_pw=bad \
3071 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3072 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003073 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003074 -s "SSL - Verification of the message MAC failed"
3075
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003076requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003077run_test "ECJPAKE: working, DTLS" \
3078 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3079 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3080 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3081 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003082 -c "re-using cached ecjpake parameters" \
3083 -S "SSL - Verification of the message MAC failed"
3084
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003085requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003086run_test "ECJPAKE: working, DTLS, no cookie" \
3087 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3088 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3089 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3090 0 \
3091 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003092 -S "SSL - Verification of the message MAC failed"
3093
Janos Follath74537a62016-09-02 13:45:28 +01003094server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003095requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003096run_test "ECJPAKE: password mismatch, DTLS" \
3097 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3098 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3099 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3100 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003101 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003102 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003103
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003104# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003105requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003106run_test "ECJPAKE: working, DTLS, nolog" \
3107 "$P_SRV dtls=1 ecjpake_pw=bla" \
3108 "$P_CLI dtls=1 ecjpake_pw=bla \
3109 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3110 0
3111
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003112# Tests for ciphersuites per version
3113
Janos Follathe2681a42016-03-07 15:57:05 +00003114requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003115run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003116 "$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 +02003117 "$P_CLI force_version=ssl3" \
3118 0 \
3119 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3120
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003121run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003122 "$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 +01003123 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003124 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003125 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003127run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003128 "$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 +02003129 "$P_CLI force_version=tls1_1" \
3130 0 \
3131 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3132
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003133run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003134 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003135 "$P_CLI force_version=tls1_2" \
3136 0 \
3137 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3138
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003139# Test for ClientHello without extensions
3140
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003141requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003142run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003143 "$P_SRV debug_level=3" \
3144 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3145 0 \
3146 -s "dumping 'client hello extensions' (0 bytes)"
3147
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003148requires_gnutls
3149run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3150 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3151 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3152 0 \
3153 -s "dumping 'client hello extensions' (0 bytes)"
3154
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003155# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003156
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003157run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003158 "$P_SRV" \
3159 "$P_CLI request_size=100" \
3160 0 \
3161 -s "Read from client: 100 bytes read$"
3162
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003163run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003164 "$P_SRV" \
3165 "$P_CLI request_size=500" \
3166 0 \
3167 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003168
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003169# Tests for small packets
3170
Janos Follathe2681a42016-03-07 15:57:05 +00003171requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003172run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003173 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003174 "$P_CLI request_size=1 force_version=ssl3 \
3175 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3176 0 \
3177 -s "Read from client: 1 bytes read"
3178
Janos Follathe2681a42016-03-07 15:57:05 +00003179requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003180run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003181 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003182 "$P_CLI request_size=1 force_version=ssl3 \
3183 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3184 0 \
3185 -s "Read from client: 1 bytes read"
3186
3187run_test "Small packet TLS 1.0 BlockCipher" \
3188 "$P_SRV" \
3189 "$P_CLI request_size=1 force_version=tls1 \
3190 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3191 0 \
3192 -s "Read from client: 1 bytes read"
3193
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003194run_test "Small packet TLS 1.0 BlockCipher without EtM" \
3195 "$P_SRV" \
3196 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3197 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3198 0 \
3199 -s "Read from client: 1 bytes read"
3200
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003201run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
3202 "$P_SRV" \
3203 "$P_CLI request_size=1 force_version=tls1 \
3204 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3205 trunc_hmac=1" \
3206 0 \
3207 -s "Read from client: 1 bytes read"
3208
3209run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003210 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003211 "$P_CLI request_size=1 force_version=tls1 \
3212 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3213 trunc_hmac=1" \
3214 0 \
3215 -s "Read from client: 1 bytes read"
3216
3217run_test "Small packet TLS 1.1 BlockCipher" \
3218 "$P_SRV" \
3219 "$P_CLI request_size=1 force_version=tls1_1 \
3220 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3221 0 \
3222 -s "Read from client: 1 bytes read"
3223
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003224run_test "Small packet TLS 1.1 BlockCipher without EtM" \
3225 "$P_SRV" \
3226 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
3227 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3228 0 \
3229 -s "Read from client: 1 bytes read"
3230
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003231run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003232 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003233 "$P_CLI request_size=1 force_version=tls1_1 \
3234 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3235 0 \
3236 -s "Read from client: 1 bytes read"
3237
3238run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3239 "$P_SRV" \
3240 "$P_CLI request_size=1 force_version=tls1_1 \
3241 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3242 trunc_hmac=1" \
3243 0 \
3244 -s "Read from client: 1 bytes read"
3245
3246run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003247 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003248 "$P_CLI request_size=1 force_version=tls1_1 \
3249 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3250 trunc_hmac=1" \
3251 0 \
3252 -s "Read from client: 1 bytes read"
3253
3254run_test "Small packet TLS 1.2 BlockCipher" \
3255 "$P_SRV" \
3256 "$P_CLI request_size=1 force_version=tls1_2 \
3257 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3258 0 \
3259 -s "Read from client: 1 bytes read"
3260
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003261run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3262 "$P_SRV" \
3263 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3264 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3265 0 \
3266 -s "Read from client: 1 bytes read"
3267
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003268run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3269 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003270 "$P_CLI request_size=1 force_version=tls1_2 \
3271 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003272 0 \
3273 -s "Read from client: 1 bytes read"
3274
3275run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3276 "$P_SRV" \
3277 "$P_CLI request_size=1 force_version=tls1_2 \
3278 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3279 trunc_hmac=1" \
3280 0 \
3281 -s "Read from client: 1 bytes read"
3282
3283run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003284 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003285 "$P_CLI request_size=1 force_version=tls1_2 \
3286 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3287 0 \
3288 -s "Read from client: 1 bytes read"
3289
3290run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003291 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003292 "$P_CLI request_size=1 force_version=tls1_2 \
3293 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3294 trunc_hmac=1" \
3295 0 \
3296 -s "Read from client: 1 bytes read"
3297
3298run_test "Small packet TLS 1.2 AEAD" \
3299 "$P_SRV" \
3300 "$P_CLI request_size=1 force_version=tls1_2 \
3301 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3302 0 \
3303 -s "Read from client: 1 bytes read"
3304
3305run_test "Small packet TLS 1.2 AEAD shorter tag" \
3306 "$P_SRV" \
3307 "$P_CLI request_size=1 force_version=tls1_2 \
3308 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3309 0 \
3310 -s "Read from client: 1 bytes read"
3311
Janos Follath00efff72016-05-06 13:48:23 +01003312# A test for extensions in SSLv3
3313
3314requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3315run_test "SSLv3 with extensions, server side" \
3316 "$P_SRV min_version=ssl3 debug_level=3" \
3317 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3318 0 \
3319 -S "dumping 'client hello extensions'" \
3320 -S "server hello, total extension length:"
3321
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003322# Test for large packets
3323
Janos Follathe2681a42016-03-07 15:57:05 +00003324requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003325run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003326 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003327 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003328 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3329 0 \
3330 -s "Read from client: 16384 bytes read"
3331
Janos Follathe2681a42016-03-07 15:57:05 +00003332requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003333run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003334 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003335 "$P_CLI request_size=16384 force_version=ssl3 \
3336 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3337 0 \
3338 -s "Read from client: 16384 bytes read"
3339
3340run_test "Large packet TLS 1.0 BlockCipher" \
3341 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003342 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003343 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3344 0 \
3345 -s "Read from client: 16384 bytes read"
3346
3347run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3348 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003349 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003350 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3351 trunc_hmac=1" \
3352 0 \
3353 -s "Read from client: 16384 bytes read"
3354
3355run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
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é-Gonnard8920f692014-06-18 22:05:08 +02003357 "$P_CLI request_size=16384 force_version=tls1 \
3358 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3359 trunc_hmac=1" \
3360 0 \
3361 -s "Read from client: 16384 bytes read"
3362
3363run_test "Large packet TLS 1.1 BlockCipher" \
3364 "$P_SRV" \
3365 "$P_CLI request_size=16384 force_version=tls1_1 \
3366 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3367 0 \
3368 -s "Read from client: 16384 bytes read"
3369
3370run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003371 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003372 "$P_CLI request_size=16384 force_version=tls1_1 \
3373 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3374 0 \
3375 -s "Read from client: 16384 bytes read"
3376
3377run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3378 "$P_SRV" \
3379 "$P_CLI request_size=16384 force_version=tls1_1 \
3380 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3381 trunc_hmac=1" \
3382 0 \
3383 -s "Read from client: 16384 bytes read"
3384
3385run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003386 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003387 "$P_CLI request_size=16384 force_version=tls1_1 \
3388 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3389 trunc_hmac=1" \
3390 0 \
3391 -s "Read from client: 16384 bytes read"
3392
3393run_test "Large packet TLS 1.2 BlockCipher" \
3394 "$P_SRV" \
3395 "$P_CLI request_size=16384 force_version=tls1_2 \
3396 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3397 0 \
3398 -s "Read from client: 16384 bytes read"
3399
3400run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3401 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003402 "$P_CLI request_size=16384 force_version=tls1_2 \
3403 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003404 0 \
3405 -s "Read from client: 16384 bytes read"
3406
3407run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3408 "$P_SRV" \
3409 "$P_CLI request_size=16384 force_version=tls1_2 \
3410 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3411 trunc_hmac=1" \
3412 0 \
3413 -s "Read from client: 16384 bytes read"
3414
3415run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003416 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003417 "$P_CLI request_size=16384 force_version=tls1_2 \
3418 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3419 0 \
3420 -s "Read from client: 16384 bytes read"
3421
3422run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003423 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003424 "$P_CLI request_size=16384 force_version=tls1_2 \
3425 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3426 trunc_hmac=1" \
3427 0 \
3428 -s "Read from client: 16384 bytes read"
3429
3430run_test "Large packet TLS 1.2 AEAD" \
3431 "$P_SRV" \
3432 "$P_CLI request_size=16384 force_version=tls1_2 \
3433 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3434 0 \
3435 -s "Read from client: 16384 bytes read"
3436
3437run_test "Large packet TLS 1.2 AEAD shorter tag" \
3438 "$P_SRV" \
3439 "$P_CLI request_size=16384 force_version=tls1_2 \
3440 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3441 0 \
3442 -s "Read from client: 16384 bytes read"
3443
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003444# Tests for DTLS HelloVerifyRequest
3445
3446run_test "DTLS cookie: enabled" \
3447 "$P_SRV dtls=1 debug_level=2" \
3448 "$P_CLI dtls=1 debug_level=2" \
3449 0 \
3450 -s "cookie verification failed" \
3451 -s "cookie verification passed" \
3452 -S "cookie verification skipped" \
3453 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003454 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003455 -S "SSL - The requested feature is not available"
3456
3457run_test "DTLS cookie: disabled" \
3458 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3459 "$P_CLI dtls=1 debug_level=2" \
3460 0 \
3461 -S "cookie verification failed" \
3462 -S "cookie verification passed" \
3463 -s "cookie verification skipped" \
3464 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003465 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003466 -S "SSL - The requested feature is not available"
3467
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003468run_test "DTLS cookie: default (failing)" \
3469 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3470 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3471 1 \
3472 -s "cookie verification failed" \
3473 -S "cookie verification passed" \
3474 -S "cookie verification skipped" \
3475 -C "received hello verify request" \
3476 -S "hello verification requested" \
3477 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003478
3479requires_ipv6
3480run_test "DTLS cookie: enabled, IPv6" \
3481 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3482 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3483 0 \
3484 -s "cookie verification failed" \
3485 -s "cookie verification passed" \
3486 -S "cookie verification skipped" \
3487 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003488 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003489 -S "SSL - The requested feature is not available"
3490
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003491run_test "DTLS cookie: enabled, nbio" \
3492 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3493 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3494 0 \
3495 -s "cookie verification failed" \
3496 -s "cookie verification passed" \
3497 -S "cookie verification skipped" \
3498 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003499 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003500 -S "SSL - The requested feature is not available"
3501
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003502# Tests for client reconnecting from the same port with DTLS
3503
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003504not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003505run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003506 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3507 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003508 0 \
3509 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003510 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003511 -S "Client initiated reconnection from same port"
3512
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003513not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003514run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003515 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3516 "$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 +02003517 0 \
3518 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003519 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003520 -s "Client initiated reconnection from same port"
3521
Paul Bakker362689d2016-05-13 10:33:25 +01003522not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3523run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003524 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3525 "$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 +02003526 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003527 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003528 -s "Client initiated reconnection from same port"
3529
Paul Bakker362689d2016-05-13 10:33:25 +01003530only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3531run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3532 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3533 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3534 0 \
3535 -S "The operation timed out" \
3536 -s "Client initiated reconnection from same port"
3537
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003538run_test "DTLS client reconnect from same port: no cookies" \
3539 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003540 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3541 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003542 -s "The operation timed out" \
3543 -S "Client initiated reconnection from same port"
3544
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003545# Tests for various cases of client authentication with DTLS
3546# (focused on handshake flows and message parsing)
3547
3548run_test "DTLS client auth: required" \
3549 "$P_SRV dtls=1 auth_mode=required" \
3550 "$P_CLI dtls=1" \
3551 0 \
3552 -s "Verifying peer X.509 certificate... ok"
3553
3554run_test "DTLS client auth: optional, client has no cert" \
3555 "$P_SRV dtls=1 auth_mode=optional" \
3556 "$P_CLI dtls=1 crt_file=none key_file=none" \
3557 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003558 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003559
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003560run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003561 "$P_SRV dtls=1 auth_mode=none" \
3562 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3563 0 \
3564 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003565 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003566
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003567run_test "DTLS wrong PSK: badmac alert" \
3568 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3569 "$P_CLI dtls=1 psk=abc124" \
3570 1 \
3571 -s "SSL - Verification of the message MAC failed" \
3572 -c "SSL - A fatal alert message was received from our peer"
3573
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003574# Tests for receiving fragmented handshake messages with DTLS
3575
3576requires_gnutls
3577run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3578 "$G_SRV -u --mtu 2048 -a" \
3579 "$P_CLI dtls=1 debug_level=2" \
3580 0 \
3581 -C "found fragmented DTLS handshake message" \
3582 -C "error"
3583
3584requires_gnutls
3585run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3586 "$G_SRV -u --mtu 512" \
3587 "$P_CLI dtls=1 debug_level=2" \
3588 0 \
3589 -c "found fragmented DTLS handshake message" \
3590 -C "error"
3591
3592requires_gnutls
3593run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3594 "$G_SRV -u --mtu 128" \
3595 "$P_CLI dtls=1 debug_level=2" \
3596 0 \
3597 -c "found fragmented DTLS handshake message" \
3598 -C "error"
3599
3600requires_gnutls
3601run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3602 "$G_SRV -u --mtu 128" \
3603 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3604 0 \
3605 -c "found fragmented DTLS handshake message" \
3606 -C "error"
3607
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003608requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003609run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3610 "$G_SRV -u --mtu 256" \
3611 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3612 0 \
3613 -c "found fragmented DTLS handshake message" \
3614 -c "client hello, adding renegotiation extension" \
3615 -c "found renegotiation extension" \
3616 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003617 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003618 -C "error" \
3619 -s "Extra-header:"
3620
3621requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003622run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3623 "$G_SRV -u --mtu 256" \
3624 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3625 0 \
3626 -c "found fragmented DTLS handshake message" \
3627 -c "client hello, adding renegotiation extension" \
3628 -c "found renegotiation extension" \
3629 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003630 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003631 -C "error" \
3632 -s "Extra-header:"
3633
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003634run_test "DTLS reassembly: no fragmentation (openssl server)" \
3635 "$O_SRV -dtls1 -mtu 2048" \
3636 "$P_CLI dtls=1 debug_level=2" \
3637 0 \
3638 -C "found fragmented DTLS handshake message" \
3639 -C "error"
3640
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003641run_test "DTLS reassembly: some fragmentation (openssl server)" \
3642 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003643 "$P_CLI dtls=1 debug_level=2" \
3644 0 \
3645 -c "found fragmented DTLS handshake message" \
3646 -C "error"
3647
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003648run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003649 "$O_SRV -dtls1 -mtu 256" \
3650 "$P_CLI dtls=1 debug_level=2" \
3651 0 \
3652 -c "found fragmented DTLS handshake message" \
3653 -C "error"
3654
3655run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3656 "$O_SRV -dtls1 -mtu 256" \
3657 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3658 0 \
3659 -c "found fragmented DTLS handshake message" \
3660 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003661
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003662# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003663
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003664not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003665run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003666 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003667 "$P_SRV dtls=1 debug_level=2" \
3668 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003669 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003670 -C "replayed record" \
3671 -S "replayed record" \
3672 -C "record from another epoch" \
3673 -S "record from another epoch" \
3674 -C "discarding invalid record" \
3675 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003676 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003677 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003678 -c "HTTP/1.0 200 OK"
3679
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003680not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003681run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003682 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003683 "$P_SRV dtls=1 debug_level=2" \
3684 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003685 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003686 -c "replayed record" \
3687 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003688 -c "discarding invalid record" \
3689 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003690 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003691 -s "Extra-header:" \
3692 -c "HTTP/1.0 200 OK"
3693
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003694run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3695 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003696 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3697 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003698 0 \
3699 -c "replayed record" \
3700 -S "replayed record" \
3701 -c "discarding invalid record" \
3702 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003703 -c "resend" \
3704 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003705 -s "Extra-header:" \
3706 -c "HTTP/1.0 200 OK"
3707
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003708run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003709 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003710 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003711 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003712 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003713 -c "discarding invalid record (mac)" \
3714 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003715 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003716 -c "HTTP/1.0 200 OK" \
3717 -S "too many records with bad MAC" \
3718 -S "Verification of the message MAC failed"
3719
3720run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3721 -p "$P_PXY bad_ad=1" \
3722 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3723 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3724 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003725 -C "discarding invalid record (mac)" \
3726 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003727 -S "Extra-header:" \
3728 -C "HTTP/1.0 200 OK" \
3729 -s "too many records with bad MAC" \
3730 -s "Verification of the message MAC failed"
3731
3732run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3733 -p "$P_PXY bad_ad=1" \
3734 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3735 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3736 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003737 -c "discarding invalid record (mac)" \
3738 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003739 -s "Extra-header:" \
3740 -c "HTTP/1.0 200 OK" \
3741 -S "too many records with bad MAC" \
3742 -S "Verification of the message MAC failed"
3743
3744run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3745 -p "$P_PXY bad_ad=1" \
3746 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3747 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3748 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003749 -c "discarding invalid record (mac)" \
3750 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003751 -s "Extra-header:" \
3752 -c "HTTP/1.0 200 OK" \
3753 -s "too many records with bad MAC" \
3754 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003755
3756run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003757 -p "$P_PXY delay_ccs=1" \
3758 "$P_SRV dtls=1 debug_level=1" \
3759 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003760 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003761 -c "record from another epoch" \
3762 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003763 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003764 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003765 -s "Extra-header:" \
3766 -c "HTTP/1.0 200 OK"
3767
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003768# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003769
Janos Follath74537a62016-09-02 13:45:28 +01003770client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003771run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003772 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003773 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3774 psk=abc123" \
3775 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003776 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3777 0 \
3778 -s "Extra-header:" \
3779 -c "HTTP/1.0 200 OK"
3780
Janos Follath74537a62016-09-02 13:45:28 +01003781client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003782run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3783 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003784 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3785 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003786 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3787 0 \
3788 -s "Extra-header:" \
3789 -c "HTTP/1.0 200 OK"
3790
Janos Follath74537a62016-09-02 13:45:28 +01003791client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003792run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3793 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003794 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3795 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003796 0 \
3797 -s "Extra-header:" \
3798 -c "HTTP/1.0 200 OK"
3799
Janos Follath74537a62016-09-02 13:45:28 +01003800client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003801run_test "DTLS proxy: 3d, FS, client auth" \
3802 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003803 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3804 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003805 0 \
3806 -s "Extra-header:" \
3807 -c "HTTP/1.0 200 OK"
3808
Janos Follath74537a62016-09-02 13:45:28 +01003809client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003810run_test "DTLS proxy: 3d, FS, ticket" \
3811 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003812 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3813 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003814 0 \
3815 -s "Extra-header:" \
3816 -c "HTTP/1.0 200 OK"
3817
Janos Follath74537a62016-09-02 13:45:28 +01003818client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003819run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3820 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003821 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3822 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003823 0 \
3824 -s "Extra-header:" \
3825 -c "HTTP/1.0 200 OK"
3826
Janos Follath74537a62016-09-02 13:45:28 +01003827client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003828run_test "DTLS proxy: 3d, max handshake, nbio" \
3829 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003830 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3831 auth_mode=required" \
3832 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003833 0 \
3834 -s "Extra-header:" \
3835 -c "HTTP/1.0 200 OK"
3836
Janos Follath74537a62016-09-02 13:45:28 +01003837client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003838run_test "DTLS proxy: 3d, min handshake, resumption" \
3839 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3840 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3841 psk=abc123 debug_level=3" \
3842 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3843 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3844 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3845 0 \
3846 -s "a session has been resumed" \
3847 -c "a session has been resumed" \
3848 -s "Extra-header:" \
3849 -c "HTTP/1.0 200 OK"
3850
Janos Follath74537a62016-09-02 13:45:28 +01003851client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003852run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3853 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3854 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3855 psk=abc123 debug_level=3 nbio=2" \
3856 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3857 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3858 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3859 0 \
3860 -s "a session has been resumed" \
3861 -c "a session has been resumed" \
3862 -s "Extra-header:" \
3863 -c "HTTP/1.0 200 OK"
3864
Janos Follath74537a62016-09-02 13:45:28 +01003865client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003866run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003867 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003868 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3869 psk=abc123 renegotiation=1 debug_level=2" \
3870 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3871 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003872 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3873 0 \
3874 -c "=> renegotiate" \
3875 -s "=> renegotiate" \
3876 -s "Extra-header:" \
3877 -c "HTTP/1.0 200 OK"
3878
Janos Follath74537a62016-09-02 13:45:28 +01003879client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003880run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3881 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003882 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3883 psk=abc123 renegotiation=1 debug_level=2" \
3884 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3885 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003886 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3887 0 \
3888 -c "=> renegotiate" \
3889 -s "=> renegotiate" \
3890 -s "Extra-header:" \
3891 -c "HTTP/1.0 200 OK"
3892
Janos Follath74537a62016-09-02 13:45:28 +01003893client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003894run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003895 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003896 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003897 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003898 debug_level=2" \
3899 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003900 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003901 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3902 0 \
3903 -c "=> renegotiate" \
3904 -s "=> renegotiate" \
3905 -s "Extra-header:" \
3906 -c "HTTP/1.0 200 OK"
3907
Janos Follath74537a62016-09-02 13:45:28 +01003908client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003909run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003910 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003911 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003912 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003913 debug_level=2 nbio=2" \
3914 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003915 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003916 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3917 0 \
3918 -c "=> renegotiate" \
3919 -s "=> renegotiate" \
3920 -s "Extra-header:" \
3921 -c "HTTP/1.0 200 OK"
3922
Janos Follath74537a62016-09-02 13:45:28 +01003923client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003924not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003925run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003926 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3927 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003928 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003929 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003930 -c "HTTP/1.0 200 OK"
3931
Janos Follath74537a62016-09-02 13:45:28 +01003932client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003933not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003934run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3935 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3936 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003937 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003938 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003939 -c "HTTP/1.0 200 OK"
3940
Janos Follath74537a62016-09-02 13:45:28 +01003941client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003942not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003943run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3944 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3945 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003946 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003947 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003948 -c "HTTP/1.0 200 OK"
3949
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003950requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003951client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003952not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003953run_test "DTLS proxy: 3d, gnutls server" \
3954 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3955 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003956 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003957 0 \
3958 -s "Extra-header:" \
3959 -c "Extra-header:"
3960
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003961requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003962client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003963not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003964run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3965 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3966 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003967 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003968 0 \
3969 -s "Extra-header:" \
3970 -c "Extra-header:"
3971
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003972requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003973client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003974not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003975run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3976 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3977 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003978 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003979 0 \
3980 -s "Extra-header:" \
3981 -c "Extra-header:"
3982
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003983# Final report
3984
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003985echo "------------------------------------------------------------------------"
3986
3987if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003988 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003989else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003990 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003991fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003992PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003993echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003994
3995exit $FAILS