blob: 429d9cd19afa80a40d788480c34819666270dde1 [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
336# -S pattern pattern that must be absent in server output
337# -C pattern pattern that must be absent in client output
338run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100339 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200340 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100341
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100342 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
343 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200344 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100345 return
346 fi
347
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100348 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100349
Paul Bakkerb7584a52016-05-10 10:50:43 +0100350 # Do we only run numbered tests?
351 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
352 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
353 else
354 SKIP_NEXT="YES"
355 fi
356
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200357 # should we skip?
358 if [ "X$SKIP_NEXT" = "XYES" ]; then
359 SKIP_NEXT="NO"
360 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200361 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200362 return
363 fi
364
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200365 # does this test use a proxy?
366 if [ "X$1" = "X-p" ]; then
367 PXY_CMD="$2"
368 shift 2
369 else
370 PXY_CMD=""
371 fi
372
373 # get commands and client output
374 SRV_CMD="$1"
375 CLI_CMD="$2"
376 CLI_EXPECT="$3"
377 shift 3
378
379 # fix client port
380 if [ -n "$PXY_CMD" ]; then
381 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
382 else
383 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
384 fi
385
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200386 # update DTLS variable
387 detect_dtls "$SRV_CMD"
388
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100389 # prepend valgrind to our commands if active
390 if [ "$MEMCHECK" -gt 0 ]; then
391 if is_polar "$SRV_CMD"; then
392 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
393 fi
394 if is_polar "$CLI_CMD"; then
395 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
396 fi
397 fi
398
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200399 TIMES_LEFT=2
400 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200401 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200402
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200403 # run the commands
404 if [ -n "$PXY_CMD" ]; then
405 echo "$PXY_CMD" > $PXY_OUT
406 $PXY_CMD >> $PXY_OUT 2>&1 &
407 PXY_PID=$!
408 # assume proxy starts faster than server
409 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200410
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200411 check_osrv_dtls
412 echo "$SRV_CMD" > $SRV_OUT
413 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
414 SRV_PID=$!
415 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200416
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200417 echo "$CLI_CMD" > $CLI_OUT
418 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
419 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100420
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200421 # terminate the server (and the proxy)
422 kill $SRV_PID
423 wait $SRV_PID
424 if [ -n "$PXY_CMD" ]; then
425 kill $PXY_PID >/dev/null 2>&1
426 wait $PXY_PID
427 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100428
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200429 # retry only on timeouts
430 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
431 printf "RETRY "
432 else
433 TIMES_LEFT=0
434 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200435 done
436
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100437 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200438 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100439 # expected client exit to incorrectly succeed in case of catastrophic
440 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100441 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200442 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100443 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100444 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100445 return
446 fi
447 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100448 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200449 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100450 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100451 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100452 return
453 fi
454 fi
455
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100456 # check server exit code
457 if [ $? != 0 ]; then
458 fail "server fail"
459 return
460 fi
461
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100462 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100463 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
464 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100465 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200466 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100467 return
468 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100469
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100470 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200471 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100472 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100473 while [ $# -gt 0 ]
474 do
475 case $1 in
476 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100477 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100478 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100479 return
480 fi
481 ;;
482
483 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100484 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100485 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100486 return
487 fi
488 ;;
489
490 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100491 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100492 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100493 return
494 fi
495 ;;
496
497 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100498 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100499 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100500 return
501 fi
502 ;;
503
504 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200505 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100506 exit 1
507 esac
508 shift 2
509 done
510
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100511 # check valgrind's results
512 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200513 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100514 fail "Server has memory errors"
515 return
516 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200517 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100518 fail "Client has memory errors"
519 return
520 fi
521 fi
522
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100523 # if we're here, everything is ok
524 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100525 if [ "$PRESERVE_LOGS" -gt 0 ]; then
526 mv $SRV_OUT o-srv-${TESTS}.log
527 mv $CLI_OUT o-cli-${TESTS}.log
528 fi
529
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200530 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100531}
532
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100533cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200534 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200535 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
536 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
537 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
538 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100539 exit 1
540}
541
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100542#
543# MAIN
544#
545
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000546if cd $( dirname $0 ); then :; else
547 echo "cd $( dirname $0 ) failed" >&2
548 exit 1
549fi
550
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100551get_options "$@"
552
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100553# sanity checks, avoid an avalanche of errors
554if [ ! -x "$P_SRV" ]; then
555 echo "Command '$P_SRV' is not an executable file"
556 exit 1
557fi
558if [ ! -x "$P_CLI" ]; then
559 echo "Command '$P_CLI' is not an executable file"
560 exit 1
561fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200562if [ ! -x "$P_PXY" ]; then
563 echo "Command '$P_PXY' is not an executable file"
564 exit 1
565fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100566if [ "$MEMCHECK" -gt 0 ]; then
567 if which valgrind >/dev/null 2>&1; then :; else
568 echo "Memcheck not possible. Valgrind not found"
569 exit 1
570 fi
571fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100572if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
573 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100574 exit 1
575fi
576
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200577# used by watchdog
578MAIN_PID="$$"
579
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200580# be more patient with valgrind
581if [ "$MEMCHECK" -gt 0 ]; then
582 START_DELAY=3
583 DOG_DELAY=30
584else
585 START_DELAY=1
586 DOG_DELAY=10
587fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200588CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100589SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200590
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200591# Pick a "unique" server port in the range 10000-19999, and a proxy port
592PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000593PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200594SRV_PORT="1$PORT_BASE"
595PXY_PORT="2$PORT_BASE"
596unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200597
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200598# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000599# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200600P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
601P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100602P_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 +0200603O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200604O_CLI="$O_CLI -connect localhost:+SRV_PORT"
605G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000606G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200607
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200608# Also pick a unique name for intermediate files
609SRV_OUT="srv_out.$$"
610CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200611PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200612SESSION="session.$$"
613
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200614SKIP_NEXT="NO"
615
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100616trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100617
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200618# Basic test
619
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200620# Checks that:
621# - things work with all ciphersuites active (used with config-full in all.sh)
622# - the expected (highest security) parameters are selected
623# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200624run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200625 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200626 "$P_CLI" \
627 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200628 -s "Protocol is TLSv1.2" \
629 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
630 -s "client hello v3, signature_algorithm ext: 6" \
631 -s "ECDHE curve: secp521r1" \
632 -S "error" \
633 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200634
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000635run_test "Default, DTLS" \
636 "$P_SRV dtls=1" \
637 "$P_CLI dtls=1" \
638 0 \
639 -s "Protocol is DTLSv1.2" \
640 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
641
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100642# Tests for rc4 option
643
Simon Butchera410af52016-05-19 22:12:18 +0100644requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100645run_test "RC4: server disabled, client enabled" \
646 "$P_SRV" \
647 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
648 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100649 -s "SSL - The server has no ciphersuites in common"
650
Simon Butchera410af52016-05-19 22:12:18 +0100651requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100652run_test "RC4: server half, client enabled" \
653 "$P_SRV arc4=1" \
654 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
655 1 \
656 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100657
658run_test "RC4: server enabled, client disabled" \
659 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
660 "$P_CLI" \
661 1 \
662 -s "SSL - The server has no ciphersuites in common"
663
664run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100665 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100666 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
667 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100668 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100669 -S "SSL - The server has no ciphersuites in common"
670
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100671# Tests for Truncated HMAC extension
672
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100673run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200674 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100675 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100676 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100677 -s "dumping 'computed mac' (20 bytes)" \
678 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100679
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100680run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200681 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100682 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
683 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100684 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100685 -s "dumping 'computed mac' (20 bytes)" \
686 -S "dumping 'computed mac' (10 bytes)"
687
688run_test "Truncated HMAC: client enabled, server default" \
689 "$P_SRV debug_level=4" \
690 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
691 trunc_hmac=1" \
692 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100693 -s "dumping 'computed mac' (20 bytes)" \
694 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100695
696run_test "Truncated HMAC: client enabled, server disabled" \
697 "$P_SRV debug_level=4 trunc_hmac=0" \
698 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
699 trunc_hmac=1" \
700 0 \
701 -s "dumping 'computed mac' (20 bytes)" \
702 -S "dumping 'computed mac' (10 bytes)"
703
704run_test "Truncated HMAC: client enabled, server enabled" \
705 "$P_SRV debug_level=4 trunc_hmac=1" \
706 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
707 trunc_hmac=1" \
708 0 \
709 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100710 -s "dumping 'computed mac' (10 bytes)"
711
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100712# Tests for Encrypt-then-MAC extension
713
714run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100715 "$P_SRV debug_level=3 \
716 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100717 "$P_CLI debug_level=3" \
718 0 \
719 -c "client hello, adding encrypt_then_mac extension" \
720 -s "found encrypt then mac extension" \
721 -s "server hello, adding encrypt then mac extension" \
722 -c "found encrypt_then_mac extension" \
723 -c "using encrypt then mac" \
724 -s "using encrypt then mac"
725
726run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100727 "$P_SRV debug_level=3 etm=0 \
728 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100729 "$P_CLI debug_level=3 etm=1" \
730 0 \
731 -c "client hello, adding encrypt_then_mac extension" \
732 -s "found encrypt then mac extension" \
733 -S "server hello, adding encrypt then mac extension" \
734 -C "found encrypt_then_mac extension" \
735 -C "using encrypt then mac" \
736 -S "using encrypt then mac"
737
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100738run_test "Encrypt then MAC: client enabled, aead cipher" \
739 "$P_SRV debug_level=3 etm=1 \
740 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
741 "$P_CLI debug_level=3 etm=1" \
742 0 \
743 -c "client hello, adding encrypt_then_mac extension" \
744 -s "found encrypt then mac extension" \
745 -S "server hello, adding encrypt then mac extension" \
746 -C "found encrypt_then_mac extension" \
747 -C "using encrypt then mac" \
748 -S "using encrypt then mac"
749
750run_test "Encrypt then MAC: client enabled, stream cipher" \
751 "$P_SRV debug_level=3 etm=1 \
752 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100753 "$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 +0100754 0 \
755 -c "client hello, adding encrypt_then_mac extension" \
756 -s "found encrypt then mac extension" \
757 -S "server hello, adding encrypt then mac extension" \
758 -C "found encrypt_then_mac extension" \
759 -C "using encrypt then mac" \
760 -S "using encrypt then mac"
761
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100762run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100763 "$P_SRV debug_level=3 etm=1 \
764 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100765 "$P_CLI debug_level=3 etm=0" \
766 0 \
767 -C "client hello, adding encrypt_then_mac extension" \
768 -S "found encrypt then mac extension" \
769 -S "server hello, adding encrypt then mac extension" \
770 -C "found encrypt_then_mac extension" \
771 -C "using encrypt then mac" \
772 -S "using encrypt then mac"
773
Janos Follathe2681a42016-03-07 15:57:05 +0000774requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100775run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100776 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100777 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100778 "$P_CLI debug_level=3 force_version=ssl3" \
779 0 \
780 -C "client hello, adding encrypt_then_mac extension" \
781 -S "found encrypt then mac extension" \
782 -S "server hello, adding encrypt then mac extension" \
783 -C "found encrypt_then_mac extension" \
784 -C "using encrypt then mac" \
785 -S "using encrypt then mac"
786
Janos Follathe2681a42016-03-07 15:57:05 +0000787requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100788run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100789 "$P_SRV debug_level=3 force_version=ssl3 \
790 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100791 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100792 0 \
793 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100794 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100795 -S "server hello, adding encrypt then mac extension" \
796 -C "found encrypt_then_mac extension" \
797 -C "using encrypt then mac" \
798 -S "using encrypt then mac"
799
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200800# Tests for Extended Master Secret extension
801
802run_test "Extended Master Secret: default" \
803 "$P_SRV debug_level=3" \
804 "$P_CLI debug_level=3" \
805 0 \
806 -c "client hello, adding extended_master_secret extension" \
807 -s "found extended master secret extension" \
808 -s "server hello, adding extended master secret extension" \
809 -c "found extended_master_secret extension" \
810 -c "using extended master secret" \
811 -s "using extended master secret"
812
813run_test "Extended Master Secret: client enabled, server disabled" \
814 "$P_SRV debug_level=3 extended_ms=0" \
815 "$P_CLI debug_level=3 extended_ms=1" \
816 0 \
817 -c "client hello, adding extended_master_secret extension" \
818 -s "found extended master secret extension" \
819 -S "server hello, adding extended master secret extension" \
820 -C "found extended_master_secret extension" \
821 -C "using extended master secret" \
822 -S "using extended master secret"
823
824run_test "Extended Master Secret: client disabled, server enabled" \
825 "$P_SRV debug_level=3 extended_ms=1" \
826 "$P_CLI debug_level=3 extended_ms=0" \
827 0 \
828 -C "client hello, adding extended_master_secret extension" \
829 -S "found extended master secret extension" \
830 -S "server hello, adding extended master secret extension" \
831 -C "found extended_master_secret extension" \
832 -C "using extended master secret" \
833 -S "using extended master secret"
834
Janos Follathe2681a42016-03-07 15:57:05 +0000835requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200836run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100837 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200838 "$P_CLI debug_level=3 force_version=ssl3" \
839 0 \
840 -C "client hello, adding extended_master_secret extension" \
841 -S "found extended master secret extension" \
842 -S "server hello, adding extended master secret extension" \
843 -C "found extended_master_secret extension" \
844 -C "using extended master secret" \
845 -S "using extended master secret"
846
Janos Follathe2681a42016-03-07 15:57:05 +0000847requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200848run_test "Extended Master Secret: client enabled, server SSLv3" \
849 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100850 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200851 0 \
852 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100853 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200854 -S "server hello, adding extended master secret extension" \
855 -C "found extended_master_secret extension" \
856 -C "using extended master secret" \
857 -S "using extended master secret"
858
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200859# Tests for FALLBACK_SCSV
860
861run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200862 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200863 "$P_CLI debug_level=3 force_version=tls1_1" \
864 0 \
865 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200866 -S "received FALLBACK_SCSV" \
867 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200868 -C "is a fatal alert message (msg 86)"
869
870run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200871 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200872 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
873 0 \
874 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200875 -S "received FALLBACK_SCSV" \
876 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200877 -C "is a fatal alert message (msg 86)"
878
879run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200880 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200881 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200882 1 \
883 -c "adding FALLBACK_SCSV" \
884 -s "received FALLBACK_SCSV" \
885 -s "inapropriate fallback" \
886 -c "is a fatal alert message (msg 86)"
887
888run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200889 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200890 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200891 0 \
892 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200893 -s "received FALLBACK_SCSV" \
894 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200895 -C "is a fatal alert message (msg 86)"
896
897requires_openssl_with_fallback_scsv
898run_test "Fallback SCSV: default, openssl server" \
899 "$O_SRV" \
900 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
901 0 \
902 -C "adding FALLBACK_SCSV" \
903 -C "is a fatal alert message (msg 86)"
904
905requires_openssl_with_fallback_scsv
906run_test "Fallback SCSV: enabled, openssl server" \
907 "$O_SRV" \
908 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
909 1 \
910 -c "adding FALLBACK_SCSV" \
911 -c "is a fatal alert message (msg 86)"
912
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200913requires_openssl_with_fallback_scsv
914run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200915 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200916 "$O_CLI -tls1_1" \
917 0 \
918 -S "received FALLBACK_SCSV" \
919 -S "inapropriate fallback"
920
921requires_openssl_with_fallback_scsv
922run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200923 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200924 "$O_CLI -tls1_1 -fallback_scsv" \
925 1 \
926 -s "received FALLBACK_SCSV" \
927 -s "inapropriate fallback"
928
929requires_openssl_with_fallback_scsv
930run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200931 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200932 "$O_CLI -fallback_scsv" \
933 0 \
934 -s "received FALLBACK_SCSV" \
935 -S "inapropriate fallback"
936
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100937# Tests for CBC 1/n-1 record splitting
938
939run_test "CBC Record splitting: TLS 1.2, no splitting" \
940 "$P_SRV" \
941 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
942 request_size=123 force_version=tls1_2" \
943 0 \
944 -s "Read from client: 123 bytes read" \
945 -S "Read from client: 1 bytes read" \
946 -S "122 bytes read"
947
948run_test "CBC Record splitting: TLS 1.1, no splitting" \
949 "$P_SRV" \
950 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
951 request_size=123 force_version=tls1_1" \
952 0 \
953 -s "Read from client: 123 bytes read" \
954 -S "Read from client: 1 bytes read" \
955 -S "122 bytes read"
956
957run_test "CBC Record splitting: TLS 1.0, splitting" \
958 "$P_SRV" \
959 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
960 request_size=123 force_version=tls1" \
961 0 \
962 -S "Read from client: 123 bytes read" \
963 -s "Read from client: 1 bytes read" \
964 -s "122 bytes read"
965
Janos Follathe2681a42016-03-07 15:57:05 +0000966requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100967run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100968 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100969 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
970 request_size=123 force_version=ssl3" \
971 0 \
972 -S "Read from client: 123 bytes read" \
973 -s "Read from client: 1 bytes read" \
974 -s "122 bytes read"
975
976run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100977 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100978 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
979 request_size=123 force_version=tls1" \
980 0 \
981 -s "Read from client: 123 bytes read" \
982 -S "Read from client: 1 bytes read" \
983 -S "122 bytes read"
984
985run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
986 "$P_SRV" \
987 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
988 request_size=123 force_version=tls1 recsplit=0" \
989 0 \
990 -s "Read from client: 123 bytes read" \
991 -S "Read from client: 1 bytes read" \
992 -S "122 bytes read"
993
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100994run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
995 "$P_SRV nbio=2" \
996 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
997 request_size=123 force_version=tls1" \
998 0 \
999 -S "Read from client: 123 bytes read" \
1000 -s "Read from client: 1 bytes read" \
1001 -s "122 bytes read"
1002
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001003# Tests for Session Tickets
1004
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001005run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001006 "$P_SRV debug_level=3 tickets=1" \
1007 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001008 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001009 -c "client hello, adding session ticket extension" \
1010 -s "found session ticket extension" \
1011 -s "server hello, adding session ticket extension" \
1012 -c "found session_ticket extension" \
1013 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001014 -S "session successfully restored from cache" \
1015 -s "session successfully restored from ticket" \
1016 -s "a session has been resumed" \
1017 -c "a session has been resumed"
1018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001019run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001020 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1021 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001022 0 \
1023 -c "client hello, adding session ticket extension" \
1024 -s "found session ticket extension" \
1025 -s "server hello, adding session ticket extension" \
1026 -c "found session_ticket extension" \
1027 -c "parse new session ticket" \
1028 -S "session successfully restored from cache" \
1029 -s "session successfully restored from ticket" \
1030 -s "a session has been resumed" \
1031 -c "a session has been resumed"
1032
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001033run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001034 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1035 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001036 0 \
1037 -c "client hello, adding session ticket extension" \
1038 -s "found session ticket extension" \
1039 -s "server hello, adding session ticket extension" \
1040 -c "found session_ticket extension" \
1041 -c "parse new session ticket" \
1042 -S "session successfully restored from cache" \
1043 -S "session successfully restored from ticket" \
1044 -S "a session has been resumed" \
1045 -C "a session has been resumed"
1046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001047run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001048 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001049 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001050 0 \
1051 -c "client hello, adding session ticket extension" \
1052 -c "found session_ticket extension" \
1053 -c "parse new session ticket" \
1054 -c "a session has been resumed"
1055
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001056run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001057 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001058 "( $O_CLI -sess_out $SESSION; \
1059 $O_CLI -sess_in $SESSION; \
1060 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001061 0 \
1062 -s "found session ticket extension" \
1063 -s "server hello, adding session ticket extension" \
1064 -S "session successfully restored from cache" \
1065 -s "session successfully restored from ticket" \
1066 -s "a session has been resumed"
1067
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001068# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001070run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001071 "$P_SRV debug_level=3 tickets=0" \
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 cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001085 "$P_SRV debug_level=3 tickets=1" \
1086 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001087 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001088 -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" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001093 -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"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001098run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001099 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1100 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001101 0 \
1102 -S "session successfully restored from cache" \
1103 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001104 -S "a session has been resumed" \
1105 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001107run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001108 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1109 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001110 0 \
1111 -s "session successfully restored from cache" \
1112 -S "session successfully restored from ticket" \
1113 -s "a session has been resumed" \
1114 -c "a session has been resumed"
1115
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001116run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001117 "$P_SRV debug_level=3 tickets=0" \
1118 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001119 0 \
1120 -s "session successfully restored from cache" \
1121 -S "session successfully restored from ticket" \
1122 -s "a session has been resumed" \
1123 -c "a session has been resumed"
1124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001125run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001126 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1127 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001128 0 \
1129 -S "session successfully restored from cache" \
1130 -S "session successfully restored from ticket" \
1131 -S "a session has been resumed" \
1132 -C "a session has been resumed"
1133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001134run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001135 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1136 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001137 0 \
1138 -s "session successfully restored from cache" \
1139 -S "session successfully restored from ticket" \
1140 -s "a session has been resumed" \
1141 -c "a session has been resumed"
1142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001143run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001144 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001145 "( $O_CLI -sess_out $SESSION; \
1146 $O_CLI -sess_in $SESSION; \
1147 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001148 0 \
1149 -s "found session ticket extension" \
1150 -S "server hello, adding session ticket extension" \
1151 -s "session successfully restored from cache" \
1152 -S "session successfully restored from ticket" \
1153 -s "a session has been resumed"
1154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001155run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001156 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001157 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001158 0 \
1159 -C "found session_ticket extension" \
1160 -C "parse new session ticket" \
1161 -c "a session has been resumed"
1162
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001163# Tests for Max Fragment Length extension
1164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001165run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001166 "$P_SRV debug_level=3" \
1167 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001168 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001169 -c "Maximum fragment length is 16384" \
1170 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001171 -C "client hello, adding max_fragment_length extension" \
1172 -S "found max fragment length extension" \
1173 -S "server hello, max_fragment_length extension" \
1174 -C "found max_fragment_length extension"
1175
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001176run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001177 "$P_SRV debug_level=3" \
1178 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001179 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001180 -c "Maximum fragment length is 4096" \
1181 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001182 -c "client hello, adding max_fragment_length extension" \
1183 -s "found max fragment length extension" \
1184 -s "server hello, max_fragment_length extension" \
1185 -c "found max_fragment_length extension"
1186
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001187run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001188 "$P_SRV debug_level=3 max_frag_len=4096" \
1189 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001190 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001191 -c "Maximum fragment length is 16384" \
1192 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001193 -C "client hello, adding max_fragment_length extension" \
1194 -S "found max fragment length extension" \
1195 -S "server hello, max_fragment_length extension" \
1196 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001198requires_gnutls
1199run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001200 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001201 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001202 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001203 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001204 -c "client hello, adding max_fragment_length extension" \
1205 -c "found max_fragment_length extension"
1206
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001207run_test "Max fragment length: client, message just fits" \
1208 "$P_SRV debug_level=3" \
1209 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1210 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001211 -c "Maximum fragment length is 2048" \
1212 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001213 -c "client hello, adding max_fragment_length extension" \
1214 -s "found max fragment length extension" \
1215 -s "server hello, max_fragment_length extension" \
1216 -c "found max_fragment_length extension" \
1217 -c "2048 bytes written in 1 fragments" \
1218 -s "2048 bytes read"
1219
1220run_test "Max fragment length: client, larger message" \
1221 "$P_SRV debug_level=3" \
1222 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1223 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001224 -c "Maximum fragment length is 2048" \
1225 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001226 -c "client hello, adding max_fragment_length extension" \
1227 -s "found max fragment length extension" \
1228 -s "server hello, max_fragment_length extension" \
1229 -c "found max_fragment_length extension" \
1230 -c "2345 bytes written in 2 fragments" \
1231 -s "2048 bytes read" \
1232 -s "297 bytes read"
1233
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001234run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001235 "$P_SRV debug_level=3 dtls=1" \
1236 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1237 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001238 -c "Maximum fragment length is 2048" \
1239 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001240 -c "client hello, adding max_fragment_length extension" \
1241 -s "found max fragment length extension" \
1242 -s "server hello, max_fragment_length extension" \
1243 -c "found max_fragment_length extension" \
1244 -c "fragment larger than.*maximum"
1245
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001246# Tests for renegotiation
1247
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001248run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001249 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001250 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001251 0 \
1252 -C "client hello, adding renegotiation extension" \
1253 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1254 -S "found renegotiation extension" \
1255 -s "server hello, secure renegotiation extension" \
1256 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001257 -C "=> renegotiate" \
1258 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001259 -S "write hello request"
1260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001261run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001262 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001263 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001264 0 \
1265 -c "client hello, adding renegotiation extension" \
1266 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1267 -s "found renegotiation extension" \
1268 -s "server hello, secure renegotiation extension" \
1269 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001270 -c "=> renegotiate" \
1271 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001272 -S "write hello request"
1273
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001274run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001275 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001276 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001277 0 \
1278 -c "client hello, adding renegotiation extension" \
1279 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1280 -s "found renegotiation extension" \
1281 -s "server hello, secure renegotiation extension" \
1282 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001283 -c "=> renegotiate" \
1284 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001285 -s "write hello request"
1286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001287run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001288 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001289 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001290 0 \
1291 -c "client hello, adding renegotiation extension" \
1292 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1293 -s "found renegotiation extension" \
1294 -s "server hello, secure renegotiation extension" \
1295 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001296 -c "=> renegotiate" \
1297 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001298 -s "write hello request"
1299
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001300run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001301 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001302 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001303 1 \
1304 -c "client hello, adding renegotiation extension" \
1305 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1306 -S "found renegotiation extension" \
1307 -s "server hello, secure renegotiation extension" \
1308 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001309 -c "=> renegotiate" \
1310 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001311 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001312 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001313 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001314
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001315run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001316 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001317 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001318 0 \
1319 -C "client hello, adding renegotiation extension" \
1320 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1321 -S "found renegotiation extension" \
1322 -s "server hello, secure renegotiation extension" \
1323 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001324 -C "=> renegotiate" \
1325 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001326 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001327 -S "SSL - An unexpected message was received from our peer" \
1328 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001330run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001331 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001332 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001333 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001334 0 \
1335 -C "client hello, adding renegotiation extension" \
1336 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1337 -S "found renegotiation extension" \
1338 -s "server hello, secure renegotiation extension" \
1339 -c "found renegotiation extension" \
1340 -C "=> renegotiate" \
1341 -S "=> renegotiate" \
1342 -s "write hello request" \
1343 -S "SSL - An unexpected message was received from our peer" \
1344 -S "failed"
1345
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001346# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001347run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001348 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001349 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001350 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001351 0 \
1352 -C "client hello, adding renegotiation extension" \
1353 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1354 -S "found renegotiation extension" \
1355 -s "server hello, secure renegotiation extension" \
1356 -c "found renegotiation extension" \
1357 -C "=> renegotiate" \
1358 -S "=> renegotiate" \
1359 -s "write hello request" \
1360 -S "SSL - An unexpected message was received from our peer" \
1361 -S "failed"
1362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001363run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001364 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001365 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001366 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001367 0 \
1368 -C "client hello, adding renegotiation extension" \
1369 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1370 -S "found renegotiation extension" \
1371 -s "server hello, secure renegotiation extension" \
1372 -c "found renegotiation extension" \
1373 -C "=> renegotiate" \
1374 -S "=> renegotiate" \
1375 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001376 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001377
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001378run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001379 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001380 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001381 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001382 0 \
1383 -c "client hello, adding renegotiation extension" \
1384 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1385 -s "found renegotiation extension" \
1386 -s "server hello, secure renegotiation extension" \
1387 -c "found renegotiation extension" \
1388 -c "=> renegotiate" \
1389 -s "=> renegotiate" \
1390 -s "write hello request" \
1391 -S "SSL - An unexpected message was received from our peer" \
1392 -S "failed"
1393
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001394run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001395 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001396 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1397 0 \
1398 -C "client hello, adding renegotiation extension" \
1399 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1400 -S "found renegotiation extension" \
1401 -s "server hello, secure renegotiation extension" \
1402 -c "found renegotiation extension" \
1403 -S "record counter limit reached: renegotiate" \
1404 -C "=> renegotiate" \
1405 -S "=> renegotiate" \
1406 -S "write hello request" \
1407 -S "SSL - An unexpected message was received from our peer" \
1408 -S "failed"
1409
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001410# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001411run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001412 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001413 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001414 0 \
1415 -c "client hello, adding renegotiation extension" \
1416 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1417 -s "found renegotiation extension" \
1418 -s "server hello, secure renegotiation extension" \
1419 -c "found renegotiation extension" \
1420 -s "record counter limit reached: renegotiate" \
1421 -c "=> renegotiate" \
1422 -s "=> renegotiate" \
1423 -s "write hello request" \
1424 -S "SSL - An unexpected message was received from our peer" \
1425 -S "failed"
1426
1427run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001428 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001429 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001430 0 \
1431 -c "client hello, adding renegotiation extension" \
1432 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1433 -s "found renegotiation extension" \
1434 -s "server hello, secure renegotiation extension" \
1435 -c "found renegotiation extension" \
1436 -s "record counter limit reached: renegotiate" \
1437 -c "=> renegotiate" \
1438 -s "=> renegotiate" \
1439 -s "write hello request" \
1440 -S "SSL - An unexpected message was received from our peer" \
1441 -S "failed"
1442
1443run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001444 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001445 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1446 0 \
1447 -C "client hello, adding renegotiation extension" \
1448 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1449 -S "found renegotiation extension" \
1450 -s "server hello, secure renegotiation extension" \
1451 -c "found renegotiation extension" \
1452 -S "record counter limit reached: renegotiate" \
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é-Gonnard8e03c712014-08-30 21:42:40 +02001459run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001460 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001461 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001462 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 -c "=> renegotiate" \
1469 -s "=> renegotiate" \
1470 -S "write hello request"
1471
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001472run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001473 "$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 +02001474 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001475 0 \
1476 -c "client hello, adding renegotiation extension" \
1477 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1478 -s "found renegotiation extension" \
1479 -s "server hello, secure renegotiation extension" \
1480 -c "found renegotiation extension" \
1481 -c "=> renegotiate" \
1482 -s "=> renegotiate" \
1483 -s "write hello request"
1484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001485run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001486 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001487 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001488 0 \
1489 -c "client hello, adding renegotiation extension" \
1490 -c "found renegotiation extension" \
1491 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001492 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001493 -C "error" \
1494 -c "HTTP/1.0 200 [Oo][Kk]"
1495
Paul Bakker539d9722015-02-08 16:18:35 +01001496requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001497run_test "Renegotiation: gnutls server strict, client-initiated" \
1498 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001499 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001500 0 \
1501 -c "client hello, adding renegotiation extension" \
1502 -c "found renegotiation extension" \
1503 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001504 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001505 -C "error" \
1506 -c "HTTP/1.0 200 [Oo][Kk]"
1507
Paul Bakker539d9722015-02-08 16:18:35 +01001508requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001509run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1510 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1511 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1512 1 \
1513 -c "client hello, adding renegotiation extension" \
1514 -C "found renegotiation extension" \
1515 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001516 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001517 -c "error" \
1518 -C "HTTP/1.0 200 [Oo][Kk]"
1519
Paul Bakker539d9722015-02-08 16:18:35 +01001520requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001521run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1522 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1523 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1524 allow_legacy=0" \
1525 1 \
1526 -c "client hello, adding renegotiation extension" \
1527 -C "found renegotiation extension" \
1528 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001529 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001530 -c "error" \
1531 -C "HTTP/1.0 200 [Oo][Kk]"
1532
Paul Bakker539d9722015-02-08 16:18:35 +01001533requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001534run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1535 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1536 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1537 allow_legacy=1" \
1538 0 \
1539 -c "client hello, adding renegotiation extension" \
1540 -C "found renegotiation extension" \
1541 -c "=> renegotiate" \
1542 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001543 -C "error" \
1544 -c "HTTP/1.0 200 [Oo][Kk]"
1545
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001546run_test "Renegotiation: DTLS, client-initiated" \
1547 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1548 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1549 0 \
1550 -c "client hello, adding renegotiation extension" \
1551 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1552 -s "found renegotiation extension" \
1553 -s "server hello, secure renegotiation extension" \
1554 -c "found renegotiation extension" \
1555 -c "=> renegotiate" \
1556 -s "=> renegotiate" \
1557 -S "write hello request"
1558
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001559run_test "Renegotiation: DTLS, server-initiated" \
1560 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001561 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1562 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001563 0 \
1564 -c "client hello, adding renegotiation extension" \
1565 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1566 -s "found renegotiation extension" \
1567 -s "server hello, secure renegotiation extension" \
1568 -c "found renegotiation extension" \
1569 -c "=> renegotiate" \
1570 -s "=> renegotiate" \
1571 -s "write hello request"
1572
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001573requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001574run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1575 "$G_SRV -u --mtu 4096" \
1576 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1577 0 \
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é-Gonnardf1499f62014-08-31 17:13:13 +02001582 -C "error" \
1583 -s "Extra-header:"
1584
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001585# Test for the "secure renegotation" extension only (no actual renegotiation)
1586
Paul Bakker539d9722015-02-08 16:18:35 +01001587requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001588run_test "Renego ext: gnutls server strict, client default" \
1589 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1590 "$P_CLI debug_level=3" \
1591 0 \
1592 -c "found renegotiation extension" \
1593 -C "error" \
1594 -c "HTTP/1.0 200 [Oo][Kk]"
1595
Paul Bakker539d9722015-02-08 16:18:35 +01001596requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001597run_test "Renego ext: gnutls server unsafe, client default" \
1598 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1599 "$P_CLI debug_level=3" \
1600 0 \
1601 -C "found renegotiation extension" \
1602 -C "error" \
1603 -c "HTTP/1.0 200 [Oo][Kk]"
1604
Paul Bakker539d9722015-02-08 16:18:35 +01001605requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001606run_test "Renego ext: gnutls server unsafe, client break legacy" \
1607 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1608 "$P_CLI debug_level=3 allow_legacy=-1" \
1609 1 \
1610 -C "found renegotiation extension" \
1611 -c "error" \
1612 -C "HTTP/1.0 200 [Oo][Kk]"
1613
Paul Bakker539d9722015-02-08 16:18:35 +01001614requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001615run_test "Renego ext: gnutls client strict, server default" \
1616 "$P_SRV debug_level=3" \
1617 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1618 0 \
1619 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1620 -s "server hello, secure renegotiation extension"
1621
Paul Bakker539d9722015-02-08 16:18:35 +01001622requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001623run_test "Renego ext: gnutls client unsafe, server default" \
1624 "$P_SRV debug_level=3" \
1625 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1626 0 \
1627 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1628 -S "server hello, secure renegotiation extension"
1629
Paul Bakker539d9722015-02-08 16:18:35 +01001630requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001631run_test "Renego ext: gnutls client unsafe, server break legacy" \
1632 "$P_SRV debug_level=3 allow_legacy=-1" \
1633 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1634 1 \
1635 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1636 -S "server hello, secure renegotiation extension"
1637
Janos Follath0b242342016-02-17 10:11:21 +00001638# Tests for silently dropping trailing extra bytes in .der certificates
1639
1640requires_gnutls
1641run_test "DER format: no trailing bytes" \
1642 "$P_SRV crt_file=data_files/server5-der0.crt \
1643 key_file=data_files/server5.key" \
1644 "$G_CLI " \
1645 0 \
1646 -c "Handshake was completed" \
1647
1648requires_gnutls
1649run_test "DER format: with a trailing zero byte" \
1650 "$P_SRV crt_file=data_files/server5-der1a.crt \
1651 key_file=data_files/server5.key" \
1652 "$G_CLI " \
1653 0 \
1654 -c "Handshake was completed" \
1655
1656requires_gnutls
1657run_test "DER format: with a trailing random byte" \
1658 "$P_SRV crt_file=data_files/server5-der1b.crt \
1659 key_file=data_files/server5.key" \
1660 "$G_CLI " \
1661 0 \
1662 -c "Handshake was completed" \
1663
1664requires_gnutls
1665run_test "DER format: with 2 trailing random bytes" \
1666 "$P_SRV crt_file=data_files/server5-der2.crt \
1667 key_file=data_files/server5.key" \
1668 "$G_CLI " \
1669 0 \
1670 -c "Handshake was completed" \
1671
1672requires_gnutls
1673run_test "DER format: with 4 trailing random bytes" \
1674 "$P_SRV crt_file=data_files/server5-der4.crt \
1675 key_file=data_files/server5.key" \
1676 "$G_CLI " \
1677 0 \
1678 -c "Handshake was completed" \
1679
1680requires_gnutls
1681run_test "DER format: with 8 trailing random bytes" \
1682 "$P_SRV crt_file=data_files/server5-der8.crt \
1683 key_file=data_files/server5.key" \
1684 "$G_CLI " \
1685 0 \
1686 -c "Handshake was completed" \
1687
1688requires_gnutls
1689run_test "DER format: with 9 trailing random bytes" \
1690 "$P_SRV crt_file=data_files/server5-der9.crt \
1691 key_file=data_files/server5.key" \
1692 "$G_CLI " \
1693 0 \
1694 -c "Handshake was completed" \
1695
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001696# Tests for auth_mode
1697
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001698run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001699 "$P_SRV crt_file=data_files/server5-badsign.crt \
1700 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001701 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001702 1 \
1703 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001704 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001705 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001706 -c "X509 - Certificate verification failed"
1707
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001708run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001709 "$P_SRV crt_file=data_files/server5-badsign.crt \
1710 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001711 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001712 0 \
1713 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001714 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001715 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001716 -C "X509 - Certificate verification failed"
1717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001718run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001719 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001720 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001721 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001722 0 \
1723 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001724 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001725 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001726 -C "X509 - Certificate verification failed"
1727
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001728run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001729 "$P_SRV debug_level=3 auth_mode=required" \
1730 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001731 key_file=data_files/server5.key" \
1732 1 \
1733 -S "skip write certificate request" \
1734 -C "skip parse certificate request" \
1735 -c "got a certificate request" \
1736 -C "skip write certificate" \
1737 -C "skip write certificate verify" \
1738 -S "skip parse certificate verify" \
1739 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001740 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001741 -s "! mbedtls_ssl_handshake returned" \
1742 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001743 -s "X509 - Certificate verification failed"
1744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001745run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001746 "$P_SRV debug_level=3 auth_mode=optional" \
1747 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001748 key_file=data_files/server5.key" \
1749 0 \
1750 -S "skip write certificate request" \
1751 -C "skip parse certificate request" \
1752 -c "got a certificate request" \
1753 -C "skip write certificate" \
1754 -C "skip write certificate verify" \
1755 -S "skip parse certificate verify" \
1756 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001757 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001758 -S "! mbedtls_ssl_handshake returned" \
1759 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001760 -S "X509 - Certificate verification failed"
1761
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001762run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001763 "$P_SRV debug_level=3 auth_mode=none" \
1764 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001765 key_file=data_files/server5.key" \
1766 0 \
1767 -s "skip write certificate request" \
1768 -C "skip parse certificate request" \
1769 -c "got no certificate request" \
1770 -c "skip write certificate" \
1771 -c "skip write certificate verify" \
1772 -s "skip parse certificate verify" \
1773 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001774 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001775 -S "! mbedtls_ssl_handshake returned" \
1776 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001777 -S "X509 - Certificate verification failed"
1778
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001779run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001780 "$P_SRV debug_level=3 auth_mode=optional" \
1781 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001782 0 \
1783 -S "skip write certificate request" \
1784 -C "skip parse certificate request" \
1785 -c "got a certificate request" \
1786 -C "skip write certificate$" \
1787 -C "got no certificate to send" \
1788 -S "SSLv3 client has no certificate" \
1789 -c "skip write certificate verify" \
1790 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001791 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001792 -S "! mbedtls_ssl_handshake returned" \
1793 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001794 -S "X509 - Certificate verification failed"
1795
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001796run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001797 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001798 "$O_CLI" \
1799 0 \
1800 -S "skip write certificate request" \
1801 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001802 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001803 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001804 -S "X509 - Certificate verification failed"
1805
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001806run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001807 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001808 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001809 0 \
1810 -C "skip parse certificate request" \
1811 -c "got a certificate request" \
1812 -C "skip write certificate$" \
1813 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001814 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001815
Janos Follathe2681a42016-03-07 15:57:05 +00001816requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001817run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001818 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001819 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001820 0 \
1821 -S "skip write certificate request" \
1822 -C "skip parse certificate request" \
1823 -c "got a certificate request" \
1824 -C "skip write certificate$" \
1825 -c "skip write certificate verify" \
1826 -c "got no certificate to send" \
1827 -s "SSLv3 client has no certificate" \
1828 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001829 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001830 -S "! mbedtls_ssl_handshake returned" \
1831 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001832 -S "X509 - Certificate verification failed"
1833
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001834# Tests for certificate selection based on SHA verson
1835
1836run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1837 "$P_SRV crt_file=data_files/server5.crt \
1838 key_file=data_files/server5.key \
1839 crt_file2=data_files/server5-sha1.crt \
1840 key_file2=data_files/server5.key" \
1841 "$P_CLI force_version=tls1_2" \
1842 0 \
1843 -c "signed using.*ECDSA with SHA256" \
1844 -C "signed using.*ECDSA with SHA1"
1845
1846run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1847 "$P_SRV crt_file=data_files/server5.crt \
1848 key_file=data_files/server5.key \
1849 crt_file2=data_files/server5-sha1.crt \
1850 key_file2=data_files/server5.key" \
1851 "$P_CLI force_version=tls1_1" \
1852 0 \
1853 -C "signed using.*ECDSA with SHA256" \
1854 -c "signed using.*ECDSA with SHA1"
1855
1856run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1857 "$P_SRV crt_file=data_files/server5.crt \
1858 key_file=data_files/server5.key \
1859 crt_file2=data_files/server5-sha1.crt \
1860 key_file2=data_files/server5.key" \
1861 "$P_CLI force_version=tls1" \
1862 0 \
1863 -C "signed using.*ECDSA with SHA256" \
1864 -c "signed using.*ECDSA with SHA1"
1865
1866run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1867 "$P_SRV crt_file=data_files/server5.crt \
1868 key_file=data_files/server5.key \
1869 crt_file2=data_files/server6.crt \
1870 key_file2=data_files/server6.key" \
1871 "$P_CLI force_version=tls1_1" \
1872 0 \
1873 -c "serial number.*09" \
1874 -c "signed using.*ECDSA with SHA256" \
1875 -C "signed using.*ECDSA with SHA1"
1876
1877run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1878 "$P_SRV crt_file=data_files/server6.crt \
1879 key_file=data_files/server6.key \
1880 crt_file2=data_files/server5.crt \
1881 key_file2=data_files/server5.key" \
1882 "$P_CLI force_version=tls1_1" \
1883 0 \
1884 -c "serial number.*0A" \
1885 -c "signed using.*ECDSA with SHA256" \
1886 -C "signed using.*ECDSA with SHA1"
1887
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001888# tests for SNI
1889
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001890run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001891 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001892 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001893 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001894 0 \
1895 -S "parse ServerName extension" \
1896 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1897 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001898
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001899run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001900 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001901 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001902 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 +02001903 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001904 0 \
1905 -s "parse ServerName extension" \
1906 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1907 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001909run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001910 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001911 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001912 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 +02001913 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001914 0 \
1915 -s "parse ServerName extension" \
1916 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1917 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001918
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001919run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001920 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001921 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001922 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 +02001923 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001924 1 \
1925 -s "parse ServerName extension" \
1926 -s "ssl_sni_wrapper() returned" \
1927 -s "mbedtls_ssl_handshake returned" \
1928 -c "mbedtls_ssl_handshake returned" \
1929 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001930
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001931run_test "SNI: client auth no override: optional" \
1932 "$P_SRV debug_level=3 auth_mode=optional \
1933 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1934 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1935 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001936 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001937 -S "skip write certificate request" \
1938 -C "skip parse certificate request" \
1939 -c "got a certificate request" \
1940 -C "skip write certificate" \
1941 -C "skip write certificate verify" \
1942 -S "skip parse certificate verify"
1943
1944run_test "SNI: client auth override: none -> optional" \
1945 "$P_SRV debug_level=3 auth_mode=none \
1946 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1947 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1948 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001949 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001950 -S "skip write certificate request" \
1951 -C "skip parse certificate request" \
1952 -c "got a certificate request" \
1953 -C "skip write certificate" \
1954 -C "skip write certificate verify" \
1955 -S "skip parse certificate verify"
1956
1957run_test "SNI: client auth override: optional -> none" \
1958 "$P_SRV debug_level=3 auth_mode=optional \
1959 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1960 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1961 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001962 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001963 -s "skip write certificate request" \
1964 -C "skip parse certificate request" \
1965 -c "got no certificate request" \
1966 -c "skip write certificate" \
1967 -c "skip write certificate verify" \
1968 -s "skip parse certificate verify"
1969
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001970run_test "SNI: CA no override" \
1971 "$P_SRV debug_level=3 auth_mode=optional \
1972 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1973 ca_file=data_files/test-ca.crt \
1974 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1975 "$P_CLI debug_level=3 server_name=localhost \
1976 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1977 1 \
1978 -S "skip write certificate request" \
1979 -C "skip parse certificate request" \
1980 -c "got a certificate request" \
1981 -C "skip write certificate" \
1982 -C "skip write certificate verify" \
1983 -S "skip parse certificate verify" \
1984 -s "x509_verify_cert() returned" \
1985 -s "! The certificate is not correctly signed by the trusted CA" \
1986 -S "The certificate has been revoked (is on a CRL)"
1987
1988run_test "SNI: CA override" \
1989 "$P_SRV debug_level=3 auth_mode=optional \
1990 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1991 ca_file=data_files/test-ca.crt \
1992 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1993 "$P_CLI debug_level=3 server_name=localhost \
1994 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1995 0 \
1996 -S "skip write certificate request" \
1997 -C "skip parse certificate request" \
1998 -c "got a certificate request" \
1999 -C "skip write certificate" \
2000 -C "skip write certificate verify" \
2001 -S "skip parse certificate verify" \
2002 -S "x509_verify_cert() returned" \
2003 -S "! The certificate is not correctly signed by the trusted CA" \
2004 -S "The certificate has been revoked (is on a CRL)"
2005
2006run_test "SNI: CA override with CRL" \
2007 "$P_SRV debug_level=3 auth_mode=optional \
2008 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2009 ca_file=data_files/test-ca.crt \
2010 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2011 "$P_CLI debug_level=3 server_name=localhost \
2012 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2013 1 \
2014 -S "skip write certificate request" \
2015 -C "skip parse certificate request" \
2016 -c "got a certificate request" \
2017 -C "skip write certificate" \
2018 -C "skip write certificate verify" \
2019 -S "skip parse certificate verify" \
2020 -s "x509_verify_cert() returned" \
2021 -S "! The certificate is not correctly signed by the trusted CA" \
2022 -s "The certificate has been revoked (is on a CRL)"
2023
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002024# Tests for non-blocking I/O: exercise a variety of handshake flows
2025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002026run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002027 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2028 "$P_CLI nbio=2 tickets=0" \
2029 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002030 -S "mbedtls_ssl_handshake returned" \
2031 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002032 -c "Read from server: .* bytes read"
2033
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002034run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002035 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2036 "$P_CLI nbio=2 tickets=0" \
2037 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002038 -S "mbedtls_ssl_handshake returned" \
2039 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002040 -c "Read from server: .* bytes read"
2041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002042run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002043 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2044 "$P_CLI nbio=2 tickets=1" \
2045 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002046 -S "mbedtls_ssl_handshake returned" \
2047 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002048 -c "Read from server: .* bytes read"
2049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002050run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002051 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2052 "$P_CLI nbio=2 tickets=1" \
2053 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002054 -S "mbedtls_ssl_handshake returned" \
2055 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002056 -c "Read from server: .* bytes read"
2057
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002058run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002059 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2060 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2061 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002062 -S "mbedtls_ssl_handshake returned" \
2063 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002064 -c "Read from server: .* bytes read"
2065
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002066run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002067 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2068 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2069 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002070 -S "mbedtls_ssl_handshake returned" \
2071 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002072 -c "Read from server: .* bytes read"
2073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002074run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002075 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2076 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2077 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002078 -S "mbedtls_ssl_handshake returned" \
2079 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002080 -c "Read from server: .* bytes read"
2081
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002082# Tests for version negotiation
2083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002084run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002085 "$P_SRV" \
2086 "$P_CLI" \
2087 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002088 -S "mbedtls_ssl_handshake returned" \
2089 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002090 -s "Protocol is TLSv1.2" \
2091 -c "Protocol is TLSv1.2"
2092
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002093run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002094 "$P_SRV" \
2095 "$P_CLI max_version=tls1_1" \
2096 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002097 -S "mbedtls_ssl_handshake returned" \
2098 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002099 -s "Protocol is TLSv1.1" \
2100 -c "Protocol is TLSv1.1"
2101
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002102run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002103 "$P_SRV max_version=tls1_1" \
2104 "$P_CLI" \
2105 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002106 -S "mbedtls_ssl_handshake returned" \
2107 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002108 -s "Protocol is TLSv1.1" \
2109 -c "Protocol is TLSv1.1"
2110
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002111run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002112 "$P_SRV max_version=tls1_1" \
2113 "$P_CLI max_version=tls1_1" \
2114 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002115 -S "mbedtls_ssl_handshake returned" \
2116 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002117 -s "Protocol is TLSv1.1" \
2118 -c "Protocol is TLSv1.1"
2119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002120run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002121 "$P_SRV min_version=tls1_1" \
2122 "$P_CLI max_version=tls1_1" \
2123 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002124 -S "mbedtls_ssl_handshake returned" \
2125 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002126 -s "Protocol is TLSv1.1" \
2127 -c "Protocol is TLSv1.1"
2128
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002129run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002130 "$P_SRV max_version=tls1_1" \
2131 "$P_CLI min_version=tls1_1" \
2132 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002133 -S "mbedtls_ssl_handshake returned" \
2134 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002135 -s "Protocol is TLSv1.1" \
2136 -c "Protocol is TLSv1.1"
2137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002138run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002139 "$P_SRV max_version=tls1_1" \
2140 "$P_CLI min_version=tls1_2" \
2141 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002142 -s "mbedtls_ssl_handshake returned" \
2143 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002144 -c "SSL - Handshake protocol not within min/max boundaries"
2145
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002146run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002147 "$P_SRV min_version=tls1_2" \
2148 "$P_CLI max_version=tls1_1" \
2149 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002150 -s "mbedtls_ssl_handshake returned" \
2151 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002152 -s "SSL - Handshake protocol not within min/max boundaries"
2153
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002154# Tests for ALPN extension
2155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002156run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002157 "$P_SRV debug_level=3" \
2158 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002159 0 \
2160 -C "client hello, adding alpn extension" \
2161 -S "found alpn extension" \
2162 -C "got an alert message, type: \\[2:120]" \
2163 -S "server hello, adding alpn extension" \
2164 -C "found alpn extension " \
2165 -C "Application Layer Protocol is" \
2166 -S "Application Layer Protocol is"
2167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002168run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002169 "$P_SRV debug_level=3" \
2170 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002171 0 \
2172 -c "client hello, adding alpn extension" \
2173 -s "found alpn extension" \
2174 -C "got an alert message, type: \\[2:120]" \
2175 -S "server hello, adding alpn extension" \
2176 -C "found alpn extension " \
2177 -c "Application Layer Protocol is (none)" \
2178 -S "Application Layer Protocol is"
2179
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002180run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002181 "$P_SRV debug_level=3 alpn=abc,1234" \
2182 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002183 0 \
2184 -C "client hello, adding alpn extension" \
2185 -S "found alpn extension" \
2186 -C "got an alert message, type: \\[2:120]" \
2187 -S "server hello, adding alpn extension" \
2188 -C "found alpn extension " \
2189 -C "Application Layer Protocol is" \
2190 -s "Application Layer Protocol is (none)"
2191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002192run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002193 "$P_SRV debug_level=3 alpn=abc,1234" \
2194 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002195 0 \
2196 -c "client hello, adding alpn extension" \
2197 -s "found alpn extension" \
2198 -C "got an alert message, type: \\[2:120]" \
2199 -s "server hello, adding alpn extension" \
2200 -c "found alpn extension" \
2201 -c "Application Layer Protocol is abc" \
2202 -s "Application Layer Protocol is abc"
2203
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002204run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002205 "$P_SRV debug_level=3 alpn=abc,1234" \
2206 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002207 0 \
2208 -c "client hello, adding alpn extension" \
2209 -s "found alpn extension" \
2210 -C "got an alert message, type: \\[2:120]" \
2211 -s "server hello, adding alpn extension" \
2212 -c "found alpn extension" \
2213 -c "Application Layer Protocol is abc" \
2214 -s "Application Layer Protocol is abc"
2215
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002216run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002217 "$P_SRV debug_level=3 alpn=abc,1234" \
2218 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002219 0 \
2220 -c "client hello, adding alpn extension" \
2221 -s "found alpn extension" \
2222 -C "got an alert message, type: \\[2:120]" \
2223 -s "server hello, adding alpn extension" \
2224 -c "found alpn extension" \
2225 -c "Application Layer Protocol is 1234" \
2226 -s "Application Layer Protocol is 1234"
2227
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002228run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002229 "$P_SRV debug_level=3 alpn=abc,123" \
2230 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002231 1 \
2232 -c "client hello, adding alpn extension" \
2233 -s "found alpn extension" \
2234 -c "got an alert message, type: \\[2:120]" \
2235 -S "server hello, adding alpn extension" \
2236 -C "found alpn extension" \
2237 -C "Application Layer Protocol is 1234" \
2238 -S "Application Layer Protocol is 1234"
2239
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002240
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002241# Tests for keyUsage in leaf certificates, part 1:
2242# server-side certificate/suite selection
2243
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002244run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002245 "$P_SRV key_file=data_files/server2.key \
2246 crt_file=data_files/server2.ku-ds.crt" \
2247 "$P_CLI" \
2248 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002249 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002250
2251
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002252run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002253 "$P_SRV key_file=data_files/server2.key \
2254 crt_file=data_files/server2.ku-ke.crt" \
2255 "$P_CLI" \
2256 0 \
2257 -c "Ciphersuite is TLS-RSA-WITH-"
2258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002259run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002260 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002261 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002262 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002263 1 \
2264 -C "Ciphersuite is "
2265
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002266run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002267 "$P_SRV key_file=data_files/server5.key \
2268 crt_file=data_files/server5.ku-ds.crt" \
2269 "$P_CLI" \
2270 0 \
2271 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2272
2273
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002274run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002275 "$P_SRV key_file=data_files/server5.key \
2276 crt_file=data_files/server5.ku-ka.crt" \
2277 "$P_CLI" \
2278 0 \
2279 -c "Ciphersuite is TLS-ECDH-"
2280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002281run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002282 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002283 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002284 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002285 1 \
2286 -C "Ciphersuite is "
2287
2288# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002289# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002291run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002292 "$O_SRV -key data_files/server2.key \
2293 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002294 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002295 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2296 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002297 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002298 -C "Processing of the Certificate handshake message failed" \
2299 -c "Ciphersuite is TLS-"
2300
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002301run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002302 "$O_SRV -key data_files/server2.key \
2303 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002304 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002305 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2306 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002307 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002308 -C "Processing of the Certificate handshake message failed" \
2309 -c "Ciphersuite is TLS-"
2310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002311run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002312 "$O_SRV -key data_files/server2.key \
2313 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002314 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002315 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2316 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002317 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002318 -C "Processing of the Certificate handshake message failed" \
2319 -c "Ciphersuite is TLS-"
2320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002321run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002322 "$O_SRV -key data_files/server2.key \
2323 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002324 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002325 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2326 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002327 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002328 -c "Processing of the Certificate handshake message failed" \
2329 -C "Ciphersuite is TLS-"
2330
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002331run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2332 "$O_SRV -key data_files/server2.key \
2333 -cert data_files/server2.ku-ke.crt" \
2334 "$P_CLI debug_level=1 auth_mode=optional \
2335 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2336 0 \
2337 -c "bad certificate (usage extensions)" \
2338 -C "Processing of the Certificate handshake message failed" \
2339 -c "Ciphersuite is TLS-" \
2340 -c "! Usage does not match the keyUsage extension"
2341
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002342run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002343 "$O_SRV -key data_files/server2.key \
2344 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002345 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002346 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2347 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002348 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002349 -C "Processing of the Certificate handshake message failed" \
2350 -c "Ciphersuite is TLS-"
2351
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002352run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002353 "$O_SRV -key data_files/server2.key \
2354 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002355 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002356 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2357 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002358 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002359 -c "Processing of the Certificate handshake message failed" \
2360 -C "Ciphersuite is TLS-"
2361
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002362run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2363 "$O_SRV -key data_files/server2.key \
2364 -cert data_files/server2.ku-ds.crt" \
2365 "$P_CLI debug_level=1 auth_mode=optional \
2366 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2367 0 \
2368 -c "bad certificate (usage extensions)" \
2369 -C "Processing of the Certificate handshake message failed" \
2370 -c "Ciphersuite is TLS-" \
2371 -c "! Usage does not match the keyUsage extension"
2372
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002373# Tests for keyUsage in leaf certificates, part 3:
2374# server-side checking of client cert
2375
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002376run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002377 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002378 "$O_CLI -key data_files/server2.key \
2379 -cert data_files/server2.ku-ds.crt" \
2380 0 \
2381 -S "bad certificate (usage extensions)" \
2382 -S "Processing of the Certificate handshake message failed"
2383
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002384run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002385 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002386 "$O_CLI -key data_files/server2.key \
2387 -cert data_files/server2.ku-ke.crt" \
2388 0 \
2389 -s "bad certificate (usage extensions)" \
2390 -S "Processing of the Certificate handshake message failed"
2391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002392run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002393 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002394 "$O_CLI -key data_files/server2.key \
2395 -cert data_files/server2.ku-ke.crt" \
2396 1 \
2397 -s "bad certificate (usage extensions)" \
2398 -s "Processing of the Certificate handshake message failed"
2399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002400run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002401 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002402 "$O_CLI -key data_files/server5.key \
2403 -cert data_files/server5.ku-ds.crt" \
2404 0 \
2405 -S "bad certificate (usage extensions)" \
2406 -S "Processing of the Certificate handshake message failed"
2407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002408run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002409 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002410 "$O_CLI -key data_files/server5.key \
2411 -cert data_files/server5.ku-ka.crt" \
2412 0 \
2413 -s "bad certificate (usage extensions)" \
2414 -S "Processing of the Certificate handshake message failed"
2415
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002416# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2417
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002418run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002419 "$P_SRV key_file=data_files/server5.key \
2420 crt_file=data_files/server5.eku-srv.crt" \
2421 "$P_CLI" \
2422 0
2423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002424run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002425 "$P_SRV key_file=data_files/server5.key \
2426 crt_file=data_files/server5.eku-srv.crt" \
2427 "$P_CLI" \
2428 0
2429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002430run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002431 "$P_SRV key_file=data_files/server5.key \
2432 crt_file=data_files/server5.eku-cs_any.crt" \
2433 "$P_CLI" \
2434 0
2435
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002436run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002437 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002438 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002439 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002440 1
2441
2442# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2443
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002444run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002445 "$O_SRV -key data_files/server5.key \
2446 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002447 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002448 0 \
2449 -C "bad certificate (usage extensions)" \
2450 -C "Processing of the Certificate handshake message failed" \
2451 -c "Ciphersuite is TLS-"
2452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002453run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002454 "$O_SRV -key data_files/server5.key \
2455 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002456 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002457 0 \
2458 -C "bad certificate (usage extensions)" \
2459 -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 "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002463 "$O_SRV -key data_files/server5.key \
2464 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002465 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002466 0 \
2467 -C "bad certificate (usage extensions)" \
2468 -C "Processing of the Certificate handshake message failed" \
2469 -c "Ciphersuite is TLS-"
2470
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002471run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002472 "$O_SRV -key data_files/server5.key \
2473 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002474 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002475 1 \
2476 -c "bad certificate (usage extensions)" \
2477 -c "Processing of the Certificate handshake message failed" \
2478 -C "Ciphersuite is TLS-"
2479
2480# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2481
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002482run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002483 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002484 "$O_CLI -key data_files/server5.key \
2485 -cert data_files/server5.eku-cli.crt" \
2486 0 \
2487 -S "bad certificate (usage extensions)" \
2488 -S "Processing of the Certificate handshake message failed"
2489
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002490run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002491 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002492 "$O_CLI -key data_files/server5.key \
2493 -cert data_files/server5.eku-srv_cli.crt" \
2494 0 \
2495 -S "bad certificate (usage extensions)" \
2496 -S "Processing of the Certificate handshake message failed"
2497
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002498run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002499 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002500 "$O_CLI -key data_files/server5.key \
2501 -cert data_files/server5.eku-cs_any.crt" \
2502 0 \
2503 -S "bad certificate (usage extensions)" \
2504 -S "Processing of the Certificate handshake message failed"
2505
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002506run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002507 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002508 "$O_CLI -key data_files/server5.key \
2509 -cert data_files/server5.eku-cs.crt" \
2510 0 \
2511 -s "bad certificate (usage extensions)" \
2512 -S "Processing of the Certificate handshake message failed"
2513
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002514run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002515 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002516 "$O_CLI -key data_files/server5.key \
2517 -cert data_files/server5.eku-cs.crt" \
2518 1 \
2519 -s "bad certificate (usage extensions)" \
2520 -s "Processing of the Certificate handshake message failed"
2521
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002522# Tests for DHM parameters loading
2523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002524run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002525 "$P_SRV" \
2526 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2527 debug_level=3" \
2528 0 \
2529 -c "value of 'DHM: P ' (2048 bits)" \
2530 -c "value of 'DHM: G ' (2048 bits)"
2531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002532run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002533 "$P_SRV dhm_file=data_files/dhparams.pem" \
2534 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2535 debug_level=3" \
2536 0 \
2537 -c "value of 'DHM: P ' (1024 bits)" \
2538 -c "value of 'DHM: G ' (2 bits)"
2539
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002540# Tests for DHM client-side size checking
2541
2542run_test "DHM size: server default, client default, OK" \
2543 "$P_SRV" \
2544 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2545 debug_level=1" \
2546 0 \
2547 -C "DHM prime too short:"
2548
2549run_test "DHM size: server default, client 2048, OK" \
2550 "$P_SRV" \
2551 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2552 debug_level=1 dhmlen=2048" \
2553 0 \
2554 -C "DHM prime too short:"
2555
2556run_test "DHM size: server 1024, client default, OK" \
2557 "$P_SRV dhm_file=data_files/dhparams.pem" \
2558 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2559 debug_level=1" \
2560 0 \
2561 -C "DHM prime too short:"
2562
2563run_test "DHM size: server 1000, client default, rejected" \
2564 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2565 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2566 debug_level=1" \
2567 1 \
2568 -c "DHM prime too short:"
2569
2570run_test "DHM size: server default, client 2049, rejected" \
2571 "$P_SRV" \
2572 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2573 debug_level=1 dhmlen=2049" \
2574 1 \
2575 -c "DHM prime too short:"
2576
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002577# Tests for PSK callback
2578
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002579run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002580 "$P_SRV psk=abc123 psk_identity=foo" \
2581 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2582 psk_identity=foo psk=abc123" \
2583 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002584 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002585 -S "SSL - Unknown identity received" \
2586 -S "SSL - Verification of the message MAC failed"
2587
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002588run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002589 "$P_SRV" \
2590 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2591 psk_identity=foo psk=abc123" \
2592 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002593 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002594 -S "SSL - Unknown identity received" \
2595 -S "SSL - Verification of the message MAC failed"
2596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002597run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002598 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2599 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2600 psk_identity=foo psk=abc123" \
2601 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002602 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002603 -s "SSL - Unknown identity received" \
2604 -S "SSL - Verification of the message MAC failed"
2605
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002606run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002607 "$P_SRV psk_list=abc,dead,def,beef" \
2608 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2609 psk_identity=abc psk=dead" \
2610 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002611 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002612 -S "SSL - Unknown identity received" \
2613 -S "SSL - Verification of the message MAC failed"
2614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002615run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002616 "$P_SRV psk_list=abc,dead,def,beef" \
2617 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2618 psk_identity=def psk=beef" \
2619 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002620 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002621 -S "SSL - Unknown identity received" \
2622 -S "SSL - Verification of the message MAC failed"
2623
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002624run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002625 "$P_SRV psk_list=abc,dead,def,beef" \
2626 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2627 psk_identity=ghi psk=beef" \
2628 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002629 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002630 -s "SSL - Unknown identity received" \
2631 -S "SSL - Verification of the message MAC failed"
2632
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002633run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002634 "$P_SRV psk_list=abc,dead,def,beef" \
2635 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2636 psk_identity=abc psk=beef" \
2637 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002638 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002639 -S "SSL - Unknown identity received" \
2640 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002641
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002642# Tests for EC J-PAKE
2643
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002644requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002645run_test "ECJPAKE: client not configured" \
2646 "$P_SRV debug_level=3" \
2647 "$P_CLI debug_level=3" \
2648 0 \
2649 -C "add ciphersuite: c0ff" \
2650 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002651 -S "found ecjpake kkpp extension" \
2652 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002653 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002654 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002655 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002656 -S "None of the common ciphersuites is usable"
2657
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002658requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002659run_test "ECJPAKE: server not configured" \
2660 "$P_SRV debug_level=3" \
2661 "$P_CLI debug_level=3 ecjpake_pw=bla \
2662 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2663 1 \
2664 -c "add ciphersuite: c0ff" \
2665 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002666 -s "found ecjpake kkpp extension" \
2667 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002668 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002669 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002670 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002671 -s "None of the common ciphersuites is usable"
2672
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002673requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002674run_test "ECJPAKE: working, TLS" \
2675 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2676 "$P_CLI debug_level=3 ecjpake_pw=bla \
2677 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002678 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002679 -c "add ciphersuite: c0ff" \
2680 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002681 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002682 -s "found ecjpake kkpp extension" \
2683 -S "skip ecjpake kkpp extension" \
2684 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002685 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002686 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002687 -S "None of the common ciphersuites is usable" \
2688 -S "SSL - Verification of the message MAC failed"
2689
Janos Follath74537a62016-09-02 13:45:28 +01002690server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002691requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002692run_test "ECJPAKE: password mismatch, TLS" \
2693 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2694 "$P_CLI debug_level=3 ecjpake_pw=bad \
2695 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2696 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002697 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002698 -s "SSL - Verification of the message MAC failed"
2699
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002700requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002701run_test "ECJPAKE: working, DTLS" \
2702 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2703 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2704 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2705 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002706 -c "re-using cached ecjpake parameters" \
2707 -S "SSL - Verification of the message MAC failed"
2708
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002709requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002710run_test "ECJPAKE: working, DTLS, no cookie" \
2711 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2712 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2713 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2714 0 \
2715 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002716 -S "SSL - Verification of the message MAC failed"
2717
Janos Follath74537a62016-09-02 13:45:28 +01002718server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002719requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002720run_test "ECJPAKE: password mismatch, DTLS" \
2721 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2722 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2723 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2724 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002725 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002726 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002727
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002728# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002729requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002730run_test "ECJPAKE: working, DTLS, nolog" \
2731 "$P_SRV dtls=1 ecjpake_pw=bla" \
2732 "$P_CLI dtls=1 ecjpake_pw=bla \
2733 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2734 0
2735
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002736# Tests for ciphersuites per version
2737
Janos Follathe2681a42016-03-07 15:57:05 +00002738requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002739run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002740 "$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 +02002741 "$P_CLI force_version=ssl3" \
2742 0 \
2743 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002745run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002746 "$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 +01002747 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002748 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002749 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002750
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002751run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002752 "$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 +02002753 "$P_CLI force_version=tls1_1" \
2754 0 \
2755 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002757run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002758 "$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 +02002759 "$P_CLI force_version=tls1_2" \
2760 0 \
2761 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2762
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002763# Test for ClientHello without extensions
2764
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002765requires_gnutls
2766run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002767 "$P_SRV debug_level=3" \
2768 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2769 0 \
2770 -s "dumping 'client hello extensions' (0 bytes)"
2771
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002772# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002773
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002774run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002775 "$P_SRV" \
2776 "$P_CLI request_size=100" \
2777 0 \
2778 -s "Read from client: 100 bytes read$"
2779
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002780run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002781 "$P_SRV" \
2782 "$P_CLI request_size=500" \
2783 0 \
2784 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002785
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002786# Tests for small packets
2787
Janos Follathe2681a42016-03-07 15:57:05 +00002788requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002789run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002790 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002791 "$P_CLI request_size=1 force_version=ssl3 \
2792 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2793 0 \
2794 -s "Read from client: 1 bytes read"
2795
Janos Follathe2681a42016-03-07 15:57:05 +00002796requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002797run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002798 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002799 "$P_CLI request_size=1 force_version=ssl3 \
2800 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2801 0 \
2802 -s "Read from client: 1 bytes read"
2803
2804run_test "Small packet TLS 1.0 BlockCipher" \
2805 "$P_SRV" \
2806 "$P_CLI request_size=1 force_version=tls1 \
2807 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2808 0 \
2809 -s "Read from client: 1 bytes read"
2810
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002811run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2812 "$P_SRV" \
2813 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2814 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2815 0 \
2816 -s "Read from client: 1 bytes read"
2817
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002818run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2819 "$P_SRV" \
2820 "$P_CLI request_size=1 force_version=tls1 \
2821 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2822 trunc_hmac=1" \
2823 0 \
2824 -s "Read from client: 1 bytes read"
2825
2826run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002827 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002828 "$P_CLI request_size=1 force_version=tls1 \
2829 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2830 trunc_hmac=1" \
2831 0 \
2832 -s "Read from client: 1 bytes read"
2833
2834run_test "Small packet TLS 1.1 BlockCipher" \
2835 "$P_SRV" \
2836 "$P_CLI request_size=1 force_version=tls1_1 \
2837 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2838 0 \
2839 -s "Read from client: 1 bytes read"
2840
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002841run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2842 "$P_SRV" \
2843 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2844 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2845 0 \
2846 -s "Read from client: 1 bytes read"
2847
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002848run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002849 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002850 "$P_CLI request_size=1 force_version=tls1_1 \
2851 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2852 0 \
2853 -s "Read from client: 1 bytes read"
2854
2855run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2856 "$P_SRV" \
2857 "$P_CLI request_size=1 force_version=tls1_1 \
2858 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2859 trunc_hmac=1" \
2860 0 \
2861 -s "Read from client: 1 bytes read"
2862
2863run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002864 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002865 "$P_CLI request_size=1 force_version=tls1_1 \
2866 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2867 trunc_hmac=1" \
2868 0 \
2869 -s "Read from client: 1 bytes read"
2870
2871run_test "Small packet TLS 1.2 BlockCipher" \
2872 "$P_SRV" \
2873 "$P_CLI request_size=1 force_version=tls1_2 \
2874 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2875 0 \
2876 -s "Read from client: 1 bytes read"
2877
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002878run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2879 "$P_SRV" \
2880 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2881 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2882 0 \
2883 -s "Read from client: 1 bytes read"
2884
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002885run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2886 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002887 "$P_CLI request_size=1 force_version=tls1_2 \
2888 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002889 0 \
2890 -s "Read from client: 1 bytes read"
2891
2892run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2893 "$P_SRV" \
2894 "$P_CLI request_size=1 force_version=tls1_2 \
2895 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2896 trunc_hmac=1" \
2897 0 \
2898 -s "Read from client: 1 bytes read"
2899
2900run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002901 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002902 "$P_CLI request_size=1 force_version=tls1_2 \
2903 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2904 0 \
2905 -s "Read from client: 1 bytes read"
2906
2907run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002908 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002909 "$P_CLI request_size=1 force_version=tls1_2 \
2910 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2911 trunc_hmac=1" \
2912 0 \
2913 -s "Read from client: 1 bytes read"
2914
2915run_test "Small packet TLS 1.2 AEAD" \
2916 "$P_SRV" \
2917 "$P_CLI request_size=1 force_version=tls1_2 \
2918 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2919 0 \
2920 -s "Read from client: 1 bytes read"
2921
2922run_test "Small packet TLS 1.2 AEAD shorter tag" \
2923 "$P_SRV" \
2924 "$P_CLI request_size=1 force_version=tls1_2 \
2925 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2926 0 \
2927 -s "Read from client: 1 bytes read"
2928
Janos Follath00efff72016-05-06 13:48:23 +01002929# A test for extensions in SSLv3
2930
2931requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2932run_test "SSLv3 with extensions, server side" \
2933 "$P_SRV min_version=ssl3 debug_level=3" \
2934 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2935 0 \
2936 -S "dumping 'client hello extensions'" \
2937 -S "server hello, total extension length:"
2938
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002939# Test for large packets
2940
Janos Follathe2681a42016-03-07 15:57:05 +00002941requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002942run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002943 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002944 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002945 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2946 0 \
2947 -s "Read from client: 16384 bytes read"
2948
Janos Follathe2681a42016-03-07 15:57:05 +00002949requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002950run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002951 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002952 "$P_CLI request_size=16384 force_version=ssl3 \
2953 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2954 0 \
2955 -s "Read from client: 16384 bytes read"
2956
2957run_test "Large packet TLS 1.0 BlockCipher" \
2958 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002959 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002960 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2961 0 \
2962 -s "Read from client: 16384 bytes read"
2963
2964run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2965 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002966 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002967 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2968 trunc_hmac=1" \
2969 0 \
2970 -s "Read from client: 16384 bytes read"
2971
2972run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002973 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002974 "$P_CLI request_size=16384 force_version=tls1 \
2975 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2976 trunc_hmac=1" \
2977 0 \
2978 -s "Read from client: 16384 bytes read"
2979
2980run_test "Large packet TLS 1.1 BlockCipher" \
2981 "$P_SRV" \
2982 "$P_CLI request_size=16384 force_version=tls1_1 \
2983 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2984 0 \
2985 -s "Read from client: 16384 bytes read"
2986
2987run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002988 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002989 "$P_CLI request_size=16384 force_version=tls1_1 \
2990 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2991 0 \
2992 -s "Read from client: 16384 bytes read"
2993
2994run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2995 "$P_SRV" \
2996 "$P_CLI request_size=16384 force_version=tls1_1 \
2997 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2998 trunc_hmac=1" \
2999 0 \
3000 -s "Read from client: 16384 bytes read"
3001
3002run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003003 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003004 "$P_CLI request_size=16384 force_version=tls1_1 \
3005 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3006 trunc_hmac=1" \
3007 0 \
3008 -s "Read from client: 16384 bytes read"
3009
3010run_test "Large packet TLS 1.2 BlockCipher" \
3011 "$P_SRV" \
3012 "$P_CLI request_size=16384 force_version=tls1_2 \
3013 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3014 0 \
3015 -s "Read from client: 16384 bytes read"
3016
3017run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3018 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003019 "$P_CLI request_size=16384 force_version=tls1_2 \
3020 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003021 0 \
3022 -s "Read from client: 16384 bytes read"
3023
3024run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3025 "$P_SRV" \
3026 "$P_CLI request_size=16384 force_version=tls1_2 \
3027 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3028 trunc_hmac=1" \
3029 0 \
3030 -s "Read from client: 16384 bytes read"
3031
3032run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003033 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003034 "$P_CLI request_size=16384 force_version=tls1_2 \
3035 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3036 0 \
3037 -s "Read from client: 16384 bytes read"
3038
3039run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003040 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003041 "$P_CLI request_size=16384 force_version=tls1_2 \
3042 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3043 trunc_hmac=1" \
3044 0 \
3045 -s "Read from client: 16384 bytes read"
3046
3047run_test "Large packet TLS 1.2 AEAD" \
3048 "$P_SRV" \
3049 "$P_CLI request_size=16384 force_version=tls1_2 \
3050 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3051 0 \
3052 -s "Read from client: 16384 bytes read"
3053
3054run_test "Large packet TLS 1.2 AEAD shorter tag" \
3055 "$P_SRV" \
3056 "$P_CLI request_size=16384 force_version=tls1_2 \
3057 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3058 0 \
3059 -s "Read from client: 16384 bytes read"
3060
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003061# Tests for DTLS HelloVerifyRequest
3062
3063run_test "DTLS cookie: enabled" \
3064 "$P_SRV dtls=1 debug_level=2" \
3065 "$P_CLI dtls=1 debug_level=2" \
3066 0 \
3067 -s "cookie verification failed" \
3068 -s "cookie verification passed" \
3069 -S "cookie verification skipped" \
3070 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003071 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003072 -S "SSL - The requested feature is not available"
3073
3074run_test "DTLS cookie: disabled" \
3075 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3076 "$P_CLI dtls=1 debug_level=2" \
3077 0 \
3078 -S "cookie verification failed" \
3079 -S "cookie verification passed" \
3080 -s "cookie verification skipped" \
3081 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003082 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003083 -S "SSL - The requested feature is not available"
3084
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003085run_test "DTLS cookie: default (failing)" \
3086 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3087 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3088 1 \
3089 -s "cookie verification failed" \
3090 -S "cookie verification passed" \
3091 -S "cookie verification skipped" \
3092 -C "received hello verify request" \
3093 -S "hello verification requested" \
3094 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003095
3096requires_ipv6
3097run_test "DTLS cookie: enabled, IPv6" \
3098 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3099 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3100 0 \
3101 -s "cookie verification failed" \
3102 -s "cookie verification passed" \
3103 -S "cookie verification skipped" \
3104 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003105 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003106 -S "SSL - The requested feature is not available"
3107
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003108run_test "DTLS cookie: enabled, nbio" \
3109 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3110 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3111 0 \
3112 -s "cookie verification failed" \
3113 -s "cookie verification passed" \
3114 -S "cookie verification skipped" \
3115 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003116 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003117 -S "SSL - The requested feature is not available"
3118
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003119# Tests for client reconnecting from the same port with DTLS
3120
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003121not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003122run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003123 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3124 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003125 0 \
3126 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003127 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003128 -S "Client initiated reconnection from same port"
3129
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003130not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003131run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003132 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3133 "$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 +02003134 0 \
3135 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003136 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003137 -s "Client initiated reconnection from same port"
3138
Paul Bakker362689d2016-05-13 10:33:25 +01003139not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3140run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003141 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3142 "$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 +02003143 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003144 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003145 -s "Client initiated reconnection from same port"
3146
Paul Bakker362689d2016-05-13 10:33:25 +01003147only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3148run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3149 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3150 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3151 0 \
3152 -S "The operation timed out" \
3153 -s "Client initiated reconnection from same port"
3154
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003155run_test "DTLS client reconnect from same port: no cookies" \
3156 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003157 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3158 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003159 -s "The operation timed out" \
3160 -S "Client initiated reconnection from same port"
3161
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003162# Tests for various cases of client authentication with DTLS
3163# (focused on handshake flows and message parsing)
3164
3165run_test "DTLS client auth: required" \
3166 "$P_SRV dtls=1 auth_mode=required" \
3167 "$P_CLI dtls=1" \
3168 0 \
3169 -s "Verifying peer X.509 certificate... ok"
3170
3171run_test "DTLS client auth: optional, client has no cert" \
3172 "$P_SRV dtls=1 auth_mode=optional" \
3173 "$P_CLI dtls=1 crt_file=none key_file=none" \
3174 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003175 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003176
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003177run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003178 "$P_SRV dtls=1 auth_mode=none" \
3179 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3180 0 \
3181 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003182 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003183
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003184run_test "DTLS wrong PSK: badmac alert" \
3185 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3186 "$P_CLI dtls=1 psk=abc124" \
3187 1 \
3188 -s "SSL - Verification of the message MAC failed" \
3189 -c "SSL - A fatal alert message was received from our peer"
3190
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003191# Tests for receiving fragmented handshake messages with DTLS
3192
3193requires_gnutls
3194run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3195 "$G_SRV -u --mtu 2048 -a" \
3196 "$P_CLI dtls=1 debug_level=2" \
3197 0 \
3198 -C "found fragmented DTLS handshake message" \
3199 -C "error"
3200
3201requires_gnutls
3202run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3203 "$G_SRV -u --mtu 512" \
3204 "$P_CLI dtls=1 debug_level=2" \
3205 0 \
3206 -c "found fragmented DTLS handshake message" \
3207 -C "error"
3208
3209requires_gnutls
3210run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3211 "$G_SRV -u --mtu 128" \
3212 "$P_CLI dtls=1 debug_level=2" \
3213 0 \
3214 -c "found fragmented DTLS handshake message" \
3215 -C "error"
3216
3217requires_gnutls
3218run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3219 "$G_SRV -u --mtu 128" \
3220 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3221 0 \
3222 -c "found fragmented DTLS handshake message" \
3223 -C "error"
3224
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003225requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003226run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3227 "$G_SRV -u --mtu 256" \
3228 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3229 0 \
3230 -c "found fragmented DTLS handshake message" \
3231 -c "client hello, adding renegotiation extension" \
3232 -c "found renegotiation extension" \
3233 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003234 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003235 -C "error" \
3236 -s "Extra-header:"
3237
3238requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003239run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3240 "$G_SRV -u --mtu 256" \
3241 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3242 0 \
3243 -c "found fragmented DTLS handshake message" \
3244 -c "client hello, adding renegotiation extension" \
3245 -c "found renegotiation extension" \
3246 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003247 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003248 -C "error" \
3249 -s "Extra-header:"
3250
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003251run_test "DTLS reassembly: no fragmentation (openssl server)" \
3252 "$O_SRV -dtls1 -mtu 2048" \
3253 "$P_CLI dtls=1 debug_level=2" \
3254 0 \
3255 -C "found fragmented DTLS handshake message" \
3256 -C "error"
3257
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003258run_test "DTLS reassembly: some fragmentation (openssl server)" \
3259 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003260 "$P_CLI dtls=1 debug_level=2" \
3261 0 \
3262 -c "found fragmented DTLS handshake message" \
3263 -C "error"
3264
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003265run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003266 "$O_SRV -dtls1 -mtu 256" \
3267 "$P_CLI dtls=1 debug_level=2" \
3268 0 \
3269 -c "found fragmented DTLS handshake message" \
3270 -C "error"
3271
3272run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3273 "$O_SRV -dtls1 -mtu 256" \
3274 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3275 0 \
3276 -c "found fragmented DTLS handshake message" \
3277 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003278
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003279# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003280
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003281not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003282run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003283 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003284 "$P_SRV dtls=1 debug_level=2" \
3285 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003286 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003287 -C "replayed record" \
3288 -S "replayed record" \
3289 -C "record from another epoch" \
3290 -S "record from another epoch" \
3291 -C "discarding invalid record" \
3292 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003293 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003294 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003295 -c "HTTP/1.0 200 OK"
3296
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003297not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003298run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003299 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003300 "$P_SRV dtls=1 debug_level=2" \
3301 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003302 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003303 -c "replayed record" \
3304 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003305 -c "discarding invalid record" \
3306 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003307 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003308 -s "Extra-header:" \
3309 -c "HTTP/1.0 200 OK"
3310
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003311run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3312 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003313 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3314 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003315 0 \
3316 -c "replayed record" \
3317 -S "replayed record" \
3318 -c "discarding invalid record" \
3319 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003320 -c "resend" \
3321 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003322 -s "Extra-header:" \
3323 -c "HTTP/1.0 200 OK"
3324
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003325run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003326 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003327 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003328 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003329 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003330 -c "discarding invalid record (mac)" \
3331 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003332 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003333 -c "HTTP/1.0 200 OK" \
3334 -S "too many records with bad MAC" \
3335 -S "Verification of the message MAC failed"
3336
3337run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3338 -p "$P_PXY bad_ad=1" \
3339 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3340 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3341 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003342 -C "discarding invalid record (mac)" \
3343 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003344 -S "Extra-header:" \
3345 -C "HTTP/1.0 200 OK" \
3346 -s "too many records with bad MAC" \
3347 -s "Verification of the message MAC failed"
3348
3349run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3350 -p "$P_PXY bad_ad=1" \
3351 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3352 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3353 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003354 -c "discarding invalid record (mac)" \
3355 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003356 -s "Extra-header:" \
3357 -c "HTTP/1.0 200 OK" \
3358 -S "too many records with bad MAC" \
3359 -S "Verification of the message MAC failed"
3360
3361run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3362 -p "$P_PXY bad_ad=1" \
3363 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3364 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3365 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003366 -c "discarding invalid record (mac)" \
3367 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003368 -s "Extra-header:" \
3369 -c "HTTP/1.0 200 OK" \
3370 -s "too many records with bad MAC" \
3371 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003372
3373run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003374 -p "$P_PXY delay_ccs=1" \
3375 "$P_SRV dtls=1 debug_level=1" \
3376 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003377 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003378 -c "record from another epoch" \
3379 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003380 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003381 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003382 -s "Extra-header:" \
3383 -c "HTTP/1.0 200 OK"
3384
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003385# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003386
Janos Follath74537a62016-09-02 13:45:28 +01003387client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003388run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003389 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003390 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3391 psk=abc123" \
3392 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003393 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3394 0 \
3395 -s "Extra-header:" \
3396 -c "HTTP/1.0 200 OK"
3397
Janos Follath74537a62016-09-02 13:45:28 +01003398client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003399run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3400 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003401 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3402 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003403 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3404 0 \
3405 -s "Extra-header:" \
3406 -c "HTTP/1.0 200 OK"
3407
Janos Follath74537a62016-09-02 13:45:28 +01003408client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003409run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3410 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003411 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3412 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003413 0 \
3414 -s "Extra-header:" \
3415 -c "HTTP/1.0 200 OK"
3416
Janos Follath74537a62016-09-02 13:45:28 +01003417client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003418run_test "DTLS proxy: 3d, FS, client auth" \
3419 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003420 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3421 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003422 0 \
3423 -s "Extra-header:" \
3424 -c "HTTP/1.0 200 OK"
3425
Janos Follath74537a62016-09-02 13:45:28 +01003426client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003427run_test "DTLS proxy: 3d, FS, ticket" \
3428 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003429 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3430 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003431 0 \
3432 -s "Extra-header:" \
3433 -c "HTTP/1.0 200 OK"
3434
Janos Follath74537a62016-09-02 13:45:28 +01003435client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003436run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3437 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003438 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3439 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003440 0 \
3441 -s "Extra-header:" \
3442 -c "HTTP/1.0 200 OK"
3443
Janos Follath74537a62016-09-02 13:45:28 +01003444client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003445run_test "DTLS proxy: 3d, max handshake, nbio" \
3446 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003447 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3448 auth_mode=required" \
3449 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003450 0 \
3451 -s "Extra-header:" \
3452 -c "HTTP/1.0 200 OK"
3453
Janos Follath74537a62016-09-02 13:45:28 +01003454client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003455run_test "DTLS proxy: 3d, min handshake, resumption" \
3456 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3457 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3458 psk=abc123 debug_level=3" \
3459 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3460 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3461 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3462 0 \
3463 -s "a session has been resumed" \
3464 -c "a session has been resumed" \
3465 -s "Extra-header:" \
3466 -c "HTTP/1.0 200 OK"
3467
Janos Follath74537a62016-09-02 13:45:28 +01003468client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003469run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3470 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3471 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3472 psk=abc123 debug_level=3 nbio=2" \
3473 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3474 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3475 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3476 0 \
3477 -s "a session has been resumed" \
3478 -c "a session has been resumed" \
3479 -s "Extra-header:" \
3480 -c "HTTP/1.0 200 OK"
3481
Janos Follath74537a62016-09-02 13:45:28 +01003482client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003483run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003484 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003485 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3486 psk=abc123 renegotiation=1 debug_level=2" \
3487 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3488 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003489 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3490 0 \
3491 -c "=> renegotiate" \
3492 -s "=> renegotiate" \
3493 -s "Extra-header:" \
3494 -c "HTTP/1.0 200 OK"
3495
Janos Follath74537a62016-09-02 13:45:28 +01003496client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003497run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3498 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003499 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3500 psk=abc123 renegotiation=1 debug_level=2" \
3501 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3502 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003503 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3504 0 \
3505 -c "=> renegotiate" \
3506 -s "=> renegotiate" \
3507 -s "Extra-header:" \
3508 -c "HTTP/1.0 200 OK"
3509
Janos Follath74537a62016-09-02 13:45:28 +01003510client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003511run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003512 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003513 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003514 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003515 debug_level=2" \
3516 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003517 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003518 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3519 0 \
3520 -c "=> renegotiate" \
3521 -s "=> renegotiate" \
3522 -s "Extra-header:" \
3523 -c "HTTP/1.0 200 OK"
3524
Janos Follath74537a62016-09-02 13:45:28 +01003525client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003526run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003527 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003528 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003529 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003530 debug_level=2 nbio=2" \
3531 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003532 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003533 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3534 0 \
3535 -c "=> renegotiate" \
3536 -s "=> renegotiate" \
3537 -s "Extra-header:" \
3538 -c "HTTP/1.0 200 OK"
3539
Janos Follath74537a62016-09-02 13:45:28 +01003540client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003541not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003542run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003543 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3544 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003545 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003546 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003547 -c "HTTP/1.0 200 OK"
3548
Janos Follath74537a62016-09-02 13:45:28 +01003549client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003550not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003551run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3552 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3553 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003554 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003555 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003556 -c "HTTP/1.0 200 OK"
3557
Janos Follath74537a62016-09-02 13:45:28 +01003558client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003559not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003560run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3561 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3562 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003563 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003564 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003565 -c "HTTP/1.0 200 OK"
3566
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003567requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003568client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003569not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003570run_test "DTLS proxy: 3d, gnutls server" \
3571 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3572 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003573 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003574 0 \
3575 -s "Extra-header:" \
3576 -c "Extra-header:"
3577
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003578requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003579client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003580not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003581run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3582 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3583 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003584 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003585 0 \
3586 -s "Extra-header:" \
3587 -c "Extra-header:"
3588
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003589requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003590client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003591not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003592run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3593 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3594 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003595 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003596 0 \
3597 -s "Extra-header:" \
3598 -c "Extra-header:"
3599
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003600# Final report
3601
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003602echo "------------------------------------------------------------------------"
3603
3604if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003605 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003606else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003607 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003608fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003609PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003610echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003611
3612exit $FAILS