blob: c6649a3ea4d9b92ddac1ae315b740c7fc04c9348 [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
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010054print_usage() {
55 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010056 printf " -h|--help\tPrint this help.\n"
57 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
58 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
59 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010060 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010061 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010062 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Andres AGf04f54d2016-10-10 15:46:20 +010063 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010064}
65
66get_options() {
67 while [ $# -gt 0 ]; do
68 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010069 -f|--filter)
70 shift; FILTER=$1
71 ;;
72 -e|--exclude)
73 shift; EXCLUDE=$1
74 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010075 -m|--memcheck)
76 MEMCHECK=1
77 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010078 -n|--number)
79 shift; RUN_TEST_NUMBER=$1
80 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010081 -s|--show-numbers)
82 SHOW_TEST_NUMBER=1
83 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010084 -p|--preserve-logs)
85 PRESERVE_LOGS=1
86 ;;
Andres AGf04f54d2016-10-10 15:46:20 +010087 --seed)
88 shift; SEED="$1"
89 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010090 -h|--help)
91 print_usage
92 exit 0
93 ;;
94 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020095 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010096 print_usage
97 exit 1
98 ;;
99 esac
100 shift
101 done
102}
103
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100104# skip next test if the flag is not enabled in config.h
105requires_config_enabled() {
106 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
107 SKIP_NEXT="YES"
108 fi
109}
110
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200111# skip next test if OpenSSL doesn't support FALLBACK_SCSV
112requires_openssl_with_fallback_scsv() {
113 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
114 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
115 then
116 OPENSSL_HAS_FBSCSV="YES"
117 else
118 OPENSSL_HAS_FBSCSV="NO"
119 fi
120 fi
121 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
122 SKIP_NEXT="YES"
123 fi
124}
125
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200126# skip next test if GnuTLS isn't available
127requires_gnutls() {
128 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200129 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200130 GNUTLS_AVAILABLE="YES"
131 else
132 GNUTLS_AVAILABLE="NO"
133 fi
134 fi
135 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
136 SKIP_NEXT="YES"
137 fi
138}
139
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200140# skip next test if IPv6 isn't available on this host
141requires_ipv6() {
142 if [ -z "${HAS_IPV6:-}" ]; then
143 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
144 SRV_PID=$!
145 sleep 1
146 kill $SRV_PID >/dev/null 2>&1
147 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
148 HAS_IPV6="NO"
149 else
150 HAS_IPV6="YES"
151 fi
152 rm -r $SRV_OUT
153 fi
154
155 if [ "$HAS_IPV6" = "NO" ]; then
156 SKIP_NEXT="YES"
157 fi
158}
159
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200160# skip the next test if valgrind is in use
161not_with_valgrind() {
162 if [ "$MEMCHECK" -gt 0 ]; then
163 SKIP_NEXT="YES"
164 fi
165}
166
Paul Bakker362689d2016-05-13 10:33:25 +0100167# skip the next test if valgrind is NOT in use
168only_with_valgrind() {
169 if [ "$MEMCHECK" -eq 0 ]; then
170 SKIP_NEXT="YES"
171 fi
172}
173
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200174# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100175client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200176 CLI_DELAY_FACTOR=$1
177}
178
Janos Follath74537a62016-09-02 13:45:28 +0100179# wait for the given seconds after the client finished in the next test
180server_needs_more_time() {
181 SRV_DELAY_SECONDS=$1
182}
183
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100184# print_name <name>
185print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100186 TESTS=$(( $TESTS + 1 ))
187 LINE=""
188
189 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
190 LINE="$TESTS "
191 fi
192
193 LINE="$LINE$1"
194 printf "$LINE "
195 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100196 for i in `seq 1 $LEN`; do printf '.'; done
197 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100198
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100199}
200
201# fail <message>
202fail() {
203 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100204 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100205
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200206 mv $SRV_OUT o-srv-${TESTS}.log
207 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200208 if [ -n "$PXY_CMD" ]; then
209 mv $PXY_OUT o-pxy-${TESTS}.log
210 fi
211 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100212
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200213 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
214 echo " ! server output:"
215 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200216 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200217 echo " ! client output:"
218 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200219 if [ -n "$PXY_CMD" ]; then
220 echo " ! ========================================================"
221 echo " ! proxy output:"
222 cat o-pxy-${TESTS}.log
223 fi
224 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200225 fi
226
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200227 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100228}
229
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100230# is_polar <cmd_line>
231is_polar() {
232 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
233}
234
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200235# openssl s_server doesn't have -www with DTLS
236check_osrv_dtls() {
237 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
238 NEEDS_INPUT=1
239 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
240 else
241 NEEDS_INPUT=0
242 fi
243}
244
245# provide input to commands that need it
246provide_input() {
247 if [ $NEEDS_INPUT -eq 0 ]; then
248 return
249 fi
250
251 while true; do
252 echo "HTTP/1.0 200 OK"
253 sleep 1
254 done
255}
256
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100257# has_mem_err <log_file_name>
258has_mem_err() {
259 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
260 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
261 then
262 return 1 # false: does not have errors
263 else
264 return 0 # true: has errors
265 fi
266}
267
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200268# wait for server to start: two versions depending on lsof availability
269wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200270 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200271 START_TIME=$( date +%s )
272 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200273
274 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200275 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200276 while [ $DONE -eq 0 ]; do
277 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
278 then
279 DONE=1
280 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
281 echo "SERVERSTART TIMEOUT"
282 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
283 DONE=1
284 fi
285 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200286 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200287 while [ $DONE -eq 0 ]; do
288 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
289 then
290 DONE=1
291 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
292 echo "SERVERSTART TIMEOUT"
293 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
294 DONE=1
295 fi
296 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200297 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200298 else
299 sleep "$START_DELAY"
300 fi
301}
302
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200303# wait for client to terminate and set CLI_EXIT
304# must be called right after starting the client
305wait_client_done() {
306 CLI_PID=$!
307
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200308 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
309 CLI_DELAY_FACTOR=1
310
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200311 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200312 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200313
314 wait $CLI_PID
315 CLI_EXIT=$?
316
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200317 kill $DOG_PID >/dev/null 2>&1
318 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200319
320 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100321
322 sleep $SRV_DELAY_SECONDS
323 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200324}
325
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200326# check if the given command uses dtls and sets global variable DTLS
327detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200328 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200329 DTLS=1
330 else
331 DTLS=0
332 fi
333}
334
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200335# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100336# Options: -s pattern pattern that must be present in server output
337# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100338# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100339# -S pattern pattern that must be absent in server output
340# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100341# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100342run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100343 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200344 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100345
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100346 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
347 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200348 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100349 return
350 fi
351
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100352 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100353
Paul Bakkerb7584a52016-05-10 10:50:43 +0100354 # Do we only run numbered tests?
355 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
356 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
357 else
358 SKIP_NEXT="YES"
359 fi
360
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200361 # should we skip?
362 if [ "X$SKIP_NEXT" = "XYES" ]; then
363 SKIP_NEXT="NO"
364 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200365 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200366 return
367 fi
368
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200369 # does this test use a proxy?
370 if [ "X$1" = "X-p" ]; then
371 PXY_CMD="$2"
372 shift 2
373 else
374 PXY_CMD=""
375 fi
376
377 # get commands and client output
378 SRV_CMD="$1"
379 CLI_CMD="$2"
380 CLI_EXPECT="$3"
381 shift 3
382
383 # fix client port
384 if [ -n "$PXY_CMD" ]; then
385 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
386 else
387 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
388 fi
389
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200390 # update DTLS variable
391 detect_dtls "$SRV_CMD"
392
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100393 # prepend valgrind to our commands if active
394 if [ "$MEMCHECK" -gt 0 ]; then
395 if is_polar "$SRV_CMD"; then
396 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
397 fi
398 if is_polar "$CLI_CMD"; then
399 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
400 fi
401 fi
402
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200403 TIMES_LEFT=2
404 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200405 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200406
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200407 # run the commands
408 if [ -n "$PXY_CMD" ]; then
409 echo "$PXY_CMD" > $PXY_OUT
410 $PXY_CMD >> $PXY_OUT 2>&1 &
411 PXY_PID=$!
412 # assume proxy starts faster than server
413 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200414
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200415 check_osrv_dtls
416 echo "$SRV_CMD" > $SRV_OUT
417 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
418 SRV_PID=$!
419 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200420
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200421 echo "$CLI_CMD" > $CLI_OUT
422 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
423 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100424
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200425 # terminate the server (and the proxy)
426 kill $SRV_PID
427 wait $SRV_PID
428 if [ -n "$PXY_CMD" ]; then
429 kill $PXY_PID >/dev/null 2>&1
430 wait $PXY_PID
431 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100432
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200433 # retry only on timeouts
434 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
435 printf "RETRY "
436 else
437 TIMES_LEFT=0
438 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200439 done
440
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100441 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200442 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100443 # expected client exit to incorrectly succeed in case of catastrophic
444 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100445 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200446 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100447 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100448 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100449 return
450 fi
451 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100452 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200453 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100454 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100455 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100456 return
457 fi
458 fi
459
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100460 # check server exit code
461 if [ $? != 0 ]; then
462 fail "server fail"
463 return
464 fi
465
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100466 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100467 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
468 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100469 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200470 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100471 return
472 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100473
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100474 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200475 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100476 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100477 while [ $# -gt 0 ]
478 do
479 case $1 in
480 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100481 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 +0100482 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100483 return
484 fi
485 ;;
486
487 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100488 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 +0100489 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100490 return
491 fi
492 ;;
493
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
Simon Butcher8e004102016-10-14 00:48:33 +0100496 fail "pattern '$2' MUST NOT 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
Simon Butcher8e004102016-10-14 00:48:33 +0100503 fail "pattern '$2' MUST NOT be present in the Client output"
504 return
505 fi
506 ;;
507
508 # The filtering in the following two options (-u and -U) do the following
509 # - ignore valgrind output
510 # - filter out everything but lines right after the pattern occurances
511 # - keep one of each non-unique line
512 # - count how many lines remain
513 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
514 # if there were no duplicates.
515 "-U")
516 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
517 fail "lines following pattern '$2' must be unique in Server output"
518 return
519 fi
520 ;;
521
522 "-u")
523 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
524 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100525 return
526 fi
527 ;;
528
529 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200530 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100531 exit 1
532 esac
533 shift 2
534 done
535
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100536 # check valgrind's results
537 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200538 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100539 fail "Server has memory errors"
540 return
541 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200542 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100543 fail "Client has memory errors"
544 return
545 fi
546 fi
547
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100548 # if we're here, everything is ok
549 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100550 if [ "$PRESERVE_LOGS" -gt 0 ]; then
551 mv $SRV_OUT o-srv-${TESTS}.log
552 mv $CLI_OUT o-cli-${TESTS}.log
553 fi
554
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200555 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100556}
557
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100558cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200559 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200560 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
561 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
562 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
563 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100564 exit 1
565}
566
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100567#
568# MAIN
569#
570
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000571if cd $( dirname $0 ); then :; else
572 echo "cd $( dirname $0 ) failed" >&2
573 exit 1
574fi
575
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100576get_options "$@"
577
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100578# sanity checks, avoid an avalanche of errors
579if [ ! -x "$P_SRV" ]; then
580 echo "Command '$P_SRV' is not an executable file"
581 exit 1
582fi
583if [ ! -x "$P_CLI" ]; then
584 echo "Command '$P_CLI' is not an executable file"
585 exit 1
586fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200587if [ ! -x "$P_PXY" ]; then
588 echo "Command '$P_PXY' is not an executable file"
589 exit 1
590fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100591if [ "$MEMCHECK" -gt 0 ]; then
592 if which valgrind >/dev/null 2>&1; then :; else
593 echo "Memcheck not possible. Valgrind not found"
594 exit 1
595 fi
596fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100597if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
598 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100599 exit 1
600fi
601
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200602# used by watchdog
603MAIN_PID="$$"
604
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200605# be more patient with valgrind
606if [ "$MEMCHECK" -gt 0 ]; then
607 START_DELAY=3
608 DOG_DELAY=30
609else
610 START_DELAY=1
611 DOG_DELAY=10
612fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200613CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100614SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200615
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200616# Pick a "unique" server port in the range 10000-19999, and a proxy port
617PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000618PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200619SRV_PORT="1$PORT_BASE"
620PXY_PORT="2$PORT_BASE"
621unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200622
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200623# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000624# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200625P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
626P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100627P_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 +0200628O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200629O_CLI="$O_CLI -connect localhost:+SRV_PORT"
630G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000631G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200632
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200633# Also pick a unique name for intermediate files
634SRV_OUT="srv_out.$$"
635CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200636PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200637SESSION="session.$$"
638
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200639SKIP_NEXT="NO"
640
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100641trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100642
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200643# Basic test
644
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200645# Checks that:
646# - things work with all ciphersuites active (used with config-full in all.sh)
647# - the expected (highest security) parameters are selected
648# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200649run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200650 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200651 "$P_CLI" \
652 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200653 -s "Protocol is TLSv1.2" \
654 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
655 -s "client hello v3, signature_algorithm ext: 6" \
656 -s "ECDHE curve: secp521r1" \
657 -S "error" \
658 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200659
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000660run_test "Default, DTLS" \
661 "$P_SRV dtls=1" \
662 "$P_CLI dtls=1" \
663 0 \
664 -s "Protocol is DTLSv1.2" \
665 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
666
Simon Butcher8e004102016-10-14 00:48:33 +0100667# Test for uniqueness of IVs in AEAD ciphersuites
668run_test "Unique IV in GCM" \
669 "$P_SRV exchanges=20 debug_level=4" \
670 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
671 0 \
672 -u "IV used" \
673 -U "IV used"
674
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100675# Tests for rc4 option
676
Simon Butchera410af52016-05-19 22:12:18 +0100677requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100678run_test "RC4: server disabled, client enabled" \
679 "$P_SRV" \
680 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
681 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100682 -s "SSL - The server has no ciphersuites in common"
683
Simon Butchera410af52016-05-19 22:12:18 +0100684requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100685run_test "RC4: server half, client enabled" \
686 "$P_SRV arc4=1" \
687 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
688 1 \
689 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100690
691run_test "RC4: server enabled, client disabled" \
692 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
693 "$P_CLI" \
694 1 \
695 -s "SSL - The server has no ciphersuites in common"
696
697run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100698 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100699 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
700 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100701 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100702 -S "SSL - The server has no ciphersuites in common"
703
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100704# Tests for Truncated HMAC extension
705
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100706run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200707 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100708 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100709 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100710 -s "dumping 'computed mac' (20 bytes)" \
711 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100712
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100713run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200714 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100715 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
716 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100717 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100718 -s "dumping 'computed mac' (20 bytes)" \
719 -S "dumping 'computed mac' (10 bytes)"
720
721run_test "Truncated HMAC: client enabled, server default" \
722 "$P_SRV debug_level=4" \
723 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
724 trunc_hmac=1" \
725 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100726 -s "dumping 'computed mac' (20 bytes)" \
727 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100728
729run_test "Truncated HMAC: client enabled, server disabled" \
730 "$P_SRV debug_level=4 trunc_hmac=0" \
731 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
732 trunc_hmac=1" \
733 0 \
734 -s "dumping 'computed mac' (20 bytes)" \
735 -S "dumping 'computed mac' (10 bytes)"
736
737run_test "Truncated HMAC: client enabled, server enabled" \
738 "$P_SRV debug_level=4 trunc_hmac=1" \
739 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
740 trunc_hmac=1" \
741 0 \
742 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100743 -s "dumping 'computed mac' (10 bytes)"
744
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100745# Tests for Encrypt-then-MAC extension
746
747run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100748 "$P_SRV debug_level=3 \
749 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100750 "$P_CLI debug_level=3" \
751 0 \
752 -c "client hello, adding encrypt_then_mac extension" \
753 -s "found encrypt then mac extension" \
754 -s "server hello, adding encrypt then mac extension" \
755 -c "found encrypt_then_mac extension" \
756 -c "using encrypt then mac" \
757 -s "using encrypt then mac"
758
759run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100760 "$P_SRV debug_level=3 etm=0 \
761 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100762 "$P_CLI debug_level=3 etm=1" \
763 0 \
764 -c "client hello, adding encrypt_then_mac extension" \
765 -s "found encrypt then mac extension" \
766 -S "server hello, adding encrypt then mac extension" \
767 -C "found encrypt_then_mac extension" \
768 -C "using encrypt then mac" \
769 -S "using encrypt then mac"
770
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100771run_test "Encrypt then MAC: client enabled, aead cipher" \
772 "$P_SRV debug_level=3 etm=1 \
773 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
774 "$P_CLI debug_level=3 etm=1" \
775 0 \
776 -c "client hello, adding encrypt_then_mac extension" \
777 -s "found encrypt then mac extension" \
778 -S "server hello, adding encrypt then mac extension" \
779 -C "found encrypt_then_mac extension" \
780 -C "using encrypt then mac" \
781 -S "using encrypt then mac"
782
783run_test "Encrypt then MAC: client enabled, stream cipher" \
784 "$P_SRV debug_level=3 etm=1 \
785 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100786 "$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 +0100787 0 \
788 -c "client hello, adding encrypt_then_mac extension" \
789 -s "found encrypt then mac extension" \
790 -S "server hello, adding encrypt then mac extension" \
791 -C "found encrypt_then_mac extension" \
792 -C "using encrypt then mac" \
793 -S "using encrypt then mac"
794
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100795run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100796 "$P_SRV debug_level=3 etm=1 \
797 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100798 "$P_CLI debug_level=3 etm=0" \
799 0 \
800 -C "client hello, adding encrypt_then_mac extension" \
801 -S "found encrypt then mac extension" \
802 -S "server hello, adding encrypt then mac extension" \
803 -C "found encrypt_then_mac extension" \
804 -C "using encrypt then mac" \
805 -S "using encrypt then mac"
806
Janos Follathe2681a42016-03-07 15:57:05 +0000807requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100808run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100809 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100810 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100811 "$P_CLI debug_level=3 force_version=ssl3" \
812 0 \
813 -C "client hello, adding encrypt_then_mac extension" \
814 -S "found encrypt then mac extension" \
815 -S "server hello, adding encrypt then mac extension" \
816 -C "found encrypt_then_mac extension" \
817 -C "using encrypt then mac" \
818 -S "using encrypt then mac"
819
Janos Follathe2681a42016-03-07 15:57:05 +0000820requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100821run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100822 "$P_SRV debug_level=3 force_version=ssl3 \
823 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100824 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100825 0 \
826 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100827 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100828 -S "server hello, adding encrypt then mac extension" \
829 -C "found encrypt_then_mac extension" \
830 -C "using encrypt then mac" \
831 -S "using encrypt then mac"
832
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200833# Tests for Extended Master Secret extension
834
835run_test "Extended Master Secret: default" \
836 "$P_SRV debug_level=3" \
837 "$P_CLI debug_level=3" \
838 0 \
839 -c "client hello, adding extended_master_secret extension" \
840 -s "found extended master secret extension" \
841 -s "server hello, adding extended master secret extension" \
842 -c "found extended_master_secret extension" \
843 -c "using extended master secret" \
844 -s "using extended master secret"
845
846run_test "Extended Master Secret: client enabled, server disabled" \
847 "$P_SRV debug_level=3 extended_ms=0" \
848 "$P_CLI debug_level=3 extended_ms=1" \
849 0 \
850 -c "client hello, adding extended_master_secret extension" \
851 -s "found extended master secret extension" \
852 -S "server hello, adding extended master secret extension" \
853 -C "found extended_master_secret extension" \
854 -C "using extended master secret" \
855 -S "using extended master secret"
856
857run_test "Extended Master Secret: client disabled, server enabled" \
858 "$P_SRV debug_level=3 extended_ms=1" \
859 "$P_CLI debug_level=3 extended_ms=0" \
860 0 \
861 -C "client hello, adding extended_master_secret extension" \
862 -S "found extended master secret extension" \
863 -S "server hello, adding extended master secret extension" \
864 -C "found extended_master_secret extension" \
865 -C "using extended master secret" \
866 -S "using extended master secret"
867
Janos Follathe2681a42016-03-07 15:57:05 +0000868requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200869run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100870 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200871 "$P_CLI debug_level=3 force_version=ssl3" \
872 0 \
873 -C "client hello, adding extended_master_secret extension" \
874 -S "found extended master secret extension" \
875 -S "server hello, adding extended master secret extension" \
876 -C "found extended_master_secret extension" \
877 -C "using extended master secret" \
878 -S "using extended master secret"
879
Janos Follathe2681a42016-03-07 15:57:05 +0000880requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200881run_test "Extended Master Secret: client enabled, server SSLv3" \
882 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100883 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200884 0 \
885 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100886 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200887 -S "server hello, adding extended master secret extension" \
888 -C "found extended_master_secret extension" \
889 -C "using extended master secret" \
890 -S "using extended master secret"
891
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200892# Tests for FALLBACK_SCSV
893
894run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200895 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200896 "$P_CLI debug_level=3 force_version=tls1_1" \
897 0 \
898 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200899 -S "received FALLBACK_SCSV" \
900 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200901 -C "is a fatal alert message (msg 86)"
902
903run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200904 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200905 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
906 0 \
907 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200908 -S "received FALLBACK_SCSV" \
909 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200910 -C "is a fatal alert message (msg 86)"
911
912run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200913 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200914 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200915 1 \
916 -c "adding FALLBACK_SCSV" \
917 -s "received FALLBACK_SCSV" \
918 -s "inapropriate fallback" \
919 -c "is a fatal alert message (msg 86)"
920
921run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200922 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200923 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200924 0 \
925 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200926 -s "received FALLBACK_SCSV" \
927 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200928 -C "is a fatal alert message (msg 86)"
929
930requires_openssl_with_fallback_scsv
931run_test "Fallback SCSV: default, openssl server" \
932 "$O_SRV" \
933 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
934 0 \
935 -C "adding FALLBACK_SCSV" \
936 -C "is a fatal alert message (msg 86)"
937
938requires_openssl_with_fallback_scsv
939run_test "Fallback SCSV: enabled, openssl server" \
940 "$O_SRV" \
941 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
942 1 \
943 -c "adding FALLBACK_SCSV" \
944 -c "is a fatal alert message (msg 86)"
945
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200946requires_openssl_with_fallback_scsv
947run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200948 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200949 "$O_CLI -tls1_1" \
950 0 \
951 -S "received FALLBACK_SCSV" \
952 -S "inapropriate fallback"
953
954requires_openssl_with_fallback_scsv
955run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200956 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200957 "$O_CLI -tls1_1 -fallback_scsv" \
958 1 \
959 -s "received FALLBACK_SCSV" \
960 -s "inapropriate fallback"
961
962requires_openssl_with_fallback_scsv
963run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200964 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200965 "$O_CLI -fallback_scsv" \
966 0 \
967 -s "received FALLBACK_SCSV" \
968 -S "inapropriate fallback"
969
Gilles Peskined50177f2017-05-16 17:53:03 +0200970## ClientHello generated with
971## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
972## then manually twiddling the ciphersuite list.
973## The ClientHello content is spelled out below as a hex string as
974## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
975## The expected response is an inappropriate_fallback alert.
976requires_openssl_with_fallback_scsv
977run_test "Fallback SCSV: beginning of list" \
978 "$P_SRV debug_level=2" \
979 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
980 0 \
981 -s "received FALLBACK_SCSV" \
982 -s "inapropriate fallback"
983
984requires_openssl_with_fallback_scsv
985run_test "Fallback SCSV: end of list" \
986 "$P_SRV debug_level=2" \
987 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
988 0 \
989 -s "received FALLBACK_SCSV" \
990 -s "inapropriate fallback"
991
992## Here the expected response is a valid ServerHello prefix, up to the random.
993requires_openssl_with_fallback_scsv
994run_test "Fallback SCSV: not in list" \
995 "$P_SRV debug_level=2" \
996 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
997 0 \
998 -S "received FALLBACK_SCSV" \
999 -S "inapropriate fallback"
1000
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001001# Tests for CBC 1/n-1 record splitting
1002
1003run_test "CBC Record splitting: TLS 1.2, no splitting" \
1004 "$P_SRV" \
1005 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1006 request_size=123 force_version=tls1_2" \
1007 0 \
1008 -s "Read from client: 123 bytes read" \
1009 -S "Read from client: 1 bytes read" \
1010 -S "122 bytes read"
1011
1012run_test "CBC Record splitting: TLS 1.1, no splitting" \
1013 "$P_SRV" \
1014 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1015 request_size=123 force_version=tls1_1" \
1016 0 \
1017 -s "Read from client: 123 bytes read" \
1018 -S "Read from client: 1 bytes read" \
1019 -S "122 bytes read"
1020
1021run_test "CBC Record splitting: TLS 1.0, splitting" \
1022 "$P_SRV" \
1023 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1024 request_size=123 force_version=tls1" \
1025 0 \
1026 -S "Read from client: 123 bytes read" \
1027 -s "Read from client: 1 bytes read" \
1028 -s "122 bytes read"
1029
Janos Follathe2681a42016-03-07 15:57:05 +00001030requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001031run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001032 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001033 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1034 request_size=123 force_version=ssl3" \
1035 0 \
1036 -S "Read from client: 123 bytes read" \
1037 -s "Read from client: 1 bytes read" \
1038 -s "122 bytes read"
1039
1040run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001041 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001042 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1043 request_size=123 force_version=tls1" \
1044 0 \
1045 -s "Read from client: 123 bytes read" \
1046 -S "Read from client: 1 bytes read" \
1047 -S "122 bytes read"
1048
1049run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1050 "$P_SRV" \
1051 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1052 request_size=123 force_version=tls1 recsplit=0" \
1053 0 \
1054 -s "Read from client: 123 bytes read" \
1055 -S "Read from client: 1 bytes read" \
1056 -S "122 bytes read"
1057
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001058run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1059 "$P_SRV nbio=2" \
1060 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1061 request_size=123 force_version=tls1" \
1062 0 \
1063 -S "Read from client: 123 bytes read" \
1064 -s "Read from client: 1 bytes read" \
1065 -s "122 bytes read"
1066
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001067# Tests for Session Tickets
1068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001069run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001070 "$P_SRV debug_level=3 tickets=1" \
1071 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001072 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001073 -c "client hello, adding session ticket extension" \
1074 -s "found session ticket extension" \
1075 -s "server hello, adding session ticket extension" \
1076 -c "found session_ticket extension" \
1077 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001078 -S "session successfully restored from cache" \
1079 -s "session successfully restored from ticket" \
1080 -s "a session has been resumed" \
1081 -c "a session has been resumed"
1082
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001083run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001084 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1085 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001086 0 \
1087 -c "client hello, adding session ticket extension" \
1088 -s "found session ticket extension" \
1089 -s "server hello, adding session ticket extension" \
1090 -c "found session_ticket extension" \
1091 -c "parse new session ticket" \
1092 -S "session successfully restored from cache" \
1093 -s "session successfully restored from ticket" \
1094 -s "a session has been resumed" \
1095 -c "a session has been resumed"
1096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001097run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001098 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1099 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001100 0 \
1101 -c "client hello, adding session ticket extension" \
1102 -s "found session ticket extension" \
1103 -s "server hello, adding session ticket extension" \
1104 -c "found session_ticket extension" \
1105 -c "parse new session ticket" \
1106 -S "session successfully restored from cache" \
1107 -S "session successfully restored from ticket" \
1108 -S "a session has been resumed" \
1109 -C "a session has been resumed"
1110
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001111run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001112 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001113 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001114 0 \
1115 -c "client hello, adding session ticket extension" \
1116 -c "found session_ticket extension" \
1117 -c "parse new session ticket" \
1118 -c "a session has been resumed"
1119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001120run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001121 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001122 "( $O_CLI -sess_out $SESSION; \
1123 $O_CLI -sess_in $SESSION; \
1124 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001125 0 \
1126 -s "found session ticket extension" \
1127 -s "server hello, adding session ticket extension" \
1128 -S "session successfully restored from cache" \
1129 -s "session successfully restored from ticket" \
1130 -s "a session has been resumed"
1131
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001132# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001134run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001135 "$P_SRV debug_level=3 tickets=0" \
1136 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001137 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001138 -c "client hello, adding session ticket extension" \
1139 -s "found session ticket extension" \
1140 -S "server hello, adding session ticket extension" \
1141 -C "found session_ticket extension" \
1142 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001143 -s "session successfully restored from cache" \
1144 -S "session successfully restored from ticket" \
1145 -s "a session has been resumed" \
1146 -c "a session has been resumed"
1147
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001148run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001149 "$P_SRV debug_level=3 tickets=1" \
1150 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001151 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001152 -C "client hello, adding session ticket extension" \
1153 -S "found session ticket extension" \
1154 -S "server hello, adding session ticket extension" \
1155 -C "found session_ticket extension" \
1156 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001157 -s "session successfully restored from cache" \
1158 -S "session successfully restored from ticket" \
1159 -s "a session has been resumed" \
1160 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001161
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001162run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001163 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1164 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001165 0 \
1166 -S "session successfully restored from cache" \
1167 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001168 -S "a session has been resumed" \
1169 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001170
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001171run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001172 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1173 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001174 0 \
1175 -s "session successfully restored from cache" \
1176 -S "session successfully restored from ticket" \
1177 -s "a session has been resumed" \
1178 -c "a session has been resumed"
1179
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001180run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001181 "$P_SRV debug_level=3 tickets=0" \
1182 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001183 0 \
1184 -s "session successfully restored from cache" \
1185 -S "session successfully restored from ticket" \
1186 -s "a session has been resumed" \
1187 -c "a session has been resumed"
1188
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001189run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001190 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1191 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001192 0 \
1193 -S "session successfully restored from cache" \
1194 -S "session successfully restored from ticket" \
1195 -S "a session has been resumed" \
1196 -C "a session has been resumed"
1197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001198run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001199 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1200 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001201 0 \
1202 -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"
1206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001207run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001208 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001209 "( $O_CLI -sess_out $SESSION; \
1210 $O_CLI -sess_in $SESSION; \
1211 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001212 0 \
1213 -s "found session ticket extension" \
1214 -S "server hello, adding session ticket extension" \
1215 -s "session successfully restored from cache" \
1216 -S "session successfully restored from ticket" \
1217 -s "a session has been resumed"
1218
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001219run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001220 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001221 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001222 0 \
1223 -C "found session_ticket extension" \
1224 -C "parse new session ticket" \
1225 -c "a session has been resumed"
1226
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001227# Tests for Max Fragment Length extension
1228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001229run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001230 "$P_SRV debug_level=3" \
1231 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001232 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001233 -c "Maximum fragment length is 16384" \
1234 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001235 -C "client hello, adding max_fragment_length extension" \
1236 -S "found max fragment length extension" \
1237 -S "server hello, max_fragment_length extension" \
1238 -C "found max_fragment_length extension"
1239
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001240run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001241 "$P_SRV debug_level=3" \
1242 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001243 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001244 -c "Maximum fragment length is 4096" \
1245 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001246 -c "client hello, adding max_fragment_length extension" \
1247 -s "found max fragment length extension" \
1248 -s "server hello, max_fragment_length extension" \
1249 -c "found max_fragment_length extension"
1250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001251run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001252 "$P_SRV debug_level=3 max_frag_len=4096" \
1253 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001254 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001255 -c "Maximum fragment length is 16384" \
1256 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001257 -C "client hello, adding max_fragment_length extension" \
1258 -S "found max fragment length extension" \
1259 -S "server hello, max_fragment_length extension" \
1260 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001261
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001262requires_gnutls
1263run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001264 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001265 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001266 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001267 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001268 -c "client hello, adding max_fragment_length extension" \
1269 -c "found max_fragment_length extension"
1270
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001271run_test "Max fragment length: client, message just fits" \
1272 "$P_SRV debug_level=3" \
1273 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1274 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001275 -c "Maximum fragment length is 2048" \
1276 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001277 -c "client hello, adding max_fragment_length extension" \
1278 -s "found max fragment length extension" \
1279 -s "server hello, max_fragment_length extension" \
1280 -c "found max_fragment_length extension" \
1281 -c "2048 bytes written in 1 fragments" \
1282 -s "2048 bytes read"
1283
1284run_test "Max fragment length: client, larger message" \
1285 "$P_SRV debug_level=3" \
1286 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1287 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001288 -c "Maximum fragment length is 2048" \
1289 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001290 -c "client hello, adding max_fragment_length extension" \
1291 -s "found max fragment length extension" \
1292 -s "server hello, max_fragment_length extension" \
1293 -c "found max_fragment_length extension" \
1294 -c "2345 bytes written in 2 fragments" \
1295 -s "2048 bytes read" \
1296 -s "297 bytes read"
1297
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001298run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001299 "$P_SRV debug_level=3 dtls=1" \
1300 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1301 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001302 -c "Maximum fragment length is 2048" \
1303 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001304 -c "client hello, adding max_fragment_length extension" \
1305 -s "found max fragment length extension" \
1306 -s "server hello, max_fragment_length extension" \
1307 -c "found max_fragment_length extension" \
1308 -c "fragment larger than.*maximum"
1309
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001310# Tests for renegotiation
1311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001312run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001313 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001314 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001315 0 \
1316 -C "client hello, adding renegotiation extension" \
1317 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1318 -S "found renegotiation extension" \
1319 -s "server hello, secure renegotiation extension" \
1320 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001321 -C "=> renegotiate" \
1322 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001323 -S "write hello request"
1324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001325run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001326 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001327 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001328 0 \
1329 -c "client hello, adding renegotiation extension" \
1330 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1331 -s "found renegotiation extension" \
1332 -s "server hello, secure renegotiation extension" \
1333 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001334 -c "=> renegotiate" \
1335 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001336 -S "write hello request"
1337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001338run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001339 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001340 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001341 0 \
1342 -c "client hello, adding renegotiation extension" \
1343 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1344 -s "found renegotiation extension" \
1345 -s "server hello, secure renegotiation extension" \
1346 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001347 -c "=> renegotiate" \
1348 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001349 -s "write hello request"
1350
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001351run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001352 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001353 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001354 0 \
1355 -c "client hello, adding renegotiation extension" \
1356 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1357 -s "found renegotiation extension" \
1358 -s "server hello, secure renegotiation extension" \
1359 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001360 -c "=> renegotiate" \
1361 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001362 -s "write hello request"
1363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001364run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001365 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001366 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001367 1 \
1368 -c "client hello, adding renegotiation extension" \
1369 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1370 -S "found renegotiation extension" \
1371 -s "server hello, secure renegotiation extension" \
1372 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001373 -c "=> renegotiate" \
1374 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001375 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001376 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001377 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001379run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001380 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001381 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001382 0 \
1383 -C "client hello, adding renegotiation extension" \
1384 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1385 -S "found renegotiation extension" \
1386 -s "server hello, secure renegotiation extension" \
1387 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001388 -C "=> renegotiate" \
1389 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001390 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001391 -S "SSL - An unexpected message was received from our peer" \
1392 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001394run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001395 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001396 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001397 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001398 0 \
1399 -C "client hello, adding renegotiation extension" \
1400 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1401 -S "found renegotiation extension" \
1402 -s "server hello, secure renegotiation extension" \
1403 -c "found renegotiation extension" \
1404 -C "=> renegotiate" \
1405 -S "=> renegotiate" \
1406 -s "write hello request" \
1407 -S "SSL - An unexpected message was received from our peer" \
1408 -S "failed"
1409
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001410# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001411run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001412 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001413 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001414 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001415 0 \
1416 -C "client hello, adding renegotiation extension" \
1417 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1418 -S "found renegotiation extension" \
1419 -s "server hello, secure renegotiation extension" \
1420 -c "found renegotiation extension" \
1421 -C "=> renegotiate" \
1422 -S "=> renegotiate" \
1423 -s "write hello request" \
1424 -S "SSL - An unexpected message was received from our peer" \
1425 -S "failed"
1426
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001427run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001428 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001429 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001430 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001431 0 \
1432 -C "client hello, adding renegotiation extension" \
1433 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1434 -S "found renegotiation extension" \
1435 -s "server hello, secure renegotiation extension" \
1436 -c "found renegotiation extension" \
1437 -C "=> renegotiate" \
1438 -S "=> renegotiate" \
1439 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001440 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001441
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001442run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001443 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001444 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001445 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001446 0 \
1447 -c "client hello, adding renegotiation extension" \
1448 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1449 -s "found renegotiation extension" \
1450 -s "server hello, secure renegotiation extension" \
1451 -c "found renegotiation extension" \
1452 -c "=> renegotiate" \
1453 -s "=> renegotiate" \
1454 -s "write hello request" \
1455 -S "SSL - An unexpected message was received from our peer" \
1456 -S "failed"
1457
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001458run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001459 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001460 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1461 0 \
1462 -C "client hello, adding renegotiation extension" \
1463 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1464 -S "found renegotiation extension" \
1465 -s "server hello, secure renegotiation extension" \
1466 -c "found renegotiation extension" \
1467 -S "record counter limit reached: renegotiate" \
1468 -C "=> renegotiate" \
1469 -S "=> renegotiate" \
1470 -S "write hello request" \
1471 -S "SSL - An unexpected message was received from our peer" \
1472 -S "failed"
1473
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001474# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001475run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001476 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001477 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001478 0 \
1479 -c "client hello, adding renegotiation extension" \
1480 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1481 -s "found renegotiation extension" \
1482 -s "server hello, secure renegotiation extension" \
1483 -c "found renegotiation extension" \
1484 -s "record counter limit reached: renegotiate" \
1485 -c "=> renegotiate" \
1486 -s "=> renegotiate" \
1487 -s "write hello request" \
1488 -S "SSL - An unexpected message was received from our peer" \
1489 -S "failed"
1490
1491run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001492 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001493 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001494 0 \
1495 -c "client hello, adding renegotiation extension" \
1496 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1497 -s "found renegotiation extension" \
1498 -s "server hello, secure renegotiation extension" \
1499 -c "found renegotiation extension" \
1500 -s "record counter limit reached: renegotiate" \
1501 -c "=> renegotiate" \
1502 -s "=> renegotiate" \
1503 -s "write hello request" \
1504 -S "SSL - An unexpected message was received from our peer" \
1505 -S "failed"
1506
1507run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001508 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001509 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1510 0 \
1511 -C "client hello, adding renegotiation extension" \
1512 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1513 -S "found renegotiation extension" \
1514 -s "server hello, secure renegotiation extension" \
1515 -c "found renegotiation extension" \
1516 -S "record counter limit reached: renegotiate" \
1517 -C "=> renegotiate" \
1518 -S "=> renegotiate" \
1519 -S "write hello request" \
1520 -S "SSL - An unexpected message was received from our peer" \
1521 -S "failed"
1522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001523run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001524 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001525 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001526 0 \
1527 -c "client hello, adding renegotiation extension" \
1528 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1529 -s "found renegotiation extension" \
1530 -s "server hello, secure renegotiation extension" \
1531 -c "found renegotiation extension" \
1532 -c "=> renegotiate" \
1533 -s "=> renegotiate" \
1534 -S "write hello request"
1535
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001536run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001537 "$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 +02001538 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001539 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 -c "=> renegotiate" \
1546 -s "=> renegotiate" \
1547 -s "write hello request"
1548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001549run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001550 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001551 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001552 0 \
1553 -c "client hello, adding renegotiation extension" \
1554 -c "found renegotiation extension" \
1555 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001556 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001557 -C "error" \
1558 -c "HTTP/1.0 200 [Oo][Kk]"
1559
Paul Bakker539d9722015-02-08 16:18:35 +01001560requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001561run_test "Renegotiation: gnutls server strict, client-initiated" \
1562 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001563 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001564 0 \
1565 -c "client hello, adding renegotiation extension" \
1566 -c "found renegotiation extension" \
1567 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001568 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001569 -C "error" \
1570 -c "HTTP/1.0 200 [Oo][Kk]"
1571
Paul Bakker539d9722015-02-08 16:18:35 +01001572requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001573run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1574 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1575 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1576 1 \
1577 -c "client hello, adding renegotiation extension" \
1578 -C "found renegotiation extension" \
1579 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001580 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001581 -c "error" \
1582 -C "HTTP/1.0 200 [Oo][Kk]"
1583
Paul Bakker539d9722015-02-08 16:18:35 +01001584requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001585run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1586 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1587 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1588 allow_legacy=0" \
1589 1 \
1590 -c "client hello, adding renegotiation extension" \
1591 -C "found renegotiation extension" \
1592 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001593 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001594 -c "error" \
1595 -C "HTTP/1.0 200 [Oo][Kk]"
1596
Paul Bakker539d9722015-02-08 16:18:35 +01001597requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001598run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1599 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1600 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1601 allow_legacy=1" \
1602 0 \
1603 -c "client hello, adding renegotiation extension" \
1604 -C "found renegotiation extension" \
1605 -c "=> renegotiate" \
1606 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001607 -C "error" \
1608 -c "HTTP/1.0 200 [Oo][Kk]"
1609
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001610run_test "Renegotiation: DTLS, client-initiated" \
1611 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1612 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1613 0 \
1614 -c "client hello, adding renegotiation extension" \
1615 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1616 -s "found renegotiation extension" \
1617 -s "server hello, secure renegotiation extension" \
1618 -c "found renegotiation extension" \
1619 -c "=> renegotiate" \
1620 -s "=> renegotiate" \
1621 -S "write hello request"
1622
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001623run_test "Renegotiation: DTLS, server-initiated" \
1624 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001625 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1626 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001627 0 \
1628 -c "client hello, adding renegotiation extension" \
1629 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1630 -s "found renegotiation extension" \
1631 -s "server hello, secure renegotiation extension" \
1632 -c "found renegotiation extension" \
1633 -c "=> renegotiate" \
1634 -s "=> renegotiate" \
1635 -s "write hello request"
1636
Andres AG692ad842017-01-19 16:30:57 +00001637run_test "Renegotiation: DTLS, renego_period overflow" \
1638 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1639 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1640 0 \
1641 -c "client hello, adding renegotiation extension" \
1642 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1643 -s "found renegotiation extension" \
1644 -s "server hello, secure renegotiation extension" \
1645 -s "record counter limit reached: renegotiate" \
1646 -c "=> renegotiate" \
1647 -s "=> renegotiate" \
1648 -s "write hello request" \
1649
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001650requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001651run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1652 "$G_SRV -u --mtu 4096" \
1653 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1654 0 \
1655 -c "client hello, adding renegotiation extension" \
1656 -c "found renegotiation extension" \
1657 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001658 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001659 -C "error" \
1660 -s "Extra-header:"
1661
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001662# Test for the "secure renegotation" extension only (no actual renegotiation)
1663
Paul Bakker539d9722015-02-08 16:18:35 +01001664requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001665run_test "Renego ext: gnutls server strict, client default" \
1666 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1667 "$P_CLI debug_level=3" \
1668 0 \
1669 -c "found renegotiation extension" \
1670 -C "error" \
1671 -c "HTTP/1.0 200 [Oo][Kk]"
1672
Paul Bakker539d9722015-02-08 16:18:35 +01001673requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001674run_test "Renego ext: gnutls server unsafe, client default" \
1675 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1676 "$P_CLI debug_level=3" \
1677 0 \
1678 -C "found renegotiation extension" \
1679 -C "error" \
1680 -c "HTTP/1.0 200 [Oo][Kk]"
1681
Paul Bakker539d9722015-02-08 16:18:35 +01001682requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001683run_test "Renego ext: gnutls server unsafe, client break legacy" \
1684 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1685 "$P_CLI debug_level=3 allow_legacy=-1" \
1686 1 \
1687 -C "found renegotiation extension" \
1688 -c "error" \
1689 -C "HTTP/1.0 200 [Oo][Kk]"
1690
Paul Bakker539d9722015-02-08 16:18:35 +01001691requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001692run_test "Renego ext: gnutls client strict, server default" \
1693 "$P_SRV debug_level=3" \
1694 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1695 0 \
1696 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1697 -s "server hello, secure renegotiation extension"
1698
Paul Bakker539d9722015-02-08 16:18:35 +01001699requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001700run_test "Renego ext: gnutls client unsafe, server default" \
1701 "$P_SRV debug_level=3" \
1702 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1703 0 \
1704 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1705 -S "server hello, secure renegotiation extension"
1706
Paul Bakker539d9722015-02-08 16:18:35 +01001707requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001708run_test "Renego ext: gnutls client unsafe, server break legacy" \
1709 "$P_SRV debug_level=3 allow_legacy=-1" \
1710 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1711 1 \
1712 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1713 -S "server hello, secure renegotiation extension"
1714
Janos Follath0b242342016-02-17 10:11:21 +00001715# Tests for silently dropping trailing extra bytes in .der certificates
1716
1717requires_gnutls
1718run_test "DER format: no trailing bytes" \
1719 "$P_SRV crt_file=data_files/server5-der0.crt \
1720 key_file=data_files/server5.key" \
1721 "$G_CLI " \
1722 0 \
1723 -c "Handshake was completed" \
1724
1725requires_gnutls
1726run_test "DER format: with a trailing zero byte" \
1727 "$P_SRV crt_file=data_files/server5-der1a.crt \
1728 key_file=data_files/server5.key" \
1729 "$G_CLI " \
1730 0 \
1731 -c "Handshake was completed" \
1732
1733requires_gnutls
1734run_test "DER format: with a trailing random byte" \
1735 "$P_SRV crt_file=data_files/server5-der1b.crt \
1736 key_file=data_files/server5.key" \
1737 "$G_CLI " \
1738 0 \
1739 -c "Handshake was completed" \
1740
1741requires_gnutls
1742run_test "DER format: with 2 trailing random bytes" \
1743 "$P_SRV crt_file=data_files/server5-der2.crt \
1744 key_file=data_files/server5.key" \
1745 "$G_CLI " \
1746 0 \
1747 -c "Handshake was completed" \
1748
1749requires_gnutls
1750run_test "DER format: with 4 trailing random bytes" \
1751 "$P_SRV crt_file=data_files/server5-der4.crt \
1752 key_file=data_files/server5.key" \
1753 "$G_CLI " \
1754 0 \
1755 -c "Handshake was completed" \
1756
1757requires_gnutls
1758run_test "DER format: with 8 trailing random bytes" \
1759 "$P_SRV crt_file=data_files/server5-der8.crt \
1760 key_file=data_files/server5.key" \
1761 "$G_CLI " \
1762 0 \
1763 -c "Handshake was completed" \
1764
1765requires_gnutls
1766run_test "DER format: with 9 trailing random bytes" \
1767 "$P_SRV crt_file=data_files/server5-der9.crt \
1768 key_file=data_files/server5.key" \
1769 "$G_CLI " \
1770 0 \
1771 -c "Handshake was completed" \
1772
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001773# Tests for auth_mode
1774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001775run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001776 "$P_SRV crt_file=data_files/server5-badsign.crt \
1777 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001778 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001779 1 \
1780 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001781 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001782 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001783 -c "X509 - Certificate verification failed"
1784
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001785run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001786 "$P_SRV crt_file=data_files/server5-badsign.crt \
1787 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001788 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001789 0 \
1790 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001791 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001792 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001793 -C "X509 - Certificate verification failed"
1794
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001795run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001796 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001797 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001798 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001799 0 \
1800 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001801 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001802 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001803 -C "X509 - Certificate verification failed"
1804
Simon Butcher99000142016-10-13 17:21:01 +01001805run_test "Authentication: client SHA256, server required" \
1806 "$P_SRV auth_mode=required" \
1807 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1808 key_file=data_files/server6.key \
1809 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1810 0 \
1811 -c "Supported Signature Algorithm found: 4," \
1812 -c "Supported Signature Algorithm found: 5,"
1813
1814run_test "Authentication: client SHA384, server required" \
1815 "$P_SRV auth_mode=required" \
1816 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1817 key_file=data_files/server6.key \
1818 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
1819 0 \
1820 -c "Supported Signature Algorithm found: 4," \
1821 -c "Supported Signature Algorithm found: 5,"
1822
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001823run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001824 "$P_SRV debug_level=3 auth_mode=required" \
1825 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001826 key_file=data_files/server5.key" \
1827 1 \
1828 -S "skip write certificate request" \
1829 -C "skip parse certificate request" \
1830 -c "got a certificate request" \
1831 -C "skip write certificate" \
1832 -C "skip write certificate verify" \
1833 -S "skip parse certificate verify" \
1834 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001835 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001836 -s "! mbedtls_ssl_handshake returned" \
1837 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001838 -s "X509 - Certificate verification failed"
1839
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001840run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001841 "$P_SRV debug_level=3 auth_mode=optional" \
1842 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001843 key_file=data_files/server5.key" \
1844 0 \
1845 -S "skip write certificate request" \
1846 -C "skip parse certificate request" \
1847 -c "got a certificate request" \
1848 -C "skip write certificate" \
1849 -C "skip write certificate verify" \
1850 -S "skip parse certificate verify" \
1851 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001852 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001853 -S "! mbedtls_ssl_handshake returned" \
1854 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001855 -S "X509 - Certificate verification failed"
1856
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001857run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001858 "$P_SRV debug_level=3 auth_mode=none" \
1859 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001860 key_file=data_files/server5.key" \
1861 0 \
1862 -s "skip write certificate request" \
1863 -C "skip parse certificate request" \
1864 -c "got no certificate request" \
1865 -c "skip write certificate" \
1866 -c "skip write certificate verify" \
1867 -s "skip parse certificate verify" \
1868 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001869 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001870 -S "! mbedtls_ssl_handshake returned" \
1871 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001872 -S "X509 - Certificate verification failed"
1873
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001874run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001875 "$P_SRV debug_level=3 auth_mode=optional" \
1876 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001877 0 \
1878 -S "skip write certificate request" \
1879 -C "skip parse certificate request" \
1880 -c "got a certificate request" \
1881 -C "skip write certificate$" \
1882 -C "got no certificate to send" \
1883 -S "SSLv3 client has no certificate" \
1884 -c "skip write certificate verify" \
1885 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001886 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001887 -S "! mbedtls_ssl_handshake returned" \
1888 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001889 -S "X509 - Certificate verification failed"
1890
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001891run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001892 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001893 "$O_CLI" \
1894 0 \
1895 -S "skip write certificate request" \
1896 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001897 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001898 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001899 -S "X509 - Certificate verification failed"
1900
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001901run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001902 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001903 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001904 0 \
1905 -C "skip parse certificate request" \
1906 -c "got a certificate request" \
1907 -C "skip write certificate$" \
1908 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001909 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001910
Janos Follathe2681a42016-03-07 15:57:05 +00001911requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001912run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001913 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001914 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001915 0 \
1916 -S "skip write certificate request" \
1917 -C "skip parse certificate request" \
1918 -c "got a certificate request" \
1919 -C "skip write certificate$" \
1920 -c "skip write certificate verify" \
1921 -c "got no certificate to send" \
1922 -s "SSLv3 client has no certificate" \
1923 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001924 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001925 -S "! mbedtls_ssl_handshake returned" \
1926 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001927 -S "X509 - Certificate verification failed"
1928
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001929# Tests for certificate selection based on SHA verson
1930
1931run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1932 "$P_SRV crt_file=data_files/server5.crt \
1933 key_file=data_files/server5.key \
1934 crt_file2=data_files/server5-sha1.crt \
1935 key_file2=data_files/server5.key" \
1936 "$P_CLI force_version=tls1_2" \
1937 0 \
1938 -c "signed using.*ECDSA with SHA256" \
1939 -C "signed using.*ECDSA with SHA1"
1940
1941run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1942 "$P_SRV crt_file=data_files/server5.crt \
1943 key_file=data_files/server5.key \
1944 crt_file2=data_files/server5-sha1.crt \
1945 key_file2=data_files/server5.key" \
1946 "$P_CLI force_version=tls1_1" \
1947 0 \
1948 -C "signed using.*ECDSA with SHA256" \
1949 -c "signed using.*ECDSA with SHA1"
1950
1951run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1952 "$P_SRV crt_file=data_files/server5.crt \
1953 key_file=data_files/server5.key \
1954 crt_file2=data_files/server5-sha1.crt \
1955 key_file2=data_files/server5.key" \
1956 "$P_CLI force_version=tls1" \
1957 0 \
1958 -C "signed using.*ECDSA with SHA256" \
1959 -c "signed using.*ECDSA with SHA1"
1960
1961run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1962 "$P_SRV crt_file=data_files/server5.crt \
1963 key_file=data_files/server5.key \
1964 crt_file2=data_files/server6.crt \
1965 key_file2=data_files/server6.key" \
1966 "$P_CLI force_version=tls1_1" \
1967 0 \
1968 -c "serial number.*09" \
1969 -c "signed using.*ECDSA with SHA256" \
1970 -C "signed using.*ECDSA with SHA1"
1971
1972run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1973 "$P_SRV crt_file=data_files/server6.crt \
1974 key_file=data_files/server6.key \
1975 crt_file2=data_files/server5.crt \
1976 key_file2=data_files/server5.key" \
1977 "$P_CLI force_version=tls1_1" \
1978 0 \
1979 -c "serial number.*0A" \
1980 -c "signed using.*ECDSA with SHA256" \
1981 -C "signed using.*ECDSA with SHA1"
1982
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001983# tests for SNI
1984
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001985run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001986 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001987 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001988 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001989 0 \
1990 -S "parse ServerName extension" \
1991 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1992 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001994run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001995 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001996 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001997 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 +02001998 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001999 0 \
2000 -s "parse ServerName extension" \
2001 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2002 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002003
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002004run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002005 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002006 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002007 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 +02002008 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002009 0 \
2010 -s "parse ServerName extension" \
2011 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2012 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002014run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002015 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002016 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002017 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 +02002018 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002019 1 \
2020 -s "parse ServerName extension" \
2021 -s "ssl_sni_wrapper() returned" \
2022 -s "mbedtls_ssl_handshake returned" \
2023 -c "mbedtls_ssl_handshake returned" \
2024 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002025
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002026run_test "SNI: client auth no override: optional" \
2027 "$P_SRV debug_level=3 auth_mode=optional \
2028 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2029 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2030 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002031 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002032 -S "skip write certificate request" \
2033 -C "skip parse certificate request" \
2034 -c "got a certificate request" \
2035 -C "skip write certificate" \
2036 -C "skip write certificate verify" \
2037 -S "skip parse certificate verify"
2038
2039run_test "SNI: client auth override: none -> optional" \
2040 "$P_SRV debug_level=3 auth_mode=none \
2041 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2042 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2043 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002044 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002045 -S "skip write certificate request" \
2046 -C "skip parse certificate request" \
2047 -c "got a certificate request" \
2048 -C "skip write certificate" \
2049 -C "skip write certificate verify" \
2050 -S "skip parse certificate verify"
2051
2052run_test "SNI: client auth override: optional -> none" \
2053 "$P_SRV debug_level=3 auth_mode=optional \
2054 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2055 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2056 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002057 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002058 -s "skip write certificate request" \
2059 -C "skip parse certificate request" \
2060 -c "got no certificate request" \
2061 -c "skip write certificate" \
2062 -c "skip write certificate verify" \
2063 -s "skip parse certificate verify"
2064
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002065run_test "SNI: CA no override" \
2066 "$P_SRV debug_level=3 auth_mode=optional \
2067 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2068 ca_file=data_files/test-ca.crt \
2069 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2070 "$P_CLI debug_level=3 server_name=localhost \
2071 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2072 1 \
2073 -S "skip write certificate request" \
2074 -C "skip parse certificate request" \
2075 -c "got a certificate request" \
2076 -C "skip write certificate" \
2077 -C "skip write certificate verify" \
2078 -S "skip parse certificate verify" \
2079 -s "x509_verify_cert() returned" \
2080 -s "! The certificate is not correctly signed by the trusted CA" \
2081 -S "The certificate has been revoked (is on a CRL)"
2082
2083run_test "SNI: CA override" \
2084 "$P_SRV debug_level=3 auth_mode=optional \
2085 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2086 ca_file=data_files/test-ca.crt \
2087 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2088 "$P_CLI debug_level=3 server_name=localhost \
2089 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2090 0 \
2091 -S "skip write certificate request" \
2092 -C "skip parse certificate request" \
2093 -c "got a certificate request" \
2094 -C "skip write certificate" \
2095 -C "skip write certificate verify" \
2096 -S "skip parse certificate verify" \
2097 -S "x509_verify_cert() returned" \
2098 -S "! The certificate is not correctly signed by the trusted CA" \
2099 -S "The certificate has been revoked (is on a CRL)"
2100
2101run_test "SNI: CA override with CRL" \
2102 "$P_SRV debug_level=3 auth_mode=optional \
2103 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2104 ca_file=data_files/test-ca.crt \
2105 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2106 "$P_CLI debug_level=3 server_name=localhost \
2107 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2108 1 \
2109 -S "skip write certificate request" \
2110 -C "skip parse certificate request" \
2111 -c "got a certificate request" \
2112 -C "skip write certificate" \
2113 -C "skip write certificate verify" \
2114 -S "skip parse certificate verify" \
2115 -s "x509_verify_cert() returned" \
2116 -S "! The certificate is not correctly signed by the trusted CA" \
2117 -s "The certificate has been revoked (is on a CRL)"
2118
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002119# Tests for non-blocking I/O: exercise a variety of handshake flows
2120
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002121run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002122 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2123 "$P_CLI nbio=2 tickets=0" \
2124 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002125 -S "mbedtls_ssl_handshake returned" \
2126 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002127 -c "Read from server: .* bytes read"
2128
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002129run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002130 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2131 "$P_CLI nbio=2 tickets=0" \
2132 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002133 -S "mbedtls_ssl_handshake returned" \
2134 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002135 -c "Read from server: .* bytes read"
2136
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002137run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002138 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2139 "$P_CLI nbio=2 tickets=1" \
2140 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002141 -S "mbedtls_ssl_handshake returned" \
2142 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002143 -c "Read from server: .* bytes read"
2144
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002145run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002146 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2147 "$P_CLI nbio=2 tickets=1" \
2148 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002149 -S "mbedtls_ssl_handshake returned" \
2150 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002151 -c "Read from server: .* bytes read"
2152
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002153run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002154 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2155 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2156 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002157 -S "mbedtls_ssl_handshake returned" \
2158 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002159 -c "Read from server: .* bytes read"
2160
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002161run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002162 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2163 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2164 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002165 -S "mbedtls_ssl_handshake returned" \
2166 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002167 -c "Read from server: .* bytes read"
2168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002169run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002170 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2171 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2172 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002173 -S "mbedtls_ssl_handshake returned" \
2174 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002175 -c "Read from server: .* bytes read"
2176
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002177# Tests for version negotiation
2178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002179run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002180 "$P_SRV" \
2181 "$P_CLI" \
2182 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002183 -S "mbedtls_ssl_handshake returned" \
2184 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002185 -s "Protocol is TLSv1.2" \
2186 -c "Protocol is TLSv1.2"
2187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002188run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002189 "$P_SRV" \
2190 "$P_CLI max_version=tls1_1" \
2191 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002192 -S "mbedtls_ssl_handshake returned" \
2193 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002194 -s "Protocol is TLSv1.1" \
2195 -c "Protocol is TLSv1.1"
2196
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002197run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002198 "$P_SRV max_version=tls1_1" \
2199 "$P_CLI" \
2200 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002201 -S "mbedtls_ssl_handshake returned" \
2202 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002203 -s "Protocol is TLSv1.1" \
2204 -c "Protocol is TLSv1.1"
2205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002206run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002207 "$P_SRV max_version=tls1_1" \
2208 "$P_CLI max_version=tls1_1" \
2209 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002210 -S "mbedtls_ssl_handshake returned" \
2211 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002212 -s "Protocol is TLSv1.1" \
2213 -c "Protocol is TLSv1.1"
2214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002215run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002216 "$P_SRV min_version=tls1_1" \
2217 "$P_CLI max_version=tls1_1" \
2218 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002219 -S "mbedtls_ssl_handshake returned" \
2220 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002221 -s "Protocol is TLSv1.1" \
2222 -c "Protocol is TLSv1.1"
2223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002224run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002225 "$P_SRV max_version=tls1_1" \
2226 "$P_CLI min_version=tls1_1" \
2227 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002228 -S "mbedtls_ssl_handshake returned" \
2229 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002230 -s "Protocol is TLSv1.1" \
2231 -c "Protocol is TLSv1.1"
2232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002233run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002234 "$P_SRV max_version=tls1_1" \
2235 "$P_CLI min_version=tls1_2" \
2236 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002237 -s "mbedtls_ssl_handshake returned" \
2238 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002239 -c "SSL - Handshake protocol not within min/max boundaries"
2240
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002241run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002242 "$P_SRV min_version=tls1_2" \
2243 "$P_CLI max_version=tls1_1" \
2244 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002245 -s "mbedtls_ssl_handshake returned" \
2246 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002247 -s "SSL - Handshake protocol not within min/max boundaries"
2248
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002249# Tests for ALPN extension
2250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002251run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002252 "$P_SRV debug_level=3" \
2253 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002254 0 \
2255 -C "client hello, adding alpn extension" \
2256 -S "found alpn extension" \
2257 -C "got an alert message, type: \\[2:120]" \
2258 -S "server hello, adding alpn extension" \
2259 -C "found alpn extension " \
2260 -C "Application Layer Protocol is" \
2261 -S "Application Layer Protocol is"
2262
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002263run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002264 "$P_SRV debug_level=3" \
2265 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002266 0 \
2267 -c "client hello, adding alpn extension" \
2268 -s "found alpn extension" \
2269 -C "got an alert message, type: \\[2:120]" \
2270 -S "server hello, adding alpn extension" \
2271 -C "found alpn extension " \
2272 -c "Application Layer Protocol is (none)" \
2273 -S "Application Layer Protocol is"
2274
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002275run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002276 "$P_SRV debug_level=3 alpn=abc,1234" \
2277 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002278 0 \
2279 -C "client hello, adding alpn extension" \
2280 -S "found alpn extension" \
2281 -C "got an alert message, type: \\[2:120]" \
2282 -S "server hello, adding alpn extension" \
2283 -C "found alpn extension " \
2284 -C "Application Layer Protocol is" \
2285 -s "Application Layer Protocol is (none)"
2286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002287run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002288 "$P_SRV debug_level=3 alpn=abc,1234" \
2289 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002290 0 \
2291 -c "client hello, adding alpn extension" \
2292 -s "found alpn extension" \
2293 -C "got an alert message, type: \\[2:120]" \
2294 -s "server hello, adding alpn extension" \
2295 -c "found alpn extension" \
2296 -c "Application Layer Protocol is abc" \
2297 -s "Application Layer Protocol is abc"
2298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002299run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002300 "$P_SRV debug_level=3 alpn=abc,1234" \
2301 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002302 0 \
2303 -c "client hello, adding alpn extension" \
2304 -s "found alpn extension" \
2305 -C "got an alert message, type: \\[2:120]" \
2306 -s "server hello, adding alpn extension" \
2307 -c "found alpn extension" \
2308 -c "Application Layer Protocol is abc" \
2309 -s "Application Layer Protocol is abc"
2310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002311run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002312 "$P_SRV debug_level=3 alpn=abc,1234" \
2313 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002314 0 \
2315 -c "client hello, adding alpn extension" \
2316 -s "found alpn extension" \
2317 -C "got an alert message, type: \\[2:120]" \
2318 -s "server hello, adding alpn extension" \
2319 -c "found alpn extension" \
2320 -c "Application Layer Protocol is 1234" \
2321 -s "Application Layer Protocol is 1234"
2322
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002323run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002324 "$P_SRV debug_level=3 alpn=abc,123" \
2325 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002326 1 \
2327 -c "client hello, adding alpn extension" \
2328 -s "found alpn extension" \
2329 -c "got an alert message, type: \\[2:120]" \
2330 -S "server hello, adding alpn extension" \
2331 -C "found alpn extension" \
2332 -C "Application Layer Protocol is 1234" \
2333 -S "Application Layer Protocol is 1234"
2334
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002335
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002336# Tests for keyUsage in leaf certificates, part 1:
2337# server-side certificate/suite selection
2338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002339run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002340 "$P_SRV key_file=data_files/server2.key \
2341 crt_file=data_files/server2.ku-ds.crt" \
2342 "$P_CLI" \
2343 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002344 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002345
2346
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002347run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002348 "$P_SRV key_file=data_files/server2.key \
2349 crt_file=data_files/server2.ku-ke.crt" \
2350 "$P_CLI" \
2351 0 \
2352 -c "Ciphersuite is TLS-RSA-WITH-"
2353
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002354run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002355 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002356 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002357 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002358 1 \
2359 -C "Ciphersuite is "
2360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002361run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002362 "$P_SRV key_file=data_files/server5.key \
2363 crt_file=data_files/server5.ku-ds.crt" \
2364 "$P_CLI" \
2365 0 \
2366 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2367
2368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002369run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002370 "$P_SRV key_file=data_files/server5.key \
2371 crt_file=data_files/server5.ku-ka.crt" \
2372 "$P_CLI" \
2373 0 \
2374 -c "Ciphersuite is TLS-ECDH-"
2375
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002376run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002377 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002378 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002379 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002380 1 \
2381 -C "Ciphersuite is "
2382
2383# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002384# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002385
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002386run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002387 "$O_SRV -key data_files/server2.key \
2388 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002389 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002390 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2391 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002392 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002393 -C "Processing of the Certificate handshake message failed" \
2394 -c "Ciphersuite is TLS-"
2395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002396run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002397 "$O_SRV -key data_files/server2.key \
2398 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002399 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002400 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2401 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002402 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002403 -C "Processing of the Certificate handshake message failed" \
2404 -c "Ciphersuite is TLS-"
2405
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002406run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002407 "$O_SRV -key data_files/server2.key \
2408 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002409 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002410 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2411 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002412 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002413 -C "Processing of the Certificate handshake message failed" \
2414 -c "Ciphersuite is TLS-"
2415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002416run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002417 "$O_SRV -key data_files/server2.key \
2418 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002419 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002420 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2421 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002422 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002423 -c "Processing of the Certificate handshake message failed" \
2424 -C "Ciphersuite is TLS-"
2425
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002426run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2427 "$O_SRV -key data_files/server2.key \
2428 -cert data_files/server2.ku-ke.crt" \
2429 "$P_CLI debug_level=1 auth_mode=optional \
2430 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2431 0 \
2432 -c "bad certificate (usage extensions)" \
2433 -C "Processing of the Certificate handshake message failed" \
2434 -c "Ciphersuite is TLS-" \
2435 -c "! Usage does not match the keyUsage extension"
2436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002437run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002438 "$O_SRV -key data_files/server2.key \
2439 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002440 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002441 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2442 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002443 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002444 -C "Processing of the Certificate handshake message failed" \
2445 -c "Ciphersuite is TLS-"
2446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002447run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002448 "$O_SRV -key data_files/server2.key \
2449 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002450 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002451 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2452 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002453 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002454 -c "Processing of the Certificate handshake message failed" \
2455 -C "Ciphersuite is TLS-"
2456
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002457run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2458 "$O_SRV -key data_files/server2.key \
2459 -cert data_files/server2.ku-ds.crt" \
2460 "$P_CLI debug_level=1 auth_mode=optional \
2461 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2462 0 \
2463 -c "bad certificate (usage extensions)" \
2464 -C "Processing of the Certificate handshake message failed" \
2465 -c "Ciphersuite is TLS-" \
2466 -c "! Usage does not match the keyUsage extension"
2467
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002468# Tests for keyUsage in leaf certificates, part 3:
2469# server-side checking of client cert
2470
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002471run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002472 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002473 "$O_CLI -key data_files/server2.key \
2474 -cert data_files/server2.ku-ds.crt" \
2475 0 \
2476 -S "bad certificate (usage extensions)" \
2477 -S "Processing of the Certificate handshake message failed"
2478
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002479run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002480 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002481 "$O_CLI -key data_files/server2.key \
2482 -cert data_files/server2.ku-ke.crt" \
2483 0 \
2484 -s "bad certificate (usage extensions)" \
2485 -S "Processing of the Certificate handshake message failed"
2486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002487run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002488 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002489 "$O_CLI -key data_files/server2.key \
2490 -cert data_files/server2.ku-ke.crt" \
2491 1 \
2492 -s "bad certificate (usage extensions)" \
2493 -s "Processing of the Certificate handshake message failed"
2494
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002495run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002496 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002497 "$O_CLI -key data_files/server5.key \
2498 -cert data_files/server5.ku-ds.crt" \
2499 0 \
2500 -S "bad certificate (usage extensions)" \
2501 -S "Processing of the Certificate handshake message failed"
2502
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002503run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002504 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002505 "$O_CLI -key data_files/server5.key \
2506 -cert data_files/server5.ku-ka.crt" \
2507 0 \
2508 -s "bad certificate (usage extensions)" \
2509 -S "Processing of the Certificate handshake message failed"
2510
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002511# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2512
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002513run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002514 "$P_SRV key_file=data_files/server5.key \
2515 crt_file=data_files/server5.eku-srv.crt" \
2516 "$P_CLI" \
2517 0
2518
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002519run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002520 "$P_SRV key_file=data_files/server5.key \
2521 crt_file=data_files/server5.eku-srv.crt" \
2522 "$P_CLI" \
2523 0
2524
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002525run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002526 "$P_SRV key_file=data_files/server5.key \
2527 crt_file=data_files/server5.eku-cs_any.crt" \
2528 "$P_CLI" \
2529 0
2530
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002531run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002532 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002533 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002534 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002535 1
2536
2537# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2538
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002539run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002540 "$O_SRV -key data_files/server5.key \
2541 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002542 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002543 0 \
2544 -C "bad certificate (usage extensions)" \
2545 -C "Processing of the Certificate handshake message failed" \
2546 -c "Ciphersuite is TLS-"
2547
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002548run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002549 "$O_SRV -key data_files/server5.key \
2550 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002551 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002552 0 \
2553 -C "bad certificate (usage extensions)" \
2554 -C "Processing of the Certificate handshake message failed" \
2555 -c "Ciphersuite is TLS-"
2556
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002557run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002558 "$O_SRV -key data_files/server5.key \
2559 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002560 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002561 0 \
2562 -C "bad certificate (usage extensions)" \
2563 -C "Processing of the Certificate handshake message failed" \
2564 -c "Ciphersuite is TLS-"
2565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002566run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002567 "$O_SRV -key data_files/server5.key \
2568 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002569 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002570 1 \
2571 -c "bad certificate (usage extensions)" \
2572 -c "Processing of the Certificate handshake message failed" \
2573 -C "Ciphersuite is TLS-"
2574
2575# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002577run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002578 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002579 "$O_CLI -key data_files/server5.key \
2580 -cert data_files/server5.eku-cli.crt" \
2581 0 \
2582 -S "bad certificate (usage extensions)" \
2583 -S "Processing of the Certificate handshake message failed"
2584
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002585run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002586 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002587 "$O_CLI -key data_files/server5.key \
2588 -cert data_files/server5.eku-srv_cli.crt" \
2589 0 \
2590 -S "bad certificate (usage extensions)" \
2591 -S "Processing of the Certificate handshake message failed"
2592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002593run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002594 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002595 "$O_CLI -key data_files/server5.key \
2596 -cert data_files/server5.eku-cs_any.crt" \
2597 0 \
2598 -S "bad certificate (usage extensions)" \
2599 -S "Processing of the Certificate handshake message failed"
2600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002601run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002602 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002603 "$O_CLI -key data_files/server5.key \
2604 -cert data_files/server5.eku-cs.crt" \
2605 0 \
2606 -s "bad certificate (usage extensions)" \
2607 -S "Processing of the Certificate handshake message failed"
2608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002609run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002610 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002611 "$O_CLI -key data_files/server5.key \
2612 -cert data_files/server5.eku-cs.crt" \
2613 1 \
2614 -s "bad certificate (usage extensions)" \
2615 -s "Processing of the Certificate handshake message failed"
2616
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002617# Tests for DHM parameters loading
2618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002619run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002620 "$P_SRV" \
2621 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2622 debug_level=3" \
2623 0 \
2624 -c "value of 'DHM: P ' (2048 bits)" \
2625 -c "value of 'DHM: G ' (2048 bits)"
2626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002627run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002628 "$P_SRV dhm_file=data_files/dhparams.pem" \
2629 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2630 debug_level=3" \
2631 0 \
2632 -c "value of 'DHM: P ' (1024 bits)" \
2633 -c "value of 'DHM: G ' (2 bits)"
2634
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002635# Tests for DHM client-side size checking
2636
2637run_test "DHM size: server default, client default, OK" \
2638 "$P_SRV" \
2639 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2640 debug_level=1" \
2641 0 \
2642 -C "DHM prime too short:"
2643
2644run_test "DHM size: server default, client 2048, OK" \
2645 "$P_SRV" \
2646 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2647 debug_level=1 dhmlen=2048" \
2648 0 \
2649 -C "DHM prime too short:"
2650
2651run_test "DHM size: server 1024, client default, OK" \
2652 "$P_SRV dhm_file=data_files/dhparams.pem" \
2653 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2654 debug_level=1" \
2655 0 \
2656 -C "DHM prime too short:"
2657
2658run_test "DHM size: server 1000, client default, rejected" \
2659 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2660 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2661 debug_level=1" \
2662 1 \
2663 -c "DHM prime too short:"
2664
2665run_test "DHM size: server default, client 2049, rejected" \
2666 "$P_SRV" \
2667 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2668 debug_level=1 dhmlen=2049" \
2669 1 \
2670 -c "DHM prime too short:"
2671
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002672# Tests for PSK callback
2673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002674run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002675 "$P_SRV psk=abc123 psk_identity=foo" \
2676 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2677 psk_identity=foo psk=abc123" \
2678 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002679 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002680 -S "SSL - Unknown identity received" \
2681 -S "SSL - Verification of the message MAC failed"
2682
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002683run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002684 "$P_SRV" \
2685 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2686 psk_identity=foo psk=abc123" \
2687 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002688 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002689 -S "SSL - Unknown identity received" \
2690 -S "SSL - Verification of the message MAC failed"
2691
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002692run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002693 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2694 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2695 psk_identity=foo psk=abc123" \
2696 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002697 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002698 -s "SSL - Unknown identity received" \
2699 -S "SSL - Verification of the message MAC failed"
2700
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002701run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002702 "$P_SRV psk_list=abc,dead,def,beef" \
2703 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2704 psk_identity=abc psk=dead" \
2705 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002706 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002707 -S "SSL - Unknown identity received" \
2708 -S "SSL - Verification of the message MAC failed"
2709
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002710run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002711 "$P_SRV psk_list=abc,dead,def,beef" \
2712 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2713 psk_identity=def psk=beef" \
2714 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002715 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002716 -S "SSL - Unknown identity received" \
2717 -S "SSL - Verification of the message MAC failed"
2718
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002719run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002720 "$P_SRV psk_list=abc,dead,def,beef" \
2721 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2722 psk_identity=ghi psk=beef" \
2723 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002724 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002725 -s "SSL - Unknown identity received" \
2726 -S "SSL - Verification of the message MAC failed"
2727
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002728run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002729 "$P_SRV psk_list=abc,dead,def,beef" \
2730 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2731 psk_identity=abc psk=beef" \
2732 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002733 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002734 -S "SSL - Unknown identity received" \
2735 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002736
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002737# Tests for EC J-PAKE
2738
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002739requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002740run_test "ECJPAKE: client not configured" \
2741 "$P_SRV debug_level=3" \
2742 "$P_CLI debug_level=3" \
2743 0 \
2744 -C "add ciphersuite: c0ff" \
2745 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002746 -S "found ecjpake kkpp extension" \
2747 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002748 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002749 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002750 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002751 -S "None of the common ciphersuites is usable"
2752
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002753requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002754run_test "ECJPAKE: server not configured" \
2755 "$P_SRV debug_level=3" \
2756 "$P_CLI debug_level=3 ecjpake_pw=bla \
2757 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2758 1 \
2759 -c "add ciphersuite: c0ff" \
2760 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002761 -s "found ecjpake kkpp extension" \
2762 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002763 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002764 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002765 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002766 -s "None of the common ciphersuites is usable"
2767
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002768requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002769run_test "ECJPAKE: working, TLS" \
2770 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2771 "$P_CLI debug_level=3 ecjpake_pw=bla \
2772 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002773 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002774 -c "add ciphersuite: c0ff" \
2775 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002776 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002777 -s "found ecjpake kkpp extension" \
2778 -S "skip ecjpake kkpp extension" \
2779 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002780 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002781 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002782 -S "None of the common ciphersuites is usable" \
2783 -S "SSL - Verification of the message MAC failed"
2784
Janos Follath74537a62016-09-02 13:45:28 +01002785server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002786requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002787run_test "ECJPAKE: password mismatch, TLS" \
2788 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2789 "$P_CLI debug_level=3 ecjpake_pw=bad \
2790 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2791 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002792 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002793 -s "SSL - Verification of the message MAC failed"
2794
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002795requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002796run_test "ECJPAKE: working, DTLS" \
2797 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2798 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2799 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2800 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002801 -c "re-using cached ecjpake parameters" \
2802 -S "SSL - Verification of the message MAC failed"
2803
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002804requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002805run_test "ECJPAKE: working, DTLS, no cookie" \
2806 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2807 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2808 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2809 0 \
2810 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002811 -S "SSL - Verification of the message MAC failed"
2812
Janos Follath74537a62016-09-02 13:45:28 +01002813server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002814requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002815run_test "ECJPAKE: password mismatch, DTLS" \
2816 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2817 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2818 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2819 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002820 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002821 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002822
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002823# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002824requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002825run_test "ECJPAKE: working, DTLS, nolog" \
2826 "$P_SRV dtls=1 ecjpake_pw=bla" \
2827 "$P_CLI dtls=1 ecjpake_pw=bla \
2828 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2829 0
2830
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002831# Tests for ciphersuites per version
2832
Janos Follathe2681a42016-03-07 15:57:05 +00002833requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002834run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002835 "$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 +02002836 "$P_CLI force_version=ssl3" \
2837 0 \
2838 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2839
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002840run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002841 "$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 +01002842 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002843 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002844 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002846run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002847 "$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 +02002848 "$P_CLI force_version=tls1_1" \
2849 0 \
2850 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002852run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002853 "$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 +02002854 "$P_CLI force_version=tls1_2" \
2855 0 \
2856 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2857
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002858# Test for ClientHello without extensions
2859
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002860requires_gnutls
2861run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002862 "$P_SRV debug_level=3" \
2863 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2864 0 \
2865 -s "dumping 'client hello extensions' (0 bytes)"
2866
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002867# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002868
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002869run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002870 "$P_SRV" \
2871 "$P_CLI request_size=100" \
2872 0 \
2873 -s "Read from client: 100 bytes read$"
2874
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002875run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002876 "$P_SRV" \
2877 "$P_CLI request_size=500" \
2878 0 \
2879 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002880
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002881# Tests for small packets
2882
Janos Follathe2681a42016-03-07 15:57:05 +00002883requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002884run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002885 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002886 "$P_CLI request_size=1 force_version=ssl3 \
2887 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2888 0 \
2889 -s "Read from client: 1 bytes read"
2890
Janos Follathe2681a42016-03-07 15:57:05 +00002891requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002892run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002893 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002894 "$P_CLI request_size=1 force_version=ssl3 \
2895 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2896 0 \
2897 -s "Read from client: 1 bytes read"
2898
2899run_test "Small packet TLS 1.0 BlockCipher" \
2900 "$P_SRV" \
2901 "$P_CLI request_size=1 force_version=tls1 \
2902 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2903 0 \
2904 -s "Read from client: 1 bytes read"
2905
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002906run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2907 "$P_SRV" \
2908 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2909 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2910 0 \
2911 -s "Read from client: 1 bytes read"
2912
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002913run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2914 "$P_SRV" \
2915 "$P_CLI request_size=1 force_version=tls1 \
2916 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2917 trunc_hmac=1" \
2918 0 \
2919 -s "Read from client: 1 bytes read"
2920
2921run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002922 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002923 "$P_CLI request_size=1 force_version=tls1 \
2924 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2925 trunc_hmac=1" \
2926 0 \
2927 -s "Read from client: 1 bytes read"
2928
2929run_test "Small packet TLS 1.1 BlockCipher" \
2930 "$P_SRV" \
2931 "$P_CLI request_size=1 force_version=tls1_1 \
2932 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2933 0 \
2934 -s "Read from client: 1 bytes read"
2935
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002936run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2937 "$P_SRV" \
2938 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2939 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2940 0 \
2941 -s "Read from client: 1 bytes read"
2942
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002943run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002944 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002945 "$P_CLI request_size=1 force_version=tls1_1 \
2946 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2947 0 \
2948 -s "Read from client: 1 bytes read"
2949
2950run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2951 "$P_SRV" \
2952 "$P_CLI request_size=1 force_version=tls1_1 \
2953 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2954 trunc_hmac=1" \
2955 0 \
2956 -s "Read from client: 1 bytes read"
2957
2958run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002959 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002960 "$P_CLI request_size=1 force_version=tls1_1 \
2961 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2962 trunc_hmac=1" \
2963 0 \
2964 -s "Read from client: 1 bytes read"
2965
2966run_test "Small packet TLS 1.2 BlockCipher" \
2967 "$P_SRV" \
2968 "$P_CLI request_size=1 force_version=tls1_2 \
2969 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2970 0 \
2971 -s "Read from client: 1 bytes read"
2972
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002973run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2974 "$P_SRV" \
2975 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2976 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2977 0 \
2978 -s "Read from client: 1 bytes read"
2979
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002980run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2981 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002982 "$P_CLI request_size=1 force_version=tls1_2 \
2983 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002984 0 \
2985 -s "Read from client: 1 bytes read"
2986
2987run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2988 "$P_SRV" \
2989 "$P_CLI request_size=1 force_version=tls1_2 \
2990 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2991 trunc_hmac=1" \
2992 0 \
2993 -s "Read from client: 1 bytes read"
2994
2995run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002996 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002997 "$P_CLI request_size=1 force_version=tls1_2 \
2998 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2999 0 \
3000 -s "Read from client: 1 bytes read"
3001
3002run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003003 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003004 "$P_CLI request_size=1 force_version=tls1_2 \
3005 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3006 trunc_hmac=1" \
3007 0 \
3008 -s "Read from client: 1 bytes read"
3009
3010run_test "Small packet TLS 1.2 AEAD" \
3011 "$P_SRV" \
3012 "$P_CLI request_size=1 force_version=tls1_2 \
3013 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3014 0 \
3015 -s "Read from client: 1 bytes read"
3016
3017run_test "Small packet TLS 1.2 AEAD shorter tag" \
3018 "$P_SRV" \
3019 "$P_CLI request_size=1 force_version=tls1_2 \
3020 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3021 0 \
3022 -s "Read from client: 1 bytes read"
3023
Janos Follath00efff72016-05-06 13:48:23 +01003024# A test for extensions in SSLv3
3025
3026requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3027run_test "SSLv3 with extensions, server side" \
3028 "$P_SRV min_version=ssl3 debug_level=3" \
3029 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3030 0 \
3031 -S "dumping 'client hello extensions'" \
3032 -S "server hello, total extension length:"
3033
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003034# Test for large packets
3035
Janos Follathe2681a42016-03-07 15:57:05 +00003036requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003037run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003038 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003039 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003040 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3041 0 \
3042 -s "Read from client: 16384 bytes read"
3043
Janos Follathe2681a42016-03-07 15:57:05 +00003044requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003045run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003046 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003047 "$P_CLI request_size=16384 force_version=ssl3 \
3048 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3049 0 \
3050 -s "Read from client: 16384 bytes read"
3051
3052run_test "Large packet TLS 1.0 BlockCipher" \
3053 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003054 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003055 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3056 0 \
3057 -s "Read from client: 16384 bytes read"
3058
3059run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3060 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003061 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003062 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3063 trunc_hmac=1" \
3064 0 \
3065 -s "Read from client: 16384 bytes read"
3066
3067run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003068 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003069 "$P_CLI request_size=16384 force_version=tls1 \
3070 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3071 trunc_hmac=1" \
3072 0 \
3073 -s "Read from client: 16384 bytes read"
3074
3075run_test "Large packet TLS 1.1 BlockCipher" \
3076 "$P_SRV" \
3077 "$P_CLI request_size=16384 force_version=tls1_1 \
3078 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3079 0 \
3080 -s "Read from client: 16384 bytes read"
3081
3082run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003083 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003084 "$P_CLI request_size=16384 force_version=tls1_1 \
3085 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3086 0 \
3087 -s "Read from client: 16384 bytes read"
3088
3089run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3090 "$P_SRV" \
3091 "$P_CLI request_size=16384 force_version=tls1_1 \
3092 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3093 trunc_hmac=1" \
3094 0 \
3095 -s "Read from client: 16384 bytes read"
3096
3097run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003098 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003099 "$P_CLI request_size=16384 force_version=tls1_1 \
3100 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3101 trunc_hmac=1" \
3102 0 \
3103 -s "Read from client: 16384 bytes read"
3104
3105run_test "Large packet TLS 1.2 BlockCipher" \
3106 "$P_SRV" \
3107 "$P_CLI request_size=16384 force_version=tls1_2 \
3108 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3109 0 \
3110 -s "Read from client: 16384 bytes read"
3111
3112run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3113 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003114 "$P_CLI request_size=16384 force_version=tls1_2 \
3115 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003116 0 \
3117 -s "Read from client: 16384 bytes read"
3118
3119run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3120 "$P_SRV" \
3121 "$P_CLI request_size=16384 force_version=tls1_2 \
3122 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3123 trunc_hmac=1" \
3124 0 \
3125 -s "Read from client: 16384 bytes read"
3126
3127run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003128 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003129 "$P_CLI request_size=16384 force_version=tls1_2 \
3130 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3131 0 \
3132 -s "Read from client: 16384 bytes read"
3133
3134run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
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é-Gonnard8920f692014-06-18 22:05:08 +02003136 "$P_CLI request_size=16384 force_version=tls1_2 \
3137 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3138 trunc_hmac=1" \
3139 0 \
3140 -s "Read from client: 16384 bytes read"
3141
3142run_test "Large packet TLS 1.2 AEAD" \
3143 "$P_SRV" \
3144 "$P_CLI request_size=16384 force_version=tls1_2 \
3145 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3146 0 \
3147 -s "Read from client: 16384 bytes read"
3148
3149run_test "Large packet TLS 1.2 AEAD shorter tag" \
3150 "$P_SRV" \
3151 "$P_CLI request_size=16384 force_version=tls1_2 \
3152 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3153 0 \
3154 -s "Read from client: 16384 bytes read"
3155
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003156# Tests for DTLS HelloVerifyRequest
3157
3158run_test "DTLS cookie: enabled" \
3159 "$P_SRV dtls=1 debug_level=2" \
3160 "$P_CLI dtls=1 debug_level=2" \
3161 0 \
3162 -s "cookie verification failed" \
3163 -s "cookie verification passed" \
3164 -S "cookie verification skipped" \
3165 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003166 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003167 -S "SSL - The requested feature is not available"
3168
3169run_test "DTLS cookie: disabled" \
3170 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3171 "$P_CLI dtls=1 debug_level=2" \
3172 0 \
3173 -S "cookie verification failed" \
3174 -S "cookie verification passed" \
3175 -s "cookie verification skipped" \
3176 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003177 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003178 -S "SSL - The requested feature is not available"
3179
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003180run_test "DTLS cookie: default (failing)" \
3181 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3182 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3183 1 \
3184 -s "cookie verification failed" \
3185 -S "cookie verification passed" \
3186 -S "cookie verification skipped" \
3187 -C "received hello verify request" \
3188 -S "hello verification requested" \
3189 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003190
3191requires_ipv6
3192run_test "DTLS cookie: enabled, IPv6" \
3193 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3194 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3195 0 \
3196 -s "cookie verification failed" \
3197 -s "cookie verification passed" \
3198 -S "cookie verification skipped" \
3199 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003200 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003201 -S "SSL - The requested feature is not available"
3202
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003203run_test "DTLS cookie: enabled, nbio" \
3204 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3205 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3206 0 \
3207 -s "cookie verification failed" \
3208 -s "cookie verification passed" \
3209 -S "cookie verification skipped" \
3210 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003211 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003212 -S "SSL - The requested feature is not available"
3213
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003214# Tests for client reconnecting from the same port with DTLS
3215
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003216not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003217run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003218 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3219 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003220 0 \
3221 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003222 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003223 -S "Client initiated reconnection from same port"
3224
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003225not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003226run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003227 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3228 "$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 +02003229 0 \
3230 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003231 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003232 -s "Client initiated reconnection from same port"
3233
Paul Bakker362689d2016-05-13 10:33:25 +01003234not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3235run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003236 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3237 "$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 +02003238 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003239 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003240 -s "Client initiated reconnection from same port"
3241
Paul Bakker362689d2016-05-13 10:33:25 +01003242only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3243run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3244 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3245 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3246 0 \
3247 -S "The operation timed out" \
3248 -s "Client initiated reconnection from same port"
3249
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003250run_test "DTLS client reconnect from same port: no cookies" \
3251 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003252 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3253 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003254 -s "The operation timed out" \
3255 -S "Client initiated reconnection from same port"
3256
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003257# Tests for various cases of client authentication with DTLS
3258# (focused on handshake flows and message parsing)
3259
3260run_test "DTLS client auth: required" \
3261 "$P_SRV dtls=1 auth_mode=required" \
3262 "$P_CLI dtls=1" \
3263 0 \
3264 -s "Verifying peer X.509 certificate... ok"
3265
3266run_test "DTLS client auth: optional, client has no cert" \
3267 "$P_SRV dtls=1 auth_mode=optional" \
3268 "$P_CLI dtls=1 crt_file=none key_file=none" \
3269 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003270 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003271
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003272run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003273 "$P_SRV dtls=1 auth_mode=none" \
3274 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3275 0 \
3276 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003277 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003278
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003279run_test "DTLS wrong PSK: badmac alert" \
3280 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3281 "$P_CLI dtls=1 psk=abc124" \
3282 1 \
3283 -s "SSL - Verification of the message MAC failed" \
3284 -c "SSL - A fatal alert message was received from our peer"
3285
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003286# Tests for receiving fragmented handshake messages with DTLS
3287
3288requires_gnutls
3289run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3290 "$G_SRV -u --mtu 2048 -a" \
3291 "$P_CLI dtls=1 debug_level=2" \
3292 0 \
3293 -C "found fragmented DTLS handshake message" \
3294 -C "error"
3295
3296requires_gnutls
3297run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3298 "$G_SRV -u --mtu 512" \
3299 "$P_CLI dtls=1 debug_level=2" \
3300 0 \
3301 -c "found fragmented DTLS handshake message" \
3302 -C "error"
3303
3304requires_gnutls
3305run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3306 "$G_SRV -u --mtu 128" \
3307 "$P_CLI dtls=1 debug_level=2" \
3308 0 \
3309 -c "found fragmented DTLS handshake message" \
3310 -C "error"
3311
3312requires_gnutls
3313run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3314 "$G_SRV -u --mtu 128" \
3315 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3316 0 \
3317 -c "found fragmented DTLS handshake message" \
3318 -C "error"
3319
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003320requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003321run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3322 "$G_SRV -u --mtu 256" \
3323 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3324 0 \
3325 -c "found fragmented DTLS handshake message" \
3326 -c "client hello, adding renegotiation extension" \
3327 -c "found renegotiation extension" \
3328 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003329 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003330 -C "error" \
3331 -s "Extra-header:"
3332
3333requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003334run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3335 "$G_SRV -u --mtu 256" \
3336 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3337 0 \
3338 -c "found fragmented DTLS handshake message" \
3339 -c "client hello, adding renegotiation extension" \
3340 -c "found renegotiation extension" \
3341 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003342 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003343 -C "error" \
3344 -s "Extra-header:"
3345
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003346run_test "DTLS reassembly: no fragmentation (openssl server)" \
3347 "$O_SRV -dtls1 -mtu 2048" \
3348 "$P_CLI dtls=1 debug_level=2" \
3349 0 \
3350 -C "found fragmented DTLS handshake message" \
3351 -C "error"
3352
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003353run_test "DTLS reassembly: some fragmentation (openssl server)" \
3354 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003355 "$P_CLI dtls=1 debug_level=2" \
3356 0 \
3357 -c "found fragmented DTLS handshake message" \
3358 -C "error"
3359
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003360run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003361 "$O_SRV -dtls1 -mtu 256" \
3362 "$P_CLI dtls=1 debug_level=2" \
3363 0 \
3364 -c "found fragmented DTLS handshake message" \
3365 -C "error"
3366
3367run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3368 "$O_SRV -dtls1 -mtu 256" \
3369 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3370 0 \
3371 -c "found fragmented DTLS handshake message" \
3372 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003373
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003374# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003375
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003376not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003377run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003378 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003379 "$P_SRV dtls=1 debug_level=2" \
3380 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003381 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003382 -C "replayed record" \
3383 -S "replayed record" \
3384 -C "record from another epoch" \
3385 -S "record from another epoch" \
3386 -C "discarding invalid record" \
3387 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003388 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003389 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003390 -c "HTTP/1.0 200 OK"
3391
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003392not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003393run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003394 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003395 "$P_SRV dtls=1 debug_level=2" \
3396 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003397 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003398 -c "replayed record" \
3399 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003400 -c "discarding invalid record" \
3401 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003402 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003403 -s "Extra-header:" \
3404 -c "HTTP/1.0 200 OK"
3405
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003406run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3407 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003408 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3409 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003410 0 \
3411 -c "replayed record" \
3412 -S "replayed record" \
3413 -c "discarding invalid record" \
3414 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003415 -c "resend" \
3416 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003417 -s "Extra-header:" \
3418 -c "HTTP/1.0 200 OK"
3419
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003420run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003421 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003422 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003423 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003424 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003425 -c "discarding invalid record (mac)" \
3426 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003427 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003428 -c "HTTP/1.0 200 OK" \
3429 -S "too many records with bad MAC" \
3430 -S "Verification of the message MAC failed"
3431
3432run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3433 -p "$P_PXY bad_ad=1" \
3434 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3435 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3436 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003437 -C "discarding invalid record (mac)" \
3438 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003439 -S "Extra-header:" \
3440 -C "HTTP/1.0 200 OK" \
3441 -s "too many records with bad MAC" \
3442 -s "Verification of the message MAC failed"
3443
3444run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3445 -p "$P_PXY bad_ad=1" \
3446 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3447 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3448 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003449 -c "discarding invalid record (mac)" \
3450 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003451 -s "Extra-header:" \
3452 -c "HTTP/1.0 200 OK" \
3453 -S "too many records with bad MAC" \
3454 -S "Verification of the message MAC failed"
3455
3456run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3457 -p "$P_PXY bad_ad=1" \
3458 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3459 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3460 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003461 -c "discarding invalid record (mac)" \
3462 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003463 -s "Extra-header:" \
3464 -c "HTTP/1.0 200 OK" \
3465 -s "too many records with bad MAC" \
3466 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003467
3468run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003469 -p "$P_PXY delay_ccs=1" \
3470 "$P_SRV dtls=1 debug_level=1" \
3471 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003472 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003473 -c "record from another epoch" \
3474 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003475 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003476 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003477 -s "Extra-header:" \
3478 -c "HTTP/1.0 200 OK"
3479
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003480# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003481
Janos Follath74537a62016-09-02 13:45:28 +01003482client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003483run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003484 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003485 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3486 psk=abc123" \
3487 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003488 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3489 0 \
3490 -s "Extra-header:" \
3491 -c "HTTP/1.0 200 OK"
3492
Janos Follath74537a62016-09-02 13:45:28 +01003493client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003494run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3495 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003496 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3497 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003498 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3499 0 \
3500 -s "Extra-header:" \
3501 -c "HTTP/1.0 200 OK"
3502
Janos Follath74537a62016-09-02 13:45:28 +01003503client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003504run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3505 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003506 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3507 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003508 0 \
3509 -s "Extra-header:" \
3510 -c "HTTP/1.0 200 OK"
3511
Janos Follath74537a62016-09-02 13:45:28 +01003512client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003513run_test "DTLS proxy: 3d, FS, client auth" \
3514 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003515 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3516 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003517 0 \
3518 -s "Extra-header:" \
3519 -c "HTTP/1.0 200 OK"
3520
Janos Follath74537a62016-09-02 13:45:28 +01003521client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003522run_test "DTLS proxy: 3d, FS, ticket" \
3523 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003524 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3525 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003526 0 \
3527 -s "Extra-header:" \
3528 -c "HTTP/1.0 200 OK"
3529
Janos Follath74537a62016-09-02 13:45:28 +01003530client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003531run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3532 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003533 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3534 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003535 0 \
3536 -s "Extra-header:" \
3537 -c "HTTP/1.0 200 OK"
3538
Janos Follath74537a62016-09-02 13:45:28 +01003539client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003540run_test "DTLS proxy: 3d, max handshake, nbio" \
3541 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003542 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3543 auth_mode=required" \
3544 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003545 0 \
3546 -s "Extra-header:" \
3547 -c "HTTP/1.0 200 OK"
3548
Janos Follath74537a62016-09-02 13:45:28 +01003549client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003550run_test "DTLS proxy: 3d, min handshake, resumption" \
3551 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3552 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3553 psk=abc123 debug_level=3" \
3554 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3555 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3556 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3557 0 \
3558 -s "a session has been resumed" \
3559 -c "a session has been resumed" \
3560 -s "Extra-header:" \
3561 -c "HTTP/1.0 200 OK"
3562
Janos Follath74537a62016-09-02 13:45:28 +01003563client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003564run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3565 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3566 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3567 psk=abc123 debug_level=3 nbio=2" \
3568 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3569 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3570 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3571 0 \
3572 -s "a session has been resumed" \
3573 -c "a session has been resumed" \
3574 -s "Extra-header:" \
3575 -c "HTTP/1.0 200 OK"
3576
Janos Follath74537a62016-09-02 13:45:28 +01003577client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003578run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003579 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003580 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3581 psk=abc123 renegotiation=1 debug_level=2" \
3582 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3583 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003584 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3585 0 \
3586 -c "=> renegotiate" \
3587 -s "=> renegotiate" \
3588 -s "Extra-header:" \
3589 -c "HTTP/1.0 200 OK"
3590
Janos Follath74537a62016-09-02 13:45:28 +01003591client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003592run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3593 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003594 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3595 psk=abc123 renegotiation=1 debug_level=2" \
3596 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3597 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003598 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3599 0 \
3600 -c "=> renegotiate" \
3601 -s "=> renegotiate" \
3602 -s "Extra-header:" \
3603 -c "HTTP/1.0 200 OK"
3604
Janos Follath74537a62016-09-02 13:45:28 +01003605client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003606run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003607 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003608 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003609 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003610 debug_level=2" \
3611 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003612 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003613 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3614 0 \
3615 -c "=> renegotiate" \
3616 -s "=> renegotiate" \
3617 -s "Extra-header:" \
3618 -c "HTTP/1.0 200 OK"
3619
Janos Follath74537a62016-09-02 13:45:28 +01003620client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003621run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003622 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003623 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003624 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003625 debug_level=2 nbio=2" \
3626 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003627 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003628 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3629 0 \
3630 -c "=> renegotiate" \
3631 -s "=> renegotiate" \
3632 -s "Extra-header:" \
3633 -c "HTTP/1.0 200 OK"
3634
Janos Follath74537a62016-09-02 13:45:28 +01003635client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003636not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003637run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003638 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3639 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003640 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003641 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003642 -c "HTTP/1.0 200 OK"
3643
Janos Follath74537a62016-09-02 13:45:28 +01003644client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003645not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003646run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3647 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3648 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003649 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003650 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003651 -c "HTTP/1.0 200 OK"
3652
Janos Follath74537a62016-09-02 13:45:28 +01003653client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003654not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003655run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3656 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3657 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003658 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003659 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003660 -c "HTTP/1.0 200 OK"
3661
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003662requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003663client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003664not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003665run_test "DTLS proxy: 3d, gnutls server" \
3666 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3667 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003668 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003669 0 \
3670 -s "Extra-header:" \
3671 -c "Extra-header:"
3672
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003673requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003674client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003675not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003676run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3677 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3678 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003679 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003680 0 \
3681 -s "Extra-header:" \
3682 -c "Extra-header:"
3683
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003684requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003685client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003686not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003687run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3688 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3689 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003690 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003691 0 \
3692 -s "Extra-header:" \
3693 -c "Extra-header:"
3694
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003695# Final report
3696
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003697echo "------------------------------------------------------------------------"
3698
3699if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003700 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003701else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003702 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003703fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003704PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003705echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003706
3707exit $FAILS