blob: 0f07982369d2078970f4a00a354bde3540ca7ac8 [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}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010031
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020032O_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 +010033O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020034G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010035G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010036
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010037TESTS=0
38FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020039SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010040
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000041CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020042
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010043MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010044FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020045EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010046
Paul Bakkere20310a2016-05-10 11:18:17 +010047SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010048RUN_TEST_NUMBER=''
49
Paul Bakkeracaac852016-05-10 11:47:13 +010050PRESERVE_LOGS=0
51
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052print_usage() {
53 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010054 printf " -h|--help\tPrint this help.\n"
55 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
56 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
57 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010058 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010059 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010060 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Andres AGf04f54d2016-10-10 15:46:20 +010061 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062}
63
64get_options() {
65 while [ $# -gt 0 ]; do
66 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010067 -f|--filter)
68 shift; FILTER=$1
69 ;;
70 -e|--exclude)
71 shift; EXCLUDE=$1
72 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010073 -m|--memcheck)
74 MEMCHECK=1
75 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010076 -n|--number)
77 shift; RUN_TEST_NUMBER=$1
78 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010079 -s|--show-numbers)
80 SHOW_TEST_NUMBER=1
81 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010082 -p|--preserve-logs)
83 PRESERVE_LOGS=1
84 ;;
Andres AGf04f54d2016-10-10 15:46:20 +010085 --seed)
86 shift; SEED="$1"
87 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010088 -h|--help)
89 print_usage
90 exit 0
91 ;;
92 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020093 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010094 print_usage
95 exit 1
96 ;;
97 esac
98 shift
99 done
100}
101
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100102# skip next test if the flag is not enabled in config.h
103requires_config_enabled() {
104 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
105 SKIP_NEXT="YES"
106 fi
107}
108
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200109# skip next test if OpenSSL doesn't support FALLBACK_SCSV
110requires_openssl_with_fallback_scsv() {
111 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
112 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
113 then
114 OPENSSL_HAS_FBSCSV="YES"
115 else
116 OPENSSL_HAS_FBSCSV="NO"
117 fi
118 fi
119 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
120 SKIP_NEXT="YES"
121 fi
122}
123
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200124# skip next test if GnuTLS isn't available
125requires_gnutls() {
126 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200127 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200128 GNUTLS_AVAILABLE="YES"
129 else
130 GNUTLS_AVAILABLE="NO"
131 fi
132 fi
133 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
134 SKIP_NEXT="YES"
135 fi
136}
137
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200138# skip next test if IPv6 isn't available on this host
139requires_ipv6() {
140 if [ -z "${HAS_IPV6:-}" ]; then
141 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
142 SRV_PID=$!
143 sleep 1
144 kill $SRV_PID >/dev/null 2>&1
145 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
146 HAS_IPV6="NO"
147 else
148 HAS_IPV6="YES"
149 fi
150 rm -r $SRV_OUT
151 fi
152
153 if [ "$HAS_IPV6" = "NO" ]; then
154 SKIP_NEXT="YES"
155 fi
156}
157
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200158# skip the next test if valgrind is in use
159not_with_valgrind() {
160 if [ "$MEMCHECK" -gt 0 ]; then
161 SKIP_NEXT="YES"
162 fi
163}
164
Paul Bakker362689d2016-05-13 10:33:25 +0100165# skip the next test if valgrind is NOT in use
166only_with_valgrind() {
167 if [ "$MEMCHECK" -eq 0 ]; then
168 SKIP_NEXT="YES"
169 fi
170}
171
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200172# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100173client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200174 CLI_DELAY_FACTOR=$1
175}
176
Janos Follath74537a62016-09-02 13:45:28 +0100177# wait for the given seconds after the client finished in the next test
178server_needs_more_time() {
179 SRV_DELAY_SECONDS=$1
180}
181
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100182# print_name <name>
183print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100184 TESTS=$(( $TESTS + 1 ))
185 LINE=""
186
187 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
188 LINE="$TESTS "
189 fi
190
191 LINE="$LINE$1"
192 printf "$LINE "
193 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100194 for i in `seq 1 $LEN`; do printf '.'; done
195 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100196
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100197}
198
199# fail <message>
200fail() {
201 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100202 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100203
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200204 mv $SRV_OUT o-srv-${TESTS}.log
205 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200206 if [ -n "$PXY_CMD" ]; then
207 mv $PXY_OUT o-pxy-${TESTS}.log
208 fi
209 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100210
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200211 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
212 echo " ! server output:"
213 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200214 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200215 echo " ! client output:"
216 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200217 if [ -n "$PXY_CMD" ]; then
218 echo " ! ========================================================"
219 echo " ! proxy output:"
220 cat o-pxy-${TESTS}.log
221 fi
222 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200223 fi
224
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200225 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100226}
227
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100228# is_polar <cmd_line>
229is_polar() {
230 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
231}
232
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200233# openssl s_server doesn't have -www with DTLS
234check_osrv_dtls() {
235 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
236 NEEDS_INPUT=1
237 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
238 else
239 NEEDS_INPUT=0
240 fi
241}
242
243# provide input to commands that need it
244provide_input() {
245 if [ $NEEDS_INPUT -eq 0 ]; then
246 return
247 fi
248
249 while true; do
250 echo "HTTP/1.0 200 OK"
251 sleep 1
252 done
253}
254
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100255# has_mem_err <log_file_name>
256has_mem_err() {
257 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
258 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
259 then
260 return 1 # false: does not have errors
261 else
262 return 0 # true: has errors
263 fi
264}
265
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200266# wait for server to start: two versions depending on lsof availability
267wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200268 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200269 START_TIME=$( date +%s )
270 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200271
272 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200273 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200274 while [ $DONE -eq 0 ]; do
275 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
276 then
277 DONE=1
278 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
279 echo "SERVERSTART TIMEOUT"
280 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
281 DONE=1
282 fi
283 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200284 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200285 while [ $DONE -eq 0 ]; do
286 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
287 then
288 DONE=1
289 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
290 echo "SERVERSTART TIMEOUT"
291 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
292 DONE=1
293 fi
294 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200295 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200296 else
297 sleep "$START_DELAY"
298 fi
299}
300
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200301# wait for client to terminate and set CLI_EXIT
302# must be called right after starting the client
303wait_client_done() {
304 CLI_PID=$!
305
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200306 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
307 CLI_DELAY_FACTOR=1
308
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200309 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200310 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200311
312 wait $CLI_PID
313 CLI_EXIT=$?
314
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200315 kill $DOG_PID >/dev/null 2>&1
316 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200317
318 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100319
320 sleep $SRV_DELAY_SECONDS
321 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200322}
323
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200324# check if the given command uses dtls and sets global variable DTLS
325detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200326 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200327 DTLS=1
328 else
329 DTLS=0
330 fi
331}
332
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200333# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100334# Options: -s pattern pattern that must be present in server output
335# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100336# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100337# -S pattern pattern that must be absent in server output
338# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100339# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100340run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100341 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200342 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100343
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100344 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
345 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200346 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100347 return
348 fi
349
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100350 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100351
Paul Bakkerb7584a52016-05-10 10:50:43 +0100352 # Do we only run numbered tests?
353 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
354 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
355 else
356 SKIP_NEXT="YES"
357 fi
358
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200359 # should we skip?
360 if [ "X$SKIP_NEXT" = "XYES" ]; then
361 SKIP_NEXT="NO"
362 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200363 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200364 return
365 fi
366
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200367 # does this test use a proxy?
368 if [ "X$1" = "X-p" ]; then
369 PXY_CMD="$2"
370 shift 2
371 else
372 PXY_CMD=""
373 fi
374
375 # get commands and client output
376 SRV_CMD="$1"
377 CLI_CMD="$2"
378 CLI_EXPECT="$3"
379 shift 3
380
381 # fix client port
382 if [ -n "$PXY_CMD" ]; then
383 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
384 else
385 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
386 fi
387
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200388 # update DTLS variable
389 detect_dtls "$SRV_CMD"
390
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100391 # prepend valgrind to our commands if active
392 if [ "$MEMCHECK" -gt 0 ]; then
393 if is_polar "$SRV_CMD"; then
394 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
395 fi
396 if is_polar "$CLI_CMD"; then
397 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
398 fi
399 fi
400
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200401 TIMES_LEFT=2
402 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200403 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200404
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200405 # run the commands
406 if [ -n "$PXY_CMD" ]; then
407 echo "$PXY_CMD" > $PXY_OUT
408 $PXY_CMD >> $PXY_OUT 2>&1 &
409 PXY_PID=$!
410 # assume proxy starts faster than server
411 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200412
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200413 check_osrv_dtls
414 echo "$SRV_CMD" > $SRV_OUT
415 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
416 SRV_PID=$!
417 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200418
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200419 echo "$CLI_CMD" > $CLI_OUT
420 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
421 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100422
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200423 # terminate the server (and the proxy)
424 kill $SRV_PID
425 wait $SRV_PID
426 if [ -n "$PXY_CMD" ]; then
427 kill $PXY_PID >/dev/null 2>&1
428 wait $PXY_PID
429 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100430
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200431 # retry only on timeouts
432 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
433 printf "RETRY "
434 else
435 TIMES_LEFT=0
436 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200437 done
438
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100439 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200440 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100441 # expected client exit to incorrectly succeed in case of catastrophic
442 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100443 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200444 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100445 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100446 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100447 return
448 fi
449 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100450 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200451 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100452 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100453 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100454 return
455 fi
456 fi
457
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100458 # check server exit code
459 if [ $? != 0 ]; then
460 fail "server fail"
461 return
462 fi
463
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100464 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100465 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
466 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100467 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200468 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100469 return
470 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100471
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100472 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200473 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100474 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100475 while [ $# -gt 0 ]
476 do
477 case $1 in
478 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100479 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 +0100480 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100481 return
482 fi
483 ;;
484
485 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100486 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 +0100487 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100488 return
489 fi
490 ;;
491
492 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100493 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 +0100494 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100495 return
496 fi
497 ;;
498
499 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100500 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 +0100501 fail "pattern '$2' MUST NOT be present in the Client output"
502 return
503 fi
504 ;;
505
506 # The filtering in the following two options (-u and -U) do the following
507 # - ignore valgrind output
508 # - filter out everything but lines right after the pattern occurances
509 # - keep one of each non-unique line
510 # - count how many lines remain
511 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
512 # if there were no duplicates.
513 "-U")
514 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
515 fail "lines following pattern '$2' must be unique in Server output"
516 return
517 fi
518 ;;
519
520 "-u")
521 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
522 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100523 return
524 fi
525 ;;
526
527 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200528 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100529 exit 1
530 esac
531 shift 2
532 done
533
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100534 # check valgrind's results
535 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200536 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100537 fail "Server has memory errors"
538 return
539 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200540 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100541 fail "Client has memory errors"
542 return
543 fi
544 fi
545
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100546 # if we're here, everything is ok
547 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100548 if [ "$PRESERVE_LOGS" -gt 0 ]; then
549 mv $SRV_OUT o-srv-${TESTS}.log
550 mv $CLI_OUT o-cli-${TESTS}.log
551 fi
552
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200553 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100554}
555
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100556cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200557 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200558 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
559 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
560 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
561 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100562 exit 1
563}
564
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100565#
566# MAIN
567#
568
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000569if cd $( dirname $0 ); then :; else
570 echo "cd $( dirname $0 ) failed" >&2
571 exit 1
572fi
573
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100574get_options "$@"
575
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100576# sanity checks, avoid an avalanche of errors
577if [ ! -x "$P_SRV" ]; then
578 echo "Command '$P_SRV' is not an executable file"
579 exit 1
580fi
581if [ ! -x "$P_CLI" ]; then
582 echo "Command '$P_CLI' is not an executable file"
583 exit 1
584fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200585if [ ! -x "$P_PXY" ]; then
586 echo "Command '$P_PXY' is not an executable file"
587 exit 1
588fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100589if [ "$MEMCHECK" -gt 0 ]; then
590 if which valgrind >/dev/null 2>&1; then :; else
591 echo "Memcheck not possible. Valgrind not found"
592 exit 1
593 fi
594fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100595if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
596 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100597 exit 1
598fi
599
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200600# used by watchdog
601MAIN_PID="$$"
602
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200603# be more patient with valgrind
604if [ "$MEMCHECK" -gt 0 ]; then
605 START_DELAY=3
606 DOG_DELAY=30
607else
608 START_DELAY=1
609 DOG_DELAY=10
610fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200611CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100612SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200613
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200614# Pick a "unique" server port in the range 10000-19999, and a proxy port
615PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000616PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200617SRV_PORT="1$PORT_BASE"
618PXY_PORT="2$PORT_BASE"
619unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200620
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200621# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000622# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200623P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
624P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100625P_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 +0200626O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200627O_CLI="$O_CLI -connect localhost:+SRV_PORT"
628G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000629G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200630
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200631# Also pick a unique name for intermediate files
632SRV_OUT="srv_out.$$"
633CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200634PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200635SESSION="session.$$"
636
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200637SKIP_NEXT="NO"
638
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100639trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100640
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200641# Basic test
642
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200643# Checks that:
644# - things work with all ciphersuites active (used with config-full in all.sh)
645# - the expected (highest security) parameters are selected
646# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200647run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200648 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200649 "$P_CLI" \
650 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200651 -s "Protocol is TLSv1.2" \
652 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
653 -s "client hello v3, signature_algorithm ext: 6" \
654 -s "ECDHE curve: secp521r1" \
655 -S "error" \
656 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200657
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000658run_test "Default, DTLS" \
659 "$P_SRV dtls=1" \
660 "$P_CLI dtls=1" \
661 0 \
662 -s "Protocol is DTLSv1.2" \
663 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
664
Simon Butcher8e004102016-10-14 00:48:33 +0100665# Test for uniqueness of IVs in AEAD ciphersuites
666run_test "Unique IV in GCM" \
667 "$P_SRV exchanges=20 debug_level=4" \
668 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
669 0 \
670 -u "IV used" \
671 -U "IV used"
672
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100673# Tests for rc4 option
674
Simon Butchera410af52016-05-19 22:12:18 +0100675requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100676run_test "RC4: server disabled, client enabled" \
677 "$P_SRV" \
678 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
679 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100680 -s "SSL - The server has no ciphersuites in common"
681
Simon Butchera410af52016-05-19 22:12:18 +0100682requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100683run_test "RC4: server half, client enabled" \
684 "$P_SRV arc4=1" \
685 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
686 1 \
687 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100688
689run_test "RC4: server enabled, client disabled" \
690 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
691 "$P_CLI" \
692 1 \
693 -s "SSL - The server has no ciphersuites in common"
694
695run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100696 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100697 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
698 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100699 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100700 -S "SSL - The server has no ciphersuites in common"
701
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100702# Tests for Truncated HMAC extension
703
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100704run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200705 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100706 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100707 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100708 -s "dumping 'computed mac' (20 bytes)" \
709 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100710
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100711run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200712 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100713 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
714 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100715 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100716 -s "dumping 'computed mac' (20 bytes)" \
717 -S "dumping 'computed mac' (10 bytes)"
718
719run_test "Truncated HMAC: client enabled, server default" \
720 "$P_SRV debug_level=4" \
721 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
722 trunc_hmac=1" \
723 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100724 -s "dumping 'computed mac' (20 bytes)" \
725 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100726
727run_test "Truncated HMAC: client enabled, server disabled" \
728 "$P_SRV debug_level=4 trunc_hmac=0" \
729 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
730 trunc_hmac=1" \
731 0 \
732 -s "dumping 'computed mac' (20 bytes)" \
733 -S "dumping 'computed mac' (10 bytes)"
734
735run_test "Truncated HMAC: client enabled, server enabled" \
736 "$P_SRV debug_level=4 trunc_hmac=1" \
737 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
738 trunc_hmac=1" \
739 0 \
740 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100741 -s "dumping 'computed mac' (10 bytes)"
742
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100743# Tests for Encrypt-then-MAC extension
744
745run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100746 "$P_SRV debug_level=3 \
747 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100748 "$P_CLI debug_level=3" \
749 0 \
750 -c "client hello, adding encrypt_then_mac extension" \
751 -s "found encrypt then mac extension" \
752 -s "server hello, adding encrypt then mac extension" \
753 -c "found encrypt_then_mac extension" \
754 -c "using encrypt then mac" \
755 -s "using encrypt then mac"
756
757run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100758 "$P_SRV debug_level=3 etm=0 \
759 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100760 "$P_CLI debug_level=3 etm=1" \
761 0 \
762 -c "client hello, adding encrypt_then_mac extension" \
763 -s "found encrypt then mac extension" \
764 -S "server hello, adding encrypt then mac extension" \
765 -C "found encrypt_then_mac extension" \
766 -C "using encrypt then mac" \
767 -S "using encrypt then mac"
768
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100769run_test "Encrypt then MAC: client enabled, aead cipher" \
770 "$P_SRV debug_level=3 etm=1 \
771 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
772 "$P_CLI debug_level=3 etm=1" \
773 0 \
774 -c "client hello, adding encrypt_then_mac extension" \
775 -s "found encrypt then mac extension" \
776 -S "server hello, adding encrypt then mac extension" \
777 -C "found encrypt_then_mac extension" \
778 -C "using encrypt then mac" \
779 -S "using encrypt then mac"
780
781run_test "Encrypt then MAC: client enabled, stream cipher" \
782 "$P_SRV debug_level=3 etm=1 \
783 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100784 "$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 +0100785 0 \
786 -c "client hello, adding encrypt_then_mac extension" \
787 -s "found encrypt then mac extension" \
788 -S "server hello, adding encrypt then mac extension" \
789 -C "found encrypt_then_mac extension" \
790 -C "using encrypt then mac" \
791 -S "using encrypt then mac"
792
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100793run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100794 "$P_SRV debug_level=3 etm=1 \
795 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100796 "$P_CLI debug_level=3 etm=0" \
797 0 \
798 -C "client hello, adding encrypt_then_mac extension" \
799 -S "found encrypt then mac extension" \
800 -S "server hello, adding encrypt then mac extension" \
801 -C "found encrypt_then_mac extension" \
802 -C "using encrypt then mac" \
803 -S "using encrypt then mac"
804
Janos Follathe2681a42016-03-07 15:57:05 +0000805requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100806run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100807 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100808 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100809 "$P_CLI debug_level=3 force_version=ssl3" \
810 0 \
811 -C "client hello, adding encrypt_then_mac extension" \
812 -S "found encrypt then mac extension" \
813 -S "server hello, adding encrypt then mac extension" \
814 -C "found encrypt_then_mac extension" \
815 -C "using encrypt then mac" \
816 -S "using encrypt then mac"
817
Janos Follathe2681a42016-03-07 15:57:05 +0000818requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100819run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100820 "$P_SRV debug_level=3 force_version=ssl3 \
821 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100822 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100823 0 \
824 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100825 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100826 -S "server hello, adding encrypt then mac extension" \
827 -C "found encrypt_then_mac extension" \
828 -C "using encrypt then mac" \
829 -S "using encrypt then mac"
830
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200831# Tests for Extended Master Secret extension
832
833run_test "Extended Master Secret: default" \
834 "$P_SRV debug_level=3" \
835 "$P_CLI debug_level=3" \
836 0 \
837 -c "client hello, adding extended_master_secret extension" \
838 -s "found extended master secret extension" \
839 -s "server hello, adding extended master secret extension" \
840 -c "found extended_master_secret extension" \
841 -c "using extended master secret" \
842 -s "using extended master secret"
843
844run_test "Extended Master Secret: client enabled, server disabled" \
845 "$P_SRV debug_level=3 extended_ms=0" \
846 "$P_CLI debug_level=3 extended_ms=1" \
847 0 \
848 -c "client hello, adding extended_master_secret extension" \
849 -s "found extended master secret extension" \
850 -S "server hello, adding extended master secret extension" \
851 -C "found extended_master_secret extension" \
852 -C "using extended master secret" \
853 -S "using extended master secret"
854
855run_test "Extended Master Secret: client disabled, server enabled" \
856 "$P_SRV debug_level=3 extended_ms=1" \
857 "$P_CLI debug_level=3 extended_ms=0" \
858 0 \
859 -C "client hello, adding extended_master_secret extension" \
860 -S "found extended master secret extension" \
861 -S "server hello, adding extended master secret extension" \
862 -C "found extended_master_secret extension" \
863 -C "using extended master secret" \
864 -S "using extended master secret"
865
Janos Follathe2681a42016-03-07 15:57:05 +0000866requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200867run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100868 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200869 "$P_CLI debug_level=3 force_version=ssl3" \
870 0 \
871 -C "client hello, adding extended_master_secret extension" \
872 -S "found extended master secret extension" \
873 -S "server hello, adding extended master secret extension" \
874 -C "found extended_master_secret extension" \
875 -C "using extended master secret" \
876 -S "using extended master secret"
877
Janos Follathe2681a42016-03-07 15:57:05 +0000878requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200879run_test "Extended Master Secret: client enabled, server SSLv3" \
880 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100881 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200882 0 \
883 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100884 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200885 -S "server hello, adding extended master secret extension" \
886 -C "found extended_master_secret extension" \
887 -C "using extended master secret" \
888 -S "using extended master secret"
889
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200890# Tests for FALLBACK_SCSV
891
892run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200893 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200894 "$P_CLI debug_level=3 force_version=tls1_1" \
895 0 \
896 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200897 -S "received FALLBACK_SCSV" \
898 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200899 -C "is a fatal alert message (msg 86)"
900
901run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200902 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200903 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
904 0 \
905 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200906 -S "received FALLBACK_SCSV" \
907 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200908 -C "is a fatal alert message (msg 86)"
909
910run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200911 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200912 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200913 1 \
914 -c "adding FALLBACK_SCSV" \
915 -s "received FALLBACK_SCSV" \
916 -s "inapropriate fallback" \
917 -c "is a fatal alert message (msg 86)"
918
919run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200920 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200921 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200922 0 \
923 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200924 -s "received FALLBACK_SCSV" \
925 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200926 -C "is a fatal alert message (msg 86)"
927
928requires_openssl_with_fallback_scsv
929run_test "Fallback SCSV: default, openssl server" \
930 "$O_SRV" \
931 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
932 0 \
933 -C "adding FALLBACK_SCSV" \
934 -C "is a fatal alert message (msg 86)"
935
936requires_openssl_with_fallback_scsv
937run_test "Fallback SCSV: enabled, openssl server" \
938 "$O_SRV" \
939 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
940 1 \
941 -c "adding FALLBACK_SCSV" \
942 -c "is a fatal alert message (msg 86)"
943
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200944requires_openssl_with_fallback_scsv
945run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200946 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200947 "$O_CLI -tls1_1" \
948 0 \
949 -S "received FALLBACK_SCSV" \
950 -S "inapropriate fallback"
951
952requires_openssl_with_fallback_scsv
953run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200954 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200955 "$O_CLI -tls1_1 -fallback_scsv" \
956 1 \
957 -s "received FALLBACK_SCSV" \
958 -s "inapropriate fallback"
959
960requires_openssl_with_fallback_scsv
961run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200962 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200963 "$O_CLI -fallback_scsv" \
964 0 \
965 -s "received FALLBACK_SCSV" \
966 -S "inapropriate fallback"
967
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100968# Tests for CBC 1/n-1 record splitting
969
970run_test "CBC Record splitting: TLS 1.2, no splitting" \
971 "$P_SRV" \
972 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
973 request_size=123 force_version=tls1_2" \
974 0 \
975 -s "Read from client: 123 bytes read" \
976 -S "Read from client: 1 bytes read" \
977 -S "122 bytes read"
978
979run_test "CBC Record splitting: TLS 1.1, no splitting" \
980 "$P_SRV" \
981 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
982 request_size=123 force_version=tls1_1" \
983 0 \
984 -s "Read from client: 123 bytes read" \
985 -S "Read from client: 1 bytes read" \
986 -S "122 bytes read"
987
988run_test "CBC Record splitting: TLS 1.0, splitting" \
989 "$P_SRV" \
990 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
991 request_size=123 force_version=tls1" \
992 0 \
993 -S "Read from client: 123 bytes read" \
994 -s "Read from client: 1 bytes read" \
995 -s "122 bytes read"
996
Janos Follathe2681a42016-03-07 15:57:05 +0000997requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100998run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100999 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001000 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1001 request_size=123 force_version=ssl3" \
1002 0 \
1003 -S "Read from client: 123 bytes read" \
1004 -s "Read from client: 1 bytes read" \
1005 -s "122 bytes read"
1006
1007run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001008 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001009 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1010 request_size=123 force_version=tls1" \
1011 0 \
1012 -s "Read from client: 123 bytes read" \
1013 -S "Read from client: 1 bytes read" \
1014 -S "122 bytes read"
1015
1016run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1017 "$P_SRV" \
1018 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1019 request_size=123 force_version=tls1 recsplit=0" \
1020 0 \
1021 -s "Read from client: 123 bytes read" \
1022 -S "Read from client: 1 bytes read" \
1023 -S "122 bytes read"
1024
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001025run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1026 "$P_SRV nbio=2" \
1027 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1028 request_size=123 force_version=tls1" \
1029 0 \
1030 -S "Read from client: 123 bytes read" \
1031 -s "Read from client: 1 bytes read" \
1032 -s "122 bytes read"
1033
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001034# Tests for Session Tickets
1035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001036run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001037 "$P_SRV debug_level=3 tickets=1" \
1038 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001039 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001040 -c "client hello, adding session ticket extension" \
1041 -s "found session ticket extension" \
1042 -s "server hello, adding session ticket extension" \
1043 -c "found session_ticket extension" \
1044 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001045 -S "session successfully restored from cache" \
1046 -s "session successfully restored from ticket" \
1047 -s "a session has been resumed" \
1048 -c "a session has been resumed"
1049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001050run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001051 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1052 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001053 0 \
1054 -c "client hello, adding session ticket extension" \
1055 -s "found session ticket extension" \
1056 -s "server hello, adding session ticket extension" \
1057 -c "found session_ticket extension" \
1058 -c "parse new session ticket" \
1059 -S "session successfully restored from cache" \
1060 -s "session successfully restored from ticket" \
1061 -s "a session has been resumed" \
1062 -c "a session has been resumed"
1063
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001064run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001065 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1066 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001067 0 \
1068 -c "client hello, adding session ticket extension" \
1069 -s "found session ticket extension" \
1070 -s "server hello, adding session ticket extension" \
1071 -c "found session_ticket extension" \
1072 -c "parse new session ticket" \
1073 -S "session successfully restored from cache" \
1074 -S "session successfully restored from ticket" \
1075 -S "a session has been resumed" \
1076 -C "a session has been resumed"
1077
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001078run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001079 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001080 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001081 0 \
1082 -c "client hello, adding session ticket extension" \
1083 -c "found session_ticket extension" \
1084 -c "parse new session ticket" \
1085 -c "a session has been resumed"
1086
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001087run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001088 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001089 "( $O_CLI -sess_out $SESSION; \
1090 $O_CLI -sess_in $SESSION; \
1091 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001092 0 \
1093 -s "found session ticket extension" \
1094 -s "server hello, adding session ticket extension" \
1095 -S "session successfully restored from cache" \
1096 -s "session successfully restored from ticket" \
1097 -s "a session has been resumed"
1098
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001099# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001101run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001102 "$P_SRV debug_level=3 tickets=0" \
1103 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001104 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001105 -c "client hello, adding session ticket extension" \
1106 -s "found session ticket extension" \
1107 -S "server hello, adding session ticket extension" \
1108 -C "found session_ticket extension" \
1109 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001110 -s "session successfully restored from cache" \
1111 -S "session successfully restored from ticket" \
1112 -s "a session has been resumed" \
1113 -c "a session has been resumed"
1114
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001115run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001116 "$P_SRV debug_level=3 tickets=1" \
1117 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001118 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001119 -C "client hello, adding session ticket extension" \
1120 -S "found session ticket extension" \
1121 -S "server hello, adding session ticket extension" \
1122 -C "found session_ticket extension" \
1123 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001124 -s "session successfully restored from cache" \
1125 -S "session successfully restored from ticket" \
1126 -s "a session has been resumed" \
1127 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001128
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001129run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001130 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1131 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001132 0 \
1133 -S "session successfully restored from cache" \
1134 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001135 -S "a session has been resumed" \
1136 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001138run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001139 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1140 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001141 0 \
1142 -s "session successfully restored from cache" \
1143 -S "session successfully restored from ticket" \
1144 -s "a session has been resumed" \
1145 -c "a session has been resumed"
1146
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001147run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001148 "$P_SRV debug_level=3 tickets=0" \
1149 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001150 0 \
1151 -s "session successfully restored from cache" \
1152 -S "session successfully restored from ticket" \
1153 -s "a session has been resumed" \
1154 -c "a session has been resumed"
1155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001156run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001157 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1158 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001159 0 \
1160 -S "session successfully restored from cache" \
1161 -S "session successfully restored from ticket" \
1162 -S "a session has been resumed" \
1163 -C "a session has been resumed"
1164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001165run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001166 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1167 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001168 0 \
1169 -s "session successfully restored from cache" \
1170 -S "session successfully restored from ticket" \
1171 -s "a session has been resumed" \
1172 -c "a session has been resumed"
1173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001174run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001175 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001176 "( $O_CLI -sess_out $SESSION; \
1177 $O_CLI -sess_in $SESSION; \
1178 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001179 0 \
1180 -s "found session ticket extension" \
1181 -S "server hello, adding session ticket extension" \
1182 -s "session successfully restored from cache" \
1183 -S "session successfully restored from ticket" \
1184 -s "a session has been resumed"
1185
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001186run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001187 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001188 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001189 0 \
1190 -C "found session_ticket extension" \
1191 -C "parse new session ticket" \
1192 -c "a session has been resumed"
1193
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001194# Tests for Max Fragment Length extension
1195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001196run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001197 "$P_SRV debug_level=3" \
1198 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001199 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001200 -c "Maximum fragment length is 16384" \
1201 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001202 -C "client hello, adding max_fragment_length extension" \
1203 -S "found max fragment length extension" \
1204 -S "server hello, max_fragment_length extension" \
1205 -C "found max_fragment_length extension"
1206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001207run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001208 "$P_SRV debug_level=3" \
1209 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001210 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001211 -c "Maximum fragment length is 4096" \
1212 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001213 -c "client hello, adding max_fragment_length extension" \
1214 -s "found max fragment length extension" \
1215 -s "server hello, max_fragment_length extension" \
1216 -c "found max_fragment_length extension"
1217
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001218run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001219 "$P_SRV debug_level=3 max_frag_len=4096" \
1220 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001221 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001222 -c "Maximum fragment length is 16384" \
1223 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001224 -C "client hello, adding max_fragment_length extension" \
1225 -S "found max fragment length extension" \
1226 -S "server hello, max_fragment_length extension" \
1227 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001229requires_gnutls
1230run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001231 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001232 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001233 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001234 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001235 -c "client hello, adding max_fragment_length extension" \
1236 -c "found max_fragment_length extension"
1237
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001238run_test "Max fragment length: client, message just fits" \
1239 "$P_SRV debug_level=3" \
1240 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1241 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001242 -c "Maximum fragment length is 2048" \
1243 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001244 -c "client hello, adding max_fragment_length extension" \
1245 -s "found max fragment length extension" \
1246 -s "server hello, max_fragment_length extension" \
1247 -c "found max_fragment_length extension" \
1248 -c "2048 bytes written in 1 fragments" \
1249 -s "2048 bytes read"
1250
1251run_test "Max fragment length: client, larger message" \
1252 "$P_SRV debug_level=3" \
1253 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1254 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001255 -c "Maximum fragment length is 2048" \
1256 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001257 -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" \
1261 -c "2345 bytes written in 2 fragments" \
1262 -s "2048 bytes read" \
1263 -s "297 bytes read"
1264
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001265run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001266 "$P_SRV debug_level=3 dtls=1" \
1267 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1268 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001269 -c "Maximum fragment length is 2048" \
1270 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001271 -c "client hello, adding max_fragment_length extension" \
1272 -s "found max fragment length extension" \
1273 -s "server hello, max_fragment_length extension" \
1274 -c "found max_fragment_length extension" \
1275 -c "fragment larger than.*maximum"
1276
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001277# Tests for renegotiation
1278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001279run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001280 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001281 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001282 0 \
1283 -C "client hello, adding renegotiation extension" \
1284 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1285 -S "found renegotiation extension" \
1286 -s "server hello, secure renegotiation extension" \
1287 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001288 -C "=> renegotiate" \
1289 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001290 -S "write hello request"
1291
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001292run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001293 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001294 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001295 0 \
1296 -c "client hello, adding renegotiation extension" \
1297 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1298 -s "found renegotiation extension" \
1299 -s "server hello, secure renegotiation extension" \
1300 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001301 -c "=> renegotiate" \
1302 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001303 -S "write hello request"
1304
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001305run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001306 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001307 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001308 0 \
1309 -c "client hello, adding renegotiation extension" \
1310 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1311 -s "found renegotiation extension" \
1312 -s "server hello, secure renegotiation extension" \
1313 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001314 -c "=> renegotiate" \
1315 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001316 -s "write hello request"
1317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001318run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001319 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001320 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001321 0 \
1322 -c "client hello, adding renegotiation extension" \
1323 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1324 -s "found renegotiation extension" \
1325 -s "server hello, secure renegotiation extension" \
1326 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001327 -c "=> renegotiate" \
1328 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001329 -s "write hello request"
1330
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001331run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001332 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001333 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001334 1 \
1335 -c "client hello, adding renegotiation extension" \
1336 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1337 -S "found renegotiation extension" \
1338 -s "server hello, secure renegotiation extension" \
1339 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001340 -c "=> renegotiate" \
1341 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001342 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001343 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001344 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001346run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001347 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001348 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001349 0 \
1350 -C "client hello, adding renegotiation extension" \
1351 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1352 -S "found renegotiation extension" \
1353 -s "server hello, secure renegotiation extension" \
1354 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001355 -C "=> renegotiate" \
1356 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001357 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001358 -S "SSL - An unexpected message was received from our peer" \
1359 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001361run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001362 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001363 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001364 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001365 0 \
1366 -C "client hello, adding renegotiation extension" \
1367 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1368 -S "found renegotiation extension" \
1369 -s "server hello, secure renegotiation extension" \
1370 -c "found renegotiation extension" \
1371 -C "=> renegotiate" \
1372 -S "=> renegotiate" \
1373 -s "write hello request" \
1374 -S "SSL - An unexpected message was received from our peer" \
1375 -S "failed"
1376
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001377# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001378run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001379 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001380 renego_delay=2 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é-Gonnardfae355e2014-07-04 14:32:27 +02001382 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" \
1388 -C "=> renegotiate" \
1389 -S "=> renegotiate" \
1390 -s "write hello request" \
1391 -S "SSL - An unexpected message was received from our peer" \
1392 -S "failed"
1393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001394run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
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=0 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" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001407 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001408
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001409run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001410 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001411 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001412 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001413 0 \
1414 -c "client hello, adding renegotiation extension" \
1415 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1416 -s "found renegotiation extension" \
1417 -s "server hello, secure renegotiation extension" \
1418 -c "found renegotiation extension" \
1419 -c "=> renegotiate" \
1420 -s "=> renegotiate" \
1421 -s "write hello request" \
1422 -S "SSL - An unexpected message was received from our peer" \
1423 -S "failed"
1424
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001425run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001426 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001427 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1428 0 \
1429 -C "client hello, adding renegotiation extension" \
1430 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1431 -S "found renegotiation extension" \
1432 -s "server hello, secure renegotiation extension" \
1433 -c "found renegotiation extension" \
1434 -S "record counter limit reached: renegotiate" \
1435 -C "=> renegotiate" \
1436 -S "=> renegotiate" \
1437 -S "write hello request" \
1438 -S "SSL - An unexpected message was received from our peer" \
1439 -S "failed"
1440
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001441# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001442run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001443 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001444 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001445 0 \
1446 -c "client hello, adding renegotiation extension" \
1447 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1448 -s "found renegotiation extension" \
1449 -s "server hello, secure renegotiation extension" \
1450 -c "found renegotiation extension" \
1451 -s "record counter limit reached: renegotiate" \
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
1458run_test "Renegotiation: periodic, two times 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é-Gonnard9835bc02015-01-14 14:41:58 +01001460 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001461 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
1474run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001475 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001476 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1477 0 \
1478 -C "client hello, adding renegotiation extension" \
1479 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1480 -S "found renegotiation extension" \
1481 -s "server hello, secure renegotiation extension" \
1482 -c "found renegotiation extension" \
1483 -S "record counter limit reached: renegotiate" \
1484 -C "=> renegotiate" \
1485 -S "=> renegotiate" \
1486 -S "write hello request" \
1487 -S "SSL - An unexpected message was received from our peer" \
1488 -S "failed"
1489
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001490run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001491 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001492 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001493 0 \
1494 -c "client hello, adding renegotiation extension" \
1495 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1496 -s "found renegotiation extension" \
1497 -s "server hello, secure renegotiation extension" \
1498 -c "found renegotiation extension" \
1499 -c "=> renegotiate" \
1500 -s "=> renegotiate" \
1501 -S "write hello request"
1502
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001503run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001504 "$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 +02001505 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001506 0 \
1507 -c "client hello, adding renegotiation extension" \
1508 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1509 -s "found renegotiation extension" \
1510 -s "server hello, secure renegotiation extension" \
1511 -c "found renegotiation extension" \
1512 -c "=> renegotiate" \
1513 -s "=> renegotiate" \
1514 -s "write hello request"
1515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001516run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001517 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001518 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001519 0 \
1520 -c "client hello, adding renegotiation extension" \
1521 -c "found renegotiation extension" \
1522 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001523 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001524 -C "error" \
1525 -c "HTTP/1.0 200 [Oo][Kk]"
1526
Paul Bakker539d9722015-02-08 16:18:35 +01001527requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001528run_test "Renegotiation: gnutls server strict, client-initiated" \
1529 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001530 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001531 0 \
1532 -c "client hello, adding renegotiation extension" \
1533 -c "found renegotiation extension" \
1534 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001535 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001536 -C "error" \
1537 -c "HTTP/1.0 200 [Oo][Kk]"
1538
Paul Bakker539d9722015-02-08 16:18:35 +01001539requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001540run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1541 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1542 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1543 1 \
1544 -c "client hello, adding renegotiation extension" \
1545 -C "found renegotiation extension" \
1546 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001547 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001548 -c "error" \
1549 -C "HTTP/1.0 200 [Oo][Kk]"
1550
Paul Bakker539d9722015-02-08 16:18:35 +01001551requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001552run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1553 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1554 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1555 allow_legacy=0" \
1556 1 \
1557 -c "client hello, adding renegotiation extension" \
1558 -C "found renegotiation extension" \
1559 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001560 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001561 -c "error" \
1562 -C "HTTP/1.0 200 [Oo][Kk]"
1563
Paul Bakker539d9722015-02-08 16:18:35 +01001564requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001565run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1566 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1567 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1568 allow_legacy=1" \
1569 0 \
1570 -c "client hello, adding renegotiation extension" \
1571 -C "found renegotiation extension" \
1572 -c "=> renegotiate" \
1573 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001574 -C "error" \
1575 -c "HTTP/1.0 200 [Oo][Kk]"
1576
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001577run_test "Renegotiation: DTLS, client-initiated" \
1578 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1579 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1580 0 \
1581 -c "client hello, adding renegotiation extension" \
1582 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1583 -s "found renegotiation extension" \
1584 -s "server hello, secure renegotiation extension" \
1585 -c "found renegotiation extension" \
1586 -c "=> renegotiate" \
1587 -s "=> renegotiate" \
1588 -S "write hello request"
1589
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001590run_test "Renegotiation: DTLS, server-initiated" \
1591 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001592 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1593 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001594 0 \
1595 -c "client hello, adding renegotiation extension" \
1596 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1597 -s "found renegotiation extension" \
1598 -s "server hello, secure renegotiation extension" \
1599 -c "found renegotiation extension" \
1600 -c "=> renegotiate" \
1601 -s "=> renegotiate" \
1602 -s "write hello request"
1603
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001604requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001605run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1606 "$G_SRV -u --mtu 4096" \
1607 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1608 0 \
1609 -c "client hello, adding renegotiation extension" \
1610 -c "found renegotiation extension" \
1611 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001612 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001613 -C "error" \
1614 -s "Extra-header:"
1615
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001616# Test for the "secure renegotation" extension only (no actual renegotiation)
1617
Paul Bakker539d9722015-02-08 16:18:35 +01001618requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001619run_test "Renego ext: gnutls server strict, client default" \
1620 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1621 "$P_CLI debug_level=3" \
1622 0 \
1623 -c "found renegotiation extension" \
1624 -C "error" \
1625 -c "HTTP/1.0 200 [Oo][Kk]"
1626
Paul Bakker539d9722015-02-08 16:18:35 +01001627requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001628run_test "Renego ext: gnutls server unsafe, client default" \
1629 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1630 "$P_CLI debug_level=3" \
1631 0 \
1632 -C "found renegotiation extension" \
1633 -C "error" \
1634 -c "HTTP/1.0 200 [Oo][Kk]"
1635
Paul Bakker539d9722015-02-08 16:18:35 +01001636requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001637run_test "Renego ext: gnutls server unsafe, client break legacy" \
1638 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1639 "$P_CLI debug_level=3 allow_legacy=-1" \
1640 1 \
1641 -C "found renegotiation extension" \
1642 -c "error" \
1643 -C "HTTP/1.0 200 [Oo][Kk]"
1644
Paul Bakker539d9722015-02-08 16:18:35 +01001645requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001646run_test "Renego ext: gnutls client strict, server default" \
1647 "$P_SRV debug_level=3" \
1648 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1649 0 \
1650 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1651 -s "server hello, secure renegotiation extension"
1652
Paul Bakker539d9722015-02-08 16:18:35 +01001653requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001654run_test "Renego ext: gnutls client unsafe, server default" \
1655 "$P_SRV debug_level=3" \
1656 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1657 0 \
1658 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1659 -S "server hello, secure renegotiation extension"
1660
Paul Bakker539d9722015-02-08 16:18:35 +01001661requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001662run_test "Renego ext: gnutls client unsafe, server break legacy" \
1663 "$P_SRV debug_level=3 allow_legacy=-1" \
1664 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1665 1 \
1666 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1667 -S "server hello, secure renegotiation extension"
1668
Janos Follath0b242342016-02-17 10:11:21 +00001669# Tests for silently dropping trailing extra bytes in .der certificates
1670
1671requires_gnutls
1672run_test "DER format: no trailing bytes" \
1673 "$P_SRV crt_file=data_files/server5-der0.crt \
1674 key_file=data_files/server5.key" \
1675 "$G_CLI " \
1676 0 \
1677 -c "Handshake was completed" \
1678
1679requires_gnutls
1680run_test "DER format: with a trailing zero byte" \
1681 "$P_SRV crt_file=data_files/server5-der1a.crt \
1682 key_file=data_files/server5.key" \
1683 "$G_CLI " \
1684 0 \
1685 -c "Handshake was completed" \
1686
1687requires_gnutls
1688run_test "DER format: with a trailing random byte" \
1689 "$P_SRV crt_file=data_files/server5-der1b.crt \
1690 key_file=data_files/server5.key" \
1691 "$G_CLI " \
1692 0 \
1693 -c "Handshake was completed" \
1694
1695requires_gnutls
1696run_test "DER format: with 2 trailing random bytes" \
1697 "$P_SRV crt_file=data_files/server5-der2.crt \
1698 key_file=data_files/server5.key" \
1699 "$G_CLI " \
1700 0 \
1701 -c "Handshake was completed" \
1702
1703requires_gnutls
1704run_test "DER format: with 4 trailing random bytes" \
1705 "$P_SRV crt_file=data_files/server5-der4.crt \
1706 key_file=data_files/server5.key" \
1707 "$G_CLI " \
1708 0 \
1709 -c "Handshake was completed" \
1710
1711requires_gnutls
1712run_test "DER format: with 8 trailing random bytes" \
1713 "$P_SRV crt_file=data_files/server5-der8.crt \
1714 key_file=data_files/server5.key" \
1715 "$G_CLI " \
1716 0 \
1717 -c "Handshake was completed" \
1718
1719requires_gnutls
1720run_test "DER format: with 9 trailing random bytes" \
1721 "$P_SRV crt_file=data_files/server5-der9.crt \
1722 key_file=data_files/server5.key" \
1723 "$G_CLI " \
1724 0 \
1725 -c "Handshake was completed" \
1726
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001727# Tests for auth_mode
1728
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001729run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001730 "$P_SRV crt_file=data_files/server5-badsign.crt \
1731 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001732 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001733 1 \
1734 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001735 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001736 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001737 -c "X509 - Certificate verification failed"
1738
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001739run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001740 "$P_SRV crt_file=data_files/server5-badsign.crt \
1741 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001742 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001743 0 \
1744 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001745 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001746 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001747 -C "X509 - Certificate verification failed"
1748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001749run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001750 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001751 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001752 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001753 0 \
1754 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001755 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001756 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001757 -C "X509 - Certificate verification failed"
1758
Simon Butcher99000142016-10-13 17:21:01 +01001759run_test "Authentication: client SHA256, server required" \
1760 "$P_SRV auth_mode=required" \
1761 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1762 key_file=data_files/server6.key \
1763 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1764 0 \
1765 -c "Supported Signature Algorithm found: 4," \
1766 -c "Supported Signature Algorithm found: 5,"
1767
1768run_test "Authentication: client SHA384, server required" \
1769 "$P_SRV auth_mode=required" \
1770 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1771 key_file=data_files/server6.key \
1772 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
1773 0 \
1774 -c "Supported Signature Algorithm found: 4," \
1775 -c "Supported Signature Algorithm found: 5,"
1776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001777run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001778 "$P_SRV debug_level=3 auth_mode=required" \
1779 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001780 key_file=data_files/server5.key" \
1781 1 \
1782 -S "skip write certificate request" \
1783 -C "skip parse certificate request" \
1784 -c "got a certificate request" \
1785 -C "skip write certificate" \
1786 -C "skip write certificate verify" \
1787 -S "skip parse certificate verify" \
1788 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001789 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001790 -s "! mbedtls_ssl_handshake returned" \
1791 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001792 -s "X509 - Certificate verification failed"
1793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001794run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001795 "$P_SRV debug_level=3 auth_mode=optional" \
1796 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001797 key_file=data_files/server5.key" \
1798 0 \
1799 -S "skip write certificate request" \
1800 -C "skip parse certificate request" \
1801 -c "got a certificate request" \
1802 -C "skip write certificate" \
1803 -C "skip write certificate verify" \
1804 -S "skip parse certificate verify" \
1805 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001806 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001807 -S "! mbedtls_ssl_handshake returned" \
1808 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001809 -S "X509 - Certificate verification failed"
1810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001811run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001812 "$P_SRV debug_level=3 auth_mode=none" \
1813 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001814 key_file=data_files/server5.key" \
1815 0 \
1816 -s "skip write certificate request" \
1817 -C "skip parse certificate request" \
1818 -c "got no certificate request" \
1819 -c "skip write certificate" \
1820 -c "skip write certificate verify" \
1821 -s "skip parse certificate verify" \
1822 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001823 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001824 -S "! mbedtls_ssl_handshake returned" \
1825 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001826 -S "X509 - Certificate verification failed"
1827
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001828run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001829 "$P_SRV debug_level=3 auth_mode=optional" \
1830 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001831 0 \
1832 -S "skip write certificate request" \
1833 -C "skip parse certificate request" \
1834 -c "got a certificate request" \
1835 -C "skip write certificate$" \
1836 -C "got no certificate to send" \
1837 -S "SSLv3 client has no certificate" \
1838 -c "skip write certificate verify" \
1839 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001840 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001841 -S "! mbedtls_ssl_handshake returned" \
1842 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001843 -S "X509 - Certificate verification failed"
1844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001845run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001846 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001847 "$O_CLI" \
1848 0 \
1849 -S "skip write certificate request" \
1850 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001851 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001852 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001853 -S "X509 - Certificate verification failed"
1854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001855run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001856 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001857 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001858 0 \
1859 -C "skip parse certificate request" \
1860 -c "got a certificate request" \
1861 -C "skip write certificate$" \
1862 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001863 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001864
Janos Follathe2681a42016-03-07 15:57:05 +00001865requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001866run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001867 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001868 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001869 0 \
1870 -S "skip write certificate request" \
1871 -C "skip parse certificate request" \
1872 -c "got a certificate request" \
1873 -C "skip write certificate$" \
1874 -c "skip write certificate verify" \
1875 -c "got no certificate to send" \
1876 -s "SSLv3 client has no certificate" \
1877 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001878 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001879 -S "! mbedtls_ssl_handshake returned" \
1880 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001881 -S "X509 - Certificate verification failed"
1882
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001883# Tests for certificate selection based on SHA verson
1884
1885run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1886 "$P_SRV crt_file=data_files/server5.crt \
1887 key_file=data_files/server5.key \
1888 crt_file2=data_files/server5-sha1.crt \
1889 key_file2=data_files/server5.key" \
1890 "$P_CLI force_version=tls1_2" \
1891 0 \
1892 -c "signed using.*ECDSA with SHA256" \
1893 -C "signed using.*ECDSA with SHA1"
1894
1895run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1896 "$P_SRV crt_file=data_files/server5.crt \
1897 key_file=data_files/server5.key \
1898 crt_file2=data_files/server5-sha1.crt \
1899 key_file2=data_files/server5.key" \
1900 "$P_CLI force_version=tls1_1" \
1901 0 \
1902 -C "signed using.*ECDSA with SHA256" \
1903 -c "signed using.*ECDSA with SHA1"
1904
1905run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1906 "$P_SRV crt_file=data_files/server5.crt \
1907 key_file=data_files/server5.key \
1908 crt_file2=data_files/server5-sha1.crt \
1909 key_file2=data_files/server5.key" \
1910 "$P_CLI force_version=tls1" \
1911 0 \
1912 -C "signed using.*ECDSA with SHA256" \
1913 -c "signed using.*ECDSA with SHA1"
1914
1915run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1916 "$P_SRV crt_file=data_files/server5.crt \
1917 key_file=data_files/server5.key \
1918 crt_file2=data_files/server6.crt \
1919 key_file2=data_files/server6.key" \
1920 "$P_CLI force_version=tls1_1" \
1921 0 \
1922 -c "serial number.*09" \
1923 -c "signed using.*ECDSA with SHA256" \
1924 -C "signed using.*ECDSA with SHA1"
1925
1926run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1927 "$P_SRV crt_file=data_files/server6.crt \
1928 key_file=data_files/server6.key \
1929 crt_file2=data_files/server5.crt \
1930 key_file2=data_files/server5.key" \
1931 "$P_CLI force_version=tls1_1" \
1932 0 \
1933 -c "serial number.*0A" \
1934 -c "signed using.*ECDSA with SHA256" \
1935 -C "signed using.*ECDSA with SHA1"
1936
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001937# tests for SNI
1938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001939run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001940 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001941 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001942 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001943 0 \
1944 -S "parse ServerName extension" \
1945 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1946 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001947
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001948run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001949 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001950 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001951 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 +02001952 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001953 0 \
1954 -s "parse ServerName extension" \
1955 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1956 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001958run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001959 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001960 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001961 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 +02001962 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001963 0 \
1964 -s "parse ServerName extension" \
1965 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1966 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001968run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001969 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001970 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001971 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 +02001972 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001973 1 \
1974 -s "parse ServerName extension" \
1975 -s "ssl_sni_wrapper() returned" \
1976 -s "mbedtls_ssl_handshake returned" \
1977 -c "mbedtls_ssl_handshake returned" \
1978 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001979
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001980run_test "SNI: client auth no override: optional" \
1981 "$P_SRV debug_level=3 auth_mode=optional \
1982 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1983 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1984 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001985 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001986 -S "skip write certificate request" \
1987 -C "skip parse certificate request" \
1988 -c "got a certificate request" \
1989 -C "skip write certificate" \
1990 -C "skip write certificate verify" \
1991 -S "skip parse certificate verify"
1992
1993run_test "SNI: client auth override: none -> optional" \
1994 "$P_SRV debug_level=3 auth_mode=none \
1995 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1996 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1997 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001998 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001999 -S "skip write certificate request" \
2000 -C "skip parse certificate request" \
2001 -c "got a certificate request" \
2002 -C "skip write certificate" \
2003 -C "skip write certificate verify" \
2004 -S "skip parse certificate verify"
2005
2006run_test "SNI: client auth override: optional -> none" \
2007 "$P_SRV debug_level=3 auth_mode=optional \
2008 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2009 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2010 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002011 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002012 -s "skip write certificate request" \
2013 -C "skip parse certificate request" \
2014 -c "got no certificate request" \
2015 -c "skip write certificate" \
2016 -c "skip write certificate verify" \
2017 -s "skip parse certificate verify"
2018
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002019run_test "SNI: CA no override" \
2020 "$P_SRV debug_level=3 auth_mode=optional \
2021 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2022 ca_file=data_files/test-ca.crt \
2023 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2024 "$P_CLI debug_level=3 server_name=localhost \
2025 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2026 1 \
2027 -S "skip write certificate request" \
2028 -C "skip parse certificate request" \
2029 -c "got a certificate request" \
2030 -C "skip write certificate" \
2031 -C "skip write certificate verify" \
2032 -S "skip parse certificate verify" \
2033 -s "x509_verify_cert() returned" \
2034 -s "! The certificate is not correctly signed by the trusted CA" \
2035 -S "The certificate has been revoked (is on a CRL)"
2036
2037run_test "SNI: CA override" \
2038 "$P_SRV debug_level=3 auth_mode=optional \
2039 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2040 ca_file=data_files/test-ca.crt \
2041 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2042 "$P_CLI debug_level=3 server_name=localhost \
2043 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2044 0 \
2045 -S "skip write certificate request" \
2046 -C "skip parse certificate request" \
2047 -c "got a certificate request" \
2048 -C "skip write certificate" \
2049 -C "skip write certificate verify" \
2050 -S "skip parse certificate verify" \
2051 -S "x509_verify_cert() returned" \
2052 -S "! The certificate is not correctly signed by the trusted CA" \
2053 -S "The certificate has been revoked (is on a CRL)"
2054
2055run_test "SNI: CA override with CRL" \
2056 "$P_SRV debug_level=3 auth_mode=optional \
2057 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2058 ca_file=data_files/test-ca.crt \
2059 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2060 "$P_CLI debug_level=3 server_name=localhost \
2061 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2062 1 \
2063 -S "skip write certificate request" \
2064 -C "skip parse certificate request" \
2065 -c "got a certificate request" \
2066 -C "skip write certificate" \
2067 -C "skip write certificate verify" \
2068 -S "skip parse certificate verify" \
2069 -s "x509_verify_cert() returned" \
2070 -S "! The certificate is not correctly signed by the trusted CA" \
2071 -s "The certificate has been revoked (is on a CRL)"
2072
Andres AG1a834452016-12-07 10:01:30 +00002073# Tests for SNI and DTLS
2074
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01002075run_test "SNI: DTLS, no SNI callback" \
2076 "$P_SRV debug_level=3 dtls=1 \
2077 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2078 "$P_CLI server_name=localhost dtls=1" \
2079 0 \
2080 -S "parse ServerName extension" \
2081 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2082 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2083
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002084run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00002085 "$P_SRV debug_level=3 dtls=1 \
2086 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2087 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2088 "$P_CLI server_name=localhost dtls=1" \
2089 0 \
2090 -s "parse ServerName extension" \
2091 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2092 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2093
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01002094run_test "SNI: DTLS, matching cert 2" \
2095 "$P_SRV debug_level=3 dtls=1 \
2096 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2097 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2098 "$P_CLI server_name=polarssl.example dtls=1" \
2099 0 \
2100 -s "parse ServerName extension" \
2101 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2102 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2103
2104run_test "SNI: DTLS, no matching cert" \
2105 "$P_SRV debug_level=3 dtls=1 \
2106 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2107 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2108 "$P_CLI server_name=nonesuch.example dtls=1" \
2109 1 \
2110 -s "parse ServerName extension" \
2111 -s "ssl_sni_wrapper() returned" \
2112 -s "mbedtls_ssl_handshake returned" \
2113 -c "mbedtls_ssl_handshake returned" \
2114 -c "SSL - A fatal alert message was received from our peer"
2115
2116run_test "SNI: DTLS, client auth no override: optional" \
2117 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2118 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2119 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2120 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2121 0 \
2122 -S "skip write certificate request" \
2123 -C "skip parse certificate request" \
2124 -c "got a certificate request" \
2125 -C "skip write certificate" \
2126 -C "skip write certificate verify" \
2127 -S "skip parse certificate verify"
2128
2129run_test "SNI: DTLS, client auth override: none -> optional" \
2130 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2131 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2132 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2133 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2134 0 \
2135 -S "skip write certificate request" \
2136 -C "skip parse certificate request" \
2137 -c "got a certificate request" \
2138 -C "skip write certificate" \
2139 -C "skip write certificate verify" \
2140 -S "skip parse certificate verify"
2141
2142run_test "SNI: DTLS, client auth override: optional -> none" \
2143 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2144 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2145 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2146 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2147 0 \
2148 -s "skip write certificate request" \
2149 -C "skip parse certificate request" \
2150 -c "got no certificate request" \
2151 -c "skip write certificate" \
2152 -c "skip write certificate verify" \
2153 -s "skip parse certificate verify"
2154
2155run_test "SNI: DTLS, CA no override" \
2156 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2157 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2158 ca_file=data_files/test-ca.crt \
2159 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2160 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2161 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2162 1 \
2163 -S "skip write certificate request" \
2164 -C "skip parse certificate request" \
2165 -c "got a certificate request" \
2166 -C "skip write certificate" \
2167 -C "skip write certificate verify" \
2168 -S "skip parse certificate verify" \
2169 -s "x509_verify_cert() returned" \
2170 -s "! The certificate is not correctly signed by the trusted CA" \
2171 -S "The certificate has been revoked (is on a CRL)"
2172
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002173run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00002174 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2175 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2176 ca_file=data_files/test-ca.crt \
2177 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2178 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2179 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2180 0 \
2181 -S "skip write certificate request" \
2182 -C "skip parse certificate request" \
2183 -c "got a certificate request" \
2184 -C "skip write certificate" \
2185 -C "skip write certificate verify" \
2186 -S "skip parse certificate verify" \
2187 -S "x509_verify_cert() returned" \
2188 -S "! The certificate is not correctly signed by the trusted CA" \
2189 -S "The certificate has been revoked (is on a CRL)"
2190
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01002191run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00002192 "$P_SRV debug_level=3 auth_mode=optional \
2193 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2194 ca_file=data_files/test-ca.crt \
2195 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2196 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2197 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2198 1 \
2199 -S "skip write certificate request" \
2200 -C "skip parse certificate request" \
2201 -c "got a certificate request" \
2202 -C "skip write certificate" \
2203 -C "skip write certificate verify" \
2204 -S "skip parse certificate verify" \
2205 -s "x509_verify_cert() returned" \
2206 -S "! The certificate is not correctly signed by the trusted CA" \
2207 -s "The certificate has been revoked (is on a CRL)"
2208
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002209# Tests for non-blocking I/O: exercise a variety of handshake flows
2210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002211run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002212 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2213 "$P_CLI nbio=2 tickets=0" \
2214 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002215 -S "mbedtls_ssl_handshake returned" \
2216 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002217 -c "Read from server: .* bytes read"
2218
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002219run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002220 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2221 "$P_CLI nbio=2 tickets=0" \
2222 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002223 -S "mbedtls_ssl_handshake returned" \
2224 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002225 -c "Read from server: .* bytes read"
2226
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002227run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002228 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2229 "$P_CLI nbio=2 tickets=1" \
2230 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002231 -S "mbedtls_ssl_handshake returned" \
2232 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002233 -c "Read from server: .* bytes read"
2234
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002235run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002236 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2237 "$P_CLI nbio=2 tickets=1" \
2238 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002239 -S "mbedtls_ssl_handshake returned" \
2240 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002241 -c "Read from server: .* bytes read"
2242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002243run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002244 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2245 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2246 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002247 -S "mbedtls_ssl_handshake returned" \
2248 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002249 -c "Read from server: .* bytes read"
2250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002251run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002252 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2253 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2254 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002255 -S "mbedtls_ssl_handshake returned" \
2256 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002257 -c "Read from server: .* bytes read"
2258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002259run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002260 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2261 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2262 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002263 -S "mbedtls_ssl_handshake returned" \
2264 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002265 -c "Read from server: .* bytes read"
2266
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002267# Tests for version negotiation
2268
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002269run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002270 "$P_SRV" \
2271 "$P_CLI" \
2272 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002273 -S "mbedtls_ssl_handshake returned" \
2274 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002275 -s "Protocol is TLSv1.2" \
2276 -c "Protocol is TLSv1.2"
2277
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002278run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002279 "$P_SRV" \
2280 "$P_CLI max_version=tls1_1" \
2281 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002282 -S "mbedtls_ssl_handshake returned" \
2283 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002284 -s "Protocol is TLSv1.1" \
2285 -c "Protocol is TLSv1.1"
2286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002287run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002288 "$P_SRV max_version=tls1_1" \
2289 "$P_CLI" \
2290 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002291 -S "mbedtls_ssl_handshake returned" \
2292 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002293 -s "Protocol is TLSv1.1" \
2294 -c "Protocol is TLSv1.1"
2295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002296run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002297 "$P_SRV max_version=tls1_1" \
2298 "$P_CLI max_version=tls1_1" \
2299 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002300 -S "mbedtls_ssl_handshake returned" \
2301 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002302 -s "Protocol is TLSv1.1" \
2303 -c "Protocol is TLSv1.1"
2304
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002305run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002306 "$P_SRV min_version=tls1_1" \
2307 "$P_CLI max_version=tls1_1" \
2308 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002309 -S "mbedtls_ssl_handshake returned" \
2310 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002311 -s "Protocol is TLSv1.1" \
2312 -c "Protocol is TLSv1.1"
2313
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002314run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002315 "$P_SRV max_version=tls1_1" \
2316 "$P_CLI min_version=tls1_1" \
2317 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002318 -S "mbedtls_ssl_handshake returned" \
2319 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002320 -s "Protocol is TLSv1.1" \
2321 -c "Protocol is TLSv1.1"
2322
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002323run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002324 "$P_SRV max_version=tls1_1" \
2325 "$P_CLI min_version=tls1_2" \
2326 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002327 -s "mbedtls_ssl_handshake returned" \
2328 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002329 -c "SSL - Handshake protocol not within min/max boundaries"
2330
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002331run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002332 "$P_SRV min_version=tls1_2" \
2333 "$P_CLI max_version=tls1_1" \
2334 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002335 -s "mbedtls_ssl_handshake returned" \
2336 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002337 -s "SSL - Handshake protocol not within min/max boundaries"
2338
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002339# Tests for ALPN extension
2340
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002341run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002342 "$P_SRV debug_level=3" \
2343 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002344 0 \
2345 -C "client hello, adding alpn extension" \
2346 -S "found alpn extension" \
2347 -C "got an alert message, type: \\[2:120]" \
2348 -S "server hello, adding alpn extension" \
2349 -C "found alpn extension " \
2350 -C "Application Layer Protocol is" \
2351 -S "Application Layer Protocol is"
2352
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002353run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002354 "$P_SRV debug_level=3" \
2355 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002356 0 \
2357 -c "client hello, adding alpn extension" \
2358 -s "found alpn extension" \
2359 -C "got an alert message, type: \\[2:120]" \
2360 -S "server hello, adding alpn extension" \
2361 -C "found alpn extension " \
2362 -c "Application Layer Protocol is (none)" \
2363 -S "Application Layer Protocol is"
2364
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002365run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002366 "$P_SRV debug_level=3 alpn=abc,1234" \
2367 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002368 0 \
2369 -C "client hello, adding alpn extension" \
2370 -S "found alpn extension" \
2371 -C "got an alert message, type: \\[2:120]" \
2372 -S "server hello, adding alpn extension" \
2373 -C "found alpn extension " \
2374 -C "Application Layer Protocol is" \
2375 -s "Application Layer Protocol is (none)"
2376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002377run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002378 "$P_SRV debug_level=3 alpn=abc,1234" \
2379 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002380 0 \
2381 -c "client hello, adding alpn extension" \
2382 -s "found alpn extension" \
2383 -C "got an alert message, type: \\[2:120]" \
2384 -s "server hello, adding alpn extension" \
2385 -c "found alpn extension" \
2386 -c "Application Layer Protocol is abc" \
2387 -s "Application Layer Protocol is abc"
2388
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002389run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002390 "$P_SRV debug_level=3 alpn=abc,1234" \
2391 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002392 0 \
2393 -c "client hello, adding alpn extension" \
2394 -s "found alpn extension" \
2395 -C "got an alert message, type: \\[2:120]" \
2396 -s "server hello, adding alpn extension" \
2397 -c "found alpn extension" \
2398 -c "Application Layer Protocol is abc" \
2399 -s "Application Layer Protocol is abc"
2400
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002401run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002402 "$P_SRV debug_level=3 alpn=abc,1234" \
2403 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002404 0 \
2405 -c "client hello, adding alpn extension" \
2406 -s "found alpn extension" \
2407 -C "got an alert message, type: \\[2:120]" \
2408 -s "server hello, adding alpn extension" \
2409 -c "found alpn extension" \
2410 -c "Application Layer Protocol is 1234" \
2411 -s "Application Layer Protocol is 1234"
2412
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002413run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002414 "$P_SRV debug_level=3 alpn=abc,123" \
2415 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002416 1 \
2417 -c "client hello, adding alpn extension" \
2418 -s "found alpn extension" \
2419 -c "got an alert message, type: \\[2:120]" \
2420 -S "server hello, adding alpn extension" \
2421 -C "found alpn extension" \
2422 -C "Application Layer Protocol is 1234" \
2423 -S "Application Layer Protocol is 1234"
2424
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002425
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002426# Tests for keyUsage in leaf certificates, part 1:
2427# server-side certificate/suite selection
2428
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002429run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002430 "$P_SRV key_file=data_files/server2.key \
2431 crt_file=data_files/server2.ku-ds.crt" \
2432 "$P_CLI" \
2433 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002434 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002435
2436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002437run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002438 "$P_SRV key_file=data_files/server2.key \
2439 crt_file=data_files/server2.ku-ke.crt" \
2440 "$P_CLI" \
2441 0 \
2442 -c "Ciphersuite is TLS-RSA-WITH-"
2443
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002444run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002445 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002446 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002447 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002448 1 \
2449 -C "Ciphersuite is "
2450
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002451run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002452 "$P_SRV key_file=data_files/server5.key \
2453 crt_file=data_files/server5.ku-ds.crt" \
2454 "$P_CLI" \
2455 0 \
2456 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2457
2458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002459run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002460 "$P_SRV key_file=data_files/server5.key \
2461 crt_file=data_files/server5.ku-ka.crt" \
2462 "$P_CLI" \
2463 0 \
2464 -c "Ciphersuite is TLS-ECDH-"
2465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002466run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002467 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002468 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002469 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002470 1 \
2471 -C "Ciphersuite is "
2472
2473# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002474# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002475
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002476run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002477 "$O_SRV -key data_files/server2.key \
2478 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002479 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002480 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2481 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002482 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002483 -C "Processing of the Certificate handshake message failed" \
2484 -c "Ciphersuite is TLS-"
2485
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002486run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002487 "$O_SRV -key data_files/server2.key \
2488 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002489 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002490 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2491 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002492 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002493 -C "Processing of the Certificate handshake message failed" \
2494 -c "Ciphersuite is TLS-"
2495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002496run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002497 "$O_SRV -key data_files/server2.key \
2498 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002499 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002500 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2501 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002502 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002503 -C "Processing of the Certificate handshake message failed" \
2504 -c "Ciphersuite is TLS-"
2505
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002506run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002507 "$O_SRV -key data_files/server2.key \
2508 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002509 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002510 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2511 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002512 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002513 -c "Processing of the Certificate handshake message failed" \
2514 -C "Ciphersuite is TLS-"
2515
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002516run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2517 "$O_SRV -key data_files/server2.key \
2518 -cert data_files/server2.ku-ke.crt" \
2519 "$P_CLI debug_level=1 auth_mode=optional \
2520 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2521 0 \
2522 -c "bad certificate (usage extensions)" \
2523 -C "Processing of the Certificate handshake message failed" \
2524 -c "Ciphersuite is TLS-" \
2525 -c "! Usage does not match the keyUsage extension"
2526
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002527run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002528 "$O_SRV -key data_files/server2.key \
2529 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002530 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002531 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2532 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002533 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002534 -C "Processing of the Certificate handshake message failed" \
2535 -c "Ciphersuite is TLS-"
2536
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002537run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002538 "$O_SRV -key data_files/server2.key \
2539 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002540 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002541 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2542 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002543 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002544 -c "Processing of the Certificate handshake message failed" \
2545 -C "Ciphersuite is TLS-"
2546
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002547run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2548 "$O_SRV -key data_files/server2.key \
2549 -cert data_files/server2.ku-ds.crt" \
2550 "$P_CLI debug_level=1 auth_mode=optional \
2551 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2552 0 \
2553 -c "bad certificate (usage extensions)" \
2554 -C "Processing of the Certificate handshake message failed" \
2555 -c "Ciphersuite is TLS-" \
2556 -c "! Usage does not match the keyUsage extension"
2557
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002558# Tests for keyUsage in leaf certificates, part 3:
2559# server-side checking of client cert
2560
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002561run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002562 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002563 "$O_CLI -key data_files/server2.key \
2564 -cert data_files/server2.ku-ds.crt" \
2565 0 \
2566 -S "bad certificate (usage extensions)" \
2567 -S "Processing of the Certificate handshake message failed"
2568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002569run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002570 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002571 "$O_CLI -key data_files/server2.key \
2572 -cert data_files/server2.ku-ke.crt" \
2573 0 \
2574 -s "bad certificate (usage extensions)" \
2575 -S "Processing of the Certificate handshake message failed"
2576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002577run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002578 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002579 "$O_CLI -key data_files/server2.key \
2580 -cert data_files/server2.ku-ke.crt" \
2581 1 \
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 "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002586 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002587 "$O_CLI -key data_files/server5.key \
2588 -cert data_files/server5.ku-ds.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 "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002594 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002595 "$O_CLI -key data_files/server5.key \
2596 -cert data_files/server5.ku-ka.crt" \
2597 0 \
2598 -s "bad certificate (usage extensions)" \
2599 -S "Processing of the Certificate handshake message failed"
2600
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002601# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002603run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002604 "$P_SRV key_file=data_files/server5.key \
2605 crt_file=data_files/server5.eku-srv.crt" \
2606 "$P_CLI" \
2607 0
2608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002609run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002610 "$P_SRV key_file=data_files/server5.key \
2611 crt_file=data_files/server5.eku-srv.crt" \
2612 "$P_CLI" \
2613 0
2614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002615run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002616 "$P_SRV key_file=data_files/server5.key \
2617 crt_file=data_files/server5.eku-cs_any.crt" \
2618 "$P_CLI" \
2619 0
2620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002621run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002622 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002623 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002624 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002625 1
2626
2627# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002629run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002630 "$O_SRV -key data_files/server5.key \
2631 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002632 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002633 0 \
2634 -C "bad certificate (usage extensions)" \
2635 -C "Processing of the Certificate handshake message failed" \
2636 -c "Ciphersuite is TLS-"
2637
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002638run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002639 "$O_SRV -key data_files/server5.key \
2640 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002641 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002642 0 \
2643 -C "bad certificate (usage extensions)" \
2644 -C "Processing of the Certificate handshake message failed" \
2645 -c "Ciphersuite is TLS-"
2646
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002647run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002648 "$O_SRV -key data_files/server5.key \
2649 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002650 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002651 0 \
2652 -C "bad certificate (usage extensions)" \
2653 -C "Processing of the Certificate handshake message failed" \
2654 -c "Ciphersuite is TLS-"
2655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002656run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002657 "$O_SRV -key data_files/server5.key \
2658 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002659 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002660 1 \
2661 -c "bad certificate (usage extensions)" \
2662 -c "Processing of the Certificate handshake message failed" \
2663 -C "Ciphersuite is TLS-"
2664
2665# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002667run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002668 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002669 "$O_CLI -key data_files/server5.key \
2670 -cert data_files/server5.eku-cli.crt" \
2671 0 \
2672 -S "bad certificate (usage extensions)" \
2673 -S "Processing of the Certificate handshake message failed"
2674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002675run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002676 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002677 "$O_CLI -key data_files/server5.key \
2678 -cert data_files/server5.eku-srv_cli.crt" \
2679 0 \
2680 -S "bad certificate (usage extensions)" \
2681 -S "Processing of the Certificate handshake message failed"
2682
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002683run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002684 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002685 "$O_CLI -key data_files/server5.key \
2686 -cert data_files/server5.eku-cs_any.crt" \
2687 0 \
2688 -S "bad certificate (usage extensions)" \
2689 -S "Processing of the Certificate handshake message failed"
2690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002691run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002692 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002693 "$O_CLI -key data_files/server5.key \
2694 -cert data_files/server5.eku-cs.crt" \
2695 0 \
2696 -s "bad certificate (usage extensions)" \
2697 -S "Processing of the Certificate handshake message failed"
2698
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002699run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002700 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002701 "$O_CLI -key data_files/server5.key \
2702 -cert data_files/server5.eku-cs.crt" \
2703 1 \
2704 -s "bad certificate (usage extensions)" \
2705 -s "Processing of the Certificate handshake message failed"
2706
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002707# Tests for DHM parameters loading
2708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002709run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002710 "$P_SRV" \
2711 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2712 debug_level=3" \
2713 0 \
2714 -c "value of 'DHM: P ' (2048 bits)" \
2715 -c "value of 'DHM: G ' (2048 bits)"
2716
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002717run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002718 "$P_SRV dhm_file=data_files/dhparams.pem" \
2719 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2720 debug_level=3" \
2721 0 \
2722 -c "value of 'DHM: P ' (1024 bits)" \
2723 -c "value of 'DHM: G ' (2 bits)"
2724
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002725# Tests for DHM client-side size checking
2726
2727run_test "DHM size: server default, client default, OK" \
2728 "$P_SRV" \
2729 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2730 debug_level=1" \
2731 0 \
2732 -C "DHM prime too short:"
2733
2734run_test "DHM size: server default, client 2048, OK" \
2735 "$P_SRV" \
2736 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2737 debug_level=1 dhmlen=2048" \
2738 0 \
2739 -C "DHM prime too short:"
2740
2741run_test "DHM size: server 1024, client default, OK" \
2742 "$P_SRV dhm_file=data_files/dhparams.pem" \
2743 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2744 debug_level=1" \
2745 0 \
2746 -C "DHM prime too short:"
2747
2748run_test "DHM size: server 1000, client default, rejected" \
2749 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2750 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2751 debug_level=1" \
2752 1 \
2753 -c "DHM prime too short:"
2754
2755run_test "DHM size: server default, client 2049, rejected" \
2756 "$P_SRV" \
2757 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2758 debug_level=1 dhmlen=2049" \
2759 1 \
2760 -c "DHM prime too short:"
2761
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002762# Tests for PSK callback
2763
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002764run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002765 "$P_SRV psk=abc123 psk_identity=foo" \
2766 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2767 psk_identity=foo psk=abc123" \
2768 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002769 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002770 -S "SSL - Unknown identity received" \
2771 -S "SSL - Verification of the message MAC failed"
2772
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002773run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002774 "$P_SRV" \
2775 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2776 psk_identity=foo psk=abc123" \
2777 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002778 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002779 -S "SSL - Unknown identity received" \
2780 -S "SSL - Verification of the message MAC failed"
2781
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002782run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002783 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2784 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2785 psk_identity=foo psk=abc123" \
2786 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002787 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002788 -s "SSL - Unknown identity received" \
2789 -S "SSL - Verification of the message MAC failed"
2790
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002791run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002792 "$P_SRV psk_list=abc,dead,def,beef" \
2793 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2794 psk_identity=abc psk=dead" \
2795 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002796 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002797 -S "SSL - Unknown identity received" \
2798 -S "SSL - Verification of the message MAC failed"
2799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002800run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002801 "$P_SRV psk_list=abc,dead,def,beef" \
2802 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2803 psk_identity=def psk=beef" \
2804 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002805 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002806 -S "SSL - Unknown identity received" \
2807 -S "SSL - Verification of the message MAC failed"
2808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002809run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002810 "$P_SRV psk_list=abc,dead,def,beef" \
2811 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2812 psk_identity=ghi psk=beef" \
2813 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002814 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002815 -s "SSL - Unknown identity received" \
2816 -S "SSL - Verification of the message MAC failed"
2817
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002818run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002819 "$P_SRV psk_list=abc,dead,def,beef" \
2820 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2821 psk_identity=abc psk=beef" \
2822 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002823 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002824 -S "SSL - Unknown identity received" \
2825 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002826
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002827# Tests for EC J-PAKE
2828
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002829requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002830run_test "ECJPAKE: client not configured" \
2831 "$P_SRV debug_level=3" \
2832 "$P_CLI debug_level=3" \
2833 0 \
2834 -C "add ciphersuite: c0ff" \
2835 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002836 -S "found ecjpake kkpp extension" \
2837 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002838 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002839 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002840 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002841 -S "None of the common ciphersuites is usable"
2842
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002843requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002844run_test "ECJPAKE: server not configured" \
2845 "$P_SRV debug_level=3" \
2846 "$P_CLI debug_level=3 ecjpake_pw=bla \
2847 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2848 1 \
2849 -c "add ciphersuite: c0ff" \
2850 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002851 -s "found ecjpake kkpp extension" \
2852 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002853 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002854 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002855 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002856 -s "None of the common ciphersuites is usable"
2857
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002858requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002859run_test "ECJPAKE: working, TLS" \
2860 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2861 "$P_CLI debug_level=3 ecjpake_pw=bla \
2862 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002863 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002864 -c "add ciphersuite: c0ff" \
2865 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002866 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002867 -s "found ecjpake kkpp extension" \
2868 -S "skip ecjpake kkpp extension" \
2869 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002870 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002871 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002872 -S "None of the common ciphersuites is usable" \
2873 -S "SSL - Verification of the message MAC failed"
2874
Janos Follath74537a62016-09-02 13:45:28 +01002875server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002876requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002877run_test "ECJPAKE: password mismatch, TLS" \
2878 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2879 "$P_CLI debug_level=3 ecjpake_pw=bad \
2880 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2881 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002882 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002883 -s "SSL - Verification of the message MAC failed"
2884
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002885requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002886run_test "ECJPAKE: working, DTLS" \
2887 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2888 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2889 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2890 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002891 -c "re-using cached ecjpake parameters" \
2892 -S "SSL - Verification of the message MAC failed"
2893
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002894requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002895run_test "ECJPAKE: working, DTLS, no cookie" \
2896 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2897 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2898 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2899 0 \
2900 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002901 -S "SSL - Verification of the message MAC failed"
2902
Janos Follath74537a62016-09-02 13:45:28 +01002903server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002904requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002905run_test "ECJPAKE: password mismatch, DTLS" \
2906 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2907 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2908 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2909 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002910 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002911 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002912
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002913# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002914requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002915run_test "ECJPAKE: working, DTLS, nolog" \
2916 "$P_SRV dtls=1 ecjpake_pw=bla" \
2917 "$P_CLI dtls=1 ecjpake_pw=bla \
2918 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2919 0
2920
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002921# Tests for ciphersuites per version
2922
Janos Follathe2681a42016-03-07 15:57:05 +00002923requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002924run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002925 "$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 +02002926 "$P_CLI force_version=ssl3" \
2927 0 \
2928 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002930run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002931 "$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 +01002932 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002933 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002934 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002935
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002936run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002937 "$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 +02002938 "$P_CLI force_version=tls1_1" \
2939 0 \
2940 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2941
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002942run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002943 "$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 +02002944 "$P_CLI force_version=tls1_2" \
2945 0 \
2946 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2947
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002948# Test for ClientHello without extensions
2949
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002950requires_gnutls
2951run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002952 "$P_SRV debug_level=3" \
2953 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2954 0 \
2955 -s "dumping 'client hello extensions' (0 bytes)"
2956
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002957# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002958
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002959run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002960 "$P_SRV" \
2961 "$P_CLI request_size=100" \
2962 0 \
2963 -s "Read from client: 100 bytes read$"
2964
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002965run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002966 "$P_SRV" \
2967 "$P_CLI request_size=500" \
2968 0 \
2969 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002970
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002971# Tests for small packets
2972
Janos Follathe2681a42016-03-07 15:57:05 +00002973requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002974run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002975 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002976 "$P_CLI request_size=1 force_version=ssl3 \
2977 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2978 0 \
2979 -s "Read from client: 1 bytes read"
2980
Janos Follathe2681a42016-03-07 15:57:05 +00002981requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002982run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002983 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002984 "$P_CLI request_size=1 force_version=ssl3 \
2985 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2986 0 \
2987 -s "Read from client: 1 bytes read"
2988
2989run_test "Small packet TLS 1.0 BlockCipher" \
2990 "$P_SRV" \
2991 "$P_CLI request_size=1 force_version=tls1 \
2992 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2993 0 \
2994 -s "Read from client: 1 bytes read"
2995
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002996run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2997 "$P_SRV" \
2998 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2999 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3000 0 \
3001 -s "Read from client: 1 bytes read"
3002
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003003run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
3004 "$P_SRV" \
3005 "$P_CLI request_size=1 force_version=tls1 \
3006 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3007 trunc_hmac=1" \
3008 0 \
3009 -s "Read from client: 1 bytes read"
3010
3011run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003012 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003013 "$P_CLI request_size=1 force_version=tls1 \
3014 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3015 trunc_hmac=1" \
3016 0 \
3017 -s "Read from client: 1 bytes read"
3018
3019run_test "Small packet TLS 1.1 BlockCipher" \
3020 "$P_SRV" \
3021 "$P_CLI request_size=1 force_version=tls1_1 \
3022 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3023 0 \
3024 -s "Read from client: 1 bytes read"
3025
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003026run_test "Small packet TLS 1.1 BlockCipher without EtM" \
3027 "$P_SRV" \
3028 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
3029 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3030 0 \
3031 -s "Read from client: 1 bytes read"
3032
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003033run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003034 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003035 "$P_CLI request_size=1 force_version=tls1_1 \
3036 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3037 0 \
3038 -s "Read from client: 1 bytes read"
3039
3040run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3041 "$P_SRV" \
3042 "$P_CLI request_size=1 force_version=tls1_1 \
3043 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3044 trunc_hmac=1" \
3045 0 \
3046 -s "Read from client: 1 bytes read"
3047
3048run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003049 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003050 "$P_CLI request_size=1 force_version=tls1_1 \
3051 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3052 trunc_hmac=1" \
3053 0 \
3054 -s "Read from client: 1 bytes read"
3055
3056run_test "Small packet TLS 1.2 BlockCipher" \
3057 "$P_SRV" \
3058 "$P_CLI request_size=1 force_version=tls1_2 \
3059 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3060 0 \
3061 -s "Read from client: 1 bytes read"
3062
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003063run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3064 "$P_SRV" \
3065 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3066 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3067 0 \
3068 -s "Read from client: 1 bytes read"
3069
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003070run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3071 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003072 "$P_CLI request_size=1 force_version=tls1_2 \
3073 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003074 0 \
3075 -s "Read from client: 1 bytes read"
3076
3077run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3078 "$P_SRV" \
3079 "$P_CLI request_size=1 force_version=tls1_2 \
3080 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3081 trunc_hmac=1" \
3082 0 \
3083 -s "Read from client: 1 bytes read"
3084
3085run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003086 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003087 "$P_CLI request_size=1 force_version=tls1_2 \
3088 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3089 0 \
3090 -s "Read from client: 1 bytes read"
3091
3092run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003093 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003094 "$P_CLI request_size=1 force_version=tls1_2 \
3095 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3096 trunc_hmac=1" \
3097 0 \
3098 -s "Read from client: 1 bytes read"
3099
3100run_test "Small packet TLS 1.2 AEAD" \
3101 "$P_SRV" \
3102 "$P_CLI request_size=1 force_version=tls1_2 \
3103 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3104 0 \
3105 -s "Read from client: 1 bytes read"
3106
3107run_test "Small packet TLS 1.2 AEAD shorter tag" \
3108 "$P_SRV" \
3109 "$P_CLI request_size=1 force_version=tls1_2 \
3110 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3111 0 \
3112 -s "Read from client: 1 bytes read"
3113
Janos Follath00efff72016-05-06 13:48:23 +01003114# A test for extensions in SSLv3
3115
3116requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3117run_test "SSLv3 with extensions, server side" \
3118 "$P_SRV min_version=ssl3 debug_level=3" \
3119 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3120 0 \
3121 -S "dumping 'client hello extensions'" \
3122 -S "server hello, total extension length:"
3123
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003124# Test for large packets
3125
Janos Follathe2681a42016-03-07 15:57:05 +00003126requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003127run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003128 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003129 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003130 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3131 0 \
3132 -s "Read from client: 16384 bytes read"
3133
Janos Follathe2681a42016-03-07 15:57:05 +00003134requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003135run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003136 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003137 "$P_CLI request_size=16384 force_version=ssl3 \
3138 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3139 0 \
3140 -s "Read from client: 16384 bytes read"
3141
3142run_test "Large packet TLS 1.0 BlockCipher" \
3143 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003144 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003145 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3146 0 \
3147 -s "Read from client: 16384 bytes read"
3148
3149run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3150 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003151 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003152 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3153 trunc_hmac=1" \
3154 0 \
3155 -s "Read from client: 16384 bytes read"
3156
3157run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003158 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003159 "$P_CLI request_size=16384 force_version=tls1 \
3160 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3161 trunc_hmac=1" \
3162 0 \
3163 -s "Read from client: 16384 bytes read"
3164
3165run_test "Large packet TLS 1.1 BlockCipher" \
3166 "$P_SRV" \
3167 "$P_CLI request_size=16384 force_version=tls1_1 \
3168 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3169 0 \
3170 -s "Read from client: 16384 bytes read"
3171
3172run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003173 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003174 "$P_CLI request_size=16384 force_version=tls1_1 \
3175 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3176 0 \
3177 -s "Read from client: 16384 bytes read"
3178
3179run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3180 "$P_SRV" \
3181 "$P_CLI request_size=16384 force_version=tls1_1 \
3182 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3183 trunc_hmac=1" \
3184 0 \
3185 -s "Read from client: 16384 bytes read"
3186
3187run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003188 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003189 "$P_CLI request_size=16384 force_version=tls1_1 \
3190 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3191 trunc_hmac=1" \
3192 0 \
3193 -s "Read from client: 16384 bytes read"
3194
3195run_test "Large packet TLS 1.2 BlockCipher" \
3196 "$P_SRV" \
3197 "$P_CLI request_size=16384 force_version=tls1_2 \
3198 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3199 0 \
3200 -s "Read from client: 16384 bytes read"
3201
3202run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3203 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003204 "$P_CLI request_size=16384 force_version=tls1_2 \
3205 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003206 0 \
3207 -s "Read from client: 16384 bytes read"
3208
3209run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3210 "$P_SRV" \
3211 "$P_CLI request_size=16384 force_version=tls1_2 \
3212 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3213 trunc_hmac=1" \
3214 0 \
3215 -s "Read from client: 16384 bytes read"
3216
3217run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003218 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003219 "$P_CLI request_size=16384 force_version=tls1_2 \
3220 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3221 0 \
3222 -s "Read from client: 16384 bytes read"
3223
3224run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003225 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003226 "$P_CLI request_size=16384 force_version=tls1_2 \
3227 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3228 trunc_hmac=1" \
3229 0 \
3230 -s "Read from client: 16384 bytes read"
3231
3232run_test "Large packet TLS 1.2 AEAD" \
3233 "$P_SRV" \
3234 "$P_CLI request_size=16384 force_version=tls1_2 \
3235 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3236 0 \
3237 -s "Read from client: 16384 bytes read"
3238
3239run_test "Large packet TLS 1.2 AEAD shorter tag" \
3240 "$P_SRV" \
3241 "$P_CLI request_size=16384 force_version=tls1_2 \
3242 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3243 0 \
3244 -s "Read from client: 16384 bytes read"
3245
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003246# Tests for DTLS HelloVerifyRequest
3247
3248run_test "DTLS cookie: enabled" \
3249 "$P_SRV dtls=1 debug_level=2" \
3250 "$P_CLI dtls=1 debug_level=2" \
3251 0 \
3252 -s "cookie verification failed" \
3253 -s "cookie verification passed" \
3254 -S "cookie verification skipped" \
3255 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003256 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003257 -S "SSL - The requested feature is not available"
3258
3259run_test "DTLS cookie: disabled" \
3260 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3261 "$P_CLI dtls=1 debug_level=2" \
3262 0 \
3263 -S "cookie verification failed" \
3264 -S "cookie verification passed" \
3265 -s "cookie verification skipped" \
3266 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003267 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003268 -S "SSL - The requested feature is not available"
3269
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003270run_test "DTLS cookie: default (failing)" \
3271 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3272 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3273 1 \
3274 -s "cookie verification failed" \
3275 -S "cookie verification passed" \
3276 -S "cookie verification skipped" \
3277 -C "received hello verify request" \
3278 -S "hello verification requested" \
3279 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003280
3281requires_ipv6
3282run_test "DTLS cookie: enabled, IPv6" \
3283 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3284 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3285 0 \
3286 -s "cookie verification failed" \
3287 -s "cookie verification passed" \
3288 -S "cookie verification skipped" \
3289 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003290 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003291 -S "SSL - The requested feature is not available"
3292
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003293run_test "DTLS cookie: enabled, nbio" \
3294 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3295 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3296 0 \
3297 -s "cookie verification failed" \
3298 -s "cookie verification passed" \
3299 -S "cookie verification skipped" \
3300 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003301 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003302 -S "SSL - The requested feature is not available"
3303
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003304# Tests for client reconnecting from the same port with DTLS
3305
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003306not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003307run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003308 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3309 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003310 0 \
3311 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003312 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003313 -S "Client initiated reconnection from same port"
3314
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003315not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003316run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003317 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3318 "$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 +02003319 0 \
3320 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003321 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003322 -s "Client initiated reconnection from same port"
3323
Paul Bakker362689d2016-05-13 10:33:25 +01003324not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3325run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003326 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3327 "$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 +02003328 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003329 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003330 -s "Client initiated reconnection from same port"
3331
Paul Bakker362689d2016-05-13 10:33:25 +01003332only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3333run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3334 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3335 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3336 0 \
3337 -S "The operation timed out" \
3338 -s "Client initiated reconnection from same port"
3339
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003340run_test "DTLS client reconnect from same port: no cookies" \
3341 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003342 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3343 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003344 -s "The operation timed out" \
3345 -S "Client initiated reconnection from same port"
3346
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003347# Tests for various cases of client authentication with DTLS
3348# (focused on handshake flows and message parsing)
3349
3350run_test "DTLS client auth: required" \
3351 "$P_SRV dtls=1 auth_mode=required" \
3352 "$P_CLI dtls=1" \
3353 0 \
3354 -s "Verifying peer X.509 certificate... ok"
3355
3356run_test "DTLS client auth: optional, client has no cert" \
3357 "$P_SRV dtls=1 auth_mode=optional" \
3358 "$P_CLI dtls=1 crt_file=none key_file=none" \
3359 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003360 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003361
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003362run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003363 "$P_SRV dtls=1 auth_mode=none" \
3364 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3365 0 \
3366 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003367 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003368
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003369run_test "DTLS wrong PSK: badmac alert" \
3370 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3371 "$P_CLI dtls=1 psk=abc124" \
3372 1 \
3373 -s "SSL - Verification of the message MAC failed" \
3374 -c "SSL - A fatal alert message was received from our peer"
3375
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003376# Tests for receiving fragmented handshake messages with DTLS
3377
3378requires_gnutls
3379run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3380 "$G_SRV -u --mtu 2048 -a" \
3381 "$P_CLI dtls=1 debug_level=2" \
3382 0 \
3383 -C "found fragmented DTLS handshake message" \
3384 -C "error"
3385
3386requires_gnutls
3387run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3388 "$G_SRV -u --mtu 512" \
3389 "$P_CLI dtls=1 debug_level=2" \
3390 0 \
3391 -c "found fragmented DTLS handshake message" \
3392 -C "error"
3393
3394requires_gnutls
3395run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3396 "$G_SRV -u --mtu 128" \
3397 "$P_CLI dtls=1 debug_level=2" \
3398 0 \
3399 -c "found fragmented DTLS handshake message" \
3400 -C "error"
3401
3402requires_gnutls
3403run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3404 "$G_SRV -u --mtu 128" \
3405 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3406 0 \
3407 -c "found fragmented DTLS handshake message" \
3408 -C "error"
3409
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003410requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003411run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3412 "$G_SRV -u --mtu 256" \
3413 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3414 0 \
3415 -c "found fragmented DTLS handshake message" \
3416 -c "client hello, adding renegotiation extension" \
3417 -c "found renegotiation extension" \
3418 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003419 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003420 -C "error" \
3421 -s "Extra-header:"
3422
3423requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003424run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3425 "$G_SRV -u --mtu 256" \
3426 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3427 0 \
3428 -c "found fragmented DTLS handshake message" \
3429 -c "client hello, adding renegotiation extension" \
3430 -c "found renegotiation extension" \
3431 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003432 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003433 -C "error" \
3434 -s "Extra-header:"
3435
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003436run_test "DTLS reassembly: no fragmentation (openssl server)" \
3437 "$O_SRV -dtls1 -mtu 2048" \
3438 "$P_CLI dtls=1 debug_level=2" \
3439 0 \
3440 -C "found fragmented DTLS handshake message" \
3441 -C "error"
3442
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003443run_test "DTLS reassembly: some fragmentation (openssl server)" \
3444 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003445 "$P_CLI dtls=1 debug_level=2" \
3446 0 \
3447 -c "found fragmented DTLS handshake message" \
3448 -C "error"
3449
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003450run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003451 "$O_SRV -dtls1 -mtu 256" \
3452 "$P_CLI dtls=1 debug_level=2" \
3453 0 \
3454 -c "found fragmented DTLS handshake message" \
3455 -C "error"
3456
3457run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3458 "$O_SRV -dtls1 -mtu 256" \
3459 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3460 0 \
3461 -c "found fragmented DTLS handshake message" \
3462 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003463
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003464# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003465
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003466not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003467run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003468 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003469 "$P_SRV dtls=1 debug_level=2" \
3470 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003471 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003472 -C "replayed record" \
3473 -S "replayed record" \
3474 -C "record from another epoch" \
3475 -S "record from another epoch" \
3476 -C "discarding invalid record" \
3477 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003478 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003479 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003480 -c "HTTP/1.0 200 OK"
3481
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003482not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003483run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003484 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003485 "$P_SRV dtls=1 debug_level=2" \
3486 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003487 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003488 -c "replayed record" \
3489 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003490 -c "discarding invalid record" \
3491 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003492 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003493 -s "Extra-header:" \
3494 -c "HTTP/1.0 200 OK"
3495
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003496run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3497 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003498 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3499 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003500 0 \
3501 -c "replayed record" \
3502 -S "replayed record" \
3503 -c "discarding invalid record" \
3504 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003505 -c "resend" \
3506 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003507 -s "Extra-header:" \
3508 -c "HTTP/1.0 200 OK"
3509
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003510run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003511 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003512 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003513 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003514 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003515 -c "discarding invalid record (mac)" \
3516 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003517 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003518 -c "HTTP/1.0 200 OK" \
3519 -S "too many records with bad MAC" \
3520 -S "Verification of the message MAC failed"
3521
3522run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3523 -p "$P_PXY bad_ad=1" \
3524 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3525 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3526 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003527 -C "discarding invalid record (mac)" \
3528 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003529 -S "Extra-header:" \
3530 -C "HTTP/1.0 200 OK" \
3531 -s "too many records with bad MAC" \
3532 -s "Verification of the message MAC failed"
3533
3534run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3535 -p "$P_PXY bad_ad=1" \
3536 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3537 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3538 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003539 -c "discarding invalid record (mac)" \
3540 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003541 -s "Extra-header:" \
3542 -c "HTTP/1.0 200 OK" \
3543 -S "too many records with bad MAC" \
3544 -S "Verification of the message MAC failed"
3545
3546run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3547 -p "$P_PXY bad_ad=1" \
3548 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3549 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3550 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003551 -c "discarding invalid record (mac)" \
3552 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003553 -s "Extra-header:" \
3554 -c "HTTP/1.0 200 OK" \
3555 -s "too many records with bad MAC" \
3556 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003557
3558run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003559 -p "$P_PXY delay_ccs=1" \
3560 "$P_SRV dtls=1 debug_level=1" \
3561 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003562 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003563 -c "record from another epoch" \
3564 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003565 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003566 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003567 -s "Extra-header:" \
3568 -c "HTTP/1.0 200 OK"
3569
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003570# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003571
Janos Follath74537a62016-09-02 13:45:28 +01003572client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003573run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003574 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003575 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3576 psk=abc123" \
3577 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003578 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3579 0 \
3580 -s "Extra-header:" \
3581 -c "HTTP/1.0 200 OK"
3582
Janos Follath74537a62016-09-02 13:45:28 +01003583client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003584run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3585 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003586 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3587 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003588 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3589 0 \
3590 -s "Extra-header:" \
3591 -c "HTTP/1.0 200 OK"
3592
Janos Follath74537a62016-09-02 13:45:28 +01003593client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003594run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3595 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003596 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3597 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003598 0 \
3599 -s "Extra-header:" \
3600 -c "HTTP/1.0 200 OK"
3601
Janos Follath74537a62016-09-02 13:45:28 +01003602client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003603run_test "DTLS proxy: 3d, FS, client auth" \
3604 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003605 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3606 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003607 0 \
3608 -s "Extra-header:" \
3609 -c "HTTP/1.0 200 OK"
3610
Janos Follath74537a62016-09-02 13:45:28 +01003611client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003612run_test "DTLS proxy: 3d, FS, ticket" \
3613 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003614 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3615 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003616 0 \
3617 -s "Extra-header:" \
3618 -c "HTTP/1.0 200 OK"
3619
Janos Follath74537a62016-09-02 13:45:28 +01003620client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003621run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3622 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003623 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3624 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003625 0 \
3626 -s "Extra-header:" \
3627 -c "HTTP/1.0 200 OK"
3628
Janos Follath74537a62016-09-02 13:45:28 +01003629client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003630run_test "DTLS proxy: 3d, max handshake, nbio" \
3631 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003632 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3633 auth_mode=required" \
3634 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003635 0 \
3636 -s "Extra-header:" \
3637 -c "HTTP/1.0 200 OK"
3638
Janos Follath74537a62016-09-02 13:45:28 +01003639client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003640run_test "DTLS proxy: 3d, min handshake, resumption" \
3641 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3642 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3643 psk=abc123 debug_level=3" \
3644 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3645 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3646 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3647 0 \
3648 -s "a session has been resumed" \
3649 -c "a session has been resumed" \
3650 -s "Extra-header:" \
3651 -c "HTTP/1.0 200 OK"
3652
Janos Follath74537a62016-09-02 13:45:28 +01003653client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003654run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3655 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3656 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3657 psk=abc123 debug_level=3 nbio=2" \
3658 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3659 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3660 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3661 0 \
3662 -s "a session has been resumed" \
3663 -c "a session has been resumed" \
3664 -s "Extra-header:" \
3665 -c "HTTP/1.0 200 OK"
3666
Janos Follath74537a62016-09-02 13:45:28 +01003667client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003668run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003669 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003670 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3671 psk=abc123 renegotiation=1 debug_level=2" \
3672 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3673 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003674 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3675 0 \
3676 -c "=> renegotiate" \
3677 -s "=> renegotiate" \
3678 -s "Extra-header:" \
3679 -c "HTTP/1.0 200 OK"
3680
Janos Follath74537a62016-09-02 13:45:28 +01003681client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003682run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3683 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003684 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3685 psk=abc123 renegotiation=1 debug_level=2" \
3686 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3687 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003688 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3689 0 \
3690 -c "=> renegotiate" \
3691 -s "=> renegotiate" \
3692 -s "Extra-header:" \
3693 -c "HTTP/1.0 200 OK"
3694
Janos Follath74537a62016-09-02 13:45:28 +01003695client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003696run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003697 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003698 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003699 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003700 debug_level=2" \
3701 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003702 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003703 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3704 0 \
3705 -c "=> renegotiate" \
3706 -s "=> renegotiate" \
3707 -s "Extra-header:" \
3708 -c "HTTP/1.0 200 OK"
3709
Janos Follath74537a62016-09-02 13:45:28 +01003710client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003711run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003712 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003713 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003714 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003715 debug_level=2 nbio=2" \
3716 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003717 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003718 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3719 0 \
3720 -c "=> renegotiate" \
3721 -s "=> renegotiate" \
3722 -s "Extra-header:" \
3723 -c "HTTP/1.0 200 OK"
3724
Janos Follath74537a62016-09-02 13:45:28 +01003725client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003726not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003727run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003728 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3729 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003730 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003731 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003732 -c "HTTP/1.0 200 OK"
3733
Janos Follath74537a62016-09-02 13:45:28 +01003734client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003735not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003736run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3737 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3738 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003739 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003740 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003741 -c "HTTP/1.0 200 OK"
3742
Janos Follath74537a62016-09-02 13:45:28 +01003743client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003744not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003745run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3746 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3747 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003748 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003749 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003750 -c "HTTP/1.0 200 OK"
3751
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003752requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003753client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003754not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003755run_test "DTLS proxy: 3d, gnutls server" \
3756 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3757 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003758 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003759 0 \
3760 -s "Extra-header:" \
3761 -c "Extra-header:"
3762
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003763requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003764client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003765not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003766run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3767 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3768 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003769 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003770 0 \
3771 -s "Extra-header:" \
3772 -c "Extra-header:"
3773
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003774requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003775client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003776not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003777run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3778 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3779 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003780 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003781 0 \
3782 -s "Extra-header:" \
3783 -c "Extra-header:"
3784
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003785# Final report
3786
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003787echo "------------------------------------------------------------------------"
3788
3789if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003790 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003791else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003792 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003793fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003794PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003795echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003796
3797exit $FAILS