blob: f9fbfa2dbcebe9be7ae478d2aa821c91b54dd651 [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
Gilles Peskine62469d92017-05-10 10:13:59 +0200631# Allow SHA-1, because many of our test certificates use it
632P_SRV="$P_SRV allow_sha1=1"
633P_CLI="$P_CLI allow_sha1=1"
634
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200635# Also pick a unique name for intermediate files
636SRV_OUT="srv_out.$$"
637CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200638PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200639SESSION="session.$$"
640
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200641SKIP_NEXT="NO"
642
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100643trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100644
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200645# Basic test
646
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200647# Checks that:
648# - things work with all ciphersuites active (used with config-full in all.sh)
649# - the expected (highest security) parameters are selected
650# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200651run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200652 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200653 "$P_CLI" \
654 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200655 -s "Protocol is TLSv1.2" \
656 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
657 -s "client hello v3, signature_algorithm ext: 6" \
658 -s "ECDHE curve: secp521r1" \
659 -S "error" \
660 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200661
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000662run_test "Default, DTLS" \
663 "$P_SRV dtls=1" \
664 "$P_CLI dtls=1" \
665 0 \
666 -s "Protocol is DTLSv1.2" \
667 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
668
Simon Butcher8e004102016-10-14 00:48:33 +0100669# Test for uniqueness of IVs in AEAD ciphersuites
670run_test "Unique IV in GCM" \
671 "$P_SRV exchanges=20 debug_level=4" \
672 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
673 0 \
674 -u "IV used" \
675 -U "IV used"
676
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100677# Tests for rc4 option
678
Simon Butchera410af52016-05-19 22:12:18 +0100679requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100680run_test "RC4: server disabled, client enabled" \
681 "$P_SRV" \
682 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
683 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100684 -s "SSL - The server has no ciphersuites in common"
685
Simon Butchera410af52016-05-19 22:12:18 +0100686requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100687run_test "RC4: server half, client enabled" \
688 "$P_SRV arc4=1" \
689 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
690 1 \
691 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100692
693run_test "RC4: server enabled, client disabled" \
694 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
695 "$P_CLI" \
696 1 \
697 -s "SSL - The server has no ciphersuites in common"
698
699run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100700 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100701 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
702 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100703 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100704 -S "SSL - The server has no ciphersuites in common"
705
Gilles Peskinebc70a182017-05-09 15:59:24 +0200706# Tests for SHA-1 support
707
708run_test "SHA-1 forbidden by default in server certificate" \
709 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
710 "$P_CLI debug_level=2 allow_sha1=0" \
711 1 \
712 -c "The certificate is signed with an unacceptable hash"
713
714run_test "SHA-1 explicitly allowed in server certificate" \
715 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
716 "$P_CLI allow_sha1=1" \
717 0
718
719run_test "SHA-256 allowed by default in server certificate" \
720 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
721 "$P_CLI allow_sha1=0" \
722 0
723
724run_test "SHA-1 forbidden by default in client certificate" \
725 "$P_SRV auth_mode=required allow_sha1=0" \
726 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
727 1 \
728 -s "The certificate is signed with an unacceptable hash"
729
730run_test "SHA-1 explicitly allowed in client certificate" \
731 "$P_SRV auth_mode=required allow_sha1=1" \
732 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
733 0
734
735run_test "SHA-256 allowed by default in client certificate" \
736 "$P_SRV auth_mode=required allow_sha1=0" \
737 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
738 0
739
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100740# Tests for Truncated HMAC extension
741
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100742run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200743 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100744 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100745 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100746 -s "dumping 'computed mac' (20 bytes)" \
747 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100748
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100749run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200750 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100751 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
752 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100753 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100754 -s "dumping 'computed mac' (20 bytes)" \
755 -S "dumping 'computed mac' (10 bytes)"
756
757run_test "Truncated HMAC: client enabled, server default" \
758 "$P_SRV debug_level=4" \
759 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
760 trunc_hmac=1" \
761 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100762 -s "dumping 'computed mac' (20 bytes)" \
763 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100764
765run_test "Truncated HMAC: client enabled, server disabled" \
766 "$P_SRV debug_level=4 trunc_hmac=0" \
767 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
768 trunc_hmac=1" \
769 0 \
770 -s "dumping 'computed mac' (20 bytes)" \
771 -S "dumping 'computed mac' (10 bytes)"
772
773run_test "Truncated HMAC: client enabled, server enabled" \
774 "$P_SRV debug_level=4 trunc_hmac=1" \
775 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
776 trunc_hmac=1" \
777 0 \
778 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100779 -s "dumping 'computed mac' (10 bytes)"
780
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100781# Tests for Encrypt-then-MAC extension
782
783run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100784 "$P_SRV debug_level=3 \
785 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100786 "$P_CLI debug_level=3" \
787 0 \
788 -c "client hello, adding encrypt_then_mac extension" \
789 -s "found encrypt then mac extension" \
790 -s "server hello, adding encrypt then mac extension" \
791 -c "found encrypt_then_mac extension" \
792 -c "using encrypt then mac" \
793 -s "using encrypt then mac"
794
795run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100796 "$P_SRV debug_level=3 etm=0 \
797 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100798 "$P_CLI debug_level=3 etm=1" \
799 0 \
800 -c "client hello, adding encrypt_then_mac extension" \
801 -s "found encrypt then mac extension" \
802 -S "server hello, adding encrypt then mac extension" \
803 -C "found encrypt_then_mac extension" \
804 -C "using encrypt then mac" \
805 -S "using encrypt then mac"
806
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100807run_test "Encrypt then MAC: client enabled, aead cipher" \
808 "$P_SRV debug_level=3 etm=1 \
809 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
810 "$P_CLI debug_level=3 etm=1" \
811 0 \
812 -c "client hello, adding encrypt_then_mac extension" \
813 -s "found encrypt then mac extension" \
814 -S "server hello, adding encrypt then mac extension" \
815 -C "found encrypt_then_mac extension" \
816 -C "using encrypt then mac" \
817 -S "using encrypt then mac"
818
819run_test "Encrypt then MAC: client enabled, stream cipher" \
820 "$P_SRV debug_level=3 etm=1 \
821 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100822 "$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 +0100823 0 \
824 -c "client hello, adding encrypt_then_mac extension" \
825 -s "found encrypt then mac extension" \
826 -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é-Gonnard699cafa2014-10-27 13:57:03 +0100831run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100832 "$P_SRV debug_level=3 etm=1 \
833 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100834 "$P_CLI debug_level=3 etm=0" \
835 0 \
836 -C "client hello, adding encrypt_then_mac extension" \
837 -S "found encrypt then mac extension" \
838 -S "server hello, adding encrypt then mac extension" \
839 -C "found encrypt_then_mac extension" \
840 -C "using encrypt then mac" \
841 -S "using encrypt then mac"
842
Janos Follathe2681a42016-03-07 15:57:05 +0000843requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100844run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100845 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100846 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100847 "$P_CLI debug_level=3 force_version=ssl3" \
848 0 \
849 -C "client hello, adding encrypt_then_mac extension" \
850 -S "found encrypt then mac extension" \
851 -S "server hello, adding encrypt then mac extension" \
852 -C "found encrypt_then_mac extension" \
853 -C "using encrypt then mac" \
854 -S "using encrypt then mac"
855
Janos Follathe2681a42016-03-07 15:57:05 +0000856requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100857run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100858 "$P_SRV debug_level=3 force_version=ssl3 \
859 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100860 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100861 0 \
862 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100863 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100864 -S "server hello, adding encrypt then mac extension" \
865 -C "found encrypt_then_mac extension" \
866 -C "using encrypt then mac" \
867 -S "using encrypt then mac"
868
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200869# Tests for Extended Master Secret extension
870
871run_test "Extended Master Secret: default" \
872 "$P_SRV debug_level=3" \
873 "$P_CLI debug_level=3" \
874 0 \
875 -c "client hello, adding extended_master_secret extension" \
876 -s "found extended master secret extension" \
877 -s "server hello, adding extended master secret extension" \
878 -c "found extended_master_secret extension" \
879 -c "using extended master secret" \
880 -s "using extended master secret"
881
882run_test "Extended Master Secret: client enabled, server disabled" \
883 "$P_SRV debug_level=3 extended_ms=0" \
884 "$P_CLI debug_level=3 extended_ms=1" \
885 0 \
886 -c "client hello, adding extended_master_secret extension" \
887 -s "found extended master secret extension" \
888 -S "server hello, adding extended master secret extension" \
889 -C "found extended_master_secret extension" \
890 -C "using extended master secret" \
891 -S "using extended master secret"
892
893run_test "Extended Master Secret: client disabled, server enabled" \
894 "$P_SRV debug_level=3 extended_ms=1" \
895 "$P_CLI debug_level=3 extended_ms=0" \
896 0 \
897 -C "client hello, adding extended_master_secret extension" \
898 -S "found extended master secret extension" \
899 -S "server hello, adding extended master secret extension" \
900 -C "found extended_master_secret extension" \
901 -C "using extended master secret" \
902 -S "using extended master secret"
903
Janos Follathe2681a42016-03-07 15:57:05 +0000904requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200905run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100906 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200907 "$P_CLI debug_level=3 force_version=ssl3" \
908 0 \
909 -C "client hello, adding extended_master_secret extension" \
910 -S "found extended master secret extension" \
911 -S "server hello, adding extended master secret extension" \
912 -C "found extended_master_secret extension" \
913 -C "using extended master secret" \
914 -S "using extended master secret"
915
Janos Follathe2681a42016-03-07 15:57:05 +0000916requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200917run_test "Extended Master Secret: client enabled, server SSLv3" \
918 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100919 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200920 0 \
921 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100922 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200923 -S "server hello, adding extended master secret extension" \
924 -C "found extended_master_secret extension" \
925 -C "using extended master secret" \
926 -S "using extended master secret"
927
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200928# Tests for FALLBACK_SCSV
929
930run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200931 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200932 "$P_CLI debug_level=3 force_version=tls1_1" \
933 0 \
934 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200935 -S "received FALLBACK_SCSV" \
936 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200937 -C "is a fatal alert message (msg 86)"
938
939run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200940 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200941 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
942 0 \
943 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200944 -S "received FALLBACK_SCSV" \
945 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200946 -C "is a fatal alert message (msg 86)"
947
948run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200949 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200950 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200951 1 \
952 -c "adding FALLBACK_SCSV" \
953 -s "received FALLBACK_SCSV" \
954 -s "inapropriate fallback" \
955 -c "is a fatal alert message (msg 86)"
956
957run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200958 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200959 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200960 0 \
961 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200962 -s "received FALLBACK_SCSV" \
963 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200964 -C "is a fatal alert message (msg 86)"
965
966requires_openssl_with_fallback_scsv
967run_test "Fallback SCSV: default, openssl server" \
968 "$O_SRV" \
969 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
970 0 \
971 -C "adding FALLBACK_SCSV" \
972 -C "is a fatal alert message (msg 86)"
973
974requires_openssl_with_fallback_scsv
975run_test "Fallback SCSV: enabled, openssl server" \
976 "$O_SRV" \
977 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
978 1 \
979 -c "adding FALLBACK_SCSV" \
980 -c "is a fatal alert message (msg 86)"
981
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200982requires_openssl_with_fallback_scsv
983run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200984 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200985 "$O_CLI -tls1_1" \
986 0 \
987 -S "received FALLBACK_SCSV" \
988 -S "inapropriate fallback"
989
990requires_openssl_with_fallback_scsv
991run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200992 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200993 "$O_CLI -tls1_1 -fallback_scsv" \
994 1 \
995 -s "received FALLBACK_SCSV" \
996 -s "inapropriate fallback"
997
998requires_openssl_with_fallback_scsv
999run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001000 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001001 "$O_CLI -fallback_scsv" \
1002 0 \
1003 -s "received FALLBACK_SCSV" \
1004 -S "inapropriate fallback"
1005
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001006# Tests for CBC 1/n-1 record splitting
1007
1008run_test "CBC Record splitting: TLS 1.2, no splitting" \
1009 "$P_SRV" \
1010 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1011 request_size=123 force_version=tls1_2" \
1012 0 \
1013 -s "Read from client: 123 bytes read" \
1014 -S "Read from client: 1 bytes read" \
1015 -S "122 bytes read"
1016
1017run_test "CBC Record splitting: TLS 1.1, no splitting" \
1018 "$P_SRV" \
1019 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1020 request_size=123 force_version=tls1_1" \
1021 0 \
1022 -s "Read from client: 123 bytes read" \
1023 -S "Read from client: 1 bytes read" \
1024 -S "122 bytes read"
1025
1026run_test "CBC Record splitting: TLS 1.0, splitting" \
1027 "$P_SRV" \
1028 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1029 request_size=123 force_version=tls1" \
1030 0 \
1031 -S "Read from client: 123 bytes read" \
1032 -s "Read from client: 1 bytes read" \
1033 -s "122 bytes read"
1034
Janos Follathe2681a42016-03-07 15:57:05 +00001035requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001036run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001037 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001038 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1039 request_size=123 force_version=ssl3" \
1040 0 \
1041 -S "Read from client: 123 bytes read" \
1042 -s "Read from client: 1 bytes read" \
1043 -s "122 bytes read"
1044
1045run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001046 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001047 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1048 request_size=123 force_version=tls1" \
1049 0 \
1050 -s "Read from client: 123 bytes read" \
1051 -S "Read from client: 1 bytes read" \
1052 -S "122 bytes read"
1053
1054run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1055 "$P_SRV" \
1056 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1057 request_size=123 force_version=tls1 recsplit=0" \
1058 0 \
1059 -s "Read from client: 123 bytes read" \
1060 -S "Read from client: 1 bytes read" \
1061 -S "122 bytes read"
1062
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001063run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1064 "$P_SRV nbio=2" \
1065 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1066 request_size=123 force_version=tls1" \
1067 0 \
1068 -S "Read from client: 123 bytes read" \
1069 -s "Read from client: 1 bytes read" \
1070 -s "122 bytes read"
1071
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001072# Tests for Session Tickets
1073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001074run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001075 "$P_SRV debug_level=3 tickets=1" \
1076 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001077 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001078 -c "client hello, adding session ticket extension" \
1079 -s "found session ticket extension" \
1080 -s "server hello, adding session ticket extension" \
1081 -c "found session_ticket extension" \
1082 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001083 -S "session successfully restored from cache" \
1084 -s "session successfully restored from ticket" \
1085 -s "a session has been resumed" \
1086 -c "a session has been resumed"
1087
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001088run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001089 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1090 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001091 0 \
1092 -c "client hello, adding session ticket extension" \
1093 -s "found session ticket extension" \
1094 -s "server hello, adding session ticket extension" \
1095 -c "found session_ticket extension" \
1096 -c "parse new session ticket" \
1097 -S "session successfully restored from cache" \
1098 -s "session successfully restored from ticket" \
1099 -s "a session has been resumed" \
1100 -c "a session has been resumed"
1101
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001102run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001103 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1104 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001105 0 \
1106 -c "client hello, adding session ticket extension" \
1107 -s "found session ticket extension" \
1108 -s "server hello, adding session ticket extension" \
1109 -c "found session_ticket extension" \
1110 -c "parse new session ticket" \
1111 -S "session successfully restored from cache" \
1112 -S "session successfully restored from ticket" \
1113 -S "a session has been resumed" \
1114 -C "a session has been resumed"
1115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001116run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001117 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001118 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001119 0 \
1120 -c "client hello, adding session ticket extension" \
1121 -c "found session_ticket extension" \
1122 -c "parse new session ticket" \
1123 -c "a session has been resumed"
1124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001125run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001126 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001127 "( $O_CLI -sess_out $SESSION; \
1128 $O_CLI -sess_in $SESSION; \
1129 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001130 0 \
1131 -s "found session ticket extension" \
1132 -s "server hello, adding session ticket extension" \
1133 -S "session successfully restored from cache" \
1134 -s "session successfully restored from ticket" \
1135 -s "a session has been resumed"
1136
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001137# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001138
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001139run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001140 "$P_SRV debug_level=3 tickets=0" \
1141 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001142 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001143 -c "client hello, adding session ticket extension" \
1144 -s "found session ticket extension" \
1145 -S "server hello, adding session ticket extension" \
1146 -C "found session_ticket extension" \
1147 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001148 -s "session successfully restored from cache" \
1149 -S "session successfully restored from ticket" \
1150 -s "a session has been resumed" \
1151 -c "a session has been resumed"
1152
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001153run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001154 "$P_SRV debug_level=3 tickets=1" \
1155 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001156 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001157 -C "client hello, adding session ticket extension" \
1158 -S "found session ticket extension" \
1159 -S "server hello, adding session ticket extension" \
1160 -C "found session_ticket extension" \
1161 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001162 -s "session successfully restored from cache" \
1163 -S "session successfully restored from ticket" \
1164 -s "a session has been resumed" \
1165 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001167run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001168 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1169 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001170 0 \
1171 -S "session successfully restored from cache" \
1172 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001173 -S "a session has been resumed" \
1174 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001175
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001176run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001177 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1178 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001179 0 \
1180 -s "session successfully restored from cache" \
1181 -S "session successfully restored from ticket" \
1182 -s "a session has been resumed" \
1183 -c "a session has been resumed"
1184
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001185run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001186 "$P_SRV debug_level=3 tickets=0" \
1187 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001188 0 \
1189 -s "session successfully restored from cache" \
1190 -S "session successfully restored from ticket" \
1191 -s "a session has been resumed" \
1192 -c "a session has been resumed"
1193
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001194run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001195 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1196 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001197 0 \
1198 -S "session successfully restored from cache" \
1199 -S "session successfully restored from ticket" \
1200 -S "a session has been resumed" \
1201 -C "a session has been resumed"
1202
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001203run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001204 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1205 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001206 0 \
1207 -s "session successfully restored from cache" \
1208 -S "session successfully restored from ticket" \
1209 -s "a session has been resumed" \
1210 -c "a session has been resumed"
1211
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001212run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001213 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001214 "( $O_CLI -sess_out $SESSION; \
1215 $O_CLI -sess_in $SESSION; \
1216 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001217 0 \
1218 -s "found session ticket extension" \
1219 -S "server hello, adding session ticket extension" \
1220 -s "session successfully restored from cache" \
1221 -S "session successfully restored from ticket" \
1222 -s "a session has been resumed"
1223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001224run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001225 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001226 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001227 0 \
1228 -C "found session_ticket extension" \
1229 -C "parse new session ticket" \
1230 -c "a session has been resumed"
1231
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001232# Tests for Max Fragment Length extension
1233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001234run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001235 "$P_SRV debug_level=3" \
1236 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001237 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001238 -c "Maximum fragment length is 16384" \
1239 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001240 -C "client hello, adding max_fragment_length extension" \
1241 -S "found max fragment length extension" \
1242 -S "server hello, max_fragment_length extension" \
1243 -C "found max_fragment_length extension"
1244
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001245run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001246 "$P_SRV debug_level=3" \
1247 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001248 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001249 -c "Maximum fragment length is 4096" \
1250 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001251 -c "client hello, adding max_fragment_length extension" \
1252 -s "found max fragment length extension" \
1253 -s "server hello, max_fragment_length extension" \
1254 -c "found max_fragment_length extension"
1255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001256run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_SRV debug_level=3 max_frag_len=4096" \
1258 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001259 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001260 -c "Maximum fragment length is 16384" \
1261 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001262 -C "client hello, adding max_fragment_length extension" \
1263 -S "found max fragment length extension" \
1264 -S "server hello, max_fragment_length extension" \
1265 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001267requires_gnutls
1268run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001269 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001270 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001271 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001272 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001273 -c "client hello, adding max_fragment_length extension" \
1274 -c "found max_fragment_length extension"
1275
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001276run_test "Max fragment length: client, message just fits" \
1277 "$P_SRV debug_level=3" \
1278 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1279 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001280 -c "Maximum fragment length is 2048" \
1281 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001282 -c "client hello, adding max_fragment_length extension" \
1283 -s "found max fragment length extension" \
1284 -s "server hello, max_fragment_length extension" \
1285 -c "found max_fragment_length extension" \
1286 -c "2048 bytes written in 1 fragments" \
1287 -s "2048 bytes read"
1288
1289run_test "Max fragment length: client, larger message" \
1290 "$P_SRV debug_level=3" \
1291 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1292 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001293 -c "Maximum fragment length is 2048" \
1294 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001295 -c "client hello, adding max_fragment_length extension" \
1296 -s "found max fragment length extension" \
1297 -s "server hello, max_fragment_length extension" \
1298 -c "found max_fragment_length extension" \
1299 -c "2345 bytes written in 2 fragments" \
1300 -s "2048 bytes read" \
1301 -s "297 bytes read"
1302
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001303run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001304 "$P_SRV debug_level=3 dtls=1" \
1305 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1306 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001307 -c "Maximum fragment length is 2048" \
1308 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001309 -c "client hello, adding max_fragment_length extension" \
1310 -s "found max fragment length extension" \
1311 -s "server hello, max_fragment_length extension" \
1312 -c "found max_fragment_length extension" \
1313 -c "fragment larger than.*maximum"
1314
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001315# Tests for renegotiation
1316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001317run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001318 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001319 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001320 0 \
1321 -C "client hello, adding renegotiation extension" \
1322 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1323 -S "found renegotiation extension" \
1324 -s "server hello, secure renegotiation extension" \
1325 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001326 -C "=> renegotiate" \
1327 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001328 -S "write hello request"
1329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001330run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001331 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001332 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001333 0 \
1334 -c "client hello, adding renegotiation extension" \
1335 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1336 -s "found renegotiation extension" \
1337 -s "server hello, secure renegotiation extension" \
1338 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001339 -c "=> renegotiate" \
1340 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001341 -S "write hello request"
1342
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001343run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001344 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001345 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001346 0 \
1347 -c "client hello, adding renegotiation extension" \
1348 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1349 -s "found renegotiation extension" \
1350 -s "server hello, secure renegotiation extension" \
1351 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001352 -c "=> renegotiate" \
1353 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001354 -s "write hello request"
1355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001356run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001357 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001358 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001359 0 \
1360 -c "client hello, adding renegotiation extension" \
1361 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1362 -s "found renegotiation extension" \
1363 -s "server hello, secure renegotiation extension" \
1364 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001365 -c "=> renegotiate" \
1366 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001367 -s "write hello request"
1368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001369run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001370 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001371 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001372 1 \
1373 -c "client hello, adding renegotiation extension" \
1374 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1375 -S "found renegotiation extension" \
1376 -s "server hello, secure renegotiation extension" \
1377 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001378 -c "=> renegotiate" \
1379 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001380 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001381 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001382 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001383
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001384run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001385 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001386 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001387 0 \
1388 -C "client hello, adding renegotiation extension" \
1389 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1390 -S "found renegotiation extension" \
1391 -s "server hello, secure renegotiation extension" \
1392 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001393 -C "=> renegotiate" \
1394 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001395 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001396 -S "SSL - An unexpected message was received from our peer" \
1397 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001398
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001399run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001400 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001401 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001402 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001403 0 \
1404 -C "client hello, adding renegotiation extension" \
1405 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1406 -S "found renegotiation extension" \
1407 -s "server hello, secure renegotiation extension" \
1408 -c "found renegotiation extension" \
1409 -C "=> renegotiate" \
1410 -S "=> renegotiate" \
1411 -s "write hello request" \
1412 -S "SSL - An unexpected message was received from our peer" \
1413 -S "failed"
1414
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001415# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001416run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001417 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001418 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001419 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001420 0 \
1421 -C "client hello, adding renegotiation extension" \
1422 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1423 -S "found renegotiation extension" \
1424 -s "server hello, secure renegotiation extension" \
1425 -c "found renegotiation extension" \
1426 -C "=> renegotiate" \
1427 -S "=> renegotiate" \
1428 -s "write hello request" \
1429 -S "SSL - An unexpected message was received from our peer" \
1430 -S "failed"
1431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001432run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001433 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001434 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001435 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001436 0 \
1437 -C "client hello, adding renegotiation extension" \
1438 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1439 -S "found renegotiation extension" \
1440 -s "server hello, secure renegotiation extension" \
1441 -c "found renegotiation extension" \
1442 -C "=> renegotiate" \
1443 -S "=> renegotiate" \
1444 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001445 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001447run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001448 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001449 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001450 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001451 0 \
1452 -c "client hello, adding renegotiation extension" \
1453 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1454 -s "found renegotiation extension" \
1455 -s "server hello, secure renegotiation extension" \
1456 -c "found renegotiation extension" \
1457 -c "=> renegotiate" \
1458 -s "=> renegotiate" \
1459 -s "write hello request" \
1460 -S "SSL - An unexpected message was received from our peer" \
1461 -S "failed"
1462
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001463run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001464 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001465 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1466 0 \
1467 -C "client hello, adding renegotiation extension" \
1468 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1469 -S "found renegotiation extension" \
1470 -s "server hello, secure renegotiation extension" \
1471 -c "found renegotiation extension" \
1472 -S "record counter limit reached: renegotiate" \
1473 -C "=> renegotiate" \
1474 -S "=> renegotiate" \
1475 -S "write hello request" \
1476 -S "SSL - An unexpected message was received from our peer" \
1477 -S "failed"
1478
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001479# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001480run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001481 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001482 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001483 0 \
1484 -c "client hello, adding renegotiation extension" \
1485 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1486 -s "found renegotiation extension" \
1487 -s "server hello, secure renegotiation extension" \
1488 -c "found renegotiation extension" \
1489 -s "record counter limit reached: renegotiate" \
1490 -c "=> renegotiate" \
1491 -s "=> renegotiate" \
1492 -s "write hello request" \
1493 -S "SSL - An unexpected message was received from our peer" \
1494 -S "failed"
1495
1496run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001497 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001498 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001499 0 \
1500 -c "client hello, adding renegotiation extension" \
1501 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1502 -s "found renegotiation extension" \
1503 -s "server hello, secure renegotiation extension" \
1504 -c "found renegotiation extension" \
1505 -s "record counter limit reached: renegotiate" \
1506 -c "=> renegotiate" \
1507 -s "=> renegotiate" \
1508 -s "write hello request" \
1509 -S "SSL - An unexpected message was received from our peer" \
1510 -S "failed"
1511
1512run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001513 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001514 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1515 0 \
1516 -C "client hello, adding renegotiation extension" \
1517 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1518 -S "found renegotiation extension" \
1519 -s "server hello, secure renegotiation extension" \
1520 -c "found renegotiation extension" \
1521 -S "record counter limit reached: renegotiate" \
1522 -C "=> renegotiate" \
1523 -S "=> renegotiate" \
1524 -S "write hello request" \
1525 -S "SSL - An unexpected message was received from our peer" \
1526 -S "failed"
1527
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001528run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001529 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001530 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001531 0 \
1532 -c "client hello, adding renegotiation extension" \
1533 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1534 -s "found renegotiation extension" \
1535 -s "server hello, secure renegotiation extension" \
1536 -c "found renegotiation extension" \
1537 -c "=> renegotiate" \
1538 -s "=> renegotiate" \
1539 -S "write hello request"
1540
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001541run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001542 "$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 +02001543 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001544 0 \
1545 -c "client hello, adding renegotiation extension" \
1546 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1547 -s "found renegotiation extension" \
1548 -s "server hello, secure renegotiation extension" \
1549 -c "found renegotiation extension" \
1550 -c "=> renegotiate" \
1551 -s "=> renegotiate" \
1552 -s "write hello request"
1553
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001554run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001555 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001556 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001557 0 \
1558 -c "client hello, adding renegotiation extension" \
1559 -c "found renegotiation extension" \
1560 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001561 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001562 -C "error" \
1563 -c "HTTP/1.0 200 [Oo][Kk]"
1564
Paul Bakker539d9722015-02-08 16:18:35 +01001565requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001566run_test "Renegotiation: gnutls server strict, client-initiated" \
1567 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001568 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001569 0 \
1570 -c "client hello, adding renegotiation extension" \
1571 -c "found renegotiation extension" \
1572 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001573 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001574 -C "error" \
1575 -c "HTTP/1.0 200 [Oo][Kk]"
1576
Paul Bakker539d9722015-02-08 16:18:35 +01001577requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001578run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1579 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1580 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1581 1 \
1582 -c "client hello, adding renegotiation extension" \
1583 -C "found renegotiation extension" \
1584 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001585 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001586 -c "error" \
1587 -C "HTTP/1.0 200 [Oo][Kk]"
1588
Paul Bakker539d9722015-02-08 16:18:35 +01001589requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001590run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1591 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1592 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1593 allow_legacy=0" \
1594 1 \
1595 -c "client hello, adding renegotiation extension" \
1596 -C "found renegotiation extension" \
1597 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001598 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001599 -c "error" \
1600 -C "HTTP/1.0 200 [Oo][Kk]"
1601
Paul Bakker539d9722015-02-08 16:18:35 +01001602requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001603run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1604 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1605 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1606 allow_legacy=1" \
1607 0 \
1608 -c "client hello, adding renegotiation extension" \
1609 -C "found renegotiation extension" \
1610 -c "=> renegotiate" \
1611 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001612 -C "error" \
1613 -c "HTTP/1.0 200 [Oo][Kk]"
1614
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001615run_test "Renegotiation: DTLS, client-initiated" \
1616 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1617 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1618 0 \
1619 -c "client hello, adding renegotiation extension" \
1620 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1621 -s "found renegotiation extension" \
1622 -s "server hello, secure renegotiation extension" \
1623 -c "found renegotiation extension" \
1624 -c "=> renegotiate" \
1625 -s "=> renegotiate" \
1626 -S "write hello request"
1627
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001628run_test "Renegotiation: DTLS, server-initiated" \
1629 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001630 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1631 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001632 0 \
1633 -c "client hello, adding renegotiation extension" \
1634 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1635 -s "found renegotiation extension" \
1636 -s "server hello, secure renegotiation extension" \
1637 -c "found renegotiation extension" \
1638 -c "=> renegotiate" \
1639 -s "=> renegotiate" \
1640 -s "write hello request"
1641
Andres AG692ad842017-01-19 16:30:57 +00001642run_test "Renegotiation: DTLS, renego_period overflow" \
1643 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1644 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1645 0 \
1646 -c "client hello, adding renegotiation extension" \
1647 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1648 -s "found renegotiation extension" \
1649 -s "server hello, secure renegotiation extension" \
1650 -s "record counter limit reached: renegotiate" \
1651 -c "=> renegotiate" \
1652 -s "=> renegotiate" \
1653 -s "write hello request" \
1654
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001655requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001656run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1657 "$G_SRV -u --mtu 4096" \
1658 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1659 0 \
1660 -c "client hello, adding renegotiation extension" \
1661 -c "found renegotiation extension" \
1662 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001663 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001664 -C "error" \
1665 -s "Extra-header:"
1666
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001667# Test for the "secure renegotation" extension only (no actual renegotiation)
1668
Paul Bakker539d9722015-02-08 16:18:35 +01001669requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001670run_test "Renego ext: gnutls server strict, client default" \
1671 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1672 "$P_CLI debug_level=3" \
1673 0 \
1674 -c "found renegotiation extension" \
1675 -C "error" \
1676 -c "HTTP/1.0 200 [Oo][Kk]"
1677
Paul Bakker539d9722015-02-08 16:18:35 +01001678requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001679run_test "Renego ext: gnutls server unsafe, client default" \
1680 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1681 "$P_CLI debug_level=3" \
1682 0 \
1683 -C "found renegotiation extension" \
1684 -C "error" \
1685 -c "HTTP/1.0 200 [Oo][Kk]"
1686
Paul Bakker539d9722015-02-08 16:18:35 +01001687requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001688run_test "Renego ext: gnutls server unsafe, client break legacy" \
1689 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1690 "$P_CLI debug_level=3 allow_legacy=-1" \
1691 1 \
1692 -C "found renegotiation extension" \
1693 -c "error" \
1694 -C "HTTP/1.0 200 [Oo][Kk]"
1695
Paul Bakker539d9722015-02-08 16:18:35 +01001696requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001697run_test "Renego ext: gnutls client strict, server default" \
1698 "$P_SRV debug_level=3" \
1699 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1700 0 \
1701 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1702 -s "server hello, secure renegotiation extension"
1703
Paul Bakker539d9722015-02-08 16:18:35 +01001704requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001705run_test "Renego ext: gnutls client unsafe, server default" \
1706 "$P_SRV debug_level=3" \
1707 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1708 0 \
1709 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1710 -S "server hello, secure renegotiation extension"
1711
Paul Bakker539d9722015-02-08 16:18:35 +01001712requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001713run_test "Renego ext: gnutls client unsafe, server break legacy" \
1714 "$P_SRV debug_level=3 allow_legacy=-1" \
1715 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1716 1 \
1717 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1718 -S "server hello, secure renegotiation extension"
1719
Janos Follath0b242342016-02-17 10:11:21 +00001720# Tests for silently dropping trailing extra bytes in .der certificates
1721
1722requires_gnutls
1723run_test "DER format: no trailing bytes" \
1724 "$P_SRV crt_file=data_files/server5-der0.crt \
1725 key_file=data_files/server5.key" \
1726 "$G_CLI " \
1727 0 \
1728 -c "Handshake was completed" \
1729
1730requires_gnutls
1731run_test "DER format: with a trailing zero byte" \
1732 "$P_SRV crt_file=data_files/server5-der1a.crt \
1733 key_file=data_files/server5.key" \
1734 "$G_CLI " \
1735 0 \
1736 -c "Handshake was completed" \
1737
1738requires_gnutls
1739run_test "DER format: with a trailing random byte" \
1740 "$P_SRV crt_file=data_files/server5-der1b.crt \
1741 key_file=data_files/server5.key" \
1742 "$G_CLI " \
1743 0 \
1744 -c "Handshake was completed" \
1745
1746requires_gnutls
1747run_test "DER format: with 2 trailing random bytes" \
1748 "$P_SRV crt_file=data_files/server5-der2.crt \
1749 key_file=data_files/server5.key" \
1750 "$G_CLI " \
1751 0 \
1752 -c "Handshake was completed" \
1753
1754requires_gnutls
1755run_test "DER format: with 4 trailing random bytes" \
1756 "$P_SRV crt_file=data_files/server5-der4.crt \
1757 key_file=data_files/server5.key" \
1758 "$G_CLI " \
1759 0 \
1760 -c "Handshake was completed" \
1761
1762requires_gnutls
1763run_test "DER format: with 8 trailing random bytes" \
1764 "$P_SRV crt_file=data_files/server5-der8.crt \
1765 key_file=data_files/server5.key" \
1766 "$G_CLI " \
1767 0 \
1768 -c "Handshake was completed" \
1769
1770requires_gnutls
1771run_test "DER format: with 9 trailing random bytes" \
1772 "$P_SRV crt_file=data_files/server5-der9.crt \
1773 key_file=data_files/server5.key" \
1774 "$G_CLI " \
1775 0 \
1776 -c "Handshake was completed" \
1777
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001778# Tests for auth_mode
1779
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001780run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001781 "$P_SRV crt_file=data_files/server5-badsign.crt \
1782 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001783 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001784 1 \
1785 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001786 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001787 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001788 -c "X509 - Certificate verification failed"
1789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001790run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001791 "$P_SRV crt_file=data_files/server5-badsign.crt \
1792 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001793 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001794 0 \
1795 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001796 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001797 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001798 -C "X509 - Certificate verification failed"
1799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001800run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001801 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001802 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001803 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001804 0 \
1805 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001806 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001807 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001808 -C "X509 - Certificate verification failed"
1809
Simon Butcher99000142016-10-13 17:21:01 +01001810run_test "Authentication: client SHA256, server required" \
1811 "$P_SRV auth_mode=required" \
1812 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1813 key_file=data_files/server6.key \
1814 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1815 0 \
1816 -c "Supported Signature Algorithm found: 4," \
1817 -c "Supported Signature Algorithm found: 5,"
1818
1819run_test "Authentication: client SHA384, server required" \
1820 "$P_SRV auth_mode=required" \
1821 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1822 key_file=data_files/server6.key \
1823 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
1824 0 \
1825 -c "Supported Signature Algorithm found: 4," \
1826 -c "Supported Signature Algorithm found: 5,"
1827
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001828run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001829 "$P_SRV debug_level=3 auth_mode=required" \
1830 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001831 key_file=data_files/server5.key" \
1832 1 \
1833 -S "skip write certificate request" \
1834 -C "skip parse certificate request" \
1835 -c "got a certificate request" \
1836 -C "skip write certificate" \
1837 -C "skip write certificate verify" \
1838 -S "skip parse certificate verify" \
1839 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001840 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001841 -s "! mbedtls_ssl_handshake returned" \
1842 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001843 -s "X509 - Certificate verification failed"
1844
Janos Follath89baba22017-04-10 14:34:35 +01001845run_test "Authentication: client cert not trusted, server required" \
1846 "$P_SRV debug_level=3 auth_mode=required" \
1847 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
1848 key_file=data_files/server5.key" \
1849 1 \
1850 -S "skip write certificate request" \
1851 -C "skip parse certificate request" \
1852 -c "got a certificate request" \
1853 -C "skip write certificate" \
1854 -C "skip write certificate verify" \
1855 -S "skip parse certificate verify" \
1856 -s "x509_verify_cert() returned" \
1857 -s "! The certificate is not correctly signed by the trusted CA" \
1858 -s "! mbedtls_ssl_handshake returned" \
1859 -c "! mbedtls_ssl_handshake returned" \
1860 -s "X509 - Certificate verification failed"
1861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001862run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001863 "$P_SRV debug_level=3 auth_mode=optional" \
1864 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001865 key_file=data_files/server5.key" \
1866 0 \
1867 -S "skip write certificate request" \
1868 -C "skip parse certificate request" \
1869 -c "got a certificate request" \
1870 -C "skip write certificate" \
1871 -C "skip write certificate verify" \
1872 -S "skip parse certificate verify" \
1873 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001874 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001875 -S "! mbedtls_ssl_handshake returned" \
1876 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001877 -S "X509 - Certificate verification failed"
1878
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001879run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001880 "$P_SRV debug_level=3 auth_mode=none" \
1881 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001882 key_file=data_files/server5.key" \
1883 0 \
1884 -s "skip write certificate request" \
1885 -C "skip parse certificate request" \
1886 -c "got no certificate request" \
1887 -c "skip write certificate" \
1888 -c "skip write certificate verify" \
1889 -s "skip parse certificate verify" \
1890 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001891 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001892 -S "! mbedtls_ssl_handshake returned" \
1893 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001894 -S "X509 - Certificate verification failed"
1895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001896run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001897 "$P_SRV debug_level=3 auth_mode=optional" \
1898 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001899 0 \
1900 -S "skip write certificate request" \
1901 -C "skip parse certificate request" \
1902 -c "got a certificate request" \
1903 -C "skip write certificate$" \
1904 -C "got no certificate to send" \
1905 -S "SSLv3 client has no certificate" \
1906 -c "skip write certificate verify" \
1907 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001908 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001909 -S "! mbedtls_ssl_handshake returned" \
1910 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001911 -S "X509 - Certificate verification failed"
1912
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001913run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001914 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001915 "$O_CLI" \
1916 0 \
1917 -S "skip write certificate request" \
1918 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001919 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001920 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001921 -S "X509 - Certificate verification failed"
1922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001923run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001924 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001925 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001926 0 \
1927 -C "skip parse certificate request" \
1928 -c "got a certificate request" \
1929 -C "skip write certificate$" \
1930 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001931 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001932
Janos Follathe2681a42016-03-07 15:57:05 +00001933requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001934run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001935 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001936 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001937 0 \
1938 -S "skip write certificate request" \
1939 -C "skip parse certificate request" \
1940 -c "got a certificate request" \
1941 -C "skip write certificate$" \
1942 -c "skip write certificate verify" \
1943 -c "got no certificate to send" \
1944 -s "SSLv3 client has no certificate" \
1945 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001946 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001947 -S "! mbedtls_ssl_handshake returned" \
1948 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001949 -S "X509 - Certificate verification failed"
1950
Janos Follath89baba22017-04-10 14:34:35 +01001951# Tests for CA list in CertificateRequest messages
1952
1953run_test "Authentication: send CA list in CertificateRequest (default)" \
1954 "$P_SRV debug_level=3 auth_mode=required" \
1955 "$P_CLI crt_file=data_files/server6.crt \
1956 key_file=data_files/server6.key" \
1957 0 \
1958 -s "requested DN"
1959
1960run_test "Authentication: do not send CA list in CertificateRequest" \
1961 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
1962 "$P_CLI crt_file=data_files/server6.crt \
1963 key_file=data_files/server6.key" \
1964 0 \
1965 -S "requested DN"
1966
1967run_test "Authentication: send CA list in CertificateRequest, client self signed" \
1968 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
1969 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
1970 key_file=data_files/server5.key" \
1971 1 \
1972 -S "requested DN" \
1973 -s "x509_verify_cert() returned" \
1974 -s "! The certificate is not correctly signed by the trusted CA" \
1975 -s "! mbedtls_ssl_handshake returned" \
1976 -c "! mbedtls_ssl_handshake returned" \
1977 -s "X509 - Certificate verification failed"
1978
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001979# Tests for certificate selection based on SHA verson
1980
1981run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1982 "$P_SRV crt_file=data_files/server5.crt \
1983 key_file=data_files/server5.key \
1984 crt_file2=data_files/server5-sha1.crt \
1985 key_file2=data_files/server5.key" \
1986 "$P_CLI force_version=tls1_2" \
1987 0 \
1988 -c "signed using.*ECDSA with SHA256" \
1989 -C "signed using.*ECDSA with SHA1"
1990
1991run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1992 "$P_SRV crt_file=data_files/server5.crt \
1993 key_file=data_files/server5.key \
1994 crt_file2=data_files/server5-sha1.crt \
1995 key_file2=data_files/server5.key" \
1996 "$P_CLI force_version=tls1_1" \
1997 0 \
1998 -C "signed using.*ECDSA with SHA256" \
1999 -c "signed using.*ECDSA with SHA1"
2000
2001run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2002 "$P_SRV crt_file=data_files/server5.crt \
2003 key_file=data_files/server5.key \
2004 crt_file2=data_files/server5-sha1.crt \
2005 key_file2=data_files/server5.key" \
2006 "$P_CLI force_version=tls1" \
2007 0 \
2008 -C "signed using.*ECDSA with SHA256" \
2009 -c "signed using.*ECDSA with SHA1"
2010
2011run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2012 "$P_SRV crt_file=data_files/server5.crt \
2013 key_file=data_files/server5.key \
2014 crt_file2=data_files/server6.crt \
2015 key_file2=data_files/server6.key" \
2016 "$P_CLI force_version=tls1_1" \
2017 0 \
2018 -c "serial number.*09" \
2019 -c "signed using.*ECDSA with SHA256" \
2020 -C "signed using.*ECDSA with SHA1"
2021
2022run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2023 "$P_SRV crt_file=data_files/server6.crt \
2024 key_file=data_files/server6.key \
2025 crt_file2=data_files/server5.crt \
2026 key_file2=data_files/server5.key" \
2027 "$P_CLI force_version=tls1_1" \
2028 0 \
2029 -c "serial number.*0A" \
2030 -c "signed using.*ECDSA with SHA256" \
2031 -C "signed using.*ECDSA with SHA1"
2032
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002033# tests for SNI
2034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002035run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002036 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002037 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002038 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002039 0 \
2040 -S "parse ServerName extension" \
2041 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2042 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002044run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002045 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002046 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002047 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 +02002048 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002049 0 \
2050 -s "parse ServerName extension" \
2051 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2052 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002054run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002055 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002056 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002057 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 +02002058 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002059 0 \
2060 -s "parse ServerName extension" \
2061 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2062 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002063
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002064run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002065 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002066 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002067 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 +02002068 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002069 1 \
2070 -s "parse ServerName extension" \
2071 -s "ssl_sni_wrapper() returned" \
2072 -s "mbedtls_ssl_handshake returned" \
2073 -c "mbedtls_ssl_handshake returned" \
2074 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002075
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002076run_test "SNI: client auth no override: optional" \
2077 "$P_SRV debug_level=3 auth_mode=optional \
2078 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2079 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2080 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002081 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002082 -S "skip write certificate request" \
2083 -C "skip parse certificate request" \
2084 -c "got a certificate request" \
2085 -C "skip write certificate" \
2086 -C "skip write certificate verify" \
2087 -S "skip parse certificate verify"
2088
2089run_test "SNI: client auth override: none -> optional" \
2090 "$P_SRV debug_level=3 auth_mode=none \
2091 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2092 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2093 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002094 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002095 -S "skip write certificate request" \
2096 -C "skip parse certificate request" \
2097 -c "got a certificate request" \
2098 -C "skip write certificate" \
2099 -C "skip write certificate verify" \
2100 -S "skip parse certificate verify"
2101
2102run_test "SNI: client auth override: optional -> none" \
2103 "$P_SRV debug_level=3 auth_mode=optional \
2104 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2105 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2106 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002107 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002108 -s "skip write certificate request" \
2109 -C "skip parse certificate request" \
2110 -c "got no certificate request" \
2111 -c "skip write certificate" \
2112 -c "skip write certificate verify" \
2113 -s "skip parse certificate verify"
2114
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002115run_test "SNI: CA no override" \
2116 "$P_SRV debug_level=3 auth_mode=optional \
2117 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2118 ca_file=data_files/test-ca.crt \
2119 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2120 "$P_CLI debug_level=3 server_name=localhost \
2121 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2122 1 \
2123 -S "skip write certificate request" \
2124 -C "skip parse certificate request" \
2125 -c "got a certificate request" \
2126 -C "skip write certificate" \
2127 -C "skip write certificate verify" \
2128 -S "skip parse certificate verify" \
2129 -s "x509_verify_cert() returned" \
2130 -s "! The certificate is not correctly signed by the trusted CA" \
2131 -S "The certificate has been revoked (is on a CRL)"
2132
2133run_test "SNI: CA override" \
2134 "$P_SRV debug_level=3 auth_mode=optional \
2135 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2136 ca_file=data_files/test-ca.crt \
2137 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2138 "$P_CLI debug_level=3 server_name=localhost \
2139 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2140 0 \
2141 -S "skip write certificate request" \
2142 -C "skip parse certificate request" \
2143 -c "got a certificate request" \
2144 -C "skip write certificate" \
2145 -C "skip write certificate verify" \
2146 -S "skip parse certificate verify" \
2147 -S "x509_verify_cert() returned" \
2148 -S "! The certificate is not correctly signed by the trusted CA" \
2149 -S "The certificate has been revoked (is on a CRL)"
2150
2151run_test "SNI: CA override with CRL" \
2152 "$P_SRV debug_level=3 auth_mode=optional \
2153 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2154 ca_file=data_files/test-ca.crt \
2155 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2156 "$P_CLI debug_level=3 server_name=localhost \
2157 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2158 1 \
2159 -S "skip write certificate request" \
2160 -C "skip parse certificate request" \
2161 -c "got a certificate request" \
2162 -C "skip write certificate" \
2163 -C "skip write certificate verify" \
2164 -S "skip parse certificate verify" \
2165 -s "x509_verify_cert() returned" \
2166 -S "! The certificate is not correctly signed by the trusted CA" \
2167 -s "The certificate has been revoked (is on a CRL)"
2168
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002169# Tests for non-blocking I/O: exercise a variety of handshake flows
2170
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002171run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002172 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2173 "$P_CLI nbio=2 tickets=0" \
2174 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002175 -S "mbedtls_ssl_handshake returned" \
2176 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002177 -c "Read from server: .* bytes read"
2178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002179run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002180 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2181 "$P_CLI nbio=2 tickets=0" \
2182 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002183 -S "mbedtls_ssl_handshake returned" \
2184 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002185 -c "Read from server: .* bytes read"
2186
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002187run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002188 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2189 "$P_CLI nbio=2 tickets=1" \
2190 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002191 -S "mbedtls_ssl_handshake returned" \
2192 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002193 -c "Read from server: .* bytes read"
2194
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002195run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002196 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2197 "$P_CLI nbio=2 tickets=1" \
2198 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002199 -S "mbedtls_ssl_handshake returned" \
2200 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002201 -c "Read from server: .* bytes read"
2202
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002203run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002204 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2205 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2206 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002207 -S "mbedtls_ssl_handshake returned" \
2208 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002209 -c "Read from server: .* bytes read"
2210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002211run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002212 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2213 "$P_CLI nbio=2 tickets=1 reconnect=1" \
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: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002220 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2221 "$P_CLI nbio=2 tickets=0 reconnect=1" \
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é-Gonnardf6521de2014-04-07 12:42:04 +02002227# Tests for version negotiation
2228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002229run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002230 "$P_SRV" \
2231 "$P_CLI" \
2232 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002233 -S "mbedtls_ssl_handshake returned" \
2234 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002235 -s "Protocol is TLSv1.2" \
2236 -c "Protocol is TLSv1.2"
2237
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002238run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002239 "$P_SRV" \
2240 "$P_CLI max_version=tls1_1" \
2241 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002242 -S "mbedtls_ssl_handshake returned" \
2243 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002244 -s "Protocol is TLSv1.1" \
2245 -c "Protocol is TLSv1.1"
2246
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002247run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002248 "$P_SRV max_version=tls1_1" \
2249 "$P_CLI" \
2250 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002251 -S "mbedtls_ssl_handshake returned" \
2252 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002253 -s "Protocol is TLSv1.1" \
2254 -c "Protocol is TLSv1.1"
2255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002256run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002257 "$P_SRV max_version=tls1_1" \
2258 "$P_CLI max_version=tls1_1" \
2259 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002260 -S "mbedtls_ssl_handshake returned" \
2261 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002262 -s "Protocol is TLSv1.1" \
2263 -c "Protocol is TLSv1.1"
2264
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002265run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002266 "$P_SRV min_version=tls1_1" \
2267 "$P_CLI max_version=tls1_1" \
2268 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002269 -S "mbedtls_ssl_handshake returned" \
2270 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002271 -s "Protocol is TLSv1.1" \
2272 -c "Protocol is TLSv1.1"
2273
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002274run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002275 "$P_SRV max_version=tls1_1" \
2276 "$P_CLI min_version=tls1_1" \
2277 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002278 -S "mbedtls_ssl_handshake returned" \
2279 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002280 -s "Protocol is TLSv1.1" \
2281 -c "Protocol is TLSv1.1"
2282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002283run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002284 "$P_SRV max_version=tls1_1" \
2285 "$P_CLI min_version=tls1_2" \
2286 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002287 -s "mbedtls_ssl_handshake returned" \
2288 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002289 -c "SSL - Handshake protocol not within min/max boundaries"
2290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002291run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002292 "$P_SRV min_version=tls1_2" \
2293 "$P_CLI max_version=tls1_1" \
2294 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002295 -s "mbedtls_ssl_handshake returned" \
2296 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002297 -s "SSL - Handshake protocol not within min/max boundaries"
2298
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002299# Tests for ALPN extension
2300
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002301run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002302 "$P_SRV debug_level=3" \
2303 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002304 0 \
2305 -C "client hello, adding alpn extension" \
2306 -S "found alpn extension" \
2307 -C "got an alert message, type: \\[2:120]" \
2308 -S "server hello, adding alpn extension" \
2309 -C "found alpn extension " \
2310 -C "Application Layer Protocol is" \
2311 -S "Application Layer Protocol is"
2312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002313run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002314 "$P_SRV debug_level=3" \
2315 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002316 0 \
2317 -c "client hello, adding alpn extension" \
2318 -s "found alpn extension" \
2319 -C "got an alert message, type: \\[2:120]" \
2320 -S "server hello, adding alpn extension" \
2321 -C "found alpn extension " \
2322 -c "Application Layer Protocol is (none)" \
2323 -S "Application Layer Protocol is"
2324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002325run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002326 "$P_SRV debug_level=3 alpn=abc,1234" \
2327 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002328 0 \
2329 -C "client hello, adding alpn extension" \
2330 -S "found alpn extension" \
2331 -C "got an alert message, type: \\[2:120]" \
2332 -S "server hello, adding alpn extension" \
2333 -C "found alpn extension " \
2334 -C "Application Layer Protocol is" \
2335 -s "Application Layer Protocol is (none)"
2336
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002337run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002338 "$P_SRV debug_level=3 alpn=abc,1234" \
2339 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002340 0 \
2341 -c "client hello, adding alpn extension" \
2342 -s "found alpn extension" \
2343 -C "got an alert message, type: \\[2:120]" \
2344 -s "server hello, adding alpn extension" \
2345 -c "found alpn extension" \
2346 -c "Application Layer Protocol is abc" \
2347 -s "Application Layer Protocol is abc"
2348
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002349run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002350 "$P_SRV debug_level=3 alpn=abc,1234" \
2351 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002352 0 \
2353 -c "client hello, adding alpn extension" \
2354 -s "found alpn extension" \
2355 -C "got an alert message, type: \\[2:120]" \
2356 -s "server hello, adding alpn extension" \
2357 -c "found alpn extension" \
2358 -c "Application Layer Protocol is abc" \
2359 -s "Application Layer Protocol is abc"
2360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002361run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002362 "$P_SRV debug_level=3 alpn=abc,1234" \
2363 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002364 0 \
2365 -c "client hello, adding alpn extension" \
2366 -s "found alpn extension" \
2367 -C "got an alert message, type: \\[2:120]" \
2368 -s "server hello, adding alpn extension" \
2369 -c "found alpn extension" \
2370 -c "Application Layer Protocol is 1234" \
2371 -s "Application Layer Protocol is 1234"
2372
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002373run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002374 "$P_SRV debug_level=3 alpn=abc,123" \
2375 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002376 1 \
2377 -c "client hello, adding alpn extension" \
2378 -s "found alpn extension" \
2379 -c "got an alert message, type: \\[2:120]" \
2380 -S "server hello, adding alpn extension" \
2381 -C "found alpn extension" \
2382 -C "Application Layer Protocol is 1234" \
2383 -S "Application Layer Protocol is 1234"
2384
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002385
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002386# Tests for keyUsage in leaf certificates, part 1:
2387# server-side certificate/suite selection
2388
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002389run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002390 "$P_SRV key_file=data_files/server2.key \
2391 crt_file=data_files/server2.ku-ds.crt" \
2392 "$P_CLI" \
2393 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002394 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002395
2396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002397run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002398 "$P_SRV key_file=data_files/server2.key \
2399 crt_file=data_files/server2.ku-ke.crt" \
2400 "$P_CLI" \
2401 0 \
2402 -c "Ciphersuite is TLS-RSA-WITH-"
2403
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002404run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002405 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002406 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002407 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002408 1 \
2409 -C "Ciphersuite is "
2410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002411run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002412 "$P_SRV key_file=data_files/server5.key \
2413 crt_file=data_files/server5.ku-ds.crt" \
2414 "$P_CLI" \
2415 0 \
2416 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2417
2418
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002419run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002420 "$P_SRV key_file=data_files/server5.key \
2421 crt_file=data_files/server5.ku-ka.crt" \
2422 "$P_CLI" \
2423 0 \
2424 -c "Ciphersuite is TLS-ECDH-"
2425
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002426run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002427 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002428 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002429 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002430 1 \
2431 -C "Ciphersuite is "
2432
2433# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002434# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002435
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002436run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002437 "$O_SRV -key data_files/server2.key \
2438 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002439 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002440 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2441 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002442 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002443 -C "Processing of the Certificate handshake message failed" \
2444 -c "Ciphersuite is TLS-"
2445
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002446run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002447 "$O_SRV -key data_files/server2.key \
2448 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002449 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002450 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2451 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002452 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002453 -C "Processing of the Certificate handshake message failed" \
2454 -c "Ciphersuite is TLS-"
2455
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002456run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002457 "$O_SRV -key data_files/server2.key \
2458 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002459 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002460 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2461 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002462 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002463 -C "Processing of the Certificate handshake message failed" \
2464 -c "Ciphersuite is TLS-"
2465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002466run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002467 "$O_SRV -key data_files/server2.key \
2468 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002469 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002470 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2471 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002472 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002473 -c "Processing of the Certificate handshake message failed" \
2474 -C "Ciphersuite is TLS-"
2475
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002476run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2477 "$O_SRV -key data_files/server2.key \
2478 -cert data_files/server2.ku-ke.crt" \
2479 "$P_CLI debug_level=1 auth_mode=optional \
2480 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2481 0 \
2482 -c "bad certificate (usage extensions)" \
2483 -C "Processing of the Certificate handshake message failed" \
2484 -c "Ciphersuite is TLS-" \
2485 -c "! Usage does not match the keyUsage extension"
2486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002487run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002488 "$O_SRV -key data_files/server2.key \
2489 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002490 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002491 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2492 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002493 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002494 -C "Processing of the Certificate handshake message failed" \
2495 -c "Ciphersuite is TLS-"
2496
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002497run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002498 "$O_SRV -key data_files/server2.key \
2499 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002500 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002501 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2502 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002503 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002504 -c "Processing of the Certificate handshake message failed" \
2505 -C "Ciphersuite is TLS-"
2506
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002507run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2508 "$O_SRV -key data_files/server2.key \
2509 -cert data_files/server2.ku-ds.crt" \
2510 "$P_CLI debug_level=1 auth_mode=optional \
2511 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2512 0 \
2513 -c "bad certificate (usage extensions)" \
2514 -C "Processing of the Certificate handshake message failed" \
2515 -c "Ciphersuite is TLS-" \
2516 -c "! Usage does not match the keyUsage extension"
2517
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002518# Tests for keyUsage in leaf certificates, part 3:
2519# server-side checking of client cert
2520
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002521run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002522 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002523 "$O_CLI -key data_files/server2.key \
2524 -cert data_files/server2.ku-ds.crt" \
2525 0 \
2526 -S "bad certificate (usage extensions)" \
2527 -S "Processing of the Certificate handshake message failed"
2528
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002529run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002530 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002531 "$O_CLI -key data_files/server2.key \
2532 -cert data_files/server2.ku-ke.crt" \
2533 0 \
2534 -s "bad certificate (usage extensions)" \
2535 -S "Processing of the Certificate handshake message failed"
2536
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002537run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002538 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002539 "$O_CLI -key data_files/server2.key \
2540 -cert data_files/server2.ku-ke.crt" \
2541 1 \
2542 -s "bad certificate (usage extensions)" \
2543 -s "Processing of the Certificate handshake message failed"
2544
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002545run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002546 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002547 "$O_CLI -key data_files/server5.key \
2548 -cert data_files/server5.ku-ds.crt" \
2549 0 \
2550 -S "bad certificate (usage extensions)" \
2551 -S "Processing of the Certificate handshake message failed"
2552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002553run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002554 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002555 "$O_CLI -key data_files/server5.key \
2556 -cert data_files/server5.ku-ka.crt" \
2557 0 \
2558 -s "bad certificate (usage extensions)" \
2559 -S "Processing of the Certificate handshake message failed"
2560
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002561# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2562
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002563run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002564 "$P_SRV key_file=data_files/server5.key \
2565 crt_file=data_files/server5.eku-srv.crt" \
2566 "$P_CLI" \
2567 0
2568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002569run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002570 "$P_SRV key_file=data_files/server5.key \
2571 crt_file=data_files/server5.eku-srv.crt" \
2572 "$P_CLI" \
2573 0
2574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002575run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002576 "$P_SRV key_file=data_files/server5.key \
2577 crt_file=data_files/server5.eku-cs_any.crt" \
2578 "$P_CLI" \
2579 0
2580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002581run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002582 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002583 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002584 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002585 1
2586
2587# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002589run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002590 "$O_SRV -key data_files/server5.key \
2591 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002592 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002593 0 \
2594 -C "bad certificate (usage extensions)" \
2595 -C "Processing of the Certificate handshake message failed" \
2596 -c "Ciphersuite is TLS-"
2597
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002598run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002599 "$O_SRV -key data_files/server5.key \
2600 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002601 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002602 0 \
2603 -C "bad certificate (usage extensions)" \
2604 -C "Processing of the Certificate handshake message failed" \
2605 -c "Ciphersuite is TLS-"
2606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002607run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002608 "$O_SRV -key data_files/server5.key \
2609 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002610 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002611 0 \
2612 -C "bad certificate (usage extensions)" \
2613 -C "Processing of the Certificate handshake message failed" \
2614 -c "Ciphersuite is TLS-"
2615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002616run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002617 "$O_SRV -key data_files/server5.key \
2618 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002619 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002620 1 \
2621 -c "bad certificate (usage extensions)" \
2622 -c "Processing of the Certificate handshake message failed" \
2623 -C "Ciphersuite is TLS-"
2624
2625# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002627run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002628 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002629 "$O_CLI -key data_files/server5.key \
2630 -cert data_files/server5.eku-cli.crt" \
2631 0 \
2632 -S "bad certificate (usage extensions)" \
2633 -S "Processing of the Certificate handshake message failed"
2634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002635run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002636 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002637 "$O_CLI -key data_files/server5.key \
2638 -cert data_files/server5.eku-srv_cli.crt" \
2639 0 \
2640 -S "bad certificate (usage extensions)" \
2641 -S "Processing of the Certificate handshake message failed"
2642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002643run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002644 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002645 "$O_CLI -key data_files/server5.key \
2646 -cert data_files/server5.eku-cs_any.crt" \
2647 0 \
2648 -S "bad certificate (usage extensions)" \
2649 -S "Processing of the Certificate handshake message failed"
2650
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002651run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002652 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002653 "$O_CLI -key data_files/server5.key \
2654 -cert data_files/server5.eku-cs.crt" \
2655 0 \
2656 -s "bad certificate (usage extensions)" \
2657 -S "Processing of the Certificate handshake message failed"
2658
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002659run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002660 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002661 "$O_CLI -key data_files/server5.key \
2662 -cert data_files/server5.eku-cs.crt" \
2663 1 \
2664 -s "bad certificate (usage extensions)" \
2665 -s "Processing of the Certificate handshake message failed"
2666
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002667# Tests for DHM parameters loading
2668
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002669run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002670 "$P_SRV" \
2671 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2672 debug_level=3" \
2673 0 \
2674 -c "value of 'DHM: P ' (2048 bits)" \
2675 -c "value of 'DHM: G ' (2048 bits)"
2676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002677run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002678 "$P_SRV dhm_file=data_files/dhparams.pem" \
2679 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2680 debug_level=3" \
2681 0 \
2682 -c "value of 'DHM: P ' (1024 bits)" \
2683 -c "value of 'DHM: G ' (2 bits)"
2684
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002685# Tests for DHM client-side size checking
2686
2687run_test "DHM size: server default, client default, OK" \
2688 "$P_SRV" \
2689 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2690 debug_level=1" \
2691 0 \
2692 -C "DHM prime too short:"
2693
2694run_test "DHM size: server default, client 2048, OK" \
2695 "$P_SRV" \
2696 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2697 debug_level=1 dhmlen=2048" \
2698 0 \
2699 -C "DHM prime too short:"
2700
2701run_test "DHM size: server 1024, client default, OK" \
2702 "$P_SRV dhm_file=data_files/dhparams.pem" \
2703 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2704 debug_level=1" \
2705 0 \
2706 -C "DHM prime too short:"
2707
2708run_test "DHM size: server 1000, client default, rejected" \
2709 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2710 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2711 debug_level=1" \
2712 1 \
2713 -c "DHM prime too short:"
2714
2715run_test "DHM size: server default, client 2049, rejected" \
2716 "$P_SRV" \
2717 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2718 debug_level=1 dhmlen=2049" \
2719 1 \
2720 -c "DHM prime too short:"
2721
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002722# Tests for PSK callback
2723
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002724run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002725 "$P_SRV psk=abc123 psk_identity=foo" \
2726 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2727 psk_identity=foo psk=abc123" \
2728 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002729 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002730 -S "SSL - Unknown identity received" \
2731 -S "SSL - Verification of the message MAC failed"
2732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002733run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002734 "$P_SRV" \
2735 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2736 psk_identity=foo psk=abc123" \
2737 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002738 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002739 -S "SSL - Unknown identity received" \
2740 -S "SSL - Verification of the message MAC failed"
2741
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002742run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002743 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2744 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2745 psk_identity=foo psk=abc123" \
2746 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002747 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002748 -s "SSL - Unknown identity received" \
2749 -S "SSL - Verification of the message MAC failed"
2750
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002751run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002752 "$P_SRV psk_list=abc,dead,def,beef" \
2753 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2754 psk_identity=abc psk=dead" \
2755 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002756 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002757 -S "SSL - Unknown identity received" \
2758 -S "SSL - Verification of the message MAC failed"
2759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002760run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002761 "$P_SRV psk_list=abc,dead,def,beef" \
2762 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2763 psk_identity=def psk=beef" \
2764 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002765 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002766 -S "SSL - Unknown identity received" \
2767 -S "SSL - Verification of the message MAC failed"
2768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002769run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002770 "$P_SRV psk_list=abc,dead,def,beef" \
2771 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2772 psk_identity=ghi psk=beef" \
2773 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002774 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002775 -s "SSL - Unknown identity received" \
2776 -S "SSL - Verification of the message MAC failed"
2777
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002778run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002779 "$P_SRV psk_list=abc,dead,def,beef" \
2780 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2781 psk_identity=abc psk=beef" \
2782 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002783 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002784 -S "SSL - Unknown identity received" \
2785 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002786
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002787# Tests for EC J-PAKE
2788
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002789requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002790run_test "ECJPAKE: client not configured" \
2791 "$P_SRV debug_level=3" \
2792 "$P_CLI debug_level=3" \
2793 0 \
2794 -C "add ciphersuite: c0ff" \
2795 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002796 -S "found ecjpake kkpp extension" \
2797 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002798 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002799 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002800 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002801 -S "None of the common ciphersuites is usable"
2802
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002803requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002804run_test "ECJPAKE: server not configured" \
2805 "$P_SRV debug_level=3" \
2806 "$P_CLI debug_level=3 ecjpake_pw=bla \
2807 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2808 1 \
2809 -c "add ciphersuite: c0ff" \
2810 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002811 -s "found ecjpake kkpp extension" \
2812 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002813 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002814 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002815 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002816 -s "None of the common ciphersuites is usable"
2817
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002818requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002819run_test "ECJPAKE: working, TLS" \
2820 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2821 "$P_CLI debug_level=3 ecjpake_pw=bla \
2822 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002823 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002824 -c "add ciphersuite: c0ff" \
2825 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002826 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002827 -s "found ecjpake kkpp extension" \
2828 -S "skip ecjpake kkpp extension" \
2829 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002830 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002831 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002832 -S "None of the common ciphersuites is usable" \
2833 -S "SSL - Verification of the message MAC failed"
2834
Janos Follath74537a62016-09-02 13:45:28 +01002835server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002836requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002837run_test "ECJPAKE: password mismatch, TLS" \
2838 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2839 "$P_CLI debug_level=3 ecjpake_pw=bad \
2840 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2841 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002842 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002843 -s "SSL - Verification of the message MAC failed"
2844
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002845requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002846run_test "ECJPAKE: working, DTLS" \
2847 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2848 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2849 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2850 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002851 -c "re-using cached ecjpake parameters" \
2852 -S "SSL - Verification of the message MAC failed"
2853
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002854requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002855run_test "ECJPAKE: working, DTLS, no cookie" \
2856 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2857 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2858 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2859 0 \
2860 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002861 -S "SSL - Verification of the message MAC failed"
2862
Janos Follath74537a62016-09-02 13:45:28 +01002863server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002864requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002865run_test "ECJPAKE: password mismatch, DTLS" \
2866 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2867 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2868 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2869 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002870 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002871 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002872
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002873# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002874requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002875run_test "ECJPAKE: working, DTLS, nolog" \
2876 "$P_SRV dtls=1 ecjpake_pw=bla" \
2877 "$P_CLI dtls=1 ecjpake_pw=bla \
2878 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2879 0
2880
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002881# Tests for ciphersuites per version
2882
Janos Follathe2681a42016-03-07 15:57:05 +00002883requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002884run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002885 "$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 +02002886 "$P_CLI force_version=ssl3" \
2887 0 \
2888 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2889
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002890run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002891 "$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 +01002892 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002893 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002894 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002896run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002897 "$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 +02002898 "$P_CLI force_version=tls1_1" \
2899 0 \
2900 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2901
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002902run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002903 "$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 +02002904 "$P_CLI force_version=tls1_2" \
2905 0 \
2906 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2907
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002908# Test for ClientHello without extensions
2909
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002910requires_gnutls
2911run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002912 "$P_SRV debug_level=3" \
2913 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2914 0 \
2915 -s "dumping 'client hello extensions' (0 bytes)"
2916
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002917# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002918
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002919run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002920 "$P_SRV" \
2921 "$P_CLI request_size=100" \
2922 0 \
2923 -s "Read from client: 100 bytes read$"
2924
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002925run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002926 "$P_SRV" \
2927 "$P_CLI request_size=500" \
2928 0 \
2929 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002930
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002931# Tests for small packets
2932
Janos Follathe2681a42016-03-07 15:57:05 +00002933requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002934run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002935 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002936 "$P_CLI request_size=1 force_version=ssl3 \
2937 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2938 0 \
2939 -s "Read from client: 1 bytes read"
2940
Janos Follathe2681a42016-03-07 15:57:05 +00002941requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002942run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002943 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002944 "$P_CLI request_size=1 force_version=ssl3 \
2945 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2946 0 \
2947 -s "Read from client: 1 bytes read"
2948
2949run_test "Small packet TLS 1.0 BlockCipher" \
2950 "$P_SRV" \
2951 "$P_CLI request_size=1 force_version=tls1 \
2952 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2953 0 \
2954 -s "Read from client: 1 bytes read"
2955
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002956run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2957 "$P_SRV" \
2958 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2959 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2960 0 \
2961 -s "Read from client: 1 bytes read"
2962
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002963run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2964 "$P_SRV" \
2965 "$P_CLI request_size=1 force_version=tls1 \
2966 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2967 trunc_hmac=1" \
2968 0 \
2969 -s "Read from client: 1 bytes read"
2970
2971run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002972 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002973 "$P_CLI request_size=1 force_version=tls1 \
2974 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2975 trunc_hmac=1" \
2976 0 \
2977 -s "Read from client: 1 bytes read"
2978
2979run_test "Small packet TLS 1.1 BlockCipher" \
2980 "$P_SRV" \
2981 "$P_CLI request_size=1 force_version=tls1_1 \
2982 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2983 0 \
2984 -s "Read from client: 1 bytes read"
2985
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002986run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2987 "$P_SRV" \
2988 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2989 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2990 0 \
2991 -s "Read from client: 1 bytes read"
2992
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002993run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002994 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002995 "$P_CLI request_size=1 force_version=tls1_1 \
2996 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2997 0 \
2998 -s "Read from client: 1 bytes read"
2999
3000run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3001 "$P_SRV" \
3002 "$P_CLI request_size=1 force_version=tls1_1 \
3003 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3004 trunc_hmac=1" \
3005 0 \
3006 -s "Read from client: 1 bytes read"
3007
3008run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003009 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003010 "$P_CLI request_size=1 force_version=tls1_1 \
3011 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3012 trunc_hmac=1" \
3013 0 \
3014 -s "Read from client: 1 bytes read"
3015
3016run_test "Small packet TLS 1.2 BlockCipher" \
3017 "$P_SRV" \
3018 "$P_CLI request_size=1 force_version=tls1_2 \
3019 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3020 0 \
3021 -s "Read from client: 1 bytes read"
3022
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003023run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3024 "$P_SRV" \
3025 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3026 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3027 0 \
3028 -s "Read from client: 1 bytes read"
3029
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003030run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3031 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003032 "$P_CLI request_size=1 force_version=tls1_2 \
3033 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003034 0 \
3035 -s "Read from client: 1 bytes read"
3036
3037run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3038 "$P_SRV" \
3039 "$P_CLI request_size=1 force_version=tls1_2 \
3040 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3041 trunc_hmac=1" \
3042 0 \
3043 -s "Read from client: 1 bytes read"
3044
3045run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003046 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003047 "$P_CLI request_size=1 force_version=tls1_2 \
3048 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3049 0 \
3050 -s "Read from client: 1 bytes read"
3051
3052run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003053 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003054 "$P_CLI request_size=1 force_version=tls1_2 \
3055 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3056 trunc_hmac=1" \
3057 0 \
3058 -s "Read from client: 1 bytes read"
3059
3060run_test "Small packet TLS 1.2 AEAD" \
3061 "$P_SRV" \
3062 "$P_CLI request_size=1 force_version=tls1_2 \
3063 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3064 0 \
3065 -s "Read from client: 1 bytes read"
3066
3067run_test "Small packet TLS 1.2 AEAD shorter tag" \
3068 "$P_SRV" \
3069 "$P_CLI request_size=1 force_version=tls1_2 \
3070 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3071 0 \
3072 -s "Read from client: 1 bytes read"
3073
Janos Follath00efff72016-05-06 13:48:23 +01003074# A test for extensions in SSLv3
3075
3076requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3077run_test "SSLv3 with extensions, server side" \
3078 "$P_SRV min_version=ssl3 debug_level=3" \
3079 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3080 0 \
3081 -S "dumping 'client hello extensions'" \
3082 -S "server hello, total extension length:"
3083
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003084# Test for large packets
3085
Janos Follathe2681a42016-03-07 15:57:05 +00003086requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003087run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003088 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003089 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003090 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3091 0 \
3092 -s "Read from client: 16384 bytes read"
3093
Janos Follathe2681a42016-03-07 15:57:05 +00003094requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003095run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003096 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003097 "$P_CLI request_size=16384 force_version=ssl3 \
3098 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3099 0 \
3100 -s "Read from client: 16384 bytes read"
3101
3102run_test "Large packet TLS 1.0 BlockCipher" \
3103 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003104 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003105 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3106 0 \
3107 -s "Read from client: 16384 bytes read"
3108
3109run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3110 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003111 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003112 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3113 trunc_hmac=1" \
3114 0 \
3115 -s "Read from client: 16384 bytes read"
3116
3117run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003118 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003119 "$P_CLI request_size=16384 force_version=tls1 \
3120 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3121 trunc_hmac=1" \
3122 0 \
3123 -s "Read from client: 16384 bytes read"
3124
3125run_test "Large packet TLS 1.1 BlockCipher" \
3126 "$P_SRV" \
3127 "$P_CLI request_size=16384 force_version=tls1_1 \
3128 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3129 0 \
3130 -s "Read from client: 16384 bytes read"
3131
3132run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003133 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003134 "$P_CLI request_size=16384 force_version=tls1_1 \
3135 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3136 0 \
3137 -s "Read from client: 16384 bytes read"
3138
3139run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3140 "$P_SRV" \
3141 "$P_CLI request_size=16384 force_version=tls1_1 \
3142 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3143 trunc_hmac=1" \
3144 0 \
3145 -s "Read from client: 16384 bytes read"
3146
3147run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003148 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003149 "$P_CLI request_size=16384 force_version=tls1_1 \
3150 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3151 trunc_hmac=1" \
3152 0 \
3153 -s "Read from client: 16384 bytes read"
3154
3155run_test "Large packet TLS 1.2 BlockCipher" \
3156 "$P_SRV" \
3157 "$P_CLI request_size=16384 force_version=tls1_2 \
3158 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3159 0 \
3160 -s "Read from client: 16384 bytes read"
3161
3162run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3163 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003164 "$P_CLI request_size=16384 force_version=tls1_2 \
3165 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003166 0 \
3167 -s "Read from client: 16384 bytes read"
3168
3169run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3170 "$P_SRV" \
3171 "$P_CLI request_size=16384 force_version=tls1_2 \
3172 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3173 trunc_hmac=1" \
3174 0 \
3175 -s "Read from client: 16384 bytes read"
3176
3177run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003178 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003179 "$P_CLI request_size=16384 force_version=tls1_2 \
3180 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3181 0 \
3182 -s "Read from client: 16384 bytes read"
3183
3184run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003185 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003186 "$P_CLI request_size=16384 force_version=tls1_2 \
3187 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3188 trunc_hmac=1" \
3189 0 \
3190 -s "Read from client: 16384 bytes read"
3191
3192run_test "Large packet TLS 1.2 AEAD" \
3193 "$P_SRV" \
3194 "$P_CLI request_size=16384 force_version=tls1_2 \
3195 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3196 0 \
3197 -s "Read from client: 16384 bytes read"
3198
3199run_test "Large packet TLS 1.2 AEAD shorter tag" \
3200 "$P_SRV" \
3201 "$P_CLI request_size=16384 force_version=tls1_2 \
3202 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3203 0 \
3204 -s "Read from client: 16384 bytes read"
3205
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003206# Tests for DTLS HelloVerifyRequest
3207
3208run_test "DTLS cookie: enabled" \
3209 "$P_SRV dtls=1 debug_level=2" \
3210 "$P_CLI dtls=1 debug_level=2" \
3211 0 \
3212 -s "cookie verification failed" \
3213 -s "cookie verification passed" \
3214 -S "cookie verification skipped" \
3215 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003216 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003217 -S "SSL - The requested feature is not available"
3218
3219run_test "DTLS cookie: disabled" \
3220 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3221 "$P_CLI dtls=1 debug_level=2" \
3222 0 \
3223 -S "cookie verification failed" \
3224 -S "cookie verification passed" \
3225 -s "cookie verification skipped" \
3226 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003227 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003228 -S "SSL - The requested feature is not available"
3229
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003230run_test "DTLS cookie: default (failing)" \
3231 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3232 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3233 1 \
3234 -s "cookie verification failed" \
3235 -S "cookie verification passed" \
3236 -S "cookie verification skipped" \
3237 -C "received hello verify request" \
3238 -S "hello verification requested" \
3239 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003240
3241requires_ipv6
3242run_test "DTLS cookie: enabled, IPv6" \
3243 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3244 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3245 0 \
3246 -s "cookie verification failed" \
3247 -s "cookie verification passed" \
3248 -S "cookie verification skipped" \
3249 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003250 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003251 -S "SSL - The requested feature is not available"
3252
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003253run_test "DTLS cookie: enabled, nbio" \
3254 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3255 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3256 0 \
3257 -s "cookie verification failed" \
3258 -s "cookie verification passed" \
3259 -S "cookie verification skipped" \
3260 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003261 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003262 -S "SSL - The requested feature is not available"
3263
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003264# Tests for client reconnecting from the same port with DTLS
3265
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003266not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003267run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003268 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3269 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003270 0 \
3271 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003272 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003273 -S "Client initiated reconnection from same port"
3274
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003275not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003276run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003277 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3278 "$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 +02003279 0 \
3280 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003281 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003282 -s "Client initiated reconnection from same port"
3283
Paul Bakker362689d2016-05-13 10:33:25 +01003284not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3285run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003286 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3287 "$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 +02003288 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003289 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003290 -s "Client initiated reconnection from same port"
3291
Paul Bakker362689d2016-05-13 10:33:25 +01003292only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3293run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3294 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3295 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3296 0 \
3297 -S "The operation timed out" \
3298 -s "Client initiated reconnection from same port"
3299
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003300run_test "DTLS client reconnect from same port: no cookies" \
3301 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003302 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3303 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003304 -s "The operation timed out" \
3305 -S "Client initiated reconnection from same port"
3306
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003307# Tests for various cases of client authentication with DTLS
3308# (focused on handshake flows and message parsing)
3309
3310run_test "DTLS client auth: required" \
3311 "$P_SRV dtls=1 auth_mode=required" \
3312 "$P_CLI dtls=1" \
3313 0 \
3314 -s "Verifying peer X.509 certificate... ok"
3315
3316run_test "DTLS client auth: optional, client has no cert" \
3317 "$P_SRV dtls=1 auth_mode=optional" \
3318 "$P_CLI dtls=1 crt_file=none key_file=none" \
3319 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003320 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003321
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003322run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003323 "$P_SRV dtls=1 auth_mode=none" \
3324 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3325 0 \
3326 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003327 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003328
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003329run_test "DTLS wrong PSK: badmac alert" \
3330 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3331 "$P_CLI dtls=1 psk=abc124" \
3332 1 \
3333 -s "SSL - Verification of the message MAC failed" \
3334 -c "SSL - A fatal alert message was received from our peer"
3335
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003336# Tests for receiving fragmented handshake messages with DTLS
3337
3338requires_gnutls
3339run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3340 "$G_SRV -u --mtu 2048 -a" \
3341 "$P_CLI dtls=1 debug_level=2" \
3342 0 \
3343 -C "found fragmented DTLS handshake message" \
3344 -C "error"
3345
3346requires_gnutls
3347run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3348 "$G_SRV -u --mtu 512" \
3349 "$P_CLI dtls=1 debug_level=2" \
3350 0 \
3351 -c "found fragmented DTLS handshake message" \
3352 -C "error"
3353
3354requires_gnutls
3355run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3356 "$G_SRV -u --mtu 128" \
3357 "$P_CLI dtls=1 debug_level=2" \
3358 0 \
3359 -c "found fragmented DTLS handshake message" \
3360 -C "error"
3361
3362requires_gnutls
3363run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3364 "$G_SRV -u --mtu 128" \
3365 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3366 0 \
3367 -c "found fragmented DTLS handshake message" \
3368 -C "error"
3369
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003370requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003371run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3372 "$G_SRV -u --mtu 256" \
3373 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3374 0 \
3375 -c "found fragmented DTLS handshake message" \
3376 -c "client hello, adding renegotiation extension" \
3377 -c "found renegotiation extension" \
3378 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003379 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003380 -C "error" \
3381 -s "Extra-header:"
3382
3383requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003384run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3385 "$G_SRV -u --mtu 256" \
3386 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3387 0 \
3388 -c "found fragmented DTLS handshake message" \
3389 -c "client hello, adding renegotiation extension" \
3390 -c "found renegotiation extension" \
3391 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003392 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003393 -C "error" \
3394 -s "Extra-header:"
3395
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003396run_test "DTLS reassembly: no fragmentation (openssl server)" \
3397 "$O_SRV -dtls1 -mtu 2048" \
3398 "$P_CLI dtls=1 debug_level=2" \
3399 0 \
3400 -C "found fragmented DTLS handshake message" \
3401 -C "error"
3402
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003403run_test "DTLS reassembly: some fragmentation (openssl server)" \
3404 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003405 "$P_CLI dtls=1 debug_level=2" \
3406 0 \
3407 -c "found fragmented DTLS handshake message" \
3408 -C "error"
3409
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003410run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003411 "$O_SRV -dtls1 -mtu 256" \
3412 "$P_CLI dtls=1 debug_level=2" \
3413 0 \
3414 -c "found fragmented DTLS handshake message" \
3415 -C "error"
3416
3417run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3418 "$O_SRV -dtls1 -mtu 256" \
3419 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3420 0 \
3421 -c "found fragmented DTLS handshake message" \
3422 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003423
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003424# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003425
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003426not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003427run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003428 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003429 "$P_SRV dtls=1 debug_level=2" \
3430 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003431 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003432 -C "replayed record" \
3433 -S "replayed record" \
3434 -C "record from another epoch" \
3435 -S "record from another epoch" \
3436 -C "discarding invalid record" \
3437 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003438 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003439 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003440 -c "HTTP/1.0 200 OK"
3441
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003442not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003443run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003444 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003445 "$P_SRV dtls=1 debug_level=2" \
3446 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003447 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003448 -c "replayed record" \
3449 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003450 -c "discarding invalid record" \
3451 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003452 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003453 -s "Extra-header:" \
3454 -c "HTTP/1.0 200 OK"
3455
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003456run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3457 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003458 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3459 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003460 0 \
3461 -c "replayed record" \
3462 -S "replayed record" \
3463 -c "discarding invalid record" \
3464 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003465 -c "resend" \
3466 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003467 -s "Extra-header:" \
3468 -c "HTTP/1.0 200 OK"
3469
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003470run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003471 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003472 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003473 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003474 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003475 -c "discarding invalid record (mac)" \
3476 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003477 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003478 -c "HTTP/1.0 200 OK" \
3479 -S "too many records with bad MAC" \
3480 -S "Verification of the message MAC failed"
3481
3482run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3483 -p "$P_PXY bad_ad=1" \
3484 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3485 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3486 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003487 -C "discarding invalid record (mac)" \
3488 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003489 -S "Extra-header:" \
3490 -C "HTTP/1.0 200 OK" \
3491 -s "too many records with bad MAC" \
3492 -s "Verification of the message MAC failed"
3493
3494run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3495 -p "$P_PXY bad_ad=1" \
3496 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3497 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3498 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003499 -c "discarding invalid record (mac)" \
3500 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003501 -s "Extra-header:" \
3502 -c "HTTP/1.0 200 OK" \
3503 -S "too many records with bad MAC" \
3504 -S "Verification of the message MAC failed"
3505
3506run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3507 -p "$P_PXY bad_ad=1" \
3508 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3509 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3510 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003511 -c "discarding invalid record (mac)" \
3512 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003513 -s "Extra-header:" \
3514 -c "HTTP/1.0 200 OK" \
3515 -s "too many records with bad MAC" \
3516 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003517
3518run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003519 -p "$P_PXY delay_ccs=1" \
3520 "$P_SRV dtls=1 debug_level=1" \
3521 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003522 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003523 -c "record from another epoch" \
3524 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003525 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003526 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003527 -s "Extra-header:" \
3528 -c "HTTP/1.0 200 OK"
3529
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003530# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003531
Janos Follath74537a62016-09-02 13:45:28 +01003532client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003533run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003534 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003535 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3536 psk=abc123" \
3537 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003538 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3539 0 \
3540 -s "Extra-header:" \
3541 -c "HTTP/1.0 200 OK"
3542
Janos Follath74537a62016-09-02 13:45:28 +01003543client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003544run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3545 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003546 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3547 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003548 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3549 0 \
3550 -s "Extra-header:" \
3551 -c "HTTP/1.0 200 OK"
3552
Janos Follath74537a62016-09-02 13:45:28 +01003553client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003554run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3555 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003556 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3557 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003558 0 \
3559 -s "Extra-header:" \
3560 -c "HTTP/1.0 200 OK"
3561
Janos Follath74537a62016-09-02 13:45:28 +01003562client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003563run_test "DTLS proxy: 3d, FS, client auth" \
3564 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003565 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3566 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003567 0 \
3568 -s "Extra-header:" \
3569 -c "HTTP/1.0 200 OK"
3570
Janos Follath74537a62016-09-02 13:45:28 +01003571client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003572run_test "DTLS proxy: 3d, FS, ticket" \
3573 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003574 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3575 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003576 0 \
3577 -s "Extra-header:" \
3578 -c "HTTP/1.0 200 OK"
3579
Janos Follath74537a62016-09-02 13:45:28 +01003580client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003581run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3582 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003583 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3584 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003585 0 \
3586 -s "Extra-header:" \
3587 -c "HTTP/1.0 200 OK"
3588
Janos Follath74537a62016-09-02 13:45:28 +01003589client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003590run_test "DTLS proxy: 3d, max handshake, nbio" \
3591 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003592 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3593 auth_mode=required" \
3594 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003595 0 \
3596 -s "Extra-header:" \
3597 -c "HTTP/1.0 200 OK"
3598
Janos Follath74537a62016-09-02 13:45:28 +01003599client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003600run_test "DTLS proxy: 3d, min handshake, resumption" \
3601 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3602 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3603 psk=abc123 debug_level=3" \
3604 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3605 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3606 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3607 0 \
3608 -s "a session has been resumed" \
3609 -c "a session has been resumed" \
3610 -s "Extra-header:" \
3611 -c "HTTP/1.0 200 OK"
3612
Janos Follath74537a62016-09-02 13:45:28 +01003613client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003614run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3615 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3616 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3617 psk=abc123 debug_level=3 nbio=2" \
3618 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3619 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3620 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3621 0 \
3622 -s "a session has been resumed" \
3623 -c "a session has been resumed" \
3624 -s "Extra-header:" \
3625 -c "HTTP/1.0 200 OK"
3626
Janos Follath74537a62016-09-02 13:45:28 +01003627client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003628run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003629 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003630 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3631 psk=abc123 renegotiation=1 debug_level=2" \
3632 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3633 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003634 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3635 0 \
3636 -c "=> renegotiate" \
3637 -s "=> renegotiate" \
3638 -s "Extra-header:" \
3639 -c "HTTP/1.0 200 OK"
3640
Janos Follath74537a62016-09-02 13:45:28 +01003641client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003642run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3643 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003644 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3645 psk=abc123 renegotiation=1 debug_level=2" \
3646 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3647 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003648 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3649 0 \
3650 -c "=> renegotiate" \
3651 -s "=> renegotiate" \
3652 -s "Extra-header:" \
3653 -c "HTTP/1.0 200 OK"
3654
Janos Follath74537a62016-09-02 13:45:28 +01003655client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003656run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003657 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003658 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003659 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003660 debug_level=2" \
3661 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003662 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003663 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3664 0 \
3665 -c "=> renegotiate" \
3666 -s "=> renegotiate" \
3667 -s "Extra-header:" \
3668 -c "HTTP/1.0 200 OK"
3669
Janos Follath74537a62016-09-02 13:45:28 +01003670client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003671run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003672 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003673 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003674 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003675 debug_level=2 nbio=2" \
3676 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003677 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003678 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3679 0 \
3680 -c "=> renegotiate" \
3681 -s "=> renegotiate" \
3682 -s "Extra-header:" \
3683 -c "HTTP/1.0 200 OK"
3684
Janos Follath74537a62016-09-02 13:45:28 +01003685client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003686not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003687run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003688 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3689 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003690 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003691 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003692 -c "HTTP/1.0 200 OK"
3693
Janos Follath74537a62016-09-02 13:45:28 +01003694client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003695not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003696run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3697 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3698 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003699 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003700 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003701 -c "HTTP/1.0 200 OK"
3702
Janos Follath74537a62016-09-02 13:45:28 +01003703client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003704not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003705run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3706 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3707 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003708 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003709 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003710 -c "HTTP/1.0 200 OK"
3711
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003712requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003713client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003714not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003715run_test "DTLS proxy: 3d, gnutls server" \
3716 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3717 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003718 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003719 0 \
3720 -s "Extra-header:" \
3721 -c "Extra-header:"
3722
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003723requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003724client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003725not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003726run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3727 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3728 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003729 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003730 0 \
3731 -s "Extra-header:" \
3732 -c "Extra-header:"
3733
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003734requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003735client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003736not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003737run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3738 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3739 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003740 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003741 0 \
3742 -s "Extra-header:" \
3743 -c "Extra-header:"
3744
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003745# Final report
3746
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003747echo "------------------------------------------------------------------------"
3748
3749if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003750 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003751else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003752 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003753fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003754PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003755echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003756
3757exit $FAILS