blob: 688baa7efd2eb99d387e8ad0428a080e348cb69d [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é-Gonnard1cbd39d2014-10-20 13:34:59 +0200125# skip next test if OpenSSL doesn't support FALLBACK_SCSV
126requires_openssl_with_fallback_scsv() {
127 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
128 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
129 then
130 OPENSSL_HAS_FBSCSV="YES"
131 else
132 OPENSSL_HAS_FBSCSV="NO"
133 fi
134 fi
135 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
136 SKIP_NEXT="YES"
137 fi
138}
139
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200140# skip next test if GnuTLS isn't available
141requires_gnutls() {
142 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200143 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200144 GNUTLS_AVAILABLE="YES"
145 else
146 GNUTLS_AVAILABLE="NO"
147 fi
148 fi
149 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
150 SKIP_NEXT="YES"
151 fi
152}
153
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200154# skip next test if IPv6 isn't available on this host
155requires_ipv6() {
156 if [ -z "${HAS_IPV6:-}" ]; then
157 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
158 SRV_PID=$!
159 sleep 1
160 kill $SRV_PID >/dev/null 2>&1
161 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
162 HAS_IPV6="NO"
163 else
164 HAS_IPV6="YES"
165 fi
166 rm -r $SRV_OUT
167 fi
168
169 if [ "$HAS_IPV6" = "NO" ]; then
170 SKIP_NEXT="YES"
171 fi
172}
173
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200174# skip the next test if valgrind is in use
175not_with_valgrind() {
176 if [ "$MEMCHECK" -gt 0 ]; then
177 SKIP_NEXT="YES"
178 fi
179}
180
Paul Bakker362689d2016-05-13 10:33:25 +0100181# skip the next test if valgrind is NOT in use
182only_with_valgrind() {
183 if [ "$MEMCHECK" -eq 0 ]; then
184 SKIP_NEXT="YES"
185 fi
186}
187
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200188# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100189client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200190 CLI_DELAY_FACTOR=$1
191}
192
Janos Follath74537a62016-09-02 13:45:28 +0100193# wait for the given seconds after the client finished in the next test
194server_needs_more_time() {
195 SRV_DELAY_SECONDS=$1
196}
197
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100198# print_name <name>
199print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100200 TESTS=$(( $TESTS + 1 ))
201 LINE=""
202
203 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
204 LINE="$TESTS "
205 fi
206
207 LINE="$LINE$1"
208 printf "$LINE "
209 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100210 for i in `seq 1 $LEN`; do printf '.'; done
211 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100212
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100213}
214
215# fail <message>
216fail() {
217 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100218 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100219
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200220 mv $SRV_OUT o-srv-${TESTS}.log
221 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200222 if [ -n "$PXY_CMD" ]; then
223 mv $PXY_OUT o-pxy-${TESTS}.log
224 fi
225 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100226
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200227 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
228 echo " ! server output:"
229 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200230 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200231 echo " ! client output:"
232 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200233 if [ -n "$PXY_CMD" ]; then
234 echo " ! ========================================================"
235 echo " ! proxy output:"
236 cat o-pxy-${TESTS}.log
237 fi
238 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200239 fi
240
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200241 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100242}
243
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100244# is_polar <cmd_line>
245is_polar() {
246 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
247}
248
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200249# openssl s_server doesn't have -www with DTLS
250check_osrv_dtls() {
251 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
252 NEEDS_INPUT=1
253 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
254 else
255 NEEDS_INPUT=0
256 fi
257}
258
259# provide input to commands that need it
260provide_input() {
261 if [ $NEEDS_INPUT -eq 0 ]; then
262 return
263 fi
264
265 while true; do
266 echo "HTTP/1.0 200 OK"
267 sleep 1
268 done
269}
270
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100271# has_mem_err <log_file_name>
272has_mem_err() {
273 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
274 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
275 then
276 return 1 # false: does not have errors
277 else
278 return 0 # true: has errors
279 fi
280}
281
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200282# wait for server to start: two versions depending on lsof availability
283wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200284 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200285 START_TIME=$( date +%s )
286 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200287
288 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200289 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200290 while [ $DONE -eq 0 ]; do
291 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
292 then
293 DONE=1
294 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
295 echo "SERVERSTART TIMEOUT"
296 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
297 DONE=1
298 fi
299 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200300 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200301 while [ $DONE -eq 0 ]; do
302 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
303 then
304 DONE=1
305 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
306 echo "SERVERSTART TIMEOUT"
307 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
308 DONE=1
309 fi
310 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200311 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200312 else
313 sleep "$START_DELAY"
314 fi
315}
316
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200317# wait for client to terminate and set CLI_EXIT
318# must be called right after starting the client
319wait_client_done() {
320 CLI_PID=$!
321
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200322 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
323 CLI_DELAY_FACTOR=1
324
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200325 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200326 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200327
328 wait $CLI_PID
329 CLI_EXIT=$?
330
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200331 kill $DOG_PID >/dev/null 2>&1
332 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200333
334 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100335
336 sleep $SRV_DELAY_SECONDS
337 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200338}
339
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200340# check if the given command uses dtls and sets global variable DTLS
341detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200342 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200343 DTLS=1
344 else
345 DTLS=0
346 fi
347}
348
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200349# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100350# Options: -s pattern pattern that must be present in server output
351# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100352# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100353# -S pattern pattern that must be absent in server output
354# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100355# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100356run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100357 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200358 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100359
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100360 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
361 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200362 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100363 return
364 fi
365
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100366 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100367
Paul Bakkerb7584a52016-05-10 10:50:43 +0100368 # Do we only run numbered tests?
369 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
370 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
371 else
372 SKIP_NEXT="YES"
373 fi
374
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200375 # should we skip?
376 if [ "X$SKIP_NEXT" = "XYES" ]; then
377 SKIP_NEXT="NO"
378 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200379 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200380 return
381 fi
382
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200383 # does this test use a proxy?
384 if [ "X$1" = "X-p" ]; then
385 PXY_CMD="$2"
386 shift 2
387 else
388 PXY_CMD=""
389 fi
390
391 # get commands and client output
392 SRV_CMD="$1"
393 CLI_CMD="$2"
394 CLI_EXPECT="$3"
395 shift 3
396
397 # fix client port
398 if [ -n "$PXY_CMD" ]; then
399 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
400 else
401 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
402 fi
403
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200404 # update DTLS variable
405 detect_dtls "$SRV_CMD"
406
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100407 # prepend valgrind to our commands if active
408 if [ "$MEMCHECK" -gt 0 ]; then
409 if is_polar "$SRV_CMD"; then
410 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
411 fi
412 if is_polar "$CLI_CMD"; then
413 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
414 fi
415 fi
416
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200417 TIMES_LEFT=2
418 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200419 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200420
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200421 # run the commands
422 if [ -n "$PXY_CMD" ]; then
423 echo "$PXY_CMD" > $PXY_OUT
424 $PXY_CMD >> $PXY_OUT 2>&1 &
425 PXY_PID=$!
426 # assume proxy starts faster than server
427 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200428
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200429 check_osrv_dtls
430 echo "$SRV_CMD" > $SRV_OUT
431 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
432 SRV_PID=$!
433 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200434
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200435 echo "$CLI_CMD" > $CLI_OUT
436 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
437 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100438
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200439 # terminate the server (and the proxy)
440 kill $SRV_PID
441 wait $SRV_PID
442 if [ -n "$PXY_CMD" ]; then
443 kill $PXY_PID >/dev/null 2>&1
444 wait $PXY_PID
445 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100446
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200447 # retry only on timeouts
448 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
449 printf "RETRY "
450 else
451 TIMES_LEFT=0
452 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200453 done
454
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100455 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200456 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100457 # expected client exit to incorrectly succeed in case of catastrophic
458 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100459 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200460 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100461 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100462 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100463 return
464 fi
465 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100466 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200467 if grep "Performing the SSL/TLS handshake" $CLI_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
473
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100474 # check server exit code
475 if [ $? != 0 ]; then
476 fail "server fail"
477 return
478 fi
479
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100480 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100481 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
482 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100483 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200484 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100485 return
486 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100487
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100488 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200489 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100490 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100491 while [ $# -gt 0 ]
492 do
493 case $1 in
494 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100495 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 +0100496 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100497 return
498 fi
499 ;;
500
501 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100502 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 +0100503 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100504 return
505 fi
506 ;;
507
508 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100509 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 +0100510 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100511 return
512 fi
513 ;;
514
515 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100516 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 +0100517 fail "pattern '$2' MUST NOT be present in the Client output"
518 return
519 fi
520 ;;
521
522 # The filtering in the following two options (-u and -U) do the following
523 # - ignore valgrind output
524 # - filter out everything but lines right after the pattern occurances
525 # - keep one of each non-unique line
526 # - count how many lines remain
527 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
528 # if there were no duplicates.
529 "-U")
530 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
531 fail "lines following pattern '$2' must be unique in Server output"
532 return
533 fi
534 ;;
535
536 "-u")
537 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
538 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100539 return
540 fi
541 ;;
542
543 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200544 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100545 exit 1
546 esac
547 shift 2
548 done
549
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100550 # check valgrind's results
551 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200552 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100553 fail "Server has memory errors"
554 return
555 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200556 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100557 fail "Client has memory errors"
558 return
559 fi
560 fi
561
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100562 # if we're here, everything is ok
563 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100564 if [ "$PRESERVE_LOGS" -gt 0 ]; then
565 mv $SRV_OUT o-srv-${TESTS}.log
566 mv $CLI_OUT o-cli-${TESTS}.log
567 fi
568
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200569 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100570}
571
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100572cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200573 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200574 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
575 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
576 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
577 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100578 exit 1
579}
580
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100581#
582# MAIN
583#
584
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000585if cd $( dirname $0 ); then :; else
586 echo "cd $( dirname $0 ) failed" >&2
587 exit 1
588fi
589
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100590get_options "$@"
591
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100592# sanity checks, avoid an avalanche of errors
593if [ ! -x "$P_SRV" ]; then
594 echo "Command '$P_SRV' is not an executable file"
595 exit 1
596fi
597if [ ! -x "$P_CLI" ]; then
598 echo "Command '$P_CLI' is not an executable file"
599 exit 1
600fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200601if [ ! -x "$P_PXY" ]; then
602 echo "Command '$P_PXY' is not an executable file"
603 exit 1
604fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100605if [ "$MEMCHECK" -gt 0 ]; then
606 if which valgrind >/dev/null 2>&1; then :; else
607 echo "Memcheck not possible. Valgrind not found"
608 exit 1
609 fi
610fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100611if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
612 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100613 exit 1
614fi
615
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200616# used by watchdog
617MAIN_PID="$$"
618
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200619# be more patient with valgrind
620if [ "$MEMCHECK" -gt 0 ]; then
621 START_DELAY=3
622 DOG_DELAY=30
623else
624 START_DELAY=1
625 DOG_DELAY=10
626fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200627CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100628SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200629
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200630# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000631# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200632P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
633P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100634P_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 +0200635O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200636O_CLI="$O_CLI -connect localhost:+SRV_PORT"
637G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000638G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200639
Gilles Peskine62469d92017-05-10 10:13:59 +0200640# Allow SHA-1, because many of our test certificates use it
641P_SRV="$P_SRV allow_sha1=1"
642P_CLI="$P_CLI allow_sha1=1"
643
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200644# Also pick a unique name for intermediate files
645SRV_OUT="srv_out.$$"
646CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200647PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200648SESSION="session.$$"
649
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200650SKIP_NEXT="NO"
651
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100652trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100653
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200654# Basic test
655
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200656# Checks that:
657# - things work with all ciphersuites active (used with config-full in all.sh)
658# - the expected (highest security) parameters are selected
659# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200660run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200661 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200662 "$P_CLI" \
663 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200664 -s "Protocol is TLSv1.2" \
665 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
666 -s "client hello v3, signature_algorithm ext: 6" \
667 -s "ECDHE curve: secp521r1" \
668 -S "error" \
669 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200670
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000671run_test "Default, DTLS" \
672 "$P_SRV dtls=1" \
673 "$P_CLI dtls=1" \
674 0 \
675 -s "Protocol is DTLSv1.2" \
676 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
677
Simon Butcher8e004102016-10-14 00:48:33 +0100678# Test for uniqueness of IVs in AEAD ciphersuites
679run_test "Unique IV in GCM" \
680 "$P_SRV exchanges=20 debug_level=4" \
681 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
682 0 \
683 -u "IV used" \
684 -U "IV used"
685
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100686# Tests for rc4 option
687
Simon Butchera410af52016-05-19 22:12:18 +0100688requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100689run_test "RC4: server disabled, client enabled" \
690 "$P_SRV" \
691 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
692 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100693 -s "SSL - The server has no ciphersuites in common"
694
Simon Butchera410af52016-05-19 22:12:18 +0100695requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100696run_test "RC4: server half, client enabled" \
697 "$P_SRV arc4=1" \
698 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
699 1 \
700 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100701
702run_test "RC4: server enabled, client disabled" \
703 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
704 "$P_CLI" \
705 1 \
706 -s "SSL - The server has no ciphersuites in common"
707
708run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100709 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100710 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
711 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100712 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100713 -S "SSL - The server has no ciphersuites in common"
714
Gilles Peskinebc70a182017-05-09 15:59:24 +0200715# Tests for SHA-1 support
716
717run_test "SHA-1 forbidden by default in server certificate" \
718 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
719 "$P_CLI debug_level=2 allow_sha1=0" \
720 1 \
721 -c "The certificate is signed with an unacceptable hash"
722
723run_test "SHA-1 explicitly allowed in server certificate" \
724 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
725 "$P_CLI allow_sha1=1" \
726 0
727
728run_test "SHA-256 allowed by default in server certificate" \
729 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
730 "$P_CLI allow_sha1=0" \
731 0
732
733run_test "SHA-1 forbidden by default in client certificate" \
734 "$P_SRV auth_mode=required allow_sha1=0" \
735 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
736 1 \
737 -s "The certificate is signed with an unacceptable hash"
738
739run_test "SHA-1 explicitly allowed in client certificate" \
740 "$P_SRV auth_mode=required allow_sha1=1" \
741 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
742 0
743
744run_test "SHA-256 allowed by default in client certificate" \
745 "$P_SRV auth_mode=required allow_sha1=0" \
746 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
747 0
748
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100749# Tests for Truncated HMAC extension
750
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100751run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200752 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100753 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100754 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100755 -s "dumping 'computed mac' (20 bytes)" \
756 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100757
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100758run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200759 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100760 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
761 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100762 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100763 -s "dumping 'computed mac' (20 bytes)" \
764 -S "dumping 'computed mac' (10 bytes)"
765
766run_test "Truncated HMAC: client enabled, server default" \
767 "$P_SRV debug_level=4" \
768 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
769 trunc_hmac=1" \
770 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100771 -s "dumping 'computed mac' (20 bytes)" \
772 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100773
774run_test "Truncated HMAC: client enabled, server disabled" \
775 "$P_SRV debug_level=4 trunc_hmac=0" \
776 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
777 trunc_hmac=1" \
778 0 \
779 -s "dumping 'computed mac' (20 bytes)" \
780 -S "dumping 'computed mac' (10 bytes)"
781
782run_test "Truncated HMAC: client enabled, server enabled" \
783 "$P_SRV debug_level=4 trunc_hmac=1" \
784 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
785 trunc_hmac=1" \
786 0 \
787 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100788 -s "dumping 'computed mac' (10 bytes)"
789
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100790# Tests for Encrypt-then-MAC extension
791
792run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100793 "$P_SRV debug_level=3 \
794 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100795 "$P_CLI debug_level=3" \
796 0 \
797 -c "client hello, adding encrypt_then_mac extension" \
798 -s "found encrypt then mac extension" \
799 -s "server hello, adding encrypt then mac extension" \
800 -c "found encrypt_then_mac extension" \
801 -c "using encrypt then mac" \
802 -s "using encrypt then mac"
803
804run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100805 "$P_SRV debug_level=3 etm=0 \
806 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100807 "$P_CLI debug_level=3 etm=1" \
808 0 \
809 -c "client hello, adding encrypt_then_mac extension" \
810 -s "found encrypt then mac extension" \
811 -S "server hello, adding encrypt then mac extension" \
812 -C "found encrypt_then_mac extension" \
813 -C "using encrypt then mac" \
814 -S "using encrypt then mac"
815
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100816run_test "Encrypt then MAC: client enabled, aead cipher" \
817 "$P_SRV debug_level=3 etm=1 \
818 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
819 "$P_CLI debug_level=3 etm=1" \
820 0 \
821 -c "client hello, adding encrypt_then_mac extension" \
822 -s "found encrypt then mac extension" \
823 -S "server hello, adding encrypt then mac extension" \
824 -C "found encrypt_then_mac extension" \
825 -C "using encrypt then mac" \
826 -S "using encrypt then mac"
827
828run_test "Encrypt then MAC: client enabled, stream cipher" \
829 "$P_SRV debug_level=3 etm=1 \
830 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100831 "$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 +0100832 0 \
833 -c "client hello, adding encrypt_then_mac extension" \
834 -s "found encrypt then mac extension" \
835 -S "server hello, adding encrypt then mac extension" \
836 -C "found encrypt_then_mac extension" \
837 -C "using encrypt then mac" \
838 -S "using encrypt then mac"
839
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100840run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100841 "$P_SRV debug_level=3 etm=1 \
842 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100843 "$P_CLI debug_level=3 etm=0" \
844 0 \
845 -C "client hello, adding encrypt_then_mac extension" \
846 -S "found encrypt then mac extension" \
847 -S "server hello, adding encrypt then mac extension" \
848 -C "found encrypt_then_mac extension" \
849 -C "using encrypt then mac" \
850 -S "using encrypt then mac"
851
Janos Follathe2681a42016-03-07 15:57:05 +0000852requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100853run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100854 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100855 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100856 "$P_CLI debug_level=3 force_version=ssl3" \
857 0 \
858 -C "client hello, adding encrypt_then_mac extension" \
859 -S "found encrypt then mac extension" \
860 -S "server hello, adding encrypt then mac extension" \
861 -C "found encrypt_then_mac extension" \
862 -C "using encrypt then mac" \
863 -S "using encrypt then mac"
864
Janos Follathe2681a42016-03-07 15:57:05 +0000865requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100866run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100867 "$P_SRV debug_level=3 force_version=ssl3 \
868 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100869 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100870 0 \
871 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100872 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100873 -S "server hello, adding encrypt then mac extension" \
874 -C "found encrypt_then_mac extension" \
875 -C "using encrypt then mac" \
876 -S "using encrypt then mac"
877
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200878# Tests for Extended Master Secret extension
879
880run_test "Extended Master Secret: default" \
881 "$P_SRV debug_level=3" \
882 "$P_CLI debug_level=3" \
883 0 \
884 -c "client hello, adding extended_master_secret extension" \
885 -s "found extended master secret extension" \
886 -s "server hello, adding extended master secret extension" \
887 -c "found extended_master_secret extension" \
888 -c "using extended master secret" \
889 -s "using extended master secret"
890
891run_test "Extended Master Secret: client enabled, server disabled" \
892 "$P_SRV debug_level=3 extended_ms=0" \
893 "$P_CLI debug_level=3 extended_ms=1" \
894 0 \
895 -c "client hello, adding extended_master_secret extension" \
896 -s "found extended master secret extension" \
897 -S "server hello, adding extended master secret extension" \
898 -C "found extended_master_secret extension" \
899 -C "using extended master secret" \
900 -S "using extended master secret"
901
902run_test "Extended Master Secret: client disabled, server enabled" \
903 "$P_SRV debug_level=3 extended_ms=1" \
904 "$P_CLI debug_level=3 extended_ms=0" \
905 0 \
906 -C "client hello, adding extended_master_secret extension" \
907 -S "found extended master secret extension" \
908 -S "server hello, adding extended master secret extension" \
909 -C "found extended_master_secret extension" \
910 -C "using extended master secret" \
911 -S "using extended master secret"
912
Janos Follathe2681a42016-03-07 15:57:05 +0000913requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200914run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100915 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200916 "$P_CLI debug_level=3 force_version=ssl3" \
917 0 \
918 -C "client hello, adding extended_master_secret extension" \
919 -S "found extended master secret extension" \
920 -S "server hello, adding extended master secret extension" \
921 -C "found extended_master_secret extension" \
922 -C "using extended master secret" \
923 -S "using extended master secret"
924
Janos Follathe2681a42016-03-07 15:57:05 +0000925requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200926run_test "Extended Master Secret: client enabled, server SSLv3" \
927 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100928 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200929 0 \
930 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100931 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200932 -S "server hello, adding extended master secret extension" \
933 -C "found extended_master_secret extension" \
934 -C "using extended master secret" \
935 -S "using extended master secret"
936
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200937# Tests for FALLBACK_SCSV
938
939run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200940 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200941 "$P_CLI debug_level=3 force_version=tls1_1" \
942 0 \
943 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200944 -S "received FALLBACK_SCSV" \
945 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200946 -C "is a fatal alert message (msg 86)"
947
948run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200949 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200950 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
951 0 \
952 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200953 -S "received FALLBACK_SCSV" \
954 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200955 -C "is a fatal alert message (msg 86)"
956
957run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200958 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200959 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200960 1 \
961 -c "adding FALLBACK_SCSV" \
962 -s "received FALLBACK_SCSV" \
963 -s "inapropriate fallback" \
964 -c "is a fatal alert message (msg 86)"
965
966run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200967 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200968 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200969 0 \
970 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200971 -s "received FALLBACK_SCSV" \
972 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200973 -C "is a fatal alert message (msg 86)"
974
975requires_openssl_with_fallback_scsv
976run_test "Fallback SCSV: default, openssl server" \
977 "$O_SRV" \
978 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
979 0 \
980 -C "adding FALLBACK_SCSV" \
981 -C "is a fatal alert message (msg 86)"
982
983requires_openssl_with_fallback_scsv
984run_test "Fallback SCSV: enabled, openssl server" \
985 "$O_SRV" \
986 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
987 1 \
988 -c "adding FALLBACK_SCSV" \
989 -c "is a fatal alert message (msg 86)"
990
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200991requires_openssl_with_fallback_scsv
992run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200993 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200994 "$O_CLI -tls1_1" \
995 0 \
996 -S "received FALLBACK_SCSV" \
997 -S "inapropriate fallback"
998
999requires_openssl_with_fallback_scsv
1000run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001001 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001002 "$O_CLI -tls1_1 -fallback_scsv" \
1003 1 \
1004 -s "received FALLBACK_SCSV" \
1005 -s "inapropriate fallback"
1006
1007requires_openssl_with_fallback_scsv
1008run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001009 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001010 "$O_CLI -fallback_scsv" \
1011 0 \
1012 -s "received FALLBACK_SCSV" \
1013 -S "inapropriate fallback"
1014
Gilles Peskined50177f2017-05-16 17:53:03 +02001015## ClientHello generated with
1016## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1017## then manually twiddling the ciphersuite list.
1018## The ClientHello content is spelled out below as a hex string as
1019## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1020## The expected response is an inappropriate_fallback alert.
1021requires_openssl_with_fallback_scsv
1022run_test "Fallback SCSV: beginning of list" \
1023 "$P_SRV debug_level=2" \
1024 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1025 0 \
1026 -s "received FALLBACK_SCSV" \
1027 -s "inapropriate fallback"
1028
1029requires_openssl_with_fallback_scsv
1030run_test "Fallback SCSV: end of list" \
1031 "$P_SRV debug_level=2" \
1032 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1033 0 \
1034 -s "received FALLBACK_SCSV" \
1035 -s "inapropriate fallback"
1036
1037## Here the expected response is a valid ServerHello prefix, up to the random.
1038requires_openssl_with_fallback_scsv
1039run_test "Fallback SCSV: not in list" \
1040 "$P_SRV debug_level=2" \
1041 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1042 0 \
1043 -S "received FALLBACK_SCSV" \
1044 -S "inapropriate fallback"
1045
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001046# Tests for CBC 1/n-1 record splitting
1047
1048run_test "CBC Record splitting: TLS 1.2, no splitting" \
1049 "$P_SRV" \
1050 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1051 request_size=123 force_version=tls1_2" \
1052 0 \
1053 -s "Read from client: 123 bytes read" \
1054 -S "Read from client: 1 bytes read" \
1055 -S "122 bytes read"
1056
1057run_test "CBC Record splitting: TLS 1.1, no splitting" \
1058 "$P_SRV" \
1059 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1060 request_size=123 force_version=tls1_1" \
1061 0 \
1062 -s "Read from client: 123 bytes read" \
1063 -S "Read from client: 1 bytes read" \
1064 -S "122 bytes read"
1065
1066run_test "CBC Record splitting: TLS 1.0, splitting" \
1067 "$P_SRV" \
1068 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1069 request_size=123 force_version=tls1" \
1070 0 \
1071 -S "Read from client: 123 bytes read" \
1072 -s "Read from client: 1 bytes read" \
1073 -s "122 bytes read"
1074
Janos Follathe2681a42016-03-07 15:57:05 +00001075requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001076run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001077 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001078 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1079 request_size=123 force_version=ssl3" \
1080 0 \
1081 -S "Read from client: 123 bytes read" \
1082 -s "Read from client: 1 bytes read" \
1083 -s "122 bytes read"
1084
1085run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001086 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001087 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1088 request_size=123 force_version=tls1" \
1089 0 \
1090 -s "Read from client: 123 bytes read" \
1091 -S "Read from client: 1 bytes read" \
1092 -S "122 bytes read"
1093
1094run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1095 "$P_SRV" \
1096 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1097 request_size=123 force_version=tls1 recsplit=0" \
1098 0 \
1099 -s "Read from client: 123 bytes read" \
1100 -S "Read from client: 1 bytes read" \
1101 -S "122 bytes read"
1102
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001103run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1104 "$P_SRV nbio=2" \
1105 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1106 request_size=123 force_version=tls1" \
1107 0 \
1108 -S "Read from client: 123 bytes read" \
1109 -s "Read from client: 1 bytes read" \
1110 -s "122 bytes read"
1111
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001112# Tests for Session Tickets
1113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001114run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001115 "$P_SRV debug_level=3 tickets=1" \
1116 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001117 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001118 -c "client hello, adding session ticket extension" \
1119 -s "found session ticket extension" \
1120 -s "server hello, adding session ticket extension" \
1121 -c "found session_ticket extension" \
1122 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001123 -S "session successfully restored from cache" \
1124 -s "session successfully restored from ticket" \
1125 -s "a session has been resumed" \
1126 -c "a session has been resumed"
1127
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001128run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001129 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1130 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001131 0 \
1132 -c "client hello, adding session ticket extension" \
1133 -s "found session ticket extension" \
1134 -s "server hello, adding session ticket extension" \
1135 -c "found session_ticket extension" \
1136 -c "parse new session ticket" \
1137 -S "session successfully restored from cache" \
1138 -s "session successfully restored from ticket" \
1139 -s "a session has been resumed" \
1140 -c "a session has been resumed"
1141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001142run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001143 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1144 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001145 0 \
1146 -c "client hello, adding session ticket extension" \
1147 -s "found session ticket extension" \
1148 -s "server hello, adding session ticket extension" \
1149 -c "found session_ticket extension" \
1150 -c "parse new session ticket" \
1151 -S "session successfully restored from cache" \
1152 -S "session successfully restored from ticket" \
1153 -S "a session has been resumed" \
1154 -C "a session has been resumed"
1155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001156run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001157 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001158 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001159 0 \
1160 -c "client hello, adding session ticket extension" \
1161 -c "found session_ticket extension" \
1162 -c "parse new session ticket" \
1163 -c "a session has been resumed"
1164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001165run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001166 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001167 "( $O_CLI -sess_out $SESSION; \
1168 $O_CLI -sess_in $SESSION; \
1169 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001170 0 \
1171 -s "found session ticket extension" \
1172 -s "server hello, adding session ticket extension" \
1173 -S "session successfully restored from cache" \
1174 -s "session successfully restored from ticket" \
1175 -s "a session has been resumed"
1176
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001177# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001179run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001180 "$P_SRV debug_level=3 tickets=0" \
1181 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001182 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001183 -c "client hello, adding session ticket extension" \
1184 -s "found session ticket extension" \
1185 -S "server hello, adding session ticket extension" \
1186 -C "found session_ticket extension" \
1187 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001188 -s "session successfully restored from cache" \
1189 -S "session successfully restored from ticket" \
1190 -s "a session has been resumed" \
1191 -c "a session has been resumed"
1192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001193run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001194 "$P_SRV debug_level=3 tickets=1" \
1195 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001196 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001197 -C "client hello, adding session ticket extension" \
1198 -S "found session ticket extension" \
1199 -S "server hello, adding session ticket extension" \
1200 -C "found session_ticket extension" \
1201 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001202 -s "session successfully restored from cache" \
1203 -S "session successfully restored from ticket" \
1204 -s "a session has been resumed" \
1205 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001207run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001208 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1209 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001210 0 \
1211 -S "session successfully restored from cache" \
1212 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001213 -S "a session has been resumed" \
1214 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001215
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001216run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001217 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1218 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001219 0 \
1220 -s "session successfully restored from cache" \
1221 -S "session successfully restored from ticket" \
1222 -s "a session has been resumed" \
1223 -c "a session has been resumed"
1224
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001225run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001226 "$P_SRV debug_level=3 tickets=0" \
1227 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001228 0 \
1229 -s "session successfully restored from cache" \
1230 -S "session successfully restored from ticket" \
1231 -s "a session has been resumed" \
1232 -c "a session has been resumed"
1233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001234run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001235 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1236 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001237 0 \
1238 -S "session successfully restored from cache" \
1239 -S "session successfully restored from ticket" \
1240 -S "a session has been resumed" \
1241 -C "a session has been resumed"
1242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001243run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001244 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1245 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001246 0 \
1247 -s "session successfully restored from cache" \
1248 -S "session successfully restored from ticket" \
1249 -s "a session has been resumed" \
1250 -c "a session has been resumed"
1251
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001252run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001253 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001254 "( $O_CLI -sess_out $SESSION; \
1255 $O_CLI -sess_in $SESSION; \
1256 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001257 0 \
1258 -s "found session ticket extension" \
1259 -S "server hello, adding session ticket extension" \
1260 -s "session successfully restored from cache" \
1261 -S "session successfully restored from ticket" \
1262 -s "a session has been resumed"
1263
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001264run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001265 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001266 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001267 0 \
1268 -C "found session_ticket extension" \
1269 -C "parse new session ticket" \
1270 -c "a session has been resumed"
1271
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001272# Tests for Max Fragment Length extension
1273
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001274run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001275 "$P_SRV debug_level=3" \
1276 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001277 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001278 -c "Maximum fragment length is 16384" \
1279 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001280 -C "client hello, adding max_fragment_length extension" \
1281 -S "found max fragment length extension" \
1282 -S "server hello, max_fragment_length extension" \
1283 -C "found max_fragment_length extension"
1284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001285run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001286 "$P_SRV debug_level=3" \
1287 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001288 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001289 -c "Maximum fragment length is 4096" \
1290 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001291 -c "client hello, adding max_fragment_length extension" \
1292 -s "found max fragment length extension" \
1293 -s "server hello, max_fragment_length extension" \
1294 -c "found max_fragment_length extension"
1295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001296run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001297 "$P_SRV debug_level=3 max_frag_len=4096" \
1298 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001299 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001300 -c "Maximum fragment length is 16384" \
1301 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001302 -C "client hello, adding max_fragment_length extension" \
1303 -S "found max fragment length extension" \
1304 -S "server hello, max_fragment_length extension" \
1305 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001306
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001307requires_gnutls
1308run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001309 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001310 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001311 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001312 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001313 -c "client hello, adding max_fragment_length extension" \
1314 -c "found max_fragment_length extension"
1315
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001316run_test "Max fragment length: client, message just fits" \
1317 "$P_SRV debug_level=3" \
1318 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1319 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001320 -c "Maximum fragment length is 2048" \
1321 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001322 -c "client hello, adding max_fragment_length extension" \
1323 -s "found max fragment length extension" \
1324 -s "server hello, max_fragment_length extension" \
1325 -c "found max_fragment_length extension" \
1326 -c "2048 bytes written in 1 fragments" \
1327 -s "2048 bytes read"
1328
1329run_test "Max fragment length: client, larger message" \
1330 "$P_SRV debug_level=3" \
1331 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1332 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001333 -c "Maximum fragment length is 2048" \
1334 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001335 -c "client hello, adding max_fragment_length extension" \
1336 -s "found max fragment length extension" \
1337 -s "server hello, max_fragment_length extension" \
1338 -c "found max_fragment_length extension" \
1339 -c "2345 bytes written in 2 fragments" \
1340 -s "2048 bytes read" \
1341 -s "297 bytes read"
1342
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001343run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001344 "$P_SRV debug_level=3 dtls=1" \
1345 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1346 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001347 -c "Maximum fragment length is 2048" \
1348 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001349 -c "client hello, adding max_fragment_length extension" \
1350 -s "found max fragment length extension" \
1351 -s "server hello, max_fragment_length extension" \
1352 -c "found max_fragment_length extension" \
1353 -c "fragment larger than.*maximum"
1354
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001355# Tests for renegotiation
1356
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001357run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001358 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001359 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001360 0 \
1361 -C "client hello, adding renegotiation extension" \
1362 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1363 -S "found renegotiation extension" \
1364 -s "server hello, secure renegotiation extension" \
1365 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001366 -C "=> renegotiate" \
1367 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001368 -S "write hello request"
1369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001370run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001371 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001372 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001373 0 \
1374 -c "client hello, adding renegotiation extension" \
1375 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1376 -s "found renegotiation extension" \
1377 -s "server hello, secure renegotiation extension" \
1378 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001379 -c "=> renegotiate" \
1380 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001381 -S "write hello request"
1382
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001383run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001384 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001385 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001386 0 \
1387 -c "client hello, adding renegotiation extension" \
1388 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1389 -s "found renegotiation extension" \
1390 -s "server hello, secure renegotiation extension" \
1391 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001392 -c "=> renegotiate" \
1393 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001394 -s "write hello request"
1395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001396run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001397 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001398 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001399 0 \
1400 -c "client hello, adding renegotiation extension" \
1401 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1402 -s "found renegotiation extension" \
1403 -s "server hello, secure renegotiation extension" \
1404 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001405 -c "=> renegotiate" \
1406 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001407 -s "write hello request"
1408
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001409run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001410 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001411 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001412 1 \
1413 -c "client hello, adding renegotiation extension" \
1414 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1415 -S "found renegotiation extension" \
1416 -s "server hello, secure renegotiation extension" \
1417 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001418 -c "=> renegotiate" \
1419 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001420 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001421 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001422 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001424run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001425 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001426 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001427 0 \
1428 -C "client hello, adding renegotiation extension" \
1429 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1430 -S "found renegotiation extension" \
1431 -s "server hello, secure renegotiation extension" \
1432 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001433 -C "=> renegotiate" \
1434 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001435 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001436 -S "SSL - An unexpected message was received from our peer" \
1437 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001439run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001440 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001441 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001442 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001443 0 \
1444 -C "client hello, adding renegotiation extension" \
1445 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1446 -S "found renegotiation extension" \
1447 -s "server hello, secure renegotiation extension" \
1448 -c "found renegotiation extension" \
1449 -C "=> renegotiate" \
1450 -S "=> renegotiate" \
1451 -s "write hello request" \
1452 -S "SSL - An unexpected message was received from our peer" \
1453 -S "failed"
1454
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001455# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001456run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001457 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001458 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001459 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001460 0 \
1461 -C "client hello, adding renegotiation extension" \
1462 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1463 -S "found renegotiation extension" \
1464 -s "server hello, secure renegotiation extension" \
1465 -c "found renegotiation extension" \
1466 -C "=> renegotiate" \
1467 -S "=> renegotiate" \
1468 -s "write hello request" \
1469 -S "SSL - An unexpected message was received from our peer" \
1470 -S "failed"
1471
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001472run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001473 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001474 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001475 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001476 0 \
1477 -C "client hello, adding renegotiation extension" \
1478 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1479 -S "found renegotiation extension" \
1480 -s "server hello, secure renegotiation extension" \
1481 -c "found renegotiation extension" \
1482 -C "=> renegotiate" \
1483 -S "=> renegotiate" \
1484 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001485 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001487run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001488 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001489 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001490 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001491 0 \
1492 -c "client hello, adding renegotiation extension" \
1493 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1494 -s "found renegotiation extension" \
1495 -s "server hello, secure renegotiation extension" \
1496 -c "found renegotiation extension" \
1497 -c "=> renegotiate" \
1498 -s "=> renegotiate" \
1499 -s "write hello request" \
1500 -S "SSL - An unexpected message was received from our peer" \
1501 -S "failed"
1502
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001503run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001504 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001505 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1506 0 \
1507 -C "client hello, adding renegotiation extension" \
1508 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1509 -S "found renegotiation extension" \
1510 -s "server hello, secure renegotiation extension" \
1511 -c "found renegotiation extension" \
1512 -S "record counter limit reached: renegotiate" \
1513 -C "=> renegotiate" \
1514 -S "=> renegotiate" \
1515 -S "write hello request" \
1516 -S "SSL - An unexpected message was received from our peer" \
1517 -S "failed"
1518
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001519# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001520run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001521 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001522 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001523 0 \
1524 -c "client hello, adding renegotiation extension" \
1525 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1526 -s "found renegotiation extension" \
1527 -s "server hello, secure renegotiation extension" \
1528 -c "found renegotiation extension" \
1529 -s "record counter limit reached: renegotiate" \
1530 -c "=> renegotiate" \
1531 -s "=> renegotiate" \
1532 -s "write hello request" \
1533 -S "SSL - An unexpected message was received from our peer" \
1534 -S "failed"
1535
1536run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001537 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001538 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001539 0 \
1540 -c "client hello, adding renegotiation extension" \
1541 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1542 -s "found renegotiation extension" \
1543 -s "server hello, secure renegotiation extension" \
1544 -c "found renegotiation extension" \
1545 -s "record counter limit reached: renegotiate" \
1546 -c "=> renegotiate" \
1547 -s "=> renegotiate" \
1548 -s "write hello request" \
1549 -S "SSL - An unexpected message was received from our peer" \
1550 -S "failed"
1551
1552run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001553 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001554 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1555 0 \
1556 -C "client hello, adding renegotiation extension" \
1557 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1558 -S "found renegotiation extension" \
1559 -s "server hello, secure renegotiation extension" \
1560 -c "found renegotiation extension" \
1561 -S "record counter limit reached: renegotiate" \
1562 -C "=> renegotiate" \
1563 -S "=> renegotiate" \
1564 -S "write hello request" \
1565 -S "SSL - An unexpected message was received from our peer" \
1566 -S "failed"
1567
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001568run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001569 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001570 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001571 0 \
1572 -c "client hello, adding renegotiation extension" \
1573 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1574 -s "found renegotiation extension" \
1575 -s "server hello, secure renegotiation extension" \
1576 -c "found renegotiation extension" \
1577 -c "=> renegotiate" \
1578 -s "=> renegotiate" \
1579 -S "write hello request"
1580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001581run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001582 "$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 +02001583 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001584 0 \
1585 -c "client hello, adding renegotiation extension" \
1586 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1587 -s "found renegotiation extension" \
1588 -s "server hello, secure renegotiation extension" \
1589 -c "found renegotiation extension" \
1590 -c "=> renegotiate" \
1591 -s "=> renegotiate" \
1592 -s "write hello request"
1593
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001594run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001595 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001596 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001597 0 \
1598 -c "client hello, adding renegotiation extension" \
1599 -c "found renegotiation extension" \
1600 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001601 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001602 -C "error" \
1603 -c "HTTP/1.0 200 [Oo][Kk]"
1604
Paul Bakker539d9722015-02-08 16:18:35 +01001605requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001606run_test "Renegotiation: gnutls server strict, client-initiated" \
1607 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001608 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001609 0 \
1610 -c "client hello, adding renegotiation extension" \
1611 -c "found renegotiation extension" \
1612 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001613 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001614 -C "error" \
1615 -c "HTTP/1.0 200 [Oo][Kk]"
1616
Paul Bakker539d9722015-02-08 16:18:35 +01001617requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001618run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1619 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1620 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1621 1 \
1622 -c "client hello, adding renegotiation extension" \
1623 -C "found renegotiation extension" \
1624 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001625 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001626 -c "error" \
1627 -C "HTTP/1.0 200 [Oo][Kk]"
1628
Paul Bakker539d9722015-02-08 16:18:35 +01001629requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001630run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1631 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1632 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1633 allow_legacy=0" \
1634 1 \
1635 -c "client hello, adding renegotiation extension" \
1636 -C "found renegotiation extension" \
1637 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001638 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001639 -c "error" \
1640 -C "HTTP/1.0 200 [Oo][Kk]"
1641
Paul Bakker539d9722015-02-08 16:18:35 +01001642requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001643run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1644 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1645 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1646 allow_legacy=1" \
1647 0 \
1648 -c "client hello, adding renegotiation extension" \
1649 -C "found renegotiation extension" \
1650 -c "=> renegotiate" \
1651 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001652 -C "error" \
1653 -c "HTTP/1.0 200 [Oo][Kk]"
1654
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001655run_test "Renegotiation: DTLS, client-initiated" \
1656 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1657 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1658 0 \
1659 -c "client hello, adding renegotiation extension" \
1660 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1661 -s "found renegotiation extension" \
1662 -s "server hello, secure renegotiation extension" \
1663 -c "found renegotiation extension" \
1664 -c "=> renegotiate" \
1665 -s "=> renegotiate" \
1666 -S "write hello request"
1667
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001668run_test "Renegotiation: DTLS, server-initiated" \
1669 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001670 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1671 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001672 0 \
1673 -c "client hello, adding renegotiation extension" \
1674 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1675 -s "found renegotiation extension" \
1676 -s "server hello, secure renegotiation extension" \
1677 -c "found renegotiation extension" \
1678 -c "=> renegotiate" \
1679 -s "=> renegotiate" \
1680 -s "write hello request"
1681
Andres AG692ad842017-01-19 16:30:57 +00001682run_test "Renegotiation: DTLS, renego_period overflow" \
1683 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1684 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1685 0 \
1686 -c "client hello, adding renegotiation extension" \
1687 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1688 -s "found renegotiation extension" \
1689 -s "server hello, secure renegotiation extension" \
1690 -s "record counter limit reached: renegotiate" \
1691 -c "=> renegotiate" \
1692 -s "=> renegotiate" \
1693 -s "write hello request" \
1694
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001695requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001696run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1697 "$G_SRV -u --mtu 4096" \
1698 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1699 0 \
1700 -c "client hello, adding renegotiation extension" \
1701 -c "found renegotiation extension" \
1702 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001703 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001704 -C "error" \
1705 -s "Extra-header:"
1706
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001707# Test for the "secure renegotation" extension only (no actual renegotiation)
1708
Paul Bakker539d9722015-02-08 16:18:35 +01001709requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001710run_test "Renego ext: gnutls server strict, client default" \
1711 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1712 "$P_CLI debug_level=3" \
1713 0 \
1714 -c "found renegotiation extension" \
1715 -C "error" \
1716 -c "HTTP/1.0 200 [Oo][Kk]"
1717
Paul Bakker539d9722015-02-08 16:18:35 +01001718requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001719run_test "Renego ext: gnutls server unsafe, client default" \
1720 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1721 "$P_CLI debug_level=3" \
1722 0 \
1723 -C "found renegotiation extension" \
1724 -C "error" \
1725 -c "HTTP/1.0 200 [Oo][Kk]"
1726
Paul Bakker539d9722015-02-08 16:18:35 +01001727requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001728run_test "Renego ext: gnutls server unsafe, client break legacy" \
1729 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1730 "$P_CLI debug_level=3 allow_legacy=-1" \
1731 1 \
1732 -C "found renegotiation extension" \
1733 -c "error" \
1734 -C "HTTP/1.0 200 [Oo][Kk]"
1735
Paul Bakker539d9722015-02-08 16:18:35 +01001736requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001737run_test "Renego ext: gnutls client strict, server default" \
1738 "$P_SRV debug_level=3" \
1739 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1740 0 \
1741 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1742 -s "server hello, secure renegotiation extension"
1743
Paul Bakker539d9722015-02-08 16:18:35 +01001744requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001745run_test "Renego ext: gnutls client unsafe, server default" \
1746 "$P_SRV debug_level=3" \
1747 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1748 0 \
1749 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1750 -S "server hello, secure renegotiation extension"
1751
Paul Bakker539d9722015-02-08 16:18:35 +01001752requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001753run_test "Renego ext: gnutls client unsafe, server break legacy" \
1754 "$P_SRV debug_level=3 allow_legacy=-1" \
1755 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1756 1 \
1757 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1758 -S "server hello, secure renegotiation extension"
1759
Janos Follath0b242342016-02-17 10:11:21 +00001760# Tests for silently dropping trailing extra bytes in .der certificates
1761
1762requires_gnutls
1763run_test "DER format: no trailing bytes" \
1764 "$P_SRV crt_file=data_files/server5-der0.crt \
1765 key_file=data_files/server5.key" \
1766 "$G_CLI " \
1767 0 \
1768 -c "Handshake was completed" \
1769
1770requires_gnutls
1771run_test "DER format: with a trailing zero byte" \
1772 "$P_SRV crt_file=data_files/server5-der1a.crt \
1773 key_file=data_files/server5.key" \
1774 "$G_CLI " \
1775 0 \
1776 -c "Handshake was completed" \
1777
1778requires_gnutls
1779run_test "DER format: with a trailing random byte" \
1780 "$P_SRV crt_file=data_files/server5-der1b.crt \
1781 key_file=data_files/server5.key" \
1782 "$G_CLI " \
1783 0 \
1784 -c "Handshake was completed" \
1785
1786requires_gnutls
1787run_test "DER format: with 2 trailing random bytes" \
1788 "$P_SRV crt_file=data_files/server5-der2.crt \
1789 key_file=data_files/server5.key" \
1790 "$G_CLI " \
1791 0 \
1792 -c "Handshake was completed" \
1793
1794requires_gnutls
1795run_test "DER format: with 4 trailing random bytes" \
1796 "$P_SRV crt_file=data_files/server5-der4.crt \
1797 key_file=data_files/server5.key" \
1798 "$G_CLI " \
1799 0 \
1800 -c "Handshake was completed" \
1801
1802requires_gnutls
1803run_test "DER format: with 8 trailing random bytes" \
1804 "$P_SRV crt_file=data_files/server5-der8.crt \
1805 key_file=data_files/server5.key" \
1806 "$G_CLI " \
1807 0 \
1808 -c "Handshake was completed" \
1809
1810requires_gnutls
1811run_test "DER format: with 9 trailing random bytes" \
1812 "$P_SRV crt_file=data_files/server5-der9.crt \
1813 key_file=data_files/server5.key" \
1814 "$G_CLI " \
1815 0 \
1816 -c "Handshake was completed" \
1817
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001818# Tests for auth_mode
1819
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001820run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001821 "$P_SRV crt_file=data_files/server5-badsign.crt \
1822 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001823 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001824 1 \
1825 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001826 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001827 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001828 -c "X509 - Certificate verification failed"
1829
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001830run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001831 "$P_SRV crt_file=data_files/server5-badsign.crt \
1832 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001833 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001834 0 \
1835 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001836 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001837 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001838 -C "X509 - Certificate verification failed"
1839
Hanno Beckere6706e62017-05-15 16:05:15 +01001840run_test "Authentication: server goodcert, client optional, no trusted CA" \
1841 "$P_SRV" \
1842 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1843 0 \
1844 -c "x509_verify_cert() returned" \
1845 -c "! The certificate is not correctly signed by the trusted CA" \
1846 -c "! Certificate verification flags"\
1847 -C "! mbedtls_ssl_handshake returned" \
1848 -C "X509 - Certificate verification failed" \
1849 -C "SSL - No CA Chain is set, but required to operate"
1850
1851run_test "Authentication: server goodcert, client required, no trusted CA" \
1852 "$P_SRV" \
1853 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1854 1 \
1855 -c "x509_verify_cert() returned" \
1856 -c "! The certificate is not correctly signed by the trusted CA" \
1857 -c "! Certificate verification flags"\
1858 -c "! mbedtls_ssl_handshake returned" \
1859 -c "SSL - No CA Chain is set, but required to operate"
1860
1861# The purpose of the next two tests is to test the client's behaviour when receiving a server
1862# certificate with an unsupported elliptic curve. This should usually not happen because
1863# the client informs the server about the supported curves - it does, though, in the
1864# corner case of a static ECDH suite, because the server doesn't check the curve on that
1865# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1866# different means to have the server ignoring the client's supported curve list.
1867
1868requires_config_enabled MBEDTLS_ECP_C
1869run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1870 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1871 crt_file=data_files/server5.ku-ka.crt" \
1872 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1873 1 \
1874 -c "bad certificate (EC key curve)"\
1875 -c "! Certificate verification flags"\
1876 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1877
1878requires_config_enabled MBEDTLS_ECP_C
1879run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1880 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1881 crt_file=data_files/server5.ku-ka.crt" \
1882 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1883 1 \
1884 -c "bad certificate (EC key curve)"\
1885 -c "! Certificate verification flags"\
1886 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1887
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001888run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001889 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001890 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001891 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001892 0 \
1893 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001894 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001895 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001896 -C "X509 - Certificate verification failed"
1897
Simon Butcher99000142016-10-13 17:21:01 +01001898run_test "Authentication: client SHA256, server required" \
1899 "$P_SRV auth_mode=required" \
1900 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1901 key_file=data_files/server6.key \
1902 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1903 0 \
1904 -c "Supported Signature Algorithm found: 4," \
1905 -c "Supported Signature Algorithm found: 5,"
1906
1907run_test "Authentication: client SHA384, server required" \
1908 "$P_SRV auth_mode=required" \
1909 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1910 key_file=data_files/server6.key \
1911 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
1912 0 \
1913 -c "Supported Signature Algorithm found: 4," \
1914 -c "Supported Signature Algorithm found: 5,"
1915
Gilles Peskinefd8332e2017-05-03 16:25:07 +02001916requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
1917run_test "Authentication: client has no cert, server required (SSLv3)" \
1918 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
1919 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
1920 key_file=data_files/server5.key" \
1921 1 \
1922 -S "skip write certificate request" \
1923 -C "skip parse certificate request" \
1924 -c "got a certificate request" \
1925 -c "got no certificate to send" \
1926 -S "x509_verify_cert() returned" \
1927 -s "client has no certificate" \
1928 -s "! mbedtls_ssl_handshake returned" \
1929 -c "! mbedtls_ssl_handshake returned" \
1930 -s "No client certification received from the client, but required by the authentication mode"
1931
1932run_test "Authentication: client has no cert, server required (TLS)" \
1933 "$P_SRV debug_level=3 auth_mode=required" \
1934 "$P_CLI debug_level=3 crt_file=none \
1935 key_file=data_files/server5.key" \
1936 1 \
1937 -S "skip write certificate request" \
1938 -C "skip parse certificate request" \
1939 -c "got a certificate request" \
1940 -c "= write certificate$" \
1941 -C "skip write certificate$" \
1942 -S "x509_verify_cert() returned" \
1943 -s "client has no certificate" \
1944 -s "! mbedtls_ssl_handshake returned" \
1945 -c "! mbedtls_ssl_handshake returned" \
1946 -s "No client certification received from the client, but required by the authentication mode"
1947
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001948run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001949 "$P_SRV debug_level=3 auth_mode=required" \
1950 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001951 key_file=data_files/server5.key" \
1952 1 \
1953 -S "skip write certificate request" \
1954 -C "skip parse certificate request" \
1955 -c "got a certificate request" \
1956 -C "skip write certificate" \
1957 -C "skip write certificate verify" \
1958 -S "skip parse certificate verify" \
1959 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001960 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001961 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02001962 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001963 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001964 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02001965# We don't check that the client receives the alert because it might
1966# detect that its write end of the connection is closed and abort
1967# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001968
Janos Follath89baba22017-04-10 14:34:35 +01001969run_test "Authentication: client cert not trusted, server required" \
1970 "$P_SRV debug_level=3 auth_mode=required" \
1971 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
1972 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" \
1981 -s "! The certificate is not correctly signed by the trusted CA" \
1982 -s "! mbedtls_ssl_handshake returned" \
1983 -c "! mbedtls_ssl_handshake returned" \
1984 -s "X509 - Certificate verification failed"
1985
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001986run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001987 "$P_SRV debug_level=3 auth_mode=optional" \
1988 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001989 key_file=data_files/server5.key" \
1990 0 \
1991 -S "skip write certificate request" \
1992 -C "skip parse certificate request" \
1993 -c "got a certificate request" \
1994 -C "skip write certificate" \
1995 -C "skip write certificate verify" \
1996 -S "skip parse certificate verify" \
1997 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001998 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001999 -S "! mbedtls_ssl_handshake returned" \
2000 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002001 -S "X509 - Certificate verification failed"
2002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002003run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002004 "$P_SRV debug_level=3 auth_mode=none" \
2005 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002006 key_file=data_files/server5.key" \
2007 0 \
2008 -s "skip write certificate request" \
2009 -C "skip parse certificate request" \
2010 -c "got no certificate request" \
2011 -c "skip write certificate" \
2012 -c "skip write certificate verify" \
2013 -s "skip parse certificate verify" \
2014 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002015 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002016 -S "! mbedtls_ssl_handshake returned" \
2017 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002018 -S "X509 - Certificate verification failed"
2019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002020run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002021 "$P_SRV debug_level=3 auth_mode=optional" \
2022 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002023 0 \
2024 -S "skip write certificate request" \
2025 -C "skip parse certificate request" \
2026 -c "got a certificate request" \
2027 -C "skip write certificate$" \
2028 -C "got no certificate to send" \
2029 -S "SSLv3 client has no certificate" \
2030 -c "skip write certificate verify" \
2031 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002032 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002033 -S "! mbedtls_ssl_handshake returned" \
2034 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002035 -S "X509 - Certificate verification failed"
2036
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002037run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002038 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002039 "$O_CLI" \
2040 0 \
2041 -S "skip write certificate request" \
2042 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002043 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002044 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002045 -S "X509 - Certificate verification failed"
2046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002047run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002048 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002049 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002050 0 \
2051 -C "skip parse certificate request" \
2052 -c "got a certificate request" \
2053 -C "skip write certificate$" \
2054 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002055 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002056
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002057run_test "Authentication: client no cert, openssl server required" \
2058 "$O_SRV -Verify 10" \
2059 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2060 1 \
2061 -C "skip parse certificate request" \
2062 -c "got a certificate request" \
2063 -C "skip write certificate$" \
2064 -c "skip write certificate verify" \
2065 -c "! mbedtls_ssl_handshake returned"
2066
Janos Follathe2681a42016-03-07 15:57:05 +00002067requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002068run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002069 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002070 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002071 0 \
2072 -S "skip write certificate request" \
2073 -C "skip parse certificate request" \
2074 -c "got a certificate request" \
2075 -C "skip write certificate$" \
2076 -c "skip write certificate verify" \
2077 -c "got no certificate to send" \
2078 -s "SSLv3 client has no certificate" \
2079 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002080 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002081 -S "! mbedtls_ssl_handshake returned" \
2082 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002083 -S "X509 - Certificate verification failed"
2084
Janos Follath89baba22017-04-10 14:34:35 +01002085# Tests for CA list in CertificateRequest messages
2086
2087run_test "Authentication: send CA list in CertificateRequest (default)" \
2088 "$P_SRV debug_level=3 auth_mode=required" \
2089 "$P_CLI crt_file=data_files/server6.crt \
2090 key_file=data_files/server6.key" \
2091 0 \
2092 -s "requested DN"
2093
2094run_test "Authentication: do not send CA list in CertificateRequest" \
2095 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2096 "$P_CLI crt_file=data_files/server6.crt \
2097 key_file=data_files/server6.key" \
2098 0 \
2099 -S "requested DN"
2100
2101run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2102 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2103 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2104 key_file=data_files/server5.key" \
2105 1 \
2106 -S "requested DN" \
2107 -s "x509_verify_cert() returned" \
2108 -s "! The certificate is not correctly signed by the trusted CA" \
2109 -s "! mbedtls_ssl_handshake returned" \
2110 -c "! mbedtls_ssl_handshake returned" \
2111 -s "X509 - Certificate verification failed"
2112
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002113# Tests for certificate selection based on SHA verson
2114
2115run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2116 "$P_SRV crt_file=data_files/server5.crt \
2117 key_file=data_files/server5.key \
2118 crt_file2=data_files/server5-sha1.crt \
2119 key_file2=data_files/server5.key" \
2120 "$P_CLI force_version=tls1_2" \
2121 0 \
2122 -c "signed using.*ECDSA with SHA256" \
2123 -C "signed using.*ECDSA with SHA1"
2124
2125run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2126 "$P_SRV crt_file=data_files/server5.crt \
2127 key_file=data_files/server5.key \
2128 crt_file2=data_files/server5-sha1.crt \
2129 key_file2=data_files/server5.key" \
2130 "$P_CLI force_version=tls1_1" \
2131 0 \
2132 -C "signed using.*ECDSA with SHA256" \
2133 -c "signed using.*ECDSA with SHA1"
2134
2135run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2136 "$P_SRV crt_file=data_files/server5.crt \
2137 key_file=data_files/server5.key \
2138 crt_file2=data_files/server5-sha1.crt \
2139 key_file2=data_files/server5.key" \
2140 "$P_CLI force_version=tls1" \
2141 0 \
2142 -C "signed using.*ECDSA with SHA256" \
2143 -c "signed using.*ECDSA with SHA1"
2144
2145run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2146 "$P_SRV crt_file=data_files/server5.crt \
2147 key_file=data_files/server5.key \
2148 crt_file2=data_files/server6.crt \
2149 key_file2=data_files/server6.key" \
2150 "$P_CLI force_version=tls1_1" \
2151 0 \
2152 -c "serial number.*09" \
2153 -c "signed using.*ECDSA with SHA256" \
2154 -C "signed using.*ECDSA with SHA1"
2155
2156run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2157 "$P_SRV crt_file=data_files/server6.crt \
2158 key_file=data_files/server6.key \
2159 crt_file2=data_files/server5.crt \
2160 key_file2=data_files/server5.key" \
2161 "$P_CLI force_version=tls1_1" \
2162 0 \
2163 -c "serial number.*0A" \
2164 -c "signed using.*ECDSA with SHA256" \
2165 -C "signed using.*ECDSA with SHA1"
2166
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002167# tests for SNI
2168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002169run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002170 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002171 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002172 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002173 0 \
2174 -S "parse ServerName extension" \
2175 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2176 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002177
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002178run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002179 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002180 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002181 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 +02002182 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002183 0 \
2184 -s "parse ServerName extension" \
2185 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2186 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002188run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002189 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002190 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002191 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 +02002192 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002193 0 \
2194 -s "parse ServerName extension" \
2195 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2196 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002198run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002199 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002200 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002201 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 +02002202 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002203 1 \
2204 -s "parse ServerName extension" \
2205 -s "ssl_sni_wrapper() returned" \
2206 -s "mbedtls_ssl_handshake returned" \
2207 -c "mbedtls_ssl_handshake returned" \
2208 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002209
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002210run_test "SNI: client auth no override: optional" \
2211 "$P_SRV debug_level=3 auth_mode=optional \
2212 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2213 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2214 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002215 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002216 -S "skip write certificate request" \
2217 -C "skip parse certificate request" \
2218 -c "got a certificate request" \
2219 -C "skip write certificate" \
2220 -C "skip write certificate verify" \
2221 -S "skip parse certificate verify"
2222
2223run_test "SNI: client auth override: none -> optional" \
2224 "$P_SRV debug_level=3 auth_mode=none \
2225 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2226 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2227 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002228 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002229 -S "skip write certificate request" \
2230 -C "skip parse certificate request" \
2231 -c "got a certificate request" \
2232 -C "skip write certificate" \
2233 -C "skip write certificate verify" \
2234 -S "skip parse certificate verify"
2235
2236run_test "SNI: client auth override: optional -> none" \
2237 "$P_SRV debug_level=3 auth_mode=optional \
2238 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2239 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2240 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002241 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002242 -s "skip write certificate request" \
2243 -C "skip parse certificate request" \
2244 -c "got no certificate request" \
2245 -c "skip write certificate" \
2246 -c "skip write certificate verify" \
2247 -s "skip parse certificate verify"
2248
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002249run_test "SNI: CA no override" \
2250 "$P_SRV debug_level=3 auth_mode=optional \
2251 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2252 ca_file=data_files/test-ca.crt \
2253 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2254 "$P_CLI debug_level=3 server_name=localhost \
2255 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2256 1 \
2257 -S "skip write certificate request" \
2258 -C "skip parse certificate request" \
2259 -c "got a certificate request" \
2260 -C "skip write certificate" \
2261 -C "skip write certificate verify" \
2262 -S "skip parse certificate verify" \
2263 -s "x509_verify_cert() returned" \
2264 -s "! The certificate is not correctly signed by the trusted CA" \
2265 -S "The certificate has been revoked (is on a CRL)"
2266
2267run_test "SNI: CA override" \
2268 "$P_SRV debug_level=3 auth_mode=optional \
2269 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2270 ca_file=data_files/test-ca.crt \
2271 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2272 "$P_CLI debug_level=3 server_name=localhost \
2273 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2274 0 \
2275 -S "skip write certificate request" \
2276 -C "skip parse certificate request" \
2277 -c "got a certificate request" \
2278 -C "skip write certificate" \
2279 -C "skip write certificate verify" \
2280 -S "skip parse certificate verify" \
2281 -S "x509_verify_cert() returned" \
2282 -S "! The certificate is not correctly signed by the trusted CA" \
2283 -S "The certificate has been revoked (is on a CRL)"
2284
2285run_test "SNI: CA override with CRL" \
2286 "$P_SRV debug_level=3 auth_mode=optional \
2287 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2288 ca_file=data_files/test-ca.crt \
2289 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2290 "$P_CLI debug_level=3 server_name=localhost \
2291 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2292 1 \
2293 -S "skip write certificate request" \
2294 -C "skip parse certificate request" \
2295 -c "got a certificate request" \
2296 -C "skip write certificate" \
2297 -C "skip write certificate verify" \
2298 -S "skip parse certificate verify" \
2299 -s "x509_verify_cert() returned" \
2300 -S "! The certificate is not correctly signed by the trusted CA" \
2301 -s "The certificate has been revoked (is on a CRL)"
2302
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002303# Tests for non-blocking I/O: exercise a variety of handshake flows
2304
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002305run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002306 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2307 "$P_CLI nbio=2 tickets=0" \
2308 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002309 -S "mbedtls_ssl_handshake returned" \
2310 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002311 -c "Read from server: .* bytes read"
2312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002313run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002314 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2315 "$P_CLI nbio=2 tickets=0" \
2316 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002317 -S "mbedtls_ssl_handshake returned" \
2318 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002319 -c "Read from server: .* bytes read"
2320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002321run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002322 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2323 "$P_CLI nbio=2 tickets=1" \
2324 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002325 -S "mbedtls_ssl_handshake returned" \
2326 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002327 -c "Read from server: .* bytes read"
2328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002329run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002330 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2331 "$P_CLI nbio=2 tickets=1" \
2332 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002333 -S "mbedtls_ssl_handshake returned" \
2334 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002335 -c "Read from server: .* bytes read"
2336
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002337run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002338 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2339 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2340 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002341 -S "mbedtls_ssl_handshake returned" \
2342 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002343 -c "Read from server: .* bytes read"
2344
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002345run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002346 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2347 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2348 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002349 -S "mbedtls_ssl_handshake returned" \
2350 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002351 -c "Read from server: .* bytes read"
2352
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002353run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002354 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2355 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2356 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002357 -S "mbedtls_ssl_handshake returned" \
2358 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002359 -c "Read from server: .* bytes read"
2360
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002361# Tests for version negotiation
2362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002363run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002364 "$P_SRV" \
2365 "$P_CLI" \
2366 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002367 -S "mbedtls_ssl_handshake returned" \
2368 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002369 -s "Protocol is TLSv1.2" \
2370 -c "Protocol is TLSv1.2"
2371
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002372run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002373 "$P_SRV" \
2374 "$P_CLI max_version=tls1_1" \
2375 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002376 -S "mbedtls_ssl_handshake returned" \
2377 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002378 -s "Protocol is TLSv1.1" \
2379 -c "Protocol is TLSv1.1"
2380
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002381run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002382 "$P_SRV max_version=tls1_1" \
2383 "$P_CLI" \
2384 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002385 -S "mbedtls_ssl_handshake returned" \
2386 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002387 -s "Protocol is TLSv1.1" \
2388 -c "Protocol is TLSv1.1"
2389
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002390run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002391 "$P_SRV max_version=tls1_1" \
2392 "$P_CLI max_version=tls1_1" \
2393 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002394 -S "mbedtls_ssl_handshake returned" \
2395 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002396 -s "Protocol is TLSv1.1" \
2397 -c "Protocol is TLSv1.1"
2398
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002399run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002400 "$P_SRV min_version=tls1_1" \
2401 "$P_CLI max_version=tls1_1" \
2402 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002403 -S "mbedtls_ssl_handshake returned" \
2404 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002405 -s "Protocol is TLSv1.1" \
2406 -c "Protocol is TLSv1.1"
2407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002408run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002409 "$P_SRV max_version=tls1_1" \
2410 "$P_CLI min_version=tls1_1" \
2411 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002412 -S "mbedtls_ssl_handshake returned" \
2413 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002414 -s "Protocol is TLSv1.1" \
2415 -c "Protocol is TLSv1.1"
2416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002417run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002418 "$P_SRV max_version=tls1_1" \
2419 "$P_CLI min_version=tls1_2" \
2420 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002421 -s "mbedtls_ssl_handshake returned" \
2422 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002423 -c "SSL - Handshake protocol not within min/max boundaries"
2424
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002425run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002426 "$P_SRV min_version=tls1_2" \
2427 "$P_CLI max_version=tls1_1" \
2428 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002429 -s "mbedtls_ssl_handshake returned" \
2430 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002431 -s "SSL - Handshake protocol not within min/max boundaries"
2432
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002433# Tests for ALPN extension
2434
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002435run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002436 "$P_SRV debug_level=3" \
2437 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002438 0 \
2439 -C "client hello, adding alpn extension" \
2440 -S "found alpn extension" \
2441 -C "got an alert message, type: \\[2:120]" \
2442 -S "server hello, adding alpn extension" \
2443 -C "found alpn extension " \
2444 -C "Application Layer Protocol is" \
2445 -S "Application Layer Protocol is"
2446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002447run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002448 "$P_SRV debug_level=3" \
2449 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002450 0 \
2451 -c "client hello, adding alpn extension" \
2452 -s "found alpn extension" \
2453 -C "got an alert message, type: \\[2:120]" \
2454 -S "server hello, adding alpn extension" \
2455 -C "found alpn extension " \
2456 -c "Application Layer Protocol is (none)" \
2457 -S "Application Layer Protocol is"
2458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002459run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002460 "$P_SRV debug_level=3 alpn=abc,1234" \
2461 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002462 0 \
2463 -C "client hello, adding alpn extension" \
2464 -S "found alpn extension" \
2465 -C "got an alert message, type: \\[2:120]" \
2466 -S "server hello, adding alpn extension" \
2467 -C "found alpn extension " \
2468 -C "Application Layer Protocol is" \
2469 -s "Application Layer Protocol is (none)"
2470
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002471run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002472 "$P_SRV debug_level=3 alpn=abc,1234" \
2473 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002474 0 \
2475 -c "client hello, adding alpn extension" \
2476 -s "found alpn extension" \
2477 -C "got an alert message, type: \\[2:120]" \
2478 -s "server hello, adding alpn extension" \
2479 -c "found alpn extension" \
2480 -c "Application Layer Protocol is abc" \
2481 -s "Application Layer Protocol is abc"
2482
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002483run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002484 "$P_SRV debug_level=3 alpn=abc,1234" \
2485 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002486 0 \
2487 -c "client hello, adding alpn extension" \
2488 -s "found alpn extension" \
2489 -C "got an alert message, type: \\[2:120]" \
2490 -s "server hello, adding alpn extension" \
2491 -c "found alpn extension" \
2492 -c "Application Layer Protocol is abc" \
2493 -s "Application Layer Protocol is abc"
2494
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002495run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002496 "$P_SRV debug_level=3 alpn=abc,1234" \
2497 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002498 0 \
2499 -c "client hello, adding alpn extension" \
2500 -s "found alpn extension" \
2501 -C "got an alert message, type: \\[2:120]" \
2502 -s "server hello, adding alpn extension" \
2503 -c "found alpn extension" \
2504 -c "Application Layer Protocol is 1234" \
2505 -s "Application Layer Protocol is 1234"
2506
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002507run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002508 "$P_SRV debug_level=3 alpn=abc,123" \
2509 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002510 1 \
2511 -c "client hello, adding alpn extension" \
2512 -s "found alpn extension" \
2513 -c "got an alert message, type: \\[2:120]" \
2514 -S "server hello, adding alpn extension" \
2515 -C "found alpn extension" \
2516 -C "Application Layer Protocol is 1234" \
2517 -S "Application Layer Protocol is 1234"
2518
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002519
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002520# Tests for keyUsage in leaf certificates, part 1:
2521# server-side certificate/suite selection
2522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002523run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002524 "$P_SRV key_file=data_files/server2.key \
2525 crt_file=data_files/server2.ku-ds.crt" \
2526 "$P_CLI" \
2527 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002528 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002529
2530
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002531run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002532 "$P_SRV key_file=data_files/server2.key \
2533 crt_file=data_files/server2.ku-ke.crt" \
2534 "$P_CLI" \
2535 0 \
2536 -c "Ciphersuite is TLS-RSA-WITH-"
2537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002538run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002539 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002540 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002541 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002542 1 \
2543 -C "Ciphersuite is "
2544
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002545run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002546 "$P_SRV key_file=data_files/server5.key \
2547 crt_file=data_files/server5.ku-ds.crt" \
2548 "$P_CLI" \
2549 0 \
2550 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2551
2552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002553run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002554 "$P_SRV key_file=data_files/server5.key \
2555 crt_file=data_files/server5.ku-ka.crt" \
2556 "$P_CLI" \
2557 0 \
2558 -c "Ciphersuite is TLS-ECDH-"
2559
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002560run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002561 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002562 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002563 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002564 1 \
2565 -C "Ciphersuite is "
2566
2567# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002568# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002569
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002570run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002571 "$O_SRV -key data_files/server2.key \
2572 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002573 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002574 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2575 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002576 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002577 -C "Processing of the Certificate handshake message failed" \
2578 -c "Ciphersuite is TLS-"
2579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002580run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002581 "$O_SRV -key data_files/server2.key \
2582 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002583 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002584 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2585 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002586 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002587 -C "Processing of the Certificate handshake message failed" \
2588 -c "Ciphersuite is TLS-"
2589
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002590run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002591 "$O_SRV -key data_files/server2.key \
2592 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002593 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002594 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2595 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002596 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002597 -C "Processing of the Certificate handshake message failed" \
2598 -c "Ciphersuite is TLS-"
2599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002600run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002601 "$O_SRV -key data_files/server2.key \
2602 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002603 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002604 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2605 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002606 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002607 -c "Processing of the Certificate handshake message failed" \
2608 -C "Ciphersuite is TLS-"
2609
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002610run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2611 "$O_SRV -key data_files/server2.key \
2612 -cert data_files/server2.ku-ke.crt" \
2613 "$P_CLI debug_level=1 auth_mode=optional \
2614 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2615 0 \
2616 -c "bad certificate (usage extensions)" \
2617 -C "Processing of the Certificate handshake message failed" \
2618 -c "Ciphersuite is TLS-" \
2619 -c "! Usage does not match the keyUsage extension"
2620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002621run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002622 "$O_SRV -key data_files/server2.key \
2623 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002624 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002625 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2626 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002627 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002628 -C "Processing of the Certificate handshake message failed" \
2629 -c "Ciphersuite is TLS-"
2630
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002631run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002632 "$O_SRV -key data_files/server2.key \
2633 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002634 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002635 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2636 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002637 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002638 -c "Processing of the Certificate handshake message failed" \
2639 -C "Ciphersuite is TLS-"
2640
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002641run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2642 "$O_SRV -key data_files/server2.key \
2643 -cert data_files/server2.ku-ds.crt" \
2644 "$P_CLI debug_level=1 auth_mode=optional \
2645 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2646 0 \
2647 -c "bad certificate (usage extensions)" \
2648 -C "Processing of the Certificate handshake message failed" \
2649 -c "Ciphersuite is TLS-" \
2650 -c "! Usage does not match the keyUsage extension"
2651
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002652# Tests for keyUsage in leaf certificates, part 3:
2653# server-side checking of client cert
2654
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002655run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002656 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002657 "$O_CLI -key data_files/server2.key \
2658 -cert data_files/server2.ku-ds.crt" \
2659 0 \
2660 -S "bad certificate (usage extensions)" \
2661 -S "Processing of the Certificate handshake message failed"
2662
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002663run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002664 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002665 "$O_CLI -key data_files/server2.key \
2666 -cert data_files/server2.ku-ke.crt" \
2667 0 \
2668 -s "bad certificate (usage extensions)" \
2669 -S "Processing of the Certificate handshake message failed"
2670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002671run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002672 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002673 "$O_CLI -key data_files/server2.key \
2674 -cert data_files/server2.ku-ke.crt" \
2675 1 \
2676 -s "bad certificate (usage extensions)" \
2677 -s "Processing of the Certificate handshake message failed"
2678
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002679run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002680 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002681 "$O_CLI -key data_files/server5.key \
2682 -cert data_files/server5.ku-ds.crt" \
2683 0 \
2684 -S "bad certificate (usage extensions)" \
2685 -S "Processing of the Certificate handshake message failed"
2686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002687run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002688 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002689 "$O_CLI -key data_files/server5.key \
2690 -cert data_files/server5.ku-ka.crt" \
2691 0 \
2692 -s "bad certificate (usage extensions)" \
2693 -S "Processing of the Certificate handshake message failed"
2694
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002695# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2696
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002697run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002698 "$P_SRV key_file=data_files/server5.key \
2699 crt_file=data_files/server5.eku-srv.crt" \
2700 "$P_CLI" \
2701 0
2702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002703run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002704 "$P_SRV key_file=data_files/server5.key \
2705 crt_file=data_files/server5.eku-srv.crt" \
2706 "$P_CLI" \
2707 0
2708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002709run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002710 "$P_SRV key_file=data_files/server5.key \
2711 crt_file=data_files/server5.eku-cs_any.crt" \
2712 "$P_CLI" \
2713 0
2714
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002715run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002716 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002717 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002718 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002719 1
2720
2721# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002723run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002724 "$O_SRV -key data_files/server5.key \
2725 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002726 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002727 0 \
2728 -C "bad certificate (usage extensions)" \
2729 -C "Processing of the Certificate handshake message failed" \
2730 -c "Ciphersuite is TLS-"
2731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002732run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002733 "$O_SRV -key data_files/server5.key \
2734 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002735 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002736 0 \
2737 -C "bad certificate (usage extensions)" \
2738 -C "Processing of the Certificate handshake message failed" \
2739 -c "Ciphersuite is TLS-"
2740
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002741run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002742 "$O_SRV -key data_files/server5.key \
2743 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002744 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002745 0 \
2746 -C "bad certificate (usage extensions)" \
2747 -C "Processing of the Certificate handshake message failed" \
2748 -c "Ciphersuite is TLS-"
2749
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002750run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002751 "$O_SRV -key data_files/server5.key \
2752 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002753 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002754 1 \
2755 -c "bad certificate (usage extensions)" \
2756 -c "Processing of the Certificate handshake message failed" \
2757 -C "Ciphersuite is TLS-"
2758
2759# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2760
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002761run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002762 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002763 "$O_CLI -key data_files/server5.key \
2764 -cert data_files/server5.eku-cli.crt" \
2765 0 \
2766 -S "bad certificate (usage extensions)" \
2767 -S "Processing of the Certificate handshake message failed"
2768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002769run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002770 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002771 "$O_CLI -key data_files/server5.key \
2772 -cert data_files/server5.eku-srv_cli.crt" \
2773 0 \
2774 -S "bad certificate (usage extensions)" \
2775 -S "Processing of the Certificate handshake message failed"
2776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002777run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002778 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002779 "$O_CLI -key data_files/server5.key \
2780 -cert data_files/server5.eku-cs_any.crt" \
2781 0 \
2782 -S "bad certificate (usage extensions)" \
2783 -S "Processing of the Certificate handshake message failed"
2784
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002785run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002786 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002787 "$O_CLI -key data_files/server5.key \
2788 -cert data_files/server5.eku-cs.crt" \
2789 0 \
2790 -s "bad certificate (usage extensions)" \
2791 -S "Processing of the Certificate handshake message failed"
2792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002793run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002794 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002795 "$O_CLI -key data_files/server5.key \
2796 -cert data_files/server5.eku-cs.crt" \
2797 1 \
2798 -s "bad certificate (usage extensions)" \
2799 -s "Processing of the Certificate handshake message failed"
2800
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002801# Tests for DHM parameters loading
2802
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002803run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002804 "$P_SRV" \
2805 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2806 debug_level=3" \
2807 0 \
2808 -c "value of 'DHM: P ' (2048 bits)" \
2809 -c "value of 'DHM: G ' (2048 bits)"
2810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002811run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002812 "$P_SRV dhm_file=data_files/dhparams.pem" \
2813 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2814 debug_level=3" \
2815 0 \
2816 -c "value of 'DHM: P ' (1024 bits)" \
2817 -c "value of 'DHM: G ' (2 bits)"
2818
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002819# Tests for DHM client-side size checking
2820
2821run_test "DHM size: server default, client default, OK" \
2822 "$P_SRV" \
2823 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2824 debug_level=1" \
2825 0 \
2826 -C "DHM prime too short:"
2827
2828run_test "DHM size: server default, client 2048, OK" \
2829 "$P_SRV" \
2830 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2831 debug_level=1 dhmlen=2048" \
2832 0 \
2833 -C "DHM prime too short:"
2834
2835run_test "DHM size: server 1024, client default, OK" \
2836 "$P_SRV dhm_file=data_files/dhparams.pem" \
2837 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2838 debug_level=1" \
2839 0 \
2840 -C "DHM prime too short:"
2841
2842run_test "DHM size: server 1000, client default, rejected" \
2843 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2844 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2845 debug_level=1" \
2846 1 \
2847 -c "DHM prime too short:"
2848
2849run_test "DHM size: server default, client 2049, rejected" \
2850 "$P_SRV" \
2851 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2852 debug_level=1 dhmlen=2049" \
2853 1 \
2854 -c "DHM prime too short:"
2855
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002856# Tests for PSK callback
2857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002858run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002859 "$P_SRV psk=abc123 psk_identity=foo" \
2860 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2861 psk_identity=foo psk=abc123" \
2862 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002863 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002864 -S "SSL - Unknown identity received" \
2865 -S "SSL - Verification of the message MAC failed"
2866
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002867run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002868 "$P_SRV" \
2869 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2870 psk_identity=foo psk=abc123" \
2871 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002872 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002873 -S "SSL - Unknown identity received" \
2874 -S "SSL - Verification of the message MAC failed"
2875
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002876run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002877 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2878 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2879 psk_identity=foo psk=abc123" \
2880 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002881 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002882 -s "SSL - Unknown identity received" \
2883 -S "SSL - Verification of the message MAC failed"
2884
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002885run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002886 "$P_SRV psk_list=abc,dead,def,beef" \
2887 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2888 psk_identity=abc psk=dead" \
2889 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002890 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002891 -S "SSL - Unknown identity received" \
2892 -S "SSL - Verification of the message MAC failed"
2893
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002894run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002895 "$P_SRV psk_list=abc,dead,def,beef" \
2896 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2897 psk_identity=def psk=beef" \
2898 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002899 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002900 -S "SSL - Unknown identity received" \
2901 -S "SSL - Verification of the message MAC failed"
2902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002903run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002904 "$P_SRV psk_list=abc,dead,def,beef" \
2905 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2906 psk_identity=ghi psk=beef" \
2907 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002908 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002909 -s "SSL - Unknown identity received" \
2910 -S "SSL - Verification of the message MAC failed"
2911
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002912run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002913 "$P_SRV psk_list=abc,dead,def,beef" \
2914 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2915 psk_identity=abc psk=beef" \
2916 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002917 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002918 -S "SSL - Unknown identity received" \
2919 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002920
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002921# Tests for EC J-PAKE
2922
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002923requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002924run_test "ECJPAKE: client not configured" \
2925 "$P_SRV debug_level=3" \
2926 "$P_CLI debug_level=3" \
2927 0 \
2928 -C "add ciphersuite: c0ff" \
2929 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002930 -S "found ecjpake kkpp extension" \
2931 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002932 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002933 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002934 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002935 -S "None of the common ciphersuites is usable"
2936
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002937requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002938run_test "ECJPAKE: server not configured" \
2939 "$P_SRV debug_level=3" \
2940 "$P_CLI debug_level=3 ecjpake_pw=bla \
2941 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2942 1 \
2943 -c "add ciphersuite: c0ff" \
2944 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002945 -s "found ecjpake kkpp extension" \
2946 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002947 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002948 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002949 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002950 -s "None of the common ciphersuites is usable"
2951
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002952requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002953run_test "ECJPAKE: working, TLS" \
2954 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2955 "$P_CLI debug_level=3 ecjpake_pw=bla \
2956 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002957 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002958 -c "add ciphersuite: c0ff" \
2959 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002960 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002961 -s "found ecjpake kkpp extension" \
2962 -S "skip ecjpake kkpp extension" \
2963 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002964 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002965 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002966 -S "None of the common ciphersuites is usable" \
2967 -S "SSL - Verification of the message MAC failed"
2968
Janos Follath74537a62016-09-02 13:45:28 +01002969server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002970requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002971run_test "ECJPAKE: password mismatch, TLS" \
2972 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2973 "$P_CLI debug_level=3 ecjpake_pw=bad \
2974 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2975 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002976 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002977 -s "SSL - Verification of the message MAC failed"
2978
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002979requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002980run_test "ECJPAKE: working, DTLS" \
2981 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2982 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2983 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2984 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002985 -c "re-using cached ecjpake parameters" \
2986 -S "SSL - Verification of the message MAC failed"
2987
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002988requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002989run_test "ECJPAKE: working, DTLS, no cookie" \
2990 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2991 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2992 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2993 0 \
2994 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002995 -S "SSL - Verification of the message MAC failed"
2996
Janos Follath74537a62016-09-02 13:45:28 +01002997server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002998requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002999run_test "ECJPAKE: password mismatch, DTLS" \
3000 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3001 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3002 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3003 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003004 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003005 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003006
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003007# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003008requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003009run_test "ECJPAKE: working, DTLS, nolog" \
3010 "$P_SRV dtls=1 ecjpake_pw=bla" \
3011 "$P_CLI dtls=1 ecjpake_pw=bla \
3012 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3013 0
3014
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003015# Tests for ciphersuites per version
3016
Janos Follathe2681a42016-03-07 15:57:05 +00003017requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003018run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003019 "$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 +02003020 "$P_CLI force_version=ssl3" \
3021 0 \
3022 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003024run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003025 "$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 +01003026 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003027 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003028 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003030run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003031 "$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 +02003032 "$P_CLI force_version=tls1_1" \
3033 0 \
3034 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003036run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003037 "$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 +02003038 "$P_CLI force_version=tls1_2" \
3039 0 \
3040 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3041
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003042# Test for ClientHello without extensions
3043
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003044requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003045run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003046 "$P_SRV debug_level=3" \
3047 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3048 0 \
3049 -s "dumping 'client hello extensions' (0 bytes)"
3050
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003051requires_gnutls
3052run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3053 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3054 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3055 0 \
3056 -s "dumping 'client hello extensions' (0 bytes)"
3057
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003058# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003059
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003060run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003061 "$P_SRV" \
3062 "$P_CLI request_size=100" \
3063 0 \
3064 -s "Read from client: 100 bytes read$"
3065
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003066run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003067 "$P_SRV" \
3068 "$P_CLI request_size=500" \
3069 0 \
3070 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003071
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003072# Tests for small packets
3073
Janos Follathe2681a42016-03-07 15:57:05 +00003074requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003075run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003076 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003077 "$P_CLI request_size=1 force_version=ssl3 \
3078 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3079 0 \
3080 -s "Read from client: 1 bytes read"
3081
Janos Follathe2681a42016-03-07 15:57:05 +00003082requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003083run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003084 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003085 "$P_CLI request_size=1 force_version=ssl3 \
3086 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3087 0 \
3088 -s "Read from client: 1 bytes read"
3089
3090run_test "Small packet TLS 1.0 BlockCipher" \
3091 "$P_SRV" \
3092 "$P_CLI request_size=1 force_version=tls1 \
3093 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3094 0 \
3095 -s "Read from client: 1 bytes read"
3096
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003097run_test "Small packet TLS 1.0 BlockCipher without EtM" \
3098 "$P_SRV" \
3099 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3100 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3101 0 \
3102 -s "Read from client: 1 bytes read"
3103
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003104run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
3105 "$P_SRV" \
3106 "$P_CLI request_size=1 force_version=tls1 \
3107 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3108 trunc_hmac=1" \
3109 0 \
3110 -s "Read from client: 1 bytes read"
3111
3112run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003113 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003114 "$P_CLI request_size=1 force_version=tls1 \
3115 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3116 trunc_hmac=1" \
3117 0 \
3118 -s "Read from client: 1 bytes read"
3119
3120run_test "Small packet TLS 1.1 BlockCipher" \
3121 "$P_SRV" \
3122 "$P_CLI request_size=1 force_version=tls1_1 \
3123 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3124 0 \
3125 -s "Read from client: 1 bytes read"
3126
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003127run_test "Small packet TLS 1.1 BlockCipher without EtM" \
3128 "$P_SRV" \
3129 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
3130 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3131 0 \
3132 -s "Read from client: 1 bytes read"
3133
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003134run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003135 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003136 "$P_CLI request_size=1 force_version=tls1_1 \
3137 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3138 0 \
3139 -s "Read from client: 1 bytes read"
3140
3141run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3142 "$P_SRV" \
3143 "$P_CLI request_size=1 force_version=tls1_1 \
3144 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3145 trunc_hmac=1" \
3146 0 \
3147 -s "Read from client: 1 bytes read"
3148
3149run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003150 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003151 "$P_CLI request_size=1 force_version=tls1_1 \
3152 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3153 trunc_hmac=1" \
3154 0 \
3155 -s "Read from client: 1 bytes read"
3156
3157run_test "Small packet TLS 1.2 BlockCipher" \
3158 "$P_SRV" \
3159 "$P_CLI request_size=1 force_version=tls1_2 \
3160 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3161 0 \
3162 -s "Read from client: 1 bytes read"
3163
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003164run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3165 "$P_SRV" \
3166 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3167 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3168 0 \
3169 -s "Read from client: 1 bytes read"
3170
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003171run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3172 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003173 "$P_CLI request_size=1 force_version=tls1_2 \
3174 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003175 0 \
3176 -s "Read from client: 1 bytes read"
3177
3178run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3179 "$P_SRV" \
3180 "$P_CLI request_size=1 force_version=tls1_2 \
3181 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3182 trunc_hmac=1" \
3183 0 \
3184 -s "Read from client: 1 bytes read"
3185
3186run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003187 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003188 "$P_CLI request_size=1 force_version=tls1_2 \
3189 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3190 0 \
3191 -s "Read from client: 1 bytes read"
3192
3193run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003194 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003195 "$P_CLI request_size=1 force_version=tls1_2 \
3196 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3197 trunc_hmac=1" \
3198 0 \
3199 -s "Read from client: 1 bytes read"
3200
3201run_test "Small packet TLS 1.2 AEAD" \
3202 "$P_SRV" \
3203 "$P_CLI request_size=1 force_version=tls1_2 \
3204 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3205 0 \
3206 -s "Read from client: 1 bytes read"
3207
3208run_test "Small packet TLS 1.2 AEAD shorter tag" \
3209 "$P_SRV" \
3210 "$P_CLI request_size=1 force_version=tls1_2 \
3211 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3212 0 \
3213 -s "Read from client: 1 bytes read"
3214
Janos Follath00efff72016-05-06 13:48:23 +01003215# A test for extensions in SSLv3
3216
3217requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3218run_test "SSLv3 with extensions, server side" \
3219 "$P_SRV min_version=ssl3 debug_level=3" \
3220 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3221 0 \
3222 -S "dumping 'client hello extensions'" \
3223 -S "server hello, total extension length:"
3224
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003225# Test for large packets
3226
Janos Follathe2681a42016-03-07 15:57:05 +00003227requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003228run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003229 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003230 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003231 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3232 0 \
3233 -s "Read from client: 16384 bytes read"
3234
Janos Follathe2681a42016-03-07 15:57:05 +00003235requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003236run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003237 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003238 "$P_CLI request_size=16384 force_version=ssl3 \
3239 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3240 0 \
3241 -s "Read from client: 16384 bytes read"
3242
3243run_test "Large packet TLS 1.0 BlockCipher" \
3244 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003245 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003246 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3247 0 \
3248 -s "Read from client: 16384 bytes read"
3249
3250run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3251 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003252 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003253 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3254 trunc_hmac=1" \
3255 0 \
3256 -s "Read from client: 16384 bytes read"
3257
3258run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003259 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003260 "$P_CLI request_size=16384 force_version=tls1 \
3261 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3262 trunc_hmac=1" \
3263 0 \
3264 -s "Read from client: 16384 bytes read"
3265
3266run_test "Large packet TLS 1.1 BlockCipher" \
3267 "$P_SRV" \
3268 "$P_CLI request_size=16384 force_version=tls1_1 \
3269 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3270 0 \
3271 -s "Read from client: 16384 bytes read"
3272
3273run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003274 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003275 "$P_CLI request_size=16384 force_version=tls1_1 \
3276 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3277 0 \
3278 -s "Read from client: 16384 bytes read"
3279
3280run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3281 "$P_SRV" \
3282 "$P_CLI request_size=16384 force_version=tls1_1 \
3283 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3284 trunc_hmac=1" \
3285 0 \
3286 -s "Read from client: 16384 bytes read"
3287
3288run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003289 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003290 "$P_CLI request_size=16384 force_version=tls1_1 \
3291 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3292 trunc_hmac=1" \
3293 0 \
3294 -s "Read from client: 16384 bytes read"
3295
3296run_test "Large packet TLS 1.2 BlockCipher" \
3297 "$P_SRV" \
3298 "$P_CLI request_size=16384 force_version=tls1_2 \
3299 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3300 0 \
3301 -s "Read from client: 16384 bytes read"
3302
3303run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3304 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003305 "$P_CLI request_size=16384 force_version=tls1_2 \
3306 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003307 0 \
3308 -s "Read from client: 16384 bytes read"
3309
3310run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3311 "$P_SRV" \
3312 "$P_CLI request_size=16384 force_version=tls1_2 \
3313 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3314 trunc_hmac=1" \
3315 0 \
3316 -s "Read from client: 16384 bytes read"
3317
3318run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003319 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003320 "$P_CLI request_size=16384 force_version=tls1_2 \
3321 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3322 0 \
3323 -s "Read from client: 16384 bytes read"
3324
3325run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003326 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003327 "$P_CLI request_size=16384 force_version=tls1_2 \
3328 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3329 trunc_hmac=1" \
3330 0 \
3331 -s "Read from client: 16384 bytes read"
3332
3333run_test "Large packet TLS 1.2 AEAD" \
3334 "$P_SRV" \
3335 "$P_CLI request_size=16384 force_version=tls1_2 \
3336 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3337 0 \
3338 -s "Read from client: 16384 bytes read"
3339
3340run_test "Large packet TLS 1.2 AEAD shorter tag" \
3341 "$P_SRV" \
3342 "$P_CLI request_size=16384 force_version=tls1_2 \
3343 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3344 0 \
3345 -s "Read from client: 16384 bytes read"
3346
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003347# Tests for DTLS HelloVerifyRequest
3348
3349run_test "DTLS cookie: enabled" \
3350 "$P_SRV dtls=1 debug_level=2" \
3351 "$P_CLI dtls=1 debug_level=2" \
3352 0 \
3353 -s "cookie verification failed" \
3354 -s "cookie verification passed" \
3355 -S "cookie verification skipped" \
3356 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003357 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003358 -S "SSL - The requested feature is not available"
3359
3360run_test "DTLS cookie: disabled" \
3361 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3362 "$P_CLI dtls=1 debug_level=2" \
3363 0 \
3364 -S "cookie verification failed" \
3365 -S "cookie verification passed" \
3366 -s "cookie verification skipped" \
3367 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003368 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003369 -S "SSL - The requested feature is not available"
3370
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003371run_test "DTLS cookie: default (failing)" \
3372 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3373 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3374 1 \
3375 -s "cookie verification failed" \
3376 -S "cookie verification passed" \
3377 -S "cookie verification skipped" \
3378 -C "received hello verify request" \
3379 -S "hello verification requested" \
3380 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003381
3382requires_ipv6
3383run_test "DTLS cookie: enabled, IPv6" \
3384 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3385 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3386 0 \
3387 -s "cookie verification failed" \
3388 -s "cookie verification passed" \
3389 -S "cookie verification skipped" \
3390 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003391 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003392 -S "SSL - The requested feature is not available"
3393
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003394run_test "DTLS cookie: enabled, nbio" \
3395 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3396 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3397 0 \
3398 -s "cookie verification failed" \
3399 -s "cookie verification passed" \
3400 -S "cookie verification skipped" \
3401 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003402 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003403 -S "SSL - The requested feature is not available"
3404
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003405# Tests for client reconnecting from the same port with DTLS
3406
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003407not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003408run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003409 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3410 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003411 0 \
3412 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003413 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003414 -S "Client initiated reconnection from same port"
3415
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003416not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003417run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003418 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3419 "$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 +02003420 0 \
3421 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003422 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003423 -s "Client initiated reconnection from same port"
3424
Paul Bakker362689d2016-05-13 10:33:25 +01003425not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3426run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003427 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3428 "$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 +02003429 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003430 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003431 -s "Client initiated reconnection from same port"
3432
Paul Bakker362689d2016-05-13 10:33:25 +01003433only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3434run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3435 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3436 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3437 0 \
3438 -S "The operation timed out" \
3439 -s "Client initiated reconnection from same port"
3440
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003441run_test "DTLS client reconnect from same port: no cookies" \
3442 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003443 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3444 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003445 -s "The operation timed out" \
3446 -S "Client initiated reconnection from same port"
3447
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003448# Tests for various cases of client authentication with DTLS
3449# (focused on handshake flows and message parsing)
3450
3451run_test "DTLS client auth: required" \
3452 "$P_SRV dtls=1 auth_mode=required" \
3453 "$P_CLI dtls=1" \
3454 0 \
3455 -s "Verifying peer X.509 certificate... ok"
3456
3457run_test "DTLS client auth: optional, client has no cert" \
3458 "$P_SRV dtls=1 auth_mode=optional" \
3459 "$P_CLI dtls=1 crt_file=none key_file=none" \
3460 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003461 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003462
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003463run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003464 "$P_SRV dtls=1 auth_mode=none" \
3465 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3466 0 \
3467 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003468 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003469
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003470run_test "DTLS wrong PSK: badmac alert" \
3471 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3472 "$P_CLI dtls=1 psk=abc124" \
3473 1 \
3474 -s "SSL - Verification of the message MAC failed" \
3475 -c "SSL - A fatal alert message was received from our peer"
3476
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003477# Tests for receiving fragmented handshake messages with DTLS
3478
3479requires_gnutls
3480run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3481 "$G_SRV -u --mtu 2048 -a" \
3482 "$P_CLI dtls=1 debug_level=2" \
3483 0 \
3484 -C "found fragmented DTLS handshake message" \
3485 -C "error"
3486
3487requires_gnutls
3488run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3489 "$G_SRV -u --mtu 512" \
3490 "$P_CLI dtls=1 debug_level=2" \
3491 0 \
3492 -c "found fragmented DTLS handshake message" \
3493 -C "error"
3494
3495requires_gnutls
3496run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3497 "$G_SRV -u --mtu 128" \
3498 "$P_CLI dtls=1 debug_level=2" \
3499 0 \
3500 -c "found fragmented DTLS handshake message" \
3501 -C "error"
3502
3503requires_gnutls
3504run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3505 "$G_SRV -u --mtu 128" \
3506 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3507 0 \
3508 -c "found fragmented DTLS handshake message" \
3509 -C "error"
3510
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003511requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003512run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3513 "$G_SRV -u --mtu 256" \
3514 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3515 0 \
3516 -c "found fragmented DTLS handshake message" \
3517 -c "client hello, adding renegotiation extension" \
3518 -c "found renegotiation extension" \
3519 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003520 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003521 -C "error" \
3522 -s "Extra-header:"
3523
3524requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003525run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3526 "$G_SRV -u --mtu 256" \
3527 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3528 0 \
3529 -c "found fragmented DTLS handshake message" \
3530 -c "client hello, adding renegotiation extension" \
3531 -c "found renegotiation extension" \
3532 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003533 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003534 -C "error" \
3535 -s "Extra-header:"
3536
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003537run_test "DTLS reassembly: no fragmentation (openssl server)" \
3538 "$O_SRV -dtls1 -mtu 2048" \
3539 "$P_CLI dtls=1 debug_level=2" \
3540 0 \
3541 -C "found fragmented DTLS handshake message" \
3542 -C "error"
3543
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003544run_test "DTLS reassembly: some fragmentation (openssl server)" \
3545 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003546 "$P_CLI dtls=1 debug_level=2" \
3547 0 \
3548 -c "found fragmented DTLS handshake message" \
3549 -C "error"
3550
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003551run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003552 "$O_SRV -dtls1 -mtu 256" \
3553 "$P_CLI dtls=1 debug_level=2" \
3554 0 \
3555 -c "found fragmented DTLS handshake message" \
3556 -C "error"
3557
3558run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3559 "$O_SRV -dtls1 -mtu 256" \
3560 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3561 0 \
3562 -c "found fragmented DTLS handshake message" \
3563 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003564
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003565# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003566
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003567not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003568run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003569 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003570 "$P_SRV dtls=1 debug_level=2" \
3571 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003572 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003573 -C "replayed record" \
3574 -S "replayed record" \
3575 -C "record from another epoch" \
3576 -S "record from another epoch" \
3577 -C "discarding invalid record" \
3578 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003579 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003580 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003581 -c "HTTP/1.0 200 OK"
3582
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003583not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003584run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003585 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003586 "$P_SRV dtls=1 debug_level=2" \
3587 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003588 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003589 -c "replayed record" \
3590 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003591 -c "discarding invalid record" \
3592 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003593 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003594 -s "Extra-header:" \
3595 -c "HTTP/1.0 200 OK"
3596
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003597run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3598 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003599 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3600 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003601 0 \
3602 -c "replayed record" \
3603 -S "replayed record" \
3604 -c "discarding invalid record" \
3605 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003606 -c "resend" \
3607 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003608 -s "Extra-header:" \
3609 -c "HTTP/1.0 200 OK"
3610
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003611run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003612 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003613 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003614 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003615 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003616 -c "discarding invalid record (mac)" \
3617 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003618 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003619 -c "HTTP/1.0 200 OK" \
3620 -S "too many records with bad MAC" \
3621 -S "Verification of the message MAC failed"
3622
3623run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3624 -p "$P_PXY bad_ad=1" \
3625 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3626 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3627 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003628 -C "discarding invalid record (mac)" \
3629 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003630 -S "Extra-header:" \
3631 -C "HTTP/1.0 200 OK" \
3632 -s "too many records with bad MAC" \
3633 -s "Verification of the message MAC failed"
3634
3635run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3636 -p "$P_PXY bad_ad=1" \
3637 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3638 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3639 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003640 -c "discarding invalid record (mac)" \
3641 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003642 -s "Extra-header:" \
3643 -c "HTTP/1.0 200 OK" \
3644 -S "too many records with bad MAC" \
3645 -S "Verification of the message MAC failed"
3646
3647run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3648 -p "$P_PXY bad_ad=1" \
3649 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3650 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3651 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003652 -c "discarding invalid record (mac)" \
3653 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003654 -s "Extra-header:" \
3655 -c "HTTP/1.0 200 OK" \
3656 -s "too many records with bad MAC" \
3657 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003658
3659run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003660 -p "$P_PXY delay_ccs=1" \
3661 "$P_SRV dtls=1 debug_level=1" \
3662 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003663 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003664 -c "record from another epoch" \
3665 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003666 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003667 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003668 -s "Extra-header:" \
3669 -c "HTTP/1.0 200 OK"
3670
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003671# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003672
Janos Follath74537a62016-09-02 13:45:28 +01003673client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003674run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003675 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003676 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3677 psk=abc123" \
3678 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003679 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3680 0 \
3681 -s "Extra-header:" \
3682 -c "HTTP/1.0 200 OK"
3683
Janos Follath74537a62016-09-02 13:45:28 +01003684client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003685run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3686 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003687 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3688 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003689 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3690 0 \
3691 -s "Extra-header:" \
3692 -c "HTTP/1.0 200 OK"
3693
Janos Follath74537a62016-09-02 13:45:28 +01003694client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003695run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3696 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003697 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3698 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003699 0 \
3700 -s "Extra-header:" \
3701 -c "HTTP/1.0 200 OK"
3702
Janos Follath74537a62016-09-02 13:45:28 +01003703client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003704run_test "DTLS proxy: 3d, FS, client auth" \
3705 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003706 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3707 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003708 0 \
3709 -s "Extra-header:" \
3710 -c "HTTP/1.0 200 OK"
3711
Janos Follath74537a62016-09-02 13:45:28 +01003712client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003713run_test "DTLS proxy: 3d, FS, ticket" \
3714 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003715 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3716 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003717 0 \
3718 -s "Extra-header:" \
3719 -c "HTTP/1.0 200 OK"
3720
Janos Follath74537a62016-09-02 13:45:28 +01003721client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003722run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3723 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003724 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3725 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003726 0 \
3727 -s "Extra-header:" \
3728 -c "HTTP/1.0 200 OK"
3729
Janos Follath74537a62016-09-02 13:45:28 +01003730client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003731run_test "DTLS proxy: 3d, max handshake, nbio" \
3732 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003733 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3734 auth_mode=required" \
3735 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003736 0 \
3737 -s "Extra-header:" \
3738 -c "HTTP/1.0 200 OK"
3739
Janos Follath74537a62016-09-02 13:45:28 +01003740client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003741run_test "DTLS proxy: 3d, min handshake, resumption" \
3742 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3743 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3744 psk=abc123 debug_level=3" \
3745 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3746 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3747 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3748 0 \
3749 -s "a session has been resumed" \
3750 -c "a session has been resumed" \
3751 -s "Extra-header:" \
3752 -c "HTTP/1.0 200 OK"
3753
Janos Follath74537a62016-09-02 13:45:28 +01003754client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003755run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3756 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3757 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3758 psk=abc123 debug_level=3 nbio=2" \
3759 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3760 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3761 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3762 0 \
3763 -s "a session has been resumed" \
3764 -c "a session has been resumed" \
3765 -s "Extra-header:" \
3766 -c "HTTP/1.0 200 OK"
3767
Janos Follath74537a62016-09-02 13:45:28 +01003768client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003769run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003770 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003771 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3772 psk=abc123 renegotiation=1 debug_level=2" \
3773 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3774 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003775 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3776 0 \
3777 -c "=> renegotiate" \
3778 -s "=> renegotiate" \
3779 -s "Extra-header:" \
3780 -c "HTTP/1.0 200 OK"
3781
Janos Follath74537a62016-09-02 13:45:28 +01003782client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003783run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3784 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003785 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3786 psk=abc123 renegotiation=1 debug_level=2" \
3787 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3788 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003789 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3790 0 \
3791 -c "=> renegotiate" \
3792 -s "=> renegotiate" \
3793 -s "Extra-header:" \
3794 -c "HTTP/1.0 200 OK"
3795
Janos Follath74537a62016-09-02 13:45:28 +01003796client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003797run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003798 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003799 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003800 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003801 debug_level=2" \
3802 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003803 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003804 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3805 0 \
3806 -c "=> renegotiate" \
3807 -s "=> renegotiate" \
3808 -s "Extra-header:" \
3809 -c "HTTP/1.0 200 OK"
3810
Janos Follath74537a62016-09-02 13:45:28 +01003811client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003812run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003813 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003814 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003815 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003816 debug_level=2 nbio=2" \
3817 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003818 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003819 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3820 0 \
3821 -c "=> renegotiate" \
3822 -s "=> renegotiate" \
3823 -s "Extra-header:" \
3824 -c "HTTP/1.0 200 OK"
3825
Janos Follath74537a62016-09-02 13:45:28 +01003826client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003827not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003828run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003829 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3830 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003831 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003832 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003833 -c "HTTP/1.0 200 OK"
3834
Janos Follath74537a62016-09-02 13:45:28 +01003835client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003836not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003837run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3838 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3839 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003840 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003841 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003842 -c "HTTP/1.0 200 OK"
3843
Janos Follath74537a62016-09-02 13:45:28 +01003844client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003845not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003846run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3847 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3848 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003849 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003850 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003851 -c "HTTP/1.0 200 OK"
3852
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003853requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003854client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003855not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003856run_test "DTLS proxy: 3d, gnutls server" \
3857 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3858 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003859 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003860 0 \
3861 -s "Extra-header:" \
3862 -c "Extra-header:"
3863
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003864requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003865client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003866not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003867run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3868 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3869 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003870 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003871 0 \
3872 -s "Extra-header:" \
3873 -c "Extra-header:"
3874
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003875requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003876client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003877not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003878run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3879 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3880 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003881 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003882 0 \
3883 -s "Extra-header:" \
3884 -c "Extra-header:"
3885
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003886# Final report
3887
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003888echo "------------------------------------------------------------------------"
3889
3890if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003891 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003892else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003893 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003894fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003895PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003896echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003897
3898exit $FAILS