blob: c6bf0a16a39679c6d77c4cca2488e83969934725 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010031
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020032O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010033O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020034G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010035G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010036
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010037TESTS=0
38FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020039SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010040
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000041CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020042
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010043MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010044FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020045EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010046
Paul Bakkere20310a2016-05-10 11:18:17 +010047SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010048RUN_TEST_NUMBER=''
49
Paul Bakkeracaac852016-05-10 11:47:13 +010050PRESERVE_LOGS=0
51
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052print_usage() {
53 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010054 printf " -h|--help\tPrint this help.\n"
55 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
56 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
57 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010058 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010059 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010060 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Andres AGf04f54d2016-10-10 15:46:20 +010061 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062}
63
64get_options() {
65 while [ $# -gt 0 ]; do
66 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010067 -f|--filter)
68 shift; FILTER=$1
69 ;;
70 -e|--exclude)
71 shift; EXCLUDE=$1
72 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010073 -m|--memcheck)
74 MEMCHECK=1
75 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010076 -n|--number)
77 shift; RUN_TEST_NUMBER=$1
78 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010079 -s|--show-numbers)
80 SHOW_TEST_NUMBER=1
81 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010082 -p|--preserve-logs)
83 PRESERVE_LOGS=1
84 ;;
Andres AGf04f54d2016-10-10 15:46:20 +010085 --seed)
86 shift; SEED="$1"
87 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010088 -h|--help)
89 print_usage
90 exit 0
91 ;;
92 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020093 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010094 print_usage
95 exit 1
96 ;;
97 esac
98 shift
99 done
100}
101
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100102# skip next test if the flag is not enabled in config.h
103requires_config_enabled() {
104 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
105 SKIP_NEXT="YES"
106 fi
107}
108
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200109# skip next test if OpenSSL doesn't support FALLBACK_SCSV
110requires_openssl_with_fallback_scsv() {
111 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
112 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
113 then
114 OPENSSL_HAS_FBSCSV="YES"
115 else
116 OPENSSL_HAS_FBSCSV="NO"
117 fi
118 fi
119 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
120 SKIP_NEXT="YES"
121 fi
122}
123
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200124# skip next test if GnuTLS isn't available
125requires_gnutls() {
126 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200127 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200128 GNUTLS_AVAILABLE="YES"
129 else
130 GNUTLS_AVAILABLE="NO"
131 fi
132 fi
133 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
134 SKIP_NEXT="YES"
135 fi
136}
137
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200138# skip next test if IPv6 isn't available on this host
139requires_ipv6() {
140 if [ -z "${HAS_IPV6:-}" ]; then
141 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
142 SRV_PID=$!
143 sleep 1
144 kill $SRV_PID >/dev/null 2>&1
145 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
146 HAS_IPV6="NO"
147 else
148 HAS_IPV6="YES"
149 fi
150 rm -r $SRV_OUT
151 fi
152
153 if [ "$HAS_IPV6" = "NO" ]; then
154 SKIP_NEXT="YES"
155 fi
156}
157
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200158# skip the next test if valgrind is in use
159not_with_valgrind() {
160 if [ "$MEMCHECK" -gt 0 ]; then
161 SKIP_NEXT="YES"
162 fi
163}
164
Paul Bakker362689d2016-05-13 10:33:25 +0100165# skip the next test if valgrind is NOT in use
166only_with_valgrind() {
167 if [ "$MEMCHECK" -eq 0 ]; then
168 SKIP_NEXT="YES"
169 fi
170}
171
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200172# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100173client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200174 CLI_DELAY_FACTOR=$1
175}
176
Janos Follath74537a62016-09-02 13:45:28 +0100177# wait for the given seconds after the client finished in the next test
178server_needs_more_time() {
179 SRV_DELAY_SECONDS=$1
180}
181
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100182# print_name <name>
183print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100184 TESTS=$(( $TESTS + 1 ))
185 LINE=""
186
187 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
188 LINE="$TESTS "
189 fi
190
191 LINE="$LINE$1"
192 printf "$LINE "
193 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100194 for i in `seq 1 $LEN`; do printf '.'; done
195 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100196
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100197}
198
199# fail <message>
200fail() {
201 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100202 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100203
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200204 mv $SRV_OUT o-srv-${TESTS}.log
205 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200206 if [ -n "$PXY_CMD" ]; then
207 mv $PXY_OUT o-pxy-${TESTS}.log
208 fi
209 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100210
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200211 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
212 echo " ! server output:"
213 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200214 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200215 echo " ! client output:"
216 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200217 if [ -n "$PXY_CMD" ]; then
218 echo " ! ========================================================"
219 echo " ! proxy output:"
220 cat o-pxy-${TESTS}.log
221 fi
222 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200223 fi
224
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200225 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100226}
227
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100228# is_polar <cmd_line>
229is_polar() {
230 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
231}
232
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200233# openssl s_server doesn't have -www with DTLS
234check_osrv_dtls() {
235 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
236 NEEDS_INPUT=1
237 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
238 else
239 NEEDS_INPUT=0
240 fi
241}
242
243# provide input to commands that need it
244provide_input() {
245 if [ $NEEDS_INPUT -eq 0 ]; then
246 return
247 fi
248
249 while true; do
250 echo "HTTP/1.0 200 OK"
251 sleep 1
252 done
253}
254
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100255# has_mem_err <log_file_name>
256has_mem_err() {
257 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
258 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
259 then
260 return 1 # false: does not have errors
261 else
262 return 0 # true: has errors
263 fi
264}
265
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200266# wait for server to start: two versions depending on lsof availability
267wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200268 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200269 START_TIME=$( date +%s )
270 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200271
272 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200273 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200274 while [ $DONE -eq 0 ]; do
275 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
276 then
277 DONE=1
278 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
279 echo "SERVERSTART TIMEOUT"
280 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
281 DONE=1
282 fi
283 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200284 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200285 while [ $DONE -eq 0 ]; do
286 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
287 then
288 DONE=1
289 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
290 echo "SERVERSTART TIMEOUT"
291 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
292 DONE=1
293 fi
294 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200295 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200296 else
297 sleep "$START_DELAY"
298 fi
299}
300
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200301# wait for client to terminate and set CLI_EXIT
302# must be called right after starting the client
303wait_client_done() {
304 CLI_PID=$!
305
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200306 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
307 CLI_DELAY_FACTOR=1
308
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200309 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200310 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200311
312 wait $CLI_PID
313 CLI_EXIT=$?
314
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200315 kill $DOG_PID >/dev/null 2>&1
316 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200317
318 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100319
320 sleep $SRV_DELAY_SECONDS
321 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200322}
323
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200324# check if the given command uses dtls and sets global variable DTLS
325detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200326 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200327 DTLS=1
328 else
329 DTLS=0
330 fi
331}
332
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200333# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100334# Options: -s pattern pattern that must be present in server output
335# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100336# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100337# -S pattern pattern that must be absent in server output
338# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100339# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100340run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100341 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200342 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100343
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100344 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
345 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200346 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100347 return
348 fi
349
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100350 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100351
Paul Bakkerb7584a52016-05-10 10:50:43 +0100352 # Do we only run numbered tests?
353 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
354 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
355 else
356 SKIP_NEXT="YES"
357 fi
358
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200359 # should we skip?
360 if [ "X$SKIP_NEXT" = "XYES" ]; then
361 SKIP_NEXT="NO"
362 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200363 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200364 return
365 fi
366
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200367 # does this test use a proxy?
368 if [ "X$1" = "X-p" ]; then
369 PXY_CMD="$2"
370 shift 2
371 else
372 PXY_CMD=""
373 fi
374
375 # get commands and client output
376 SRV_CMD="$1"
377 CLI_CMD="$2"
378 CLI_EXPECT="$3"
379 shift 3
380
381 # fix client port
382 if [ -n "$PXY_CMD" ]; then
383 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
384 else
385 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
386 fi
387
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200388 # update DTLS variable
389 detect_dtls "$SRV_CMD"
390
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100391 # prepend valgrind to our commands if active
392 if [ "$MEMCHECK" -gt 0 ]; then
393 if is_polar "$SRV_CMD"; then
394 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
395 fi
396 if is_polar "$CLI_CMD"; then
397 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
398 fi
399 fi
400
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200401 TIMES_LEFT=2
402 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200403 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200404
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200405 # run the commands
406 if [ -n "$PXY_CMD" ]; then
407 echo "$PXY_CMD" > $PXY_OUT
408 $PXY_CMD >> $PXY_OUT 2>&1 &
409 PXY_PID=$!
410 # assume proxy starts faster than server
411 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200412
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200413 check_osrv_dtls
414 echo "$SRV_CMD" > $SRV_OUT
415 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
416 SRV_PID=$!
417 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200418
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200419 echo "$CLI_CMD" > $CLI_OUT
420 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
421 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100422
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200423 # terminate the server (and the proxy)
424 kill $SRV_PID
425 wait $SRV_PID
426 if [ -n "$PXY_CMD" ]; then
427 kill $PXY_PID >/dev/null 2>&1
428 wait $PXY_PID
429 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100430
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200431 # retry only on timeouts
432 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
433 printf "RETRY "
434 else
435 TIMES_LEFT=0
436 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200437 done
438
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100439 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200440 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100441 # expected client exit to incorrectly succeed in case of catastrophic
442 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100443 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200444 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100445 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100446 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100447 return
448 fi
449 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100450 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200451 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100452 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100453 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100454 return
455 fi
456 fi
457
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100458 # check server exit code
459 if [ $? != 0 ]; then
460 fail "server fail"
461 return
462 fi
463
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100464 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100465 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
466 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100467 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200468 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100469 return
470 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100471
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100472 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200473 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100474 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100475 while [ $# -gt 0 ]
476 do
477 case $1 in
478 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100479 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100480 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100481 return
482 fi
483 ;;
484
485 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100486 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100487 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100488 return
489 fi
490 ;;
491
492 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100493 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100494 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100495 return
496 fi
497 ;;
498
499 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100500 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100501 fail "pattern '$2' MUST NOT be present in the Client output"
502 return
503 fi
504 ;;
505
506 # The filtering in the following two options (-u and -U) do the following
507 # - ignore valgrind output
508 # - filter out everything but lines right after the pattern occurances
509 # - keep one of each non-unique line
510 # - count how many lines remain
511 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
512 # if there were no duplicates.
513 "-U")
514 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
515 fail "lines following pattern '$2' must be unique in Server output"
516 return
517 fi
518 ;;
519
520 "-u")
521 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
522 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100523 return
524 fi
525 ;;
526
527 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200528 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100529 exit 1
530 esac
531 shift 2
532 done
533
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100534 # check valgrind's results
535 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200536 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100537 fail "Server has memory errors"
538 return
539 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200540 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100541 fail "Client has memory errors"
542 return
543 fi
544 fi
545
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100546 # if we're here, everything is ok
547 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100548 if [ "$PRESERVE_LOGS" -gt 0 ]; then
549 mv $SRV_OUT o-srv-${TESTS}.log
550 mv $CLI_OUT o-cli-${TESTS}.log
551 fi
552
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200553 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100554}
555
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100556cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200557 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200558 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
559 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
560 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
561 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100562 exit 1
563}
564
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100565#
566# MAIN
567#
568
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000569if cd $( dirname $0 ); then :; else
570 echo "cd $( dirname $0 ) failed" >&2
571 exit 1
572fi
573
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100574get_options "$@"
575
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100576# sanity checks, avoid an avalanche of errors
577if [ ! -x "$P_SRV" ]; then
578 echo "Command '$P_SRV' is not an executable file"
579 exit 1
580fi
581if [ ! -x "$P_CLI" ]; then
582 echo "Command '$P_CLI' is not an executable file"
583 exit 1
584fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200585if [ ! -x "$P_PXY" ]; then
586 echo "Command '$P_PXY' is not an executable file"
587 exit 1
588fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100589if [ "$MEMCHECK" -gt 0 ]; then
590 if which valgrind >/dev/null 2>&1; then :; else
591 echo "Memcheck not possible. Valgrind not found"
592 exit 1
593 fi
594fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100595if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
596 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100597 exit 1
598fi
599
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200600# used by watchdog
601MAIN_PID="$$"
602
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200603# be more patient with valgrind
604if [ "$MEMCHECK" -gt 0 ]; then
605 START_DELAY=3
606 DOG_DELAY=30
607else
608 START_DELAY=1
609 DOG_DELAY=10
610fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200611CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100612SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200613
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200614# Pick a "unique" server port in the range 10000-19999, and a proxy port
615PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000616PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200617SRV_PORT="1$PORT_BASE"
618PXY_PORT="2$PORT_BASE"
619unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200620
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200621# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000622# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200623P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
624P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100625P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200626O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200627O_CLI="$O_CLI -connect localhost:+SRV_PORT"
628G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000629G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200630
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200631# Also pick a unique name for intermediate files
632SRV_OUT="srv_out.$$"
633CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200634PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200635SESSION="session.$$"
636
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200637SKIP_NEXT="NO"
638
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100639trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100640
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200641# Basic test
642
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200643# Checks that:
644# - things work with all ciphersuites active (used with config-full in all.sh)
645# - the expected (highest security) parameters are selected
646# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200647run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200648 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200649 "$P_CLI" \
650 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200651 -s "Protocol is TLSv1.2" \
652 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
653 -s "client hello v3, signature_algorithm ext: 6" \
654 -s "ECDHE curve: secp521r1" \
655 -S "error" \
656 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200657
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000658run_test "Default, DTLS" \
659 "$P_SRV dtls=1" \
660 "$P_CLI dtls=1" \
661 0 \
662 -s "Protocol is DTLSv1.2" \
663 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
664
Simon Butcher8e004102016-10-14 00:48:33 +0100665# Test for uniqueness of IVs in AEAD ciphersuites
666run_test "Unique IV in GCM" \
667 "$P_SRV exchanges=20 debug_level=4" \
668 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
669 0 \
670 -u "IV used" \
671 -U "IV used"
672
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100673# Tests for rc4 option
674
Simon Butchera410af52016-05-19 22:12:18 +0100675requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100676run_test "RC4: server disabled, client enabled" \
677 "$P_SRV" \
678 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
679 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100680 -s "SSL - The server has no ciphersuites in common"
681
Simon Butchera410af52016-05-19 22:12:18 +0100682requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100683run_test "RC4: server half, client enabled" \
684 "$P_SRV arc4=1" \
685 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
686 1 \
687 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100688
689run_test "RC4: server enabled, client disabled" \
690 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
691 "$P_CLI" \
692 1 \
693 -s "SSL - The server has no ciphersuites in common"
694
695run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100696 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100697 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
698 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100699 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100700 -S "SSL - The server has no ciphersuites in common"
701
Gilles Peskinebc70a182017-05-09 15:59:24 +0200702# Tests for SHA-1 support
703
704run_test "SHA-1 forbidden by default in server certificate" \
705 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
706 "$P_CLI debug_level=2 allow_sha1=0" \
707 1 \
708 -c "The certificate is signed with an unacceptable hash"
709
710run_test "SHA-1 explicitly allowed in server certificate" \
711 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
712 "$P_CLI allow_sha1=1" \
713 0
714
715run_test "SHA-256 allowed by default in server certificate" \
716 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
717 "$P_CLI allow_sha1=0" \
718 0
719
720run_test "SHA-1 forbidden by default in client certificate" \
721 "$P_SRV auth_mode=required allow_sha1=0" \
722 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
723 1 \
724 -s "The certificate is signed with an unacceptable hash"
725
726run_test "SHA-1 explicitly allowed in client certificate" \
727 "$P_SRV auth_mode=required allow_sha1=1" \
728 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
729 0
730
731run_test "SHA-256 allowed by default in client certificate" \
732 "$P_SRV auth_mode=required allow_sha1=0" \
733 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
734 0
735
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100736# Tests for Truncated HMAC extension
737
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100738run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200739 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100740 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100741 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100742 -s "dumping 'computed mac' (20 bytes)" \
743 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100744
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100745run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200746 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100747 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
748 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100749 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100750 -s "dumping 'computed mac' (20 bytes)" \
751 -S "dumping 'computed mac' (10 bytes)"
752
753run_test "Truncated HMAC: client enabled, server default" \
754 "$P_SRV debug_level=4" \
755 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
756 trunc_hmac=1" \
757 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100758 -s "dumping 'computed mac' (20 bytes)" \
759 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100760
761run_test "Truncated HMAC: client enabled, server disabled" \
762 "$P_SRV debug_level=4 trunc_hmac=0" \
763 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
764 trunc_hmac=1" \
765 0 \
766 -s "dumping 'computed mac' (20 bytes)" \
767 -S "dumping 'computed mac' (10 bytes)"
768
769run_test "Truncated HMAC: client enabled, server enabled" \
770 "$P_SRV debug_level=4 trunc_hmac=1" \
771 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
772 trunc_hmac=1" \
773 0 \
774 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100775 -s "dumping 'computed mac' (10 bytes)"
776
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100777# Tests for Encrypt-then-MAC extension
778
779run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100780 "$P_SRV debug_level=3 \
781 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100782 "$P_CLI debug_level=3" \
783 0 \
784 -c "client hello, adding encrypt_then_mac extension" \
785 -s "found encrypt then mac extension" \
786 -s "server hello, adding encrypt then mac extension" \
787 -c "found encrypt_then_mac extension" \
788 -c "using encrypt then mac" \
789 -s "using encrypt then mac"
790
791run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100792 "$P_SRV debug_level=3 etm=0 \
793 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100794 "$P_CLI debug_level=3 etm=1" \
795 0 \
796 -c "client hello, adding encrypt_then_mac extension" \
797 -s "found encrypt then mac extension" \
798 -S "server hello, adding encrypt then mac extension" \
799 -C "found encrypt_then_mac extension" \
800 -C "using encrypt then mac" \
801 -S "using encrypt then mac"
802
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100803run_test "Encrypt then MAC: client enabled, aead cipher" \
804 "$P_SRV debug_level=3 etm=1 \
805 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
806 "$P_CLI debug_level=3 etm=1" \
807 0 \
808 -c "client hello, adding encrypt_then_mac extension" \
809 -s "found encrypt then mac extension" \
810 -S "server hello, adding encrypt then mac extension" \
811 -C "found encrypt_then_mac extension" \
812 -C "using encrypt then mac" \
813 -S "using encrypt then mac"
814
815run_test "Encrypt then MAC: client enabled, stream cipher" \
816 "$P_SRV debug_level=3 etm=1 \
817 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100818 "$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 +0100819 0 \
820 -c "client hello, adding encrypt_then_mac extension" \
821 -s "found encrypt then mac extension" \
822 -S "server hello, adding encrypt then mac extension" \
823 -C "found encrypt_then_mac extension" \
824 -C "using encrypt then mac" \
825 -S "using encrypt then mac"
826
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100827run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100828 "$P_SRV debug_level=3 etm=1 \
829 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100830 "$P_CLI debug_level=3 etm=0" \
831 0 \
832 -C "client hello, adding encrypt_then_mac extension" \
833 -S "found encrypt then mac extension" \
834 -S "server hello, adding encrypt then mac extension" \
835 -C "found encrypt_then_mac extension" \
836 -C "using encrypt then mac" \
837 -S "using encrypt then mac"
838
Janos Follathe2681a42016-03-07 15:57:05 +0000839requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100840run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100841 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100842 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100843 "$P_CLI debug_level=3 force_version=ssl3" \
844 0 \
845 -C "client hello, adding encrypt_then_mac extension" \
846 -S "found encrypt then mac extension" \
847 -S "server hello, adding encrypt then mac extension" \
848 -C "found encrypt_then_mac extension" \
849 -C "using encrypt then mac" \
850 -S "using encrypt then mac"
851
Janos Follathe2681a42016-03-07 15:57:05 +0000852requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100853run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100854 "$P_SRV debug_level=3 force_version=ssl3 \
855 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100856 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100857 0 \
858 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100859 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100860 -S "server hello, adding encrypt then mac extension" \
861 -C "found encrypt_then_mac extension" \
862 -C "using encrypt then mac" \
863 -S "using encrypt then mac"
864
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200865# Tests for Extended Master Secret extension
866
867run_test "Extended Master Secret: default" \
868 "$P_SRV debug_level=3" \
869 "$P_CLI debug_level=3" \
870 0 \
871 -c "client hello, adding extended_master_secret extension" \
872 -s "found extended master secret extension" \
873 -s "server hello, adding extended master secret extension" \
874 -c "found extended_master_secret extension" \
875 -c "using extended master secret" \
876 -s "using extended master secret"
877
878run_test "Extended Master Secret: client enabled, server disabled" \
879 "$P_SRV debug_level=3 extended_ms=0" \
880 "$P_CLI debug_level=3 extended_ms=1" \
881 0 \
882 -c "client hello, adding extended_master_secret extension" \
883 -s "found extended master secret extension" \
884 -S "server hello, adding extended master secret extension" \
885 -C "found extended_master_secret extension" \
886 -C "using extended master secret" \
887 -S "using extended master secret"
888
889run_test "Extended Master Secret: client disabled, server enabled" \
890 "$P_SRV debug_level=3 extended_ms=1" \
891 "$P_CLI debug_level=3 extended_ms=0" \
892 0 \
893 -C "client hello, adding extended_master_secret extension" \
894 -S "found extended master secret extension" \
895 -S "server hello, adding extended master secret extension" \
896 -C "found extended_master_secret extension" \
897 -C "using extended master secret" \
898 -S "using extended master secret"
899
Janos Follathe2681a42016-03-07 15:57:05 +0000900requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200901run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100902 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200903 "$P_CLI debug_level=3 force_version=ssl3" \
904 0 \
905 -C "client hello, adding extended_master_secret extension" \
906 -S "found extended master secret extension" \
907 -S "server hello, adding extended master secret extension" \
908 -C "found extended_master_secret extension" \
909 -C "using extended master secret" \
910 -S "using extended master secret"
911
Janos Follathe2681a42016-03-07 15:57:05 +0000912requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200913run_test "Extended Master Secret: client enabled, server SSLv3" \
914 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100915 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200916 0 \
917 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100918 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200919 -S "server hello, adding extended master secret extension" \
920 -C "found extended_master_secret extension" \
921 -C "using extended master secret" \
922 -S "using extended master secret"
923
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200924# Tests for FALLBACK_SCSV
925
926run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200927 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200928 "$P_CLI debug_level=3 force_version=tls1_1" \
929 0 \
930 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200931 -S "received FALLBACK_SCSV" \
932 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200933 -C "is a fatal alert message (msg 86)"
934
935run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200936 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200937 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
938 0 \
939 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200940 -S "received FALLBACK_SCSV" \
941 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200942 -C "is a fatal alert message (msg 86)"
943
944run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200945 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200946 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200947 1 \
948 -c "adding FALLBACK_SCSV" \
949 -s "received FALLBACK_SCSV" \
950 -s "inapropriate fallback" \
951 -c "is a fatal alert message (msg 86)"
952
953run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200954 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200955 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200956 0 \
957 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200958 -s "received FALLBACK_SCSV" \
959 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200960 -C "is a fatal alert message (msg 86)"
961
962requires_openssl_with_fallback_scsv
963run_test "Fallback SCSV: default, openssl server" \
964 "$O_SRV" \
965 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
966 0 \
967 -C "adding FALLBACK_SCSV" \
968 -C "is a fatal alert message (msg 86)"
969
970requires_openssl_with_fallback_scsv
971run_test "Fallback SCSV: enabled, openssl server" \
972 "$O_SRV" \
973 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
974 1 \
975 -c "adding FALLBACK_SCSV" \
976 -c "is a fatal alert message (msg 86)"
977
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200978requires_openssl_with_fallback_scsv
979run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200980 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200981 "$O_CLI -tls1_1" \
982 0 \
983 -S "received FALLBACK_SCSV" \
984 -S "inapropriate fallback"
985
986requires_openssl_with_fallback_scsv
987run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200988 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200989 "$O_CLI -tls1_1 -fallback_scsv" \
990 1 \
991 -s "received FALLBACK_SCSV" \
992 -s "inapropriate fallback"
993
994requires_openssl_with_fallback_scsv
995run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200996 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200997 "$O_CLI -fallback_scsv" \
998 0 \
999 -s "received FALLBACK_SCSV" \
1000 -S "inapropriate fallback"
1001
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001002# Tests for CBC 1/n-1 record splitting
1003
1004run_test "CBC Record splitting: TLS 1.2, no splitting" \
1005 "$P_SRV" \
1006 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1007 request_size=123 force_version=tls1_2" \
1008 0 \
1009 -s "Read from client: 123 bytes read" \
1010 -S "Read from client: 1 bytes read" \
1011 -S "122 bytes read"
1012
1013run_test "CBC Record splitting: TLS 1.1, no splitting" \
1014 "$P_SRV" \
1015 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1016 request_size=123 force_version=tls1_1" \
1017 0 \
1018 -s "Read from client: 123 bytes read" \
1019 -S "Read from client: 1 bytes read" \
1020 -S "122 bytes read"
1021
1022run_test "CBC Record splitting: TLS 1.0, splitting" \
1023 "$P_SRV" \
1024 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1025 request_size=123 force_version=tls1" \
1026 0 \
1027 -S "Read from client: 123 bytes read" \
1028 -s "Read from client: 1 bytes read" \
1029 -s "122 bytes read"
1030
Janos Follathe2681a42016-03-07 15:57:05 +00001031requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001032run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001033 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001034 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1035 request_size=123 force_version=ssl3" \
1036 0 \
1037 -S "Read from client: 123 bytes read" \
1038 -s "Read from client: 1 bytes read" \
1039 -s "122 bytes read"
1040
1041run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001042 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001043 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1044 request_size=123 force_version=tls1" \
1045 0 \
1046 -s "Read from client: 123 bytes read" \
1047 -S "Read from client: 1 bytes read" \
1048 -S "122 bytes read"
1049
1050run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1051 "$P_SRV" \
1052 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1053 request_size=123 force_version=tls1 recsplit=0" \
1054 0 \
1055 -s "Read from client: 123 bytes read" \
1056 -S "Read from client: 1 bytes read" \
1057 -S "122 bytes read"
1058
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001059run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1060 "$P_SRV nbio=2" \
1061 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1062 request_size=123 force_version=tls1" \
1063 0 \
1064 -S "Read from client: 123 bytes read" \
1065 -s "Read from client: 1 bytes read" \
1066 -s "122 bytes read"
1067
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001068# Tests for Session Tickets
1069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001070run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001071 "$P_SRV debug_level=3 tickets=1" \
1072 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001073 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001074 -c "client hello, adding session ticket extension" \
1075 -s "found session ticket extension" \
1076 -s "server hello, adding session ticket extension" \
1077 -c "found session_ticket extension" \
1078 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001079 -S "session successfully restored from cache" \
1080 -s "session successfully restored from ticket" \
1081 -s "a session has been resumed" \
1082 -c "a session has been resumed"
1083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001084run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001085 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1086 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001087 0 \
1088 -c "client hello, adding session ticket extension" \
1089 -s "found session ticket extension" \
1090 -s "server hello, adding session ticket extension" \
1091 -c "found session_ticket extension" \
1092 -c "parse new session ticket" \
1093 -S "session successfully restored from cache" \
1094 -s "session successfully restored from ticket" \
1095 -s "a session has been resumed" \
1096 -c "a session has been resumed"
1097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001098run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001099 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1100 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001101 0 \
1102 -c "client hello, adding session ticket extension" \
1103 -s "found session ticket extension" \
1104 -s "server hello, adding session ticket extension" \
1105 -c "found session_ticket extension" \
1106 -c "parse new session ticket" \
1107 -S "session successfully restored from cache" \
1108 -S "session successfully restored from ticket" \
1109 -S "a session has been resumed" \
1110 -C "a session has been resumed"
1111
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001112run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001113 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001114 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001115 0 \
1116 -c "client hello, adding session ticket extension" \
1117 -c "found session_ticket extension" \
1118 -c "parse new session ticket" \
1119 -c "a session has been resumed"
1120
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001121run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001122 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001123 "( $O_CLI -sess_out $SESSION; \
1124 $O_CLI -sess_in $SESSION; \
1125 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001126 0 \
1127 -s "found session ticket extension" \
1128 -s "server hello, adding session ticket extension" \
1129 -S "session successfully restored from cache" \
1130 -s "session successfully restored from ticket" \
1131 -s "a session has been resumed"
1132
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001133# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001134
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001135run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001136 "$P_SRV debug_level=3 tickets=0" \
1137 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001138 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001139 -c "client hello, adding session ticket extension" \
1140 -s "found session ticket extension" \
1141 -S "server hello, adding session ticket extension" \
1142 -C "found session_ticket extension" \
1143 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001144 -s "session successfully restored from cache" \
1145 -S "session successfully restored from ticket" \
1146 -s "a session has been resumed" \
1147 -c "a session has been resumed"
1148
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001149run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001150 "$P_SRV debug_level=3 tickets=1" \
1151 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001152 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001153 -C "client hello, adding session ticket extension" \
1154 -S "found session ticket extension" \
1155 -S "server hello, adding session ticket extension" \
1156 -C "found session_ticket extension" \
1157 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001158 -s "session successfully restored from cache" \
1159 -S "session successfully restored from ticket" \
1160 -s "a session has been resumed" \
1161 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001163run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001164 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1165 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001166 0 \
1167 -S "session successfully restored from cache" \
1168 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001169 -S "a session has been resumed" \
1170 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001172run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001173 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1174 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001175 0 \
1176 -s "session successfully restored from cache" \
1177 -S "session successfully restored from ticket" \
1178 -s "a session has been resumed" \
1179 -c "a session has been resumed"
1180
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001181run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001182 "$P_SRV debug_level=3 tickets=0" \
1183 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001184 0 \
1185 -s "session successfully restored from cache" \
1186 -S "session successfully restored from ticket" \
1187 -s "a session has been resumed" \
1188 -c "a session has been resumed"
1189
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001190run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001191 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1192 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001193 0 \
1194 -S "session successfully restored from cache" \
1195 -S "session successfully restored from ticket" \
1196 -S "a session has been resumed" \
1197 -C "a session has been resumed"
1198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001199run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001200 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1201 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001202 0 \
1203 -s "session successfully restored from cache" \
1204 -S "session successfully restored from ticket" \
1205 -s "a session has been resumed" \
1206 -c "a session has been resumed"
1207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001208run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001209 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001210 "( $O_CLI -sess_out $SESSION; \
1211 $O_CLI -sess_in $SESSION; \
1212 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001213 0 \
1214 -s "found session ticket extension" \
1215 -S "server hello, adding session ticket extension" \
1216 -s "session successfully restored from cache" \
1217 -S "session successfully restored from ticket" \
1218 -s "a session has been resumed"
1219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001220run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001221 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001222 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001223 0 \
1224 -C "found session_ticket extension" \
1225 -C "parse new session ticket" \
1226 -c "a session has been resumed"
1227
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001228# Tests for Max Fragment Length extension
1229
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001230run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001231 "$P_SRV debug_level=3" \
1232 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001233 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001234 -c "Maximum fragment length is 16384" \
1235 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001236 -C "client hello, adding max_fragment_length extension" \
1237 -S "found max fragment length extension" \
1238 -S "server hello, max_fragment_length extension" \
1239 -C "found max_fragment_length extension"
1240
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001241run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001242 "$P_SRV debug_level=3" \
1243 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001244 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001245 -c "Maximum fragment length is 4096" \
1246 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001247 -c "client hello, adding max_fragment_length extension" \
1248 -s "found max fragment length extension" \
1249 -s "server hello, max_fragment_length extension" \
1250 -c "found max_fragment_length extension"
1251
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001252run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001253 "$P_SRV debug_level=3 max_frag_len=4096" \
1254 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001255 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001256 -c "Maximum fragment length is 16384" \
1257 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001258 -C "client hello, adding max_fragment_length extension" \
1259 -S "found max fragment length extension" \
1260 -S "server hello, max_fragment_length extension" \
1261 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001262
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001263requires_gnutls
1264run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001265 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001266 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001267 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001268 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001269 -c "client hello, adding max_fragment_length extension" \
1270 -c "found max_fragment_length extension"
1271
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001272run_test "Max fragment length: client, message just fits" \
1273 "$P_SRV debug_level=3" \
1274 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1275 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001276 -c "Maximum fragment length is 2048" \
1277 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001278 -c "client hello, adding max_fragment_length extension" \
1279 -s "found max fragment length extension" \
1280 -s "server hello, max_fragment_length extension" \
1281 -c "found max_fragment_length extension" \
1282 -c "2048 bytes written in 1 fragments" \
1283 -s "2048 bytes read"
1284
1285run_test "Max fragment length: client, larger message" \
1286 "$P_SRV debug_level=3" \
1287 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1288 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001289 -c "Maximum fragment length is 2048" \
1290 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001291 -c "client hello, adding max_fragment_length extension" \
1292 -s "found max fragment length extension" \
1293 -s "server hello, max_fragment_length extension" \
1294 -c "found max_fragment_length extension" \
1295 -c "2345 bytes written in 2 fragments" \
1296 -s "2048 bytes read" \
1297 -s "297 bytes read"
1298
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001299run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001300 "$P_SRV debug_level=3 dtls=1" \
1301 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1302 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001303 -c "Maximum fragment length is 2048" \
1304 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001305 -c "client hello, adding max_fragment_length extension" \
1306 -s "found max fragment length extension" \
1307 -s "server hello, max_fragment_length extension" \
1308 -c "found max_fragment_length extension" \
1309 -c "fragment larger than.*maximum"
1310
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001311# Tests for renegotiation
1312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001313run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001314 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001315 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001316 0 \
1317 -C "client hello, adding renegotiation extension" \
1318 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1319 -S "found renegotiation extension" \
1320 -s "server hello, secure renegotiation extension" \
1321 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001322 -C "=> renegotiate" \
1323 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001324 -S "write hello request"
1325
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001326run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001327 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001328 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001329 0 \
1330 -c "client hello, adding renegotiation extension" \
1331 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1332 -s "found renegotiation extension" \
1333 -s "server hello, secure renegotiation extension" \
1334 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001335 -c "=> renegotiate" \
1336 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001337 -S "write hello request"
1338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001339run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001340 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001341 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001342 0 \
1343 -c "client hello, adding renegotiation extension" \
1344 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1345 -s "found renegotiation extension" \
1346 -s "server hello, secure renegotiation extension" \
1347 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001348 -c "=> renegotiate" \
1349 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001350 -s "write hello request"
1351
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001352run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001353 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001354 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001355 0 \
1356 -c "client hello, adding renegotiation extension" \
1357 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1358 -s "found renegotiation extension" \
1359 -s "server hello, secure renegotiation extension" \
1360 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001361 -c "=> renegotiate" \
1362 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001363 -s "write hello request"
1364
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001365run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001366 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001367 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001368 1 \
1369 -c "client hello, adding renegotiation extension" \
1370 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1371 -S "found renegotiation extension" \
1372 -s "server hello, secure renegotiation extension" \
1373 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001374 -c "=> renegotiate" \
1375 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001376 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001377 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001378 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001379
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001380run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001381 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001382 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001383 0 \
1384 -C "client hello, adding renegotiation extension" \
1385 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1386 -S "found renegotiation extension" \
1387 -s "server hello, secure renegotiation extension" \
1388 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001389 -C "=> renegotiate" \
1390 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001391 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001392 -S "SSL - An unexpected message was received from our peer" \
1393 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001394
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001395run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001396 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001397 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001398 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001399 0 \
1400 -C "client hello, adding renegotiation extension" \
1401 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1402 -S "found renegotiation extension" \
1403 -s "server hello, secure renegotiation extension" \
1404 -c "found renegotiation extension" \
1405 -C "=> renegotiate" \
1406 -S "=> renegotiate" \
1407 -s "write hello request" \
1408 -S "SSL - An unexpected message was received from our peer" \
1409 -S "failed"
1410
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001411# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001412run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001413 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001414 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001415 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001416 0 \
1417 -C "client hello, adding renegotiation extension" \
1418 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1419 -S "found renegotiation extension" \
1420 -s "server hello, secure renegotiation extension" \
1421 -c "found renegotiation extension" \
1422 -C "=> renegotiate" \
1423 -S "=> renegotiate" \
1424 -s "write hello request" \
1425 -S "SSL - An unexpected message was received from our peer" \
1426 -S "failed"
1427
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001428run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001429 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001430 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001431 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001432 0 \
1433 -C "client hello, adding renegotiation extension" \
1434 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1435 -S "found renegotiation extension" \
1436 -s "server hello, secure renegotiation extension" \
1437 -c "found renegotiation extension" \
1438 -C "=> renegotiate" \
1439 -S "=> renegotiate" \
1440 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001441 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001442
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001443run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001444 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001445 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001446 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001447 0 \
1448 -c "client hello, adding renegotiation extension" \
1449 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1450 -s "found renegotiation extension" \
1451 -s "server hello, secure renegotiation extension" \
1452 -c "found renegotiation extension" \
1453 -c "=> renegotiate" \
1454 -s "=> renegotiate" \
1455 -s "write hello request" \
1456 -S "SSL - An unexpected message was received from our peer" \
1457 -S "failed"
1458
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001459run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001460 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001461 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1462 0 \
1463 -C "client hello, adding renegotiation extension" \
1464 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1465 -S "found renegotiation extension" \
1466 -s "server hello, secure renegotiation extension" \
1467 -c "found renegotiation extension" \
1468 -S "record counter limit reached: renegotiate" \
1469 -C "=> renegotiate" \
1470 -S "=> renegotiate" \
1471 -S "write hello request" \
1472 -S "SSL - An unexpected message was received from our peer" \
1473 -S "failed"
1474
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001475# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001476run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001477 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001478 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001479 0 \
1480 -c "client hello, adding renegotiation extension" \
1481 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1482 -s "found renegotiation extension" \
1483 -s "server hello, secure renegotiation extension" \
1484 -c "found renegotiation extension" \
1485 -s "record counter limit reached: renegotiate" \
1486 -c "=> renegotiate" \
1487 -s "=> renegotiate" \
1488 -s "write hello request" \
1489 -S "SSL - An unexpected message was received from our peer" \
1490 -S "failed"
1491
1492run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001493 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001494 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001495 0 \
1496 -c "client hello, adding renegotiation extension" \
1497 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1498 -s "found renegotiation extension" \
1499 -s "server hello, secure renegotiation extension" \
1500 -c "found renegotiation extension" \
1501 -s "record counter limit reached: renegotiate" \
1502 -c "=> renegotiate" \
1503 -s "=> renegotiate" \
1504 -s "write hello request" \
1505 -S "SSL - An unexpected message was received from our peer" \
1506 -S "failed"
1507
1508run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001509 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001510 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1511 0 \
1512 -C "client hello, adding renegotiation extension" \
1513 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1514 -S "found renegotiation extension" \
1515 -s "server hello, secure renegotiation extension" \
1516 -c "found renegotiation extension" \
1517 -S "record counter limit reached: renegotiate" \
1518 -C "=> renegotiate" \
1519 -S "=> renegotiate" \
1520 -S "write hello request" \
1521 -S "SSL - An unexpected message was received from our peer" \
1522 -S "failed"
1523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001524run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001525 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001526 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001527 0 \
1528 -c "client hello, adding renegotiation extension" \
1529 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1530 -s "found renegotiation extension" \
1531 -s "server hello, secure renegotiation extension" \
1532 -c "found renegotiation extension" \
1533 -c "=> renegotiate" \
1534 -s "=> renegotiate" \
1535 -S "write hello request"
1536
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001537run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001538 "$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 +02001539 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001540 0 \
1541 -c "client hello, adding renegotiation extension" \
1542 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1543 -s "found renegotiation extension" \
1544 -s "server hello, secure renegotiation extension" \
1545 -c "found renegotiation extension" \
1546 -c "=> renegotiate" \
1547 -s "=> renegotiate" \
1548 -s "write hello request"
1549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001550run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001551 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001552 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001553 0 \
1554 -c "client hello, adding renegotiation extension" \
1555 -c "found renegotiation extension" \
1556 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001557 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001558 -C "error" \
1559 -c "HTTP/1.0 200 [Oo][Kk]"
1560
Paul Bakker539d9722015-02-08 16:18:35 +01001561requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001562run_test "Renegotiation: gnutls server strict, client-initiated" \
1563 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001564 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001565 0 \
1566 -c "client hello, adding renegotiation extension" \
1567 -c "found renegotiation extension" \
1568 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001569 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001570 -C "error" \
1571 -c "HTTP/1.0 200 [Oo][Kk]"
1572
Paul Bakker539d9722015-02-08 16:18:35 +01001573requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001574run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1575 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1576 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1577 1 \
1578 -c "client hello, adding renegotiation extension" \
1579 -C "found renegotiation extension" \
1580 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001581 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001582 -c "error" \
1583 -C "HTTP/1.0 200 [Oo][Kk]"
1584
Paul Bakker539d9722015-02-08 16:18:35 +01001585requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001586run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1587 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1588 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1589 allow_legacy=0" \
1590 1 \
1591 -c "client hello, adding renegotiation extension" \
1592 -C "found renegotiation extension" \
1593 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001594 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001595 -c "error" \
1596 -C "HTTP/1.0 200 [Oo][Kk]"
1597
Paul Bakker539d9722015-02-08 16:18:35 +01001598requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001599run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1600 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1601 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1602 allow_legacy=1" \
1603 0 \
1604 -c "client hello, adding renegotiation extension" \
1605 -C "found renegotiation extension" \
1606 -c "=> renegotiate" \
1607 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001608 -C "error" \
1609 -c "HTTP/1.0 200 [Oo][Kk]"
1610
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001611run_test "Renegotiation: DTLS, client-initiated" \
1612 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1613 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1614 0 \
1615 -c "client hello, adding renegotiation extension" \
1616 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1617 -s "found renegotiation extension" \
1618 -s "server hello, secure renegotiation extension" \
1619 -c "found renegotiation extension" \
1620 -c "=> renegotiate" \
1621 -s "=> renegotiate" \
1622 -S "write hello request"
1623
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001624run_test "Renegotiation: DTLS, server-initiated" \
1625 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001626 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1627 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001628 0 \
1629 -c "client hello, adding renegotiation extension" \
1630 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1631 -s "found renegotiation extension" \
1632 -s "server hello, secure renegotiation extension" \
1633 -c "found renegotiation extension" \
1634 -c "=> renegotiate" \
1635 -s "=> renegotiate" \
1636 -s "write hello request"
1637
Andres AG692ad842017-01-19 16:30:57 +00001638run_test "Renegotiation: DTLS, renego_period overflow" \
1639 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1640 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1641 0 \
1642 -c "client hello, adding renegotiation extension" \
1643 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1644 -s "found renegotiation extension" \
1645 -s "server hello, secure renegotiation extension" \
1646 -s "record counter limit reached: renegotiate" \
1647 -c "=> renegotiate" \
1648 -s "=> renegotiate" \
1649 -s "write hello request" \
1650
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001651requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001652run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1653 "$G_SRV -u --mtu 4096" \
1654 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1655 0 \
1656 -c "client hello, adding renegotiation extension" \
1657 -c "found renegotiation extension" \
1658 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001659 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001660 -C "error" \
1661 -s "Extra-header:"
1662
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001663# Test for the "secure renegotation" extension only (no actual renegotiation)
1664
Paul Bakker539d9722015-02-08 16:18:35 +01001665requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001666run_test "Renego ext: gnutls server strict, client default" \
1667 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1668 "$P_CLI debug_level=3" \
1669 0 \
1670 -c "found renegotiation extension" \
1671 -C "error" \
1672 -c "HTTP/1.0 200 [Oo][Kk]"
1673
Paul Bakker539d9722015-02-08 16:18:35 +01001674requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001675run_test "Renego ext: gnutls server unsafe, client default" \
1676 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1677 "$P_CLI debug_level=3" \
1678 0 \
1679 -C "found renegotiation extension" \
1680 -C "error" \
1681 -c "HTTP/1.0 200 [Oo][Kk]"
1682
Paul Bakker539d9722015-02-08 16:18:35 +01001683requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001684run_test "Renego ext: gnutls server unsafe, client break legacy" \
1685 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1686 "$P_CLI debug_level=3 allow_legacy=-1" \
1687 1 \
1688 -C "found renegotiation extension" \
1689 -c "error" \
1690 -C "HTTP/1.0 200 [Oo][Kk]"
1691
Paul Bakker539d9722015-02-08 16:18:35 +01001692requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001693run_test "Renego ext: gnutls client strict, server default" \
1694 "$P_SRV debug_level=3" \
1695 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1696 0 \
1697 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1698 -s "server hello, secure renegotiation extension"
1699
Paul Bakker539d9722015-02-08 16:18:35 +01001700requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001701run_test "Renego ext: gnutls client unsafe, server default" \
1702 "$P_SRV debug_level=3" \
1703 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1704 0 \
1705 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1706 -S "server hello, secure renegotiation extension"
1707
Paul Bakker539d9722015-02-08 16:18:35 +01001708requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001709run_test "Renego ext: gnutls client unsafe, server break legacy" \
1710 "$P_SRV debug_level=3 allow_legacy=-1" \
1711 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1712 1 \
1713 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1714 -S "server hello, secure renegotiation extension"
1715
Janos Follath0b242342016-02-17 10:11:21 +00001716# Tests for silently dropping trailing extra bytes in .der certificates
1717
1718requires_gnutls
1719run_test "DER format: no trailing bytes" \
1720 "$P_SRV crt_file=data_files/server5-der0.crt \
1721 key_file=data_files/server5.key" \
1722 "$G_CLI " \
1723 0 \
1724 -c "Handshake was completed" \
1725
1726requires_gnutls
1727run_test "DER format: with a trailing zero byte" \
1728 "$P_SRV crt_file=data_files/server5-der1a.crt \
1729 key_file=data_files/server5.key" \
1730 "$G_CLI " \
1731 0 \
1732 -c "Handshake was completed" \
1733
1734requires_gnutls
1735run_test "DER format: with a trailing random byte" \
1736 "$P_SRV crt_file=data_files/server5-der1b.crt \
1737 key_file=data_files/server5.key" \
1738 "$G_CLI " \
1739 0 \
1740 -c "Handshake was completed" \
1741
1742requires_gnutls
1743run_test "DER format: with 2 trailing random bytes" \
1744 "$P_SRV crt_file=data_files/server5-der2.crt \
1745 key_file=data_files/server5.key" \
1746 "$G_CLI " \
1747 0 \
1748 -c "Handshake was completed" \
1749
1750requires_gnutls
1751run_test "DER format: with 4 trailing random bytes" \
1752 "$P_SRV crt_file=data_files/server5-der4.crt \
1753 key_file=data_files/server5.key" \
1754 "$G_CLI " \
1755 0 \
1756 -c "Handshake was completed" \
1757
1758requires_gnutls
1759run_test "DER format: with 8 trailing random bytes" \
1760 "$P_SRV crt_file=data_files/server5-der8.crt \
1761 key_file=data_files/server5.key" \
1762 "$G_CLI " \
1763 0 \
1764 -c "Handshake was completed" \
1765
1766requires_gnutls
1767run_test "DER format: with 9 trailing random bytes" \
1768 "$P_SRV crt_file=data_files/server5-der9.crt \
1769 key_file=data_files/server5.key" \
1770 "$G_CLI " \
1771 0 \
1772 -c "Handshake was completed" \
1773
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001774# Tests for auth_mode
1775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001776run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001777 "$P_SRV crt_file=data_files/server5-badsign.crt \
1778 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001779 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001780 1 \
1781 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001782 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001783 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001784 -c "X509 - Certificate verification failed"
1785
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001786run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001787 "$P_SRV crt_file=data_files/server5-badsign.crt \
1788 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001789 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001790 0 \
1791 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001792 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001793 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001794 -C "X509 - Certificate verification failed"
1795
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001796run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001797 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001798 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001799 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001800 0 \
1801 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001802 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001803 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001804 -C "X509 - Certificate verification failed"
1805
Simon Butcher99000142016-10-13 17:21:01 +01001806run_test "Authentication: client SHA256, server required" \
1807 "$P_SRV auth_mode=required" \
1808 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1809 key_file=data_files/server6.key \
1810 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1811 0 \
1812 -c "Supported Signature Algorithm found: 4," \
1813 -c "Supported Signature Algorithm found: 5,"
1814
1815run_test "Authentication: client SHA384, server required" \
1816 "$P_SRV auth_mode=required" \
1817 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1818 key_file=data_files/server6.key \
1819 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
1820 0 \
1821 -c "Supported Signature Algorithm found: 4," \
1822 -c "Supported Signature Algorithm found: 5,"
1823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001824run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001825 "$P_SRV debug_level=3 auth_mode=required" \
1826 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001827 key_file=data_files/server5.key" \
1828 1 \
1829 -S "skip write certificate request" \
1830 -C "skip parse certificate request" \
1831 -c "got a certificate request" \
1832 -C "skip write certificate" \
1833 -C "skip write certificate verify" \
1834 -S "skip parse certificate verify" \
1835 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001836 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001837 -s "! mbedtls_ssl_handshake returned" \
1838 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001839 -s "X509 - Certificate verification failed"
1840
Janos Follath89baba22017-04-10 14:34:35 +01001841run_test "Authentication: client cert not trusted, server required" \
1842 "$P_SRV debug_level=3 auth_mode=required" \
1843 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
1844 key_file=data_files/server5.key" \
1845 1 \
1846 -S "skip write certificate request" \
1847 -C "skip parse certificate request" \
1848 -c "got a certificate request" \
1849 -C "skip write certificate" \
1850 -C "skip write certificate verify" \
1851 -S "skip parse certificate verify" \
1852 -s "x509_verify_cert() returned" \
1853 -s "! The certificate is not correctly signed by the trusted CA" \
1854 -s "! mbedtls_ssl_handshake returned" \
1855 -c "! mbedtls_ssl_handshake returned" \
1856 -s "X509 - Certificate verification failed"
1857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001858run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001859 "$P_SRV debug_level=3 auth_mode=optional" \
1860 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001861 key_file=data_files/server5.key" \
1862 0 \
1863 -S "skip write certificate request" \
1864 -C "skip parse certificate request" \
1865 -c "got a certificate request" \
1866 -C "skip write certificate" \
1867 -C "skip write certificate verify" \
1868 -S "skip parse certificate verify" \
1869 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001870 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001871 -S "! mbedtls_ssl_handshake returned" \
1872 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001873 -S "X509 - Certificate verification failed"
1874
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001875run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001876 "$P_SRV debug_level=3 auth_mode=none" \
1877 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001878 key_file=data_files/server5.key" \
1879 0 \
1880 -s "skip write certificate request" \
1881 -C "skip parse certificate request" \
1882 -c "got no certificate request" \
1883 -c "skip write certificate" \
1884 -c "skip write certificate verify" \
1885 -s "skip parse certificate verify" \
1886 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001887 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001888 -S "! mbedtls_ssl_handshake returned" \
1889 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001890 -S "X509 - Certificate verification failed"
1891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001892run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001893 "$P_SRV debug_level=3 auth_mode=optional" \
1894 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001895 0 \
1896 -S "skip write certificate request" \
1897 -C "skip parse certificate request" \
1898 -c "got a certificate request" \
1899 -C "skip write certificate$" \
1900 -C "got no certificate to send" \
1901 -S "SSLv3 client has no certificate" \
1902 -c "skip write certificate verify" \
1903 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001904 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001905 -S "! mbedtls_ssl_handshake returned" \
1906 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001907 -S "X509 - Certificate verification failed"
1908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001909run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001910 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001911 "$O_CLI" \
1912 0 \
1913 -S "skip write certificate request" \
1914 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001915 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001916 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001917 -S "X509 - Certificate verification failed"
1918
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001919run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001920 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001921 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001922 0 \
1923 -C "skip parse certificate request" \
1924 -c "got a certificate request" \
1925 -C "skip write certificate$" \
1926 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001927 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001928
Janos Follathe2681a42016-03-07 15:57:05 +00001929requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001930run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001931 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001932 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001933 0 \
1934 -S "skip write certificate request" \
1935 -C "skip parse certificate request" \
1936 -c "got a certificate request" \
1937 -C "skip write certificate$" \
1938 -c "skip write certificate verify" \
1939 -c "got no certificate to send" \
1940 -s "SSLv3 client has no certificate" \
1941 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001942 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001943 -S "! mbedtls_ssl_handshake returned" \
1944 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001945 -S "X509 - Certificate verification failed"
1946
Janos Follath89baba22017-04-10 14:34:35 +01001947# Tests for CA list in CertificateRequest messages
1948
1949run_test "Authentication: send CA list in CertificateRequest (default)" \
1950 "$P_SRV debug_level=3 auth_mode=required" \
1951 "$P_CLI crt_file=data_files/server6.crt \
1952 key_file=data_files/server6.key" \
1953 0 \
1954 -s "requested DN"
1955
1956run_test "Authentication: do not send CA list in CertificateRequest" \
1957 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
1958 "$P_CLI crt_file=data_files/server6.crt \
1959 key_file=data_files/server6.key" \
1960 0 \
1961 -S "requested DN"
1962
1963run_test "Authentication: send CA list in CertificateRequest, client self signed" \
1964 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
1965 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
1966 key_file=data_files/server5.key" \
1967 1 \
1968 -S "requested DN" \
1969 -s "x509_verify_cert() returned" \
1970 -s "! The certificate is not correctly signed by the trusted CA" \
1971 -s "! mbedtls_ssl_handshake returned" \
1972 -c "! mbedtls_ssl_handshake returned" \
1973 -s "X509 - Certificate verification failed"
1974
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001975# Tests for certificate selection based on SHA verson
1976
1977run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1978 "$P_SRV crt_file=data_files/server5.crt \
1979 key_file=data_files/server5.key \
1980 crt_file2=data_files/server5-sha1.crt \
1981 key_file2=data_files/server5.key" \
1982 "$P_CLI force_version=tls1_2" \
1983 0 \
1984 -c "signed using.*ECDSA with SHA256" \
1985 -C "signed using.*ECDSA with SHA1"
1986
1987run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1988 "$P_SRV crt_file=data_files/server5.crt \
1989 key_file=data_files/server5.key \
1990 crt_file2=data_files/server5-sha1.crt \
1991 key_file2=data_files/server5.key" \
1992 "$P_CLI force_version=tls1_1" \
1993 0 \
1994 -C "signed using.*ECDSA with SHA256" \
1995 -c "signed using.*ECDSA with SHA1"
1996
1997run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1998 "$P_SRV crt_file=data_files/server5.crt \
1999 key_file=data_files/server5.key \
2000 crt_file2=data_files/server5-sha1.crt \
2001 key_file2=data_files/server5.key" \
2002 "$P_CLI force_version=tls1" \
2003 0 \
2004 -C "signed using.*ECDSA with SHA256" \
2005 -c "signed using.*ECDSA with SHA1"
2006
2007run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2008 "$P_SRV crt_file=data_files/server5.crt \
2009 key_file=data_files/server5.key \
2010 crt_file2=data_files/server6.crt \
2011 key_file2=data_files/server6.key" \
2012 "$P_CLI force_version=tls1_1" \
2013 0 \
2014 -c "serial number.*09" \
2015 -c "signed using.*ECDSA with SHA256" \
2016 -C "signed using.*ECDSA with SHA1"
2017
2018run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2019 "$P_SRV crt_file=data_files/server6.crt \
2020 key_file=data_files/server6.key \
2021 crt_file2=data_files/server5.crt \
2022 key_file2=data_files/server5.key" \
2023 "$P_CLI force_version=tls1_1" \
2024 0 \
2025 -c "serial number.*0A" \
2026 -c "signed using.*ECDSA with SHA256" \
2027 -C "signed using.*ECDSA with SHA1"
2028
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002029# tests for SNI
2030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002031run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002032 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002033 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002034 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002035 0 \
2036 -S "parse ServerName extension" \
2037 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2038 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002039
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002040run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002041 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002042 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002043 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 +02002044 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002045 0 \
2046 -s "parse ServerName extension" \
2047 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2048 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002050run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002051 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002052 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002053 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 +02002054 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002055 0 \
2056 -s "parse ServerName extension" \
2057 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2058 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002060run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002061 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002062 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002063 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 +02002064 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002065 1 \
2066 -s "parse ServerName extension" \
2067 -s "ssl_sni_wrapper() returned" \
2068 -s "mbedtls_ssl_handshake returned" \
2069 -c "mbedtls_ssl_handshake returned" \
2070 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002071
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002072run_test "SNI: client auth no override: optional" \
2073 "$P_SRV debug_level=3 auth_mode=optional \
2074 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2075 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2076 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002077 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002078 -S "skip write certificate request" \
2079 -C "skip parse certificate request" \
2080 -c "got a certificate request" \
2081 -C "skip write certificate" \
2082 -C "skip write certificate verify" \
2083 -S "skip parse certificate verify"
2084
2085run_test "SNI: client auth override: none -> optional" \
2086 "$P_SRV debug_level=3 auth_mode=none \
2087 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2088 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2089 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002090 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002091 -S "skip write certificate request" \
2092 -C "skip parse certificate request" \
2093 -c "got a certificate request" \
2094 -C "skip write certificate" \
2095 -C "skip write certificate verify" \
2096 -S "skip parse certificate verify"
2097
2098run_test "SNI: client auth override: optional -> none" \
2099 "$P_SRV debug_level=3 auth_mode=optional \
2100 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2101 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2102 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002103 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002104 -s "skip write certificate request" \
2105 -C "skip parse certificate request" \
2106 -c "got no certificate request" \
2107 -c "skip write certificate" \
2108 -c "skip write certificate verify" \
2109 -s "skip parse certificate verify"
2110
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002111run_test "SNI: CA no override" \
2112 "$P_SRV debug_level=3 auth_mode=optional \
2113 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2114 ca_file=data_files/test-ca.crt \
2115 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2116 "$P_CLI debug_level=3 server_name=localhost \
2117 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2118 1 \
2119 -S "skip write certificate request" \
2120 -C "skip parse certificate request" \
2121 -c "got a certificate request" \
2122 -C "skip write certificate" \
2123 -C "skip write certificate verify" \
2124 -S "skip parse certificate verify" \
2125 -s "x509_verify_cert() returned" \
2126 -s "! The certificate is not correctly signed by the trusted CA" \
2127 -S "The certificate has been revoked (is on a CRL)"
2128
2129run_test "SNI: CA override" \
2130 "$P_SRV debug_level=3 auth_mode=optional \
2131 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2132 ca_file=data_files/test-ca.crt \
2133 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2134 "$P_CLI debug_level=3 server_name=localhost \
2135 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2136 0 \
2137 -S "skip write certificate request" \
2138 -C "skip parse certificate request" \
2139 -c "got a certificate request" \
2140 -C "skip write certificate" \
2141 -C "skip write certificate verify" \
2142 -S "skip parse certificate verify" \
2143 -S "x509_verify_cert() returned" \
2144 -S "! The certificate is not correctly signed by the trusted CA" \
2145 -S "The certificate has been revoked (is on a CRL)"
2146
2147run_test "SNI: CA override with CRL" \
2148 "$P_SRV debug_level=3 auth_mode=optional \
2149 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2150 ca_file=data_files/test-ca.crt \
2151 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2152 "$P_CLI debug_level=3 server_name=localhost \
2153 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2154 1 \
2155 -S "skip write certificate request" \
2156 -C "skip parse certificate request" \
2157 -c "got a certificate request" \
2158 -C "skip write certificate" \
2159 -C "skip write certificate verify" \
2160 -S "skip parse certificate verify" \
2161 -s "x509_verify_cert() returned" \
2162 -S "! The certificate is not correctly signed by the trusted CA" \
2163 -s "The certificate has been revoked (is on a CRL)"
2164
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002165# Tests for non-blocking I/O: exercise a variety of handshake flows
2166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002167run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002168 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2169 "$P_CLI nbio=2 tickets=0" \
2170 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002171 -S "mbedtls_ssl_handshake returned" \
2172 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002173 -c "Read from server: .* bytes read"
2174
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002175run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002176 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2177 "$P_CLI nbio=2 tickets=0" \
2178 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002179 -S "mbedtls_ssl_handshake returned" \
2180 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002181 -c "Read from server: .* bytes read"
2182
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002183run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002184 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2185 "$P_CLI nbio=2 tickets=1" \
2186 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002187 -S "mbedtls_ssl_handshake returned" \
2188 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002189 -c "Read from server: .* bytes read"
2190
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002191run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002192 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2193 "$P_CLI nbio=2 tickets=1" \
2194 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002195 -S "mbedtls_ssl_handshake returned" \
2196 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002197 -c "Read from server: .* bytes read"
2198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002199run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002200 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2201 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2202 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002203 -S "mbedtls_ssl_handshake returned" \
2204 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002205 -c "Read from server: .* bytes read"
2206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002207run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002208 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2209 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2210 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002211 -S "mbedtls_ssl_handshake returned" \
2212 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002213 -c "Read from server: .* bytes read"
2214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002215run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002216 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2217 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2218 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002219 -S "mbedtls_ssl_handshake returned" \
2220 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002221 -c "Read from server: .* bytes read"
2222
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002223# Tests for version negotiation
2224
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002225run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002226 "$P_SRV" \
2227 "$P_CLI" \
2228 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002229 -S "mbedtls_ssl_handshake returned" \
2230 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002231 -s "Protocol is TLSv1.2" \
2232 -c "Protocol is TLSv1.2"
2233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002234run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002235 "$P_SRV" \
2236 "$P_CLI max_version=tls1_1" \
2237 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002238 -S "mbedtls_ssl_handshake returned" \
2239 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002240 -s "Protocol is TLSv1.1" \
2241 -c "Protocol is TLSv1.1"
2242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002243run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002244 "$P_SRV max_version=tls1_1" \
2245 "$P_CLI" \
2246 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002247 -S "mbedtls_ssl_handshake returned" \
2248 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002249 -s "Protocol is TLSv1.1" \
2250 -c "Protocol is TLSv1.1"
2251
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002252run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002253 "$P_SRV max_version=tls1_1" \
2254 "$P_CLI max_version=tls1_1" \
2255 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002256 -S "mbedtls_ssl_handshake returned" \
2257 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002258 -s "Protocol is TLSv1.1" \
2259 -c "Protocol is TLSv1.1"
2260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002261run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002262 "$P_SRV min_version=tls1_1" \
2263 "$P_CLI max_version=tls1_1" \
2264 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002265 -S "mbedtls_ssl_handshake returned" \
2266 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002267 -s "Protocol is TLSv1.1" \
2268 -c "Protocol is TLSv1.1"
2269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002270run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002271 "$P_SRV max_version=tls1_1" \
2272 "$P_CLI min_version=tls1_1" \
2273 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002274 -S "mbedtls_ssl_handshake returned" \
2275 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002276 -s "Protocol is TLSv1.1" \
2277 -c "Protocol is TLSv1.1"
2278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002279run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002280 "$P_SRV max_version=tls1_1" \
2281 "$P_CLI min_version=tls1_2" \
2282 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002283 -s "mbedtls_ssl_handshake returned" \
2284 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002285 -c "SSL - Handshake protocol not within min/max boundaries"
2286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002287run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002288 "$P_SRV min_version=tls1_2" \
2289 "$P_CLI max_version=tls1_1" \
2290 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002291 -s "mbedtls_ssl_handshake returned" \
2292 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002293 -s "SSL - Handshake protocol not within min/max boundaries"
2294
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002295# Tests for ALPN extension
2296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002297run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002298 "$P_SRV debug_level=3" \
2299 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002300 0 \
2301 -C "client hello, adding alpn extension" \
2302 -S "found alpn extension" \
2303 -C "got an alert message, type: \\[2:120]" \
2304 -S "server hello, adding alpn extension" \
2305 -C "found alpn extension " \
2306 -C "Application Layer Protocol is" \
2307 -S "Application Layer Protocol is"
2308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002309run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002310 "$P_SRV debug_level=3" \
2311 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002312 0 \
2313 -c "client hello, adding alpn extension" \
2314 -s "found alpn extension" \
2315 -C "got an alert message, type: \\[2:120]" \
2316 -S "server hello, adding alpn extension" \
2317 -C "found alpn extension " \
2318 -c "Application Layer Protocol is (none)" \
2319 -S "Application Layer Protocol is"
2320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002321run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002322 "$P_SRV debug_level=3 alpn=abc,1234" \
2323 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002324 0 \
2325 -C "client hello, adding alpn extension" \
2326 -S "found alpn extension" \
2327 -C "got an alert message, type: \\[2:120]" \
2328 -S "server hello, adding alpn extension" \
2329 -C "found alpn extension " \
2330 -C "Application Layer Protocol is" \
2331 -s "Application Layer Protocol is (none)"
2332
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002333run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002334 "$P_SRV debug_level=3 alpn=abc,1234" \
2335 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002336 0 \
2337 -c "client hello, adding alpn extension" \
2338 -s "found alpn extension" \
2339 -C "got an alert message, type: \\[2:120]" \
2340 -s "server hello, adding alpn extension" \
2341 -c "found alpn extension" \
2342 -c "Application Layer Protocol is abc" \
2343 -s "Application Layer Protocol is abc"
2344
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002345run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002346 "$P_SRV debug_level=3 alpn=abc,1234" \
2347 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002348 0 \
2349 -c "client hello, adding alpn extension" \
2350 -s "found alpn extension" \
2351 -C "got an alert message, type: \\[2:120]" \
2352 -s "server hello, adding alpn extension" \
2353 -c "found alpn extension" \
2354 -c "Application Layer Protocol is abc" \
2355 -s "Application Layer Protocol is abc"
2356
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002357run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002358 "$P_SRV debug_level=3 alpn=abc,1234" \
2359 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002360 0 \
2361 -c "client hello, adding alpn extension" \
2362 -s "found alpn extension" \
2363 -C "got an alert message, type: \\[2:120]" \
2364 -s "server hello, adding alpn extension" \
2365 -c "found alpn extension" \
2366 -c "Application Layer Protocol is 1234" \
2367 -s "Application Layer Protocol is 1234"
2368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002369run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002370 "$P_SRV debug_level=3 alpn=abc,123" \
2371 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002372 1 \
2373 -c "client hello, adding alpn extension" \
2374 -s "found alpn extension" \
2375 -c "got an alert message, type: \\[2:120]" \
2376 -S "server hello, adding alpn extension" \
2377 -C "found alpn extension" \
2378 -C "Application Layer Protocol is 1234" \
2379 -S "Application Layer Protocol is 1234"
2380
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002381
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002382# Tests for keyUsage in leaf certificates, part 1:
2383# server-side certificate/suite selection
2384
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002385run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002386 "$P_SRV key_file=data_files/server2.key \
2387 crt_file=data_files/server2.ku-ds.crt" \
2388 "$P_CLI" \
2389 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002390 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002391
2392
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002393run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002394 "$P_SRV key_file=data_files/server2.key \
2395 crt_file=data_files/server2.ku-ke.crt" \
2396 "$P_CLI" \
2397 0 \
2398 -c "Ciphersuite is TLS-RSA-WITH-"
2399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002400run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002401 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002402 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002403 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002404 1 \
2405 -C "Ciphersuite is "
2406
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002407run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002408 "$P_SRV key_file=data_files/server5.key \
2409 crt_file=data_files/server5.ku-ds.crt" \
2410 "$P_CLI" \
2411 0 \
2412 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2413
2414
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002415run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002416 "$P_SRV key_file=data_files/server5.key \
2417 crt_file=data_files/server5.ku-ka.crt" \
2418 "$P_CLI" \
2419 0 \
2420 -c "Ciphersuite is TLS-ECDH-"
2421
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002422run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002423 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002424 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002425 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002426 1 \
2427 -C "Ciphersuite is "
2428
2429# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002430# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002432run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002433 "$O_SRV -key data_files/server2.key \
2434 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002435 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002436 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2437 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002438 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002439 -C "Processing of the Certificate handshake message failed" \
2440 -c "Ciphersuite is TLS-"
2441
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002442run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002443 "$O_SRV -key data_files/server2.key \
2444 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002445 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002446 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2447 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002448 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002449 -C "Processing of the Certificate handshake message failed" \
2450 -c "Ciphersuite is TLS-"
2451
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002452run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002453 "$O_SRV -key data_files/server2.key \
2454 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002455 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002456 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2457 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002458 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002459 -C "Processing of the Certificate handshake message failed" \
2460 -c "Ciphersuite is TLS-"
2461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002462run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002463 "$O_SRV -key data_files/server2.key \
2464 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002465 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002466 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2467 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002468 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002469 -c "Processing of the Certificate handshake message failed" \
2470 -C "Ciphersuite is TLS-"
2471
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002472run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2473 "$O_SRV -key data_files/server2.key \
2474 -cert data_files/server2.ku-ke.crt" \
2475 "$P_CLI debug_level=1 auth_mode=optional \
2476 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2477 0 \
2478 -c "bad certificate (usage extensions)" \
2479 -C "Processing of the Certificate handshake message failed" \
2480 -c "Ciphersuite is TLS-" \
2481 -c "! Usage does not match the keyUsage extension"
2482
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002483run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002484 "$O_SRV -key data_files/server2.key \
2485 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002486 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002487 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2488 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002489 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002490 -C "Processing of the Certificate handshake message failed" \
2491 -c "Ciphersuite is TLS-"
2492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002493run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002494 "$O_SRV -key data_files/server2.key \
2495 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002496 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002497 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2498 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002499 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002500 -c "Processing of the Certificate handshake message failed" \
2501 -C "Ciphersuite is TLS-"
2502
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002503run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2504 "$O_SRV -key data_files/server2.key \
2505 -cert data_files/server2.ku-ds.crt" \
2506 "$P_CLI debug_level=1 auth_mode=optional \
2507 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2508 0 \
2509 -c "bad certificate (usage extensions)" \
2510 -C "Processing of the Certificate handshake message failed" \
2511 -c "Ciphersuite is TLS-" \
2512 -c "! Usage does not match the keyUsage extension"
2513
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002514# Tests for keyUsage in leaf certificates, part 3:
2515# server-side checking of client cert
2516
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002517run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002518 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002519 "$O_CLI -key data_files/server2.key \
2520 -cert data_files/server2.ku-ds.crt" \
2521 0 \
2522 -S "bad certificate (usage extensions)" \
2523 -S "Processing of the Certificate handshake message failed"
2524
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002525run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002526 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002527 "$O_CLI -key data_files/server2.key \
2528 -cert data_files/server2.ku-ke.crt" \
2529 0 \
2530 -s "bad certificate (usage extensions)" \
2531 -S "Processing of the Certificate handshake message failed"
2532
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002533run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002534 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002535 "$O_CLI -key data_files/server2.key \
2536 -cert data_files/server2.ku-ke.crt" \
2537 1 \
2538 -s "bad certificate (usage extensions)" \
2539 -s "Processing of the Certificate handshake message failed"
2540
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002541run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002542 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002543 "$O_CLI -key data_files/server5.key \
2544 -cert data_files/server5.ku-ds.crt" \
2545 0 \
2546 -S "bad certificate (usage extensions)" \
2547 -S "Processing of the Certificate handshake message failed"
2548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002549run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002550 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002551 "$O_CLI -key data_files/server5.key \
2552 -cert data_files/server5.ku-ka.crt" \
2553 0 \
2554 -s "bad certificate (usage extensions)" \
2555 -S "Processing of the Certificate handshake message failed"
2556
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002557# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002559run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002560 "$P_SRV key_file=data_files/server5.key \
2561 crt_file=data_files/server5.eku-srv.crt" \
2562 "$P_CLI" \
2563 0
2564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002565run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002566 "$P_SRV key_file=data_files/server5.key \
2567 crt_file=data_files/server5.eku-srv.crt" \
2568 "$P_CLI" \
2569 0
2570
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002571run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002572 "$P_SRV key_file=data_files/server5.key \
2573 crt_file=data_files/server5.eku-cs_any.crt" \
2574 "$P_CLI" \
2575 0
2576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002577run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002578 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002579 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002580 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002581 1
2582
2583# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2584
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002585run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002586 "$O_SRV -key data_files/server5.key \
2587 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002588 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002589 0 \
2590 -C "bad certificate (usage extensions)" \
2591 -C "Processing of the Certificate handshake message failed" \
2592 -c "Ciphersuite is TLS-"
2593
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002594run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002595 "$O_SRV -key data_files/server5.key \
2596 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002597 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002598 0 \
2599 -C "bad certificate (usage extensions)" \
2600 -C "Processing of the Certificate handshake message failed" \
2601 -c "Ciphersuite is TLS-"
2602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002603run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002604 "$O_SRV -key data_files/server5.key \
2605 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002606 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002607 0 \
2608 -C "bad certificate (usage extensions)" \
2609 -C "Processing of the Certificate handshake message failed" \
2610 -c "Ciphersuite is TLS-"
2611
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002612run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002613 "$O_SRV -key data_files/server5.key \
2614 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002615 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002616 1 \
2617 -c "bad certificate (usage extensions)" \
2618 -c "Processing of the Certificate handshake message failed" \
2619 -C "Ciphersuite is TLS-"
2620
2621# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002623run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002624 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002625 "$O_CLI -key data_files/server5.key \
2626 -cert data_files/server5.eku-cli.crt" \
2627 0 \
2628 -S "bad certificate (usage extensions)" \
2629 -S "Processing of the Certificate handshake message failed"
2630
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002631run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002632 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002633 "$O_CLI -key data_files/server5.key \
2634 -cert data_files/server5.eku-srv_cli.crt" \
2635 0 \
2636 -S "bad certificate (usage extensions)" \
2637 -S "Processing of the Certificate handshake message failed"
2638
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002639run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002640 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002641 "$O_CLI -key data_files/server5.key \
2642 -cert data_files/server5.eku-cs_any.crt" \
2643 0 \
2644 -S "bad certificate (usage extensions)" \
2645 -S "Processing of the Certificate handshake message failed"
2646
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002647run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002648 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002649 "$O_CLI -key data_files/server5.key \
2650 -cert data_files/server5.eku-cs.crt" \
2651 0 \
2652 -s "bad certificate (usage extensions)" \
2653 -S "Processing of the Certificate handshake message failed"
2654
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002655run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002656 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002657 "$O_CLI -key data_files/server5.key \
2658 -cert data_files/server5.eku-cs.crt" \
2659 1 \
2660 -s "bad certificate (usage extensions)" \
2661 -s "Processing of the Certificate handshake message failed"
2662
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002663# Tests for DHM parameters loading
2664
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002665run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002666 "$P_SRV" \
2667 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2668 debug_level=3" \
2669 0 \
2670 -c "value of 'DHM: P ' (2048 bits)" \
2671 -c "value of 'DHM: G ' (2048 bits)"
2672
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002673run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002674 "$P_SRV dhm_file=data_files/dhparams.pem" \
2675 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2676 debug_level=3" \
2677 0 \
2678 -c "value of 'DHM: P ' (1024 bits)" \
2679 -c "value of 'DHM: G ' (2 bits)"
2680
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002681# Tests for DHM client-side size checking
2682
2683run_test "DHM size: server default, client default, OK" \
2684 "$P_SRV" \
2685 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2686 debug_level=1" \
2687 0 \
2688 -C "DHM prime too short:"
2689
2690run_test "DHM size: server default, client 2048, OK" \
2691 "$P_SRV" \
2692 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2693 debug_level=1 dhmlen=2048" \
2694 0 \
2695 -C "DHM prime too short:"
2696
2697run_test "DHM size: server 1024, client default, OK" \
2698 "$P_SRV dhm_file=data_files/dhparams.pem" \
2699 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2700 debug_level=1" \
2701 0 \
2702 -C "DHM prime too short:"
2703
2704run_test "DHM size: server 1000, client default, rejected" \
2705 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2706 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2707 debug_level=1" \
2708 1 \
2709 -c "DHM prime too short:"
2710
2711run_test "DHM size: server default, client 2049, rejected" \
2712 "$P_SRV" \
2713 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2714 debug_level=1 dhmlen=2049" \
2715 1 \
2716 -c "DHM prime too short:"
2717
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002718# Tests for PSK callback
2719
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002720run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002721 "$P_SRV psk=abc123 psk_identity=foo" \
2722 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2723 psk_identity=foo psk=abc123" \
2724 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002725 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002726 -S "SSL - Unknown identity received" \
2727 -S "SSL - Verification of the message MAC failed"
2728
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002729run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002730 "$P_SRV" \
2731 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2732 psk_identity=foo psk=abc123" \
2733 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002734 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002735 -S "SSL - Unknown identity received" \
2736 -S "SSL - Verification of the message MAC failed"
2737
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002738run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002739 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2740 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2741 psk_identity=foo psk=abc123" \
2742 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002743 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002744 -s "SSL - Unknown identity received" \
2745 -S "SSL - Verification of the message MAC failed"
2746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002747run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002748 "$P_SRV psk_list=abc,dead,def,beef" \
2749 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2750 psk_identity=abc psk=dead" \
2751 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002752 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002753 -S "SSL - Unknown identity received" \
2754 -S "SSL - Verification of the message MAC failed"
2755
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002756run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002757 "$P_SRV psk_list=abc,dead,def,beef" \
2758 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2759 psk_identity=def psk=beef" \
2760 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002761 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002762 -S "SSL - Unknown identity received" \
2763 -S "SSL - Verification of the message MAC failed"
2764
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002765run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002766 "$P_SRV psk_list=abc,dead,def,beef" \
2767 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2768 psk_identity=ghi psk=beef" \
2769 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002770 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002771 -s "SSL - Unknown identity received" \
2772 -S "SSL - Verification of the message MAC failed"
2773
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002774run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002775 "$P_SRV psk_list=abc,dead,def,beef" \
2776 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2777 psk_identity=abc psk=beef" \
2778 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002779 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002780 -S "SSL - Unknown identity received" \
2781 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002782
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002783# Tests for EC J-PAKE
2784
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002785requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002786run_test "ECJPAKE: client not configured" \
2787 "$P_SRV debug_level=3" \
2788 "$P_CLI debug_level=3" \
2789 0 \
2790 -C "add ciphersuite: c0ff" \
2791 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002792 -S "found ecjpake kkpp extension" \
2793 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002794 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002795 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002796 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002797 -S "None of the common ciphersuites is usable"
2798
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002799requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002800run_test "ECJPAKE: server not configured" \
2801 "$P_SRV debug_level=3" \
2802 "$P_CLI debug_level=3 ecjpake_pw=bla \
2803 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2804 1 \
2805 -c "add ciphersuite: c0ff" \
2806 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002807 -s "found ecjpake kkpp extension" \
2808 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002809 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002810 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002811 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002812 -s "None of the common ciphersuites is usable"
2813
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002814requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002815run_test "ECJPAKE: working, TLS" \
2816 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2817 "$P_CLI debug_level=3 ecjpake_pw=bla \
2818 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002819 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002820 -c "add ciphersuite: c0ff" \
2821 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002822 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002823 -s "found ecjpake kkpp extension" \
2824 -S "skip ecjpake kkpp extension" \
2825 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002826 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002827 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002828 -S "None of the common ciphersuites is usable" \
2829 -S "SSL - Verification of the message MAC failed"
2830
Janos Follath74537a62016-09-02 13:45:28 +01002831server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002832requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002833run_test "ECJPAKE: password mismatch, TLS" \
2834 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2835 "$P_CLI debug_level=3 ecjpake_pw=bad \
2836 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2837 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002838 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002839 -s "SSL - Verification of the message MAC failed"
2840
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002841requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002842run_test "ECJPAKE: working, DTLS" \
2843 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2844 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2845 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2846 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002847 -c "re-using cached ecjpake parameters" \
2848 -S "SSL - Verification of the message MAC failed"
2849
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002850requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002851run_test "ECJPAKE: working, DTLS, no cookie" \
2852 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2853 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2854 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2855 0 \
2856 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002857 -S "SSL - Verification of the message MAC failed"
2858
Janos Follath74537a62016-09-02 13:45:28 +01002859server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002860requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002861run_test "ECJPAKE: password mismatch, DTLS" \
2862 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2863 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2864 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2865 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002866 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002867 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002868
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002869# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002870requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002871run_test "ECJPAKE: working, DTLS, nolog" \
2872 "$P_SRV dtls=1 ecjpake_pw=bla" \
2873 "$P_CLI dtls=1 ecjpake_pw=bla \
2874 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2875 0
2876
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002877# Tests for ciphersuites per version
2878
Janos Follathe2681a42016-03-07 15:57:05 +00002879requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002880run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002881 "$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 +02002882 "$P_CLI force_version=ssl3" \
2883 0 \
2884 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2885
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002886run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002887 "$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 +01002888 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002889 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002890 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002892run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002893 "$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 +02002894 "$P_CLI force_version=tls1_1" \
2895 0 \
2896 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2897
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002898run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002899 "$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 +02002900 "$P_CLI force_version=tls1_2" \
2901 0 \
2902 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2903
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002904# Test for ClientHello without extensions
2905
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002906requires_gnutls
2907run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002908 "$P_SRV debug_level=3" \
2909 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2910 0 \
2911 -s "dumping 'client hello extensions' (0 bytes)"
2912
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002913# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002914
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002915run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002916 "$P_SRV" \
2917 "$P_CLI request_size=100" \
2918 0 \
2919 -s "Read from client: 100 bytes read$"
2920
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002921run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002922 "$P_SRV" \
2923 "$P_CLI request_size=500" \
2924 0 \
2925 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002926
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002927# Tests for small packets
2928
Janos Follathe2681a42016-03-07 15:57:05 +00002929requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002930run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002931 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002932 "$P_CLI request_size=1 force_version=ssl3 \
2933 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2934 0 \
2935 -s "Read from client: 1 bytes read"
2936
Janos Follathe2681a42016-03-07 15:57:05 +00002937requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002938run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002939 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002940 "$P_CLI request_size=1 force_version=ssl3 \
2941 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2942 0 \
2943 -s "Read from client: 1 bytes read"
2944
2945run_test "Small packet TLS 1.0 BlockCipher" \
2946 "$P_SRV" \
2947 "$P_CLI request_size=1 force_version=tls1 \
2948 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2949 0 \
2950 -s "Read from client: 1 bytes read"
2951
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002952run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2953 "$P_SRV" \
2954 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2955 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2956 0 \
2957 -s "Read from client: 1 bytes read"
2958
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002959run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2960 "$P_SRV" \
2961 "$P_CLI request_size=1 force_version=tls1 \
2962 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2963 trunc_hmac=1" \
2964 0 \
2965 -s "Read from client: 1 bytes read"
2966
2967run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002968 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002969 "$P_CLI request_size=1 force_version=tls1 \
2970 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2971 trunc_hmac=1" \
2972 0 \
2973 -s "Read from client: 1 bytes read"
2974
2975run_test "Small packet TLS 1.1 BlockCipher" \
2976 "$P_SRV" \
2977 "$P_CLI request_size=1 force_version=tls1_1 \
2978 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2979 0 \
2980 -s "Read from client: 1 bytes read"
2981
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002982run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2983 "$P_SRV" \
2984 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2985 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2986 0 \
2987 -s "Read from client: 1 bytes read"
2988
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002989run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002990 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002991 "$P_CLI request_size=1 force_version=tls1_1 \
2992 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2993 0 \
2994 -s "Read from client: 1 bytes read"
2995
2996run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2997 "$P_SRV" \
2998 "$P_CLI request_size=1 force_version=tls1_1 \
2999 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3000 trunc_hmac=1" \
3001 0 \
3002 -s "Read from client: 1 bytes read"
3003
3004run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003005 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003006 "$P_CLI request_size=1 force_version=tls1_1 \
3007 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3008 trunc_hmac=1" \
3009 0 \
3010 -s "Read from client: 1 bytes read"
3011
3012run_test "Small packet TLS 1.2 BlockCipher" \
3013 "$P_SRV" \
3014 "$P_CLI request_size=1 force_version=tls1_2 \
3015 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3016 0 \
3017 -s "Read from client: 1 bytes read"
3018
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003019run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3020 "$P_SRV" \
3021 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3022 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3023 0 \
3024 -s "Read from client: 1 bytes read"
3025
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003026run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3027 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003028 "$P_CLI request_size=1 force_version=tls1_2 \
3029 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003030 0 \
3031 -s "Read from client: 1 bytes read"
3032
3033run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3034 "$P_SRV" \
3035 "$P_CLI request_size=1 force_version=tls1_2 \
3036 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3037 trunc_hmac=1" \
3038 0 \
3039 -s "Read from client: 1 bytes read"
3040
3041run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003042 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003043 "$P_CLI request_size=1 force_version=tls1_2 \
3044 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3045 0 \
3046 -s "Read from client: 1 bytes read"
3047
3048run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003049 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003050 "$P_CLI request_size=1 force_version=tls1_2 \
3051 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3052 trunc_hmac=1" \
3053 0 \
3054 -s "Read from client: 1 bytes read"
3055
3056run_test "Small packet TLS 1.2 AEAD" \
3057 "$P_SRV" \
3058 "$P_CLI request_size=1 force_version=tls1_2 \
3059 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3060 0 \
3061 -s "Read from client: 1 bytes read"
3062
3063run_test "Small packet TLS 1.2 AEAD shorter tag" \
3064 "$P_SRV" \
3065 "$P_CLI request_size=1 force_version=tls1_2 \
3066 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3067 0 \
3068 -s "Read from client: 1 bytes read"
3069
Janos Follath00efff72016-05-06 13:48:23 +01003070# A test for extensions in SSLv3
3071
3072requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3073run_test "SSLv3 with extensions, server side" \
3074 "$P_SRV min_version=ssl3 debug_level=3" \
3075 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3076 0 \
3077 -S "dumping 'client hello extensions'" \
3078 -S "server hello, total extension length:"
3079
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003080# Test for large packets
3081
Janos Follathe2681a42016-03-07 15:57:05 +00003082requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003083run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003084 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003085 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003086 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3087 0 \
3088 -s "Read from client: 16384 bytes read"
3089
Janos Follathe2681a42016-03-07 15:57:05 +00003090requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003091run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003092 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003093 "$P_CLI request_size=16384 force_version=ssl3 \
3094 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3095 0 \
3096 -s "Read from client: 16384 bytes read"
3097
3098run_test "Large packet TLS 1.0 BlockCipher" \
3099 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003100 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003101 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3102 0 \
3103 -s "Read from client: 16384 bytes read"
3104
3105run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3106 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003107 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003108 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3109 trunc_hmac=1" \
3110 0 \
3111 -s "Read from client: 16384 bytes read"
3112
3113run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003114 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003115 "$P_CLI request_size=16384 force_version=tls1 \
3116 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3117 trunc_hmac=1" \
3118 0 \
3119 -s "Read from client: 16384 bytes read"
3120
3121run_test "Large packet TLS 1.1 BlockCipher" \
3122 "$P_SRV" \
3123 "$P_CLI request_size=16384 force_version=tls1_1 \
3124 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3125 0 \
3126 -s "Read from client: 16384 bytes read"
3127
3128run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003129 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003130 "$P_CLI request_size=16384 force_version=tls1_1 \
3131 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3132 0 \
3133 -s "Read from client: 16384 bytes read"
3134
3135run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3136 "$P_SRV" \
3137 "$P_CLI request_size=16384 force_version=tls1_1 \
3138 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3139 trunc_hmac=1" \
3140 0 \
3141 -s "Read from client: 16384 bytes read"
3142
3143run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003144 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003145 "$P_CLI request_size=16384 force_version=tls1_1 \
3146 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3147 trunc_hmac=1" \
3148 0 \
3149 -s "Read from client: 16384 bytes read"
3150
3151run_test "Large packet TLS 1.2 BlockCipher" \
3152 "$P_SRV" \
3153 "$P_CLI request_size=16384 force_version=tls1_2 \
3154 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3155 0 \
3156 -s "Read from client: 16384 bytes read"
3157
3158run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3159 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003160 "$P_CLI request_size=16384 force_version=tls1_2 \
3161 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003162 0 \
3163 -s "Read from client: 16384 bytes read"
3164
3165run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3166 "$P_SRV" \
3167 "$P_CLI request_size=16384 force_version=tls1_2 \
3168 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3169 trunc_hmac=1" \
3170 0 \
3171 -s "Read from client: 16384 bytes read"
3172
3173run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003174 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003175 "$P_CLI request_size=16384 force_version=tls1_2 \
3176 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3177 0 \
3178 -s "Read from client: 16384 bytes read"
3179
3180run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003181 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003182 "$P_CLI request_size=16384 force_version=tls1_2 \
3183 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3184 trunc_hmac=1" \
3185 0 \
3186 -s "Read from client: 16384 bytes read"
3187
3188run_test "Large packet TLS 1.2 AEAD" \
3189 "$P_SRV" \
3190 "$P_CLI request_size=16384 force_version=tls1_2 \
3191 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3192 0 \
3193 -s "Read from client: 16384 bytes read"
3194
3195run_test "Large packet TLS 1.2 AEAD shorter tag" \
3196 "$P_SRV" \
3197 "$P_CLI request_size=16384 force_version=tls1_2 \
3198 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3199 0 \
3200 -s "Read from client: 16384 bytes read"
3201
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003202# Tests for DTLS HelloVerifyRequest
3203
3204run_test "DTLS cookie: enabled" \
3205 "$P_SRV dtls=1 debug_level=2" \
3206 "$P_CLI dtls=1 debug_level=2" \
3207 0 \
3208 -s "cookie verification failed" \
3209 -s "cookie verification passed" \
3210 -S "cookie verification skipped" \
3211 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003212 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003213 -S "SSL - The requested feature is not available"
3214
3215run_test "DTLS cookie: disabled" \
3216 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3217 "$P_CLI dtls=1 debug_level=2" \
3218 0 \
3219 -S "cookie verification failed" \
3220 -S "cookie verification passed" \
3221 -s "cookie verification skipped" \
3222 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003223 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003224 -S "SSL - The requested feature is not available"
3225
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003226run_test "DTLS cookie: default (failing)" \
3227 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3228 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3229 1 \
3230 -s "cookie verification failed" \
3231 -S "cookie verification passed" \
3232 -S "cookie verification skipped" \
3233 -C "received hello verify request" \
3234 -S "hello verification requested" \
3235 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003236
3237requires_ipv6
3238run_test "DTLS cookie: enabled, IPv6" \
3239 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3240 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3241 0 \
3242 -s "cookie verification failed" \
3243 -s "cookie verification passed" \
3244 -S "cookie verification skipped" \
3245 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003246 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003247 -S "SSL - The requested feature is not available"
3248
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003249run_test "DTLS cookie: enabled, nbio" \
3250 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3251 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3252 0 \
3253 -s "cookie verification failed" \
3254 -s "cookie verification passed" \
3255 -S "cookie verification skipped" \
3256 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003257 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003258 -S "SSL - The requested feature is not available"
3259
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003260# Tests for client reconnecting from the same port with DTLS
3261
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003262not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003263run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003264 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3265 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003266 0 \
3267 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003268 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003269 -S "Client initiated reconnection from same port"
3270
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003271not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003272run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003273 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3274 "$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 +02003275 0 \
3276 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003277 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003278 -s "Client initiated reconnection from same port"
3279
Paul Bakker362689d2016-05-13 10:33:25 +01003280not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3281run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003282 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3283 "$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 +02003284 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003285 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003286 -s "Client initiated reconnection from same port"
3287
Paul Bakker362689d2016-05-13 10:33:25 +01003288only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3289run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3290 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3291 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3292 0 \
3293 -S "The operation timed out" \
3294 -s "Client initiated reconnection from same port"
3295
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003296run_test "DTLS client reconnect from same port: no cookies" \
3297 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003298 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3299 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003300 -s "The operation timed out" \
3301 -S "Client initiated reconnection from same port"
3302
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003303# Tests for various cases of client authentication with DTLS
3304# (focused on handshake flows and message parsing)
3305
3306run_test "DTLS client auth: required" \
3307 "$P_SRV dtls=1 auth_mode=required" \
3308 "$P_CLI dtls=1" \
3309 0 \
3310 -s "Verifying peer X.509 certificate... ok"
3311
3312run_test "DTLS client auth: optional, client has no cert" \
3313 "$P_SRV dtls=1 auth_mode=optional" \
3314 "$P_CLI dtls=1 crt_file=none key_file=none" \
3315 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003316 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003317
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003318run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003319 "$P_SRV dtls=1 auth_mode=none" \
3320 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3321 0 \
3322 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003323 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003324
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003325run_test "DTLS wrong PSK: badmac alert" \
3326 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3327 "$P_CLI dtls=1 psk=abc124" \
3328 1 \
3329 -s "SSL - Verification of the message MAC failed" \
3330 -c "SSL - A fatal alert message was received from our peer"
3331
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003332# Tests for receiving fragmented handshake messages with DTLS
3333
3334requires_gnutls
3335run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3336 "$G_SRV -u --mtu 2048 -a" \
3337 "$P_CLI dtls=1 debug_level=2" \
3338 0 \
3339 -C "found fragmented DTLS handshake message" \
3340 -C "error"
3341
3342requires_gnutls
3343run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3344 "$G_SRV -u --mtu 512" \
3345 "$P_CLI dtls=1 debug_level=2" \
3346 0 \
3347 -c "found fragmented DTLS handshake message" \
3348 -C "error"
3349
3350requires_gnutls
3351run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3352 "$G_SRV -u --mtu 128" \
3353 "$P_CLI dtls=1 debug_level=2" \
3354 0 \
3355 -c "found fragmented DTLS handshake message" \
3356 -C "error"
3357
3358requires_gnutls
3359run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3360 "$G_SRV -u --mtu 128" \
3361 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3362 0 \
3363 -c "found fragmented DTLS handshake message" \
3364 -C "error"
3365
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003366requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003367run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3368 "$G_SRV -u --mtu 256" \
3369 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3370 0 \
3371 -c "found fragmented DTLS handshake message" \
3372 -c "client hello, adding renegotiation extension" \
3373 -c "found renegotiation extension" \
3374 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003375 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003376 -C "error" \
3377 -s "Extra-header:"
3378
3379requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003380run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3381 "$G_SRV -u --mtu 256" \
3382 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3383 0 \
3384 -c "found fragmented DTLS handshake message" \
3385 -c "client hello, adding renegotiation extension" \
3386 -c "found renegotiation extension" \
3387 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003388 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003389 -C "error" \
3390 -s "Extra-header:"
3391
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003392run_test "DTLS reassembly: no fragmentation (openssl server)" \
3393 "$O_SRV -dtls1 -mtu 2048" \
3394 "$P_CLI dtls=1 debug_level=2" \
3395 0 \
3396 -C "found fragmented DTLS handshake message" \
3397 -C "error"
3398
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003399run_test "DTLS reassembly: some fragmentation (openssl server)" \
3400 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003401 "$P_CLI dtls=1 debug_level=2" \
3402 0 \
3403 -c "found fragmented DTLS handshake message" \
3404 -C "error"
3405
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003406run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003407 "$O_SRV -dtls1 -mtu 256" \
3408 "$P_CLI dtls=1 debug_level=2" \
3409 0 \
3410 -c "found fragmented DTLS handshake message" \
3411 -C "error"
3412
3413run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3414 "$O_SRV -dtls1 -mtu 256" \
3415 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3416 0 \
3417 -c "found fragmented DTLS handshake message" \
3418 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003419
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003420# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003421
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003422not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003423run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003424 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003425 "$P_SRV dtls=1 debug_level=2" \
3426 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003427 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003428 -C "replayed record" \
3429 -S "replayed record" \
3430 -C "record from another epoch" \
3431 -S "record from another epoch" \
3432 -C "discarding invalid record" \
3433 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003434 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003435 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003436 -c "HTTP/1.0 200 OK"
3437
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003438not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003439run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003440 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003441 "$P_SRV dtls=1 debug_level=2" \
3442 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003443 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003444 -c "replayed record" \
3445 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003446 -c "discarding invalid record" \
3447 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003448 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003449 -s "Extra-header:" \
3450 -c "HTTP/1.0 200 OK"
3451
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003452run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3453 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003454 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3455 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003456 0 \
3457 -c "replayed record" \
3458 -S "replayed record" \
3459 -c "discarding invalid record" \
3460 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003461 -c "resend" \
3462 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003463 -s "Extra-header:" \
3464 -c "HTTP/1.0 200 OK"
3465
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003466run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003467 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003468 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003469 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003470 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003471 -c "discarding invalid record (mac)" \
3472 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003473 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003474 -c "HTTP/1.0 200 OK" \
3475 -S "too many records with bad MAC" \
3476 -S "Verification of the message MAC failed"
3477
3478run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3479 -p "$P_PXY bad_ad=1" \
3480 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3481 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3482 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003483 -C "discarding invalid record (mac)" \
3484 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003485 -S "Extra-header:" \
3486 -C "HTTP/1.0 200 OK" \
3487 -s "too many records with bad MAC" \
3488 -s "Verification of the message MAC failed"
3489
3490run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3491 -p "$P_PXY bad_ad=1" \
3492 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3493 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3494 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003495 -c "discarding invalid record (mac)" \
3496 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003497 -s "Extra-header:" \
3498 -c "HTTP/1.0 200 OK" \
3499 -S "too many records with bad MAC" \
3500 -S "Verification of the message MAC failed"
3501
3502run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3503 -p "$P_PXY bad_ad=1" \
3504 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3505 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3506 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003507 -c "discarding invalid record (mac)" \
3508 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003509 -s "Extra-header:" \
3510 -c "HTTP/1.0 200 OK" \
3511 -s "too many records with bad MAC" \
3512 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003513
3514run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003515 -p "$P_PXY delay_ccs=1" \
3516 "$P_SRV dtls=1 debug_level=1" \
3517 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003518 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003519 -c "record from another epoch" \
3520 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003521 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003522 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003523 -s "Extra-header:" \
3524 -c "HTTP/1.0 200 OK"
3525
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003526# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003527
Janos Follath74537a62016-09-02 13:45:28 +01003528client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003529run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003530 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003531 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3532 psk=abc123" \
3533 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003534 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3535 0 \
3536 -s "Extra-header:" \
3537 -c "HTTP/1.0 200 OK"
3538
Janos Follath74537a62016-09-02 13:45:28 +01003539client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003540run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3541 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003542 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3543 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003544 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3545 0 \
3546 -s "Extra-header:" \
3547 -c "HTTP/1.0 200 OK"
3548
Janos Follath74537a62016-09-02 13:45:28 +01003549client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003550run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3551 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003552 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3553 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003554 0 \
3555 -s "Extra-header:" \
3556 -c "HTTP/1.0 200 OK"
3557
Janos Follath74537a62016-09-02 13:45:28 +01003558client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003559run_test "DTLS proxy: 3d, FS, client auth" \
3560 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003561 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3562 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003563 0 \
3564 -s "Extra-header:" \
3565 -c "HTTP/1.0 200 OK"
3566
Janos Follath74537a62016-09-02 13:45:28 +01003567client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003568run_test "DTLS proxy: 3d, FS, ticket" \
3569 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003570 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3571 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003572 0 \
3573 -s "Extra-header:" \
3574 -c "HTTP/1.0 200 OK"
3575
Janos Follath74537a62016-09-02 13:45:28 +01003576client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003577run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3578 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003579 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3580 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003581 0 \
3582 -s "Extra-header:" \
3583 -c "HTTP/1.0 200 OK"
3584
Janos Follath74537a62016-09-02 13:45:28 +01003585client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003586run_test "DTLS proxy: 3d, max handshake, nbio" \
3587 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003588 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3589 auth_mode=required" \
3590 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003591 0 \
3592 -s "Extra-header:" \
3593 -c "HTTP/1.0 200 OK"
3594
Janos Follath74537a62016-09-02 13:45:28 +01003595client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003596run_test "DTLS proxy: 3d, min handshake, resumption" \
3597 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3598 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3599 psk=abc123 debug_level=3" \
3600 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3601 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3602 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3603 0 \
3604 -s "a session has been resumed" \
3605 -c "a session has been resumed" \
3606 -s "Extra-header:" \
3607 -c "HTTP/1.0 200 OK"
3608
Janos Follath74537a62016-09-02 13:45:28 +01003609client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003610run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3611 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3612 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3613 psk=abc123 debug_level=3 nbio=2" \
3614 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3615 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3616 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3617 0 \
3618 -s "a session has been resumed" \
3619 -c "a session has been resumed" \
3620 -s "Extra-header:" \
3621 -c "HTTP/1.0 200 OK"
3622
Janos Follath74537a62016-09-02 13:45:28 +01003623client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003624run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003625 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003626 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3627 psk=abc123 renegotiation=1 debug_level=2" \
3628 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3629 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003630 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3631 0 \
3632 -c "=> renegotiate" \
3633 -s "=> renegotiate" \
3634 -s "Extra-header:" \
3635 -c "HTTP/1.0 200 OK"
3636
Janos Follath74537a62016-09-02 13:45:28 +01003637client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003638run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3639 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003640 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3641 psk=abc123 renegotiation=1 debug_level=2" \
3642 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3643 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003644 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3645 0 \
3646 -c "=> renegotiate" \
3647 -s "=> renegotiate" \
3648 -s "Extra-header:" \
3649 -c "HTTP/1.0 200 OK"
3650
Janos Follath74537a62016-09-02 13:45:28 +01003651client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003652run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003653 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003654 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003655 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003656 debug_level=2" \
3657 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003658 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003659 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3660 0 \
3661 -c "=> renegotiate" \
3662 -s "=> renegotiate" \
3663 -s "Extra-header:" \
3664 -c "HTTP/1.0 200 OK"
3665
Janos Follath74537a62016-09-02 13:45:28 +01003666client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003667run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003668 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003669 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003670 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003671 debug_level=2 nbio=2" \
3672 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003673 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003674 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3675 0 \
3676 -c "=> renegotiate" \
3677 -s "=> renegotiate" \
3678 -s "Extra-header:" \
3679 -c "HTTP/1.0 200 OK"
3680
Janos Follath74537a62016-09-02 13:45:28 +01003681client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003682not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003683run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003684 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3685 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003686 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003687 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003688 -c "HTTP/1.0 200 OK"
3689
Janos Follath74537a62016-09-02 13:45:28 +01003690client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003691not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003692run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3693 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3694 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003695 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003696 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003697 -c "HTTP/1.0 200 OK"
3698
Janos Follath74537a62016-09-02 13:45:28 +01003699client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003700not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003701run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3702 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3703 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003704 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003705 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003706 -c "HTTP/1.0 200 OK"
3707
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003708requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003709client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003710not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003711run_test "DTLS proxy: 3d, gnutls server" \
3712 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3713 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003714 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003715 0 \
3716 -s "Extra-header:" \
3717 -c "Extra-header:"
3718
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003719requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003720client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003721not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003722run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3723 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3724 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003725 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003726 0 \
3727 -s "Extra-header:" \
3728 -c "Extra-header:"
3729
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003730requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003731client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003732not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003733run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3734 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3735 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003736 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003737 0 \
3738 -s "Extra-header:" \
3739 -c "Extra-header:"
3740
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003741# Final report
3742
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003743echo "------------------------------------------------------------------------"
3744
3745if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003746 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003747else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003748 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003749fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003750PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003751echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003752
3753exit $FAILS