blob: 863524200238d649b5111f4c77170e9a38ae4dfe [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"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061}
62
63get_options() {
64 while [ $# -gt 0 ]; do
65 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010066 -f|--filter)
67 shift; FILTER=$1
68 ;;
69 -e|--exclude)
70 shift; EXCLUDE=$1
71 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072 -m|--memcheck)
73 MEMCHECK=1
74 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010075 -n|--number)
76 shift; RUN_TEST_NUMBER=$1
77 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010078 -s|--show-numbers)
79 SHOW_TEST_NUMBER=1
80 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010081 -p|--preserve-logs)
82 PRESERVE_LOGS=1
83 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010084 -h|--help)
85 print_usage
86 exit 0
87 ;;
88 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020089 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010090 print_usage
91 exit 1
92 ;;
93 esac
94 shift
95 done
96}
97
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010098# skip next test if the flag is not enabled in config.h
99requires_config_enabled() {
100 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
101 SKIP_NEXT="YES"
102 fi
103}
104
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200105# skip next test if OpenSSL doesn't support FALLBACK_SCSV
106requires_openssl_with_fallback_scsv() {
107 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
108 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
109 then
110 OPENSSL_HAS_FBSCSV="YES"
111 else
112 OPENSSL_HAS_FBSCSV="NO"
113 fi
114 fi
115 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
116 SKIP_NEXT="YES"
117 fi
118}
119
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200120# skip next test if GnuTLS isn't available
121requires_gnutls() {
122 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200123 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200124 GNUTLS_AVAILABLE="YES"
125 else
126 GNUTLS_AVAILABLE="NO"
127 fi
128 fi
129 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
130 SKIP_NEXT="YES"
131 fi
132}
133
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200134# skip next test if IPv6 isn't available on this host
135requires_ipv6() {
136 if [ -z "${HAS_IPV6:-}" ]; then
137 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
138 SRV_PID=$!
139 sleep 1
140 kill $SRV_PID >/dev/null 2>&1
141 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
142 HAS_IPV6="NO"
143 else
144 HAS_IPV6="YES"
145 fi
146 rm -r $SRV_OUT
147 fi
148
149 if [ "$HAS_IPV6" = "NO" ]; then
150 SKIP_NEXT="YES"
151 fi
152}
153
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200154# skip the next test if valgrind is in use
155not_with_valgrind() {
156 if [ "$MEMCHECK" -gt 0 ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Paul Bakker362689d2016-05-13 10:33:25 +0100161# skip the next test if valgrind is NOT in use
162only_with_valgrind() {
163 if [ "$MEMCHECK" -eq 0 ]; then
164 SKIP_NEXT="YES"
165 fi
166}
167
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200168# multiply the client timeout delay by the given factor for the next test
169needs_more_time() {
170 CLI_DELAY_FACTOR=$1
171}
172
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100173# print_name <name>
174print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100175 TESTS=$(( $TESTS + 1 ))
176 LINE=""
177
178 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
179 LINE="$TESTS "
180 fi
181
182 LINE="$LINE$1"
183 printf "$LINE "
184 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100185 for i in `seq 1 $LEN`; do printf '.'; done
186 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100187
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100188}
189
190# fail <message>
191fail() {
192 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100193 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100194
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200195 mv $SRV_OUT o-srv-${TESTS}.log
196 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200197 if [ -n "$PXY_CMD" ]; then
198 mv $PXY_OUT o-pxy-${TESTS}.log
199 fi
200 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100201
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200202 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
203 echo " ! server output:"
204 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200205 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200206 echo " ! client output:"
207 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200208 if [ -n "$PXY_CMD" ]; then
209 echo " ! ========================================================"
210 echo " ! proxy output:"
211 cat o-pxy-${TESTS}.log
212 fi
213 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200214 fi
215
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200216 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100217}
218
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100219# is_polar <cmd_line>
220is_polar() {
221 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
222}
223
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200224# openssl s_server doesn't have -www with DTLS
225check_osrv_dtls() {
226 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
227 NEEDS_INPUT=1
228 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
229 else
230 NEEDS_INPUT=0
231 fi
232}
233
234# provide input to commands that need it
235provide_input() {
236 if [ $NEEDS_INPUT -eq 0 ]; then
237 return
238 fi
239
240 while true; do
241 echo "HTTP/1.0 200 OK"
242 sleep 1
243 done
244}
245
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100246# has_mem_err <log_file_name>
247has_mem_err() {
248 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
249 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
250 then
251 return 1 # false: does not have errors
252 else
253 return 0 # true: has errors
254 fi
255}
256
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200257# wait for server to start: two versions depending on lsof availability
258wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200259 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200260 START_TIME=$( date +%s )
261 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200262
263 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200264 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200265 while [ $DONE -eq 0 ]; do
266 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
267 then
268 DONE=1
269 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
270 echo "SERVERSTART TIMEOUT"
271 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
272 DONE=1
273 fi
274 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200275 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200276 while [ $DONE -eq 0 ]; do
277 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
278 then
279 DONE=1
280 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
281 echo "SERVERSTART TIMEOUT"
282 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
283 DONE=1
284 fi
285 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200286 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200287 else
288 sleep "$START_DELAY"
289 fi
290}
291
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200292# wait for client to terminate and set CLI_EXIT
293# must be called right after starting the client
294wait_client_done() {
295 CLI_PID=$!
296
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200297 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
298 CLI_DELAY_FACTOR=1
299
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200300 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200301 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200302
303 wait $CLI_PID
304 CLI_EXIT=$?
305
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200306 kill $DOG_PID >/dev/null 2>&1
307 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200308
309 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
310}
311
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200312# check if the given command uses dtls and sets global variable DTLS
313detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200314 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200315 DTLS=1
316 else
317 DTLS=0
318 fi
319}
320
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200321# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100322# Options: -s pattern pattern that must be present in server output
323# -c pattern pattern that must be present in client output
324# -S pattern pattern that must be absent in server output
325# -C pattern pattern that must be absent in client output
326run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100327 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200328 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100329
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100330 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
331 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200332 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100333 return
334 fi
335
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100336 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100337
Paul Bakkerb7584a52016-05-10 10:50:43 +0100338 # Do we only run numbered tests?
339 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
340 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
341 else
342 SKIP_NEXT="YES"
343 fi
344
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200345 # should we skip?
346 if [ "X$SKIP_NEXT" = "XYES" ]; then
347 SKIP_NEXT="NO"
348 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200349 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200350 return
351 fi
352
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200353 # does this test use a proxy?
354 if [ "X$1" = "X-p" ]; then
355 PXY_CMD="$2"
356 shift 2
357 else
358 PXY_CMD=""
359 fi
360
361 # get commands and client output
362 SRV_CMD="$1"
363 CLI_CMD="$2"
364 CLI_EXPECT="$3"
365 shift 3
366
367 # fix client port
368 if [ -n "$PXY_CMD" ]; then
369 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
370 else
371 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
372 fi
373
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200374 # update DTLS variable
375 detect_dtls "$SRV_CMD"
376
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100377 # prepend valgrind to our commands if active
378 if [ "$MEMCHECK" -gt 0 ]; then
379 if is_polar "$SRV_CMD"; then
380 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
381 fi
382 if is_polar "$CLI_CMD"; then
383 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
384 fi
385 fi
386
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200387 TIMES_LEFT=2
388 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200389 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200390
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200391 # run the commands
392 if [ -n "$PXY_CMD" ]; then
393 echo "$PXY_CMD" > $PXY_OUT
394 $PXY_CMD >> $PXY_OUT 2>&1 &
395 PXY_PID=$!
396 # assume proxy starts faster than server
397 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200398
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200399 check_osrv_dtls
400 echo "$SRV_CMD" > $SRV_OUT
401 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
402 SRV_PID=$!
403 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200404
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200405 echo "$CLI_CMD" > $CLI_OUT
406 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
407 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100408
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200409 # terminate the server (and the proxy)
410 kill $SRV_PID
411 wait $SRV_PID
412 if [ -n "$PXY_CMD" ]; then
413 kill $PXY_PID >/dev/null 2>&1
414 wait $PXY_PID
415 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100416
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200417 # retry only on timeouts
418 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
419 printf "RETRY "
420 else
421 TIMES_LEFT=0
422 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200423 done
424
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100425 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200426 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100427 # expected client exit to incorrectly succeed in case of catastrophic
428 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100429 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200430 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100431 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100432 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100433 return
434 fi
435 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100436 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200437 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100438 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100439 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100440 return
441 fi
442 fi
443
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100444 # check server exit code
445 if [ $? != 0 ]; then
446 fail "server fail"
447 return
448 fi
449
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100450 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100451 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
452 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100453 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200454 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100455 return
456 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100457
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100458 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200459 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100460 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100461 while [ $# -gt 0 ]
462 do
463 case $1 in
464 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100465 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 +0100466 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100467 return
468 fi
469 ;;
470
471 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100472 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 +0100473 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100474 return
475 fi
476 ;;
477
478 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100479 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100480 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100481 return
482 fi
483 ;;
484
485 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100486 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100487 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100488 return
489 fi
490 ;;
491
492 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200493 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100494 exit 1
495 esac
496 shift 2
497 done
498
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100499 # check valgrind's results
500 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200501 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100502 fail "Server has memory errors"
503 return
504 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200505 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100506 fail "Client has memory errors"
507 return
508 fi
509 fi
510
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100511 # if we're here, everything is ok
512 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100513 if [ "$PRESERVE_LOGS" -gt 0 ]; then
514 mv $SRV_OUT o-srv-${TESTS}.log
515 mv $CLI_OUT o-cli-${TESTS}.log
516 fi
517
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200518 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100519}
520
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100521cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200522 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200523 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
524 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
525 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
526 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100527 exit 1
528}
529
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100530#
531# MAIN
532#
533
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000534if cd $( dirname $0 ); then :; else
535 echo "cd $( dirname $0 ) failed" >&2
536 exit 1
537fi
538
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100539get_options "$@"
540
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100541# sanity checks, avoid an avalanche of errors
542if [ ! -x "$P_SRV" ]; then
543 echo "Command '$P_SRV' is not an executable file"
544 exit 1
545fi
546if [ ! -x "$P_CLI" ]; then
547 echo "Command '$P_CLI' is not an executable file"
548 exit 1
549fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200550if [ ! -x "$P_PXY" ]; then
551 echo "Command '$P_PXY' is not an executable file"
552 exit 1
553fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100554if [ "$MEMCHECK" -gt 0 ]; then
555 if which valgrind >/dev/null 2>&1; then :; else
556 echo "Memcheck not possible. Valgrind not found"
557 exit 1
558 fi
559fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100560if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
561 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100562 exit 1
563fi
564
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200565# used by watchdog
566MAIN_PID="$$"
567
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200568# be more patient with valgrind
569if [ "$MEMCHECK" -gt 0 ]; then
570 START_DELAY=3
571 DOG_DELAY=30
572else
573 START_DELAY=1
574 DOG_DELAY=10
575fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200576CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200577
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200578# Pick a "unique" server port in the range 10000-19999, and a proxy port
579PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000580PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200581SRV_PORT="1$PORT_BASE"
582PXY_PORT="2$PORT_BASE"
583unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200584
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200585# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000586# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200587P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
588P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
589P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200590O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200591O_CLI="$O_CLI -connect localhost:+SRV_PORT"
592G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000593G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200594
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200595# Also pick a unique name for intermediate files
596SRV_OUT="srv_out.$$"
597CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200598PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200599SESSION="session.$$"
600
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200601SKIP_NEXT="NO"
602
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100603trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100604
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200605# Basic test
606
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200607# Checks that:
608# - things work with all ciphersuites active (used with config-full in all.sh)
609# - the expected (highest security) parameters are selected
610# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200611run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200612 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200613 "$P_CLI" \
614 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200615 -s "Protocol is TLSv1.2" \
616 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
617 -s "client hello v3, signature_algorithm ext: 6" \
618 -s "ECDHE curve: secp521r1" \
619 -S "error" \
620 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200621
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000622run_test "Default, DTLS" \
623 "$P_SRV dtls=1" \
624 "$P_CLI dtls=1" \
625 0 \
626 -s "Protocol is DTLSv1.2" \
627 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
628
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100629# Tests for rc4 option
630
Simon Butchera410af52016-05-19 22:12:18 +0100631requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100632run_test "RC4: server disabled, client enabled" \
633 "$P_SRV" \
634 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
635 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100636 -s "SSL - The server has no ciphersuites in common"
637
Simon Butchera410af52016-05-19 22:12:18 +0100638requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100639run_test "RC4: server half, client enabled" \
640 "$P_SRV arc4=1" \
641 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
642 1 \
643 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100644
645run_test "RC4: server enabled, client disabled" \
646 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
647 "$P_CLI" \
648 1 \
649 -s "SSL - The server has no ciphersuites in common"
650
651run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100652 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100653 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
654 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100655 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100656 -S "SSL - The server has no ciphersuites in common"
657
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100658# Tests for Truncated HMAC extension
659
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100660run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200661 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100662 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100663 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100664 -s "dumping 'computed mac' (20 bytes)" \
665 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100666
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100667run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200668 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100669 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
670 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100671 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100672 -s "dumping 'computed mac' (20 bytes)" \
673 -S "dumping 'computed mac' (10 bytes)"
674
675run_test "Truncated HMAC: client enabled, server default" \
676 "$P_SRV debug_level=4" \
677 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
678 trunc_hmac=1" \
679 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100680 -s "dumping 'computed mac' (20 bytes)" \
681 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100682
683run_test "Truncated HMAC: client enabled, server disabled" \
684 "$P_SRV debug_level=4 trunc_hmac=0" \
685 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
686 trunc_hmac=1" \
687 0 \
688 -s "dumping 'computed mac' (20 bytes)" \
689 -S "dumping 'computed mac' (10 bytes)"
690
691run_test "Truncated HMAC: client enabled, server enabled" \
692 "$P_SRV debug_level=4 trunc_hmac=1" \
693 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
694 trunc_hmac=1" \
695 0 \
696 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100697 -s "dumping 'computed mac' (10 bytes)"
698
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100699# Tests for Encrypt-then-MAC extension
700
701run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100702 "$P_SRV debug_level=3 \
703 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100704 "$P_CLI debug_level=3" \
705 0 \
706 -c "client hello, adding encrypt_then_mac extension" \
707 -s "found encrypt then mac extension" \
708 -s "server hello, adding encrypt then mac extension" \
709 -c "found encrypt_then_mac extension" \
710 -c "using encrypt then mac" \
711 -s "using encrypt then mac"
712
713run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100714 "$P_SRV debug_level=3 etm=0 \
715 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100716 "$P_CLI debug_level=3 etm=1" \
717 0 \
718 -c "client hello, adding encrypt_then_mac extension" \
719 -s "found encrypt then mac extension" \
720 -S "server hello, adding encrypt then mac extension" \
721 -C "found encrypt_then_mac extension" \
722 -C "using encrypt then mac" \
723 -S "using encrypt then mac"
724
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100725run_test "Encrypt then MAC: client enabled, aead cipher" \
726 "$P_SRV debug_level=3 etm=1 \
727 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
728 "$P_CLI debug_level=3 etm=1" \
729 0 \
730 -c "client hello, adding encrypt_then_mac extension" \
731 -s "found encrypt then mac extension" \
732 -S "server hello, adding encrypt then mac extension" \
733 -C "found encrypt_then_mac extension" \
734 -C "using encrypt then mac" \
735 -S "using encrypt then mac"
736
737run_test "Encrypt then MAC: client enabled, stream cipher" \
738 "$P_SRV debug_level=3 etm=1 \
739 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100740 "$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 +0100741 0 \
742 -c "client hello, adding encrypt_then_mac extension" \
743 -s "found encrypt then mac extension" \
744 -S "server hello, adding encrypt then mac extension" \
745 -C "found encrypt_then_mac extension" \
746 -C "using encrypt then mac" \
747 -S "using encrypt then mac"
748
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100749run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100750 "$P_SRV debug_level=3 etm=1 \
751 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100752 "$P_CLI debug_level=3 etm=0" \
753 0 \
754 -C "client hello, adding encrypt_then_mac extension" \
755 -S "found encrypt then mac extension" \
756 -S "server hello, adding encrypt then mac extension" \
757 -C "found encrypt_then_mac extension" \
758 -C "using encrypt then mac" \
759 -S "using encrypt then mac"
760
Janos Follathe2681a42016-03-07 15:57:05 +0000761requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100762run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100763 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100764 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100765 "$P_CLI debug_level=3 force_version=ssl3" \
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 enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100776 "$P_SRV debug_level=3 force_version=ssl3 \
777 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100778 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100779 0 \
780 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100781 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100782 -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
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200787# Tests for Extended Master Secret extension
788
789run_test "Extended Master Secret: default" \
790 "$P_SRV debug_level=3" \
791 "$P_CLI debug_level=3" \
792 0 \
793 -c "client hello, adding extended_master_secret extension" \
794 -s "found extended master secret extension" \
795 -s "server hello, adding extended master secret extension" \
796 -c "found extended_master_secret extension" \
797 -c "using extended master secret" \
798 -s "using extended master secret"
799
800run_test "Extended Master Secret: client enabled, server disabled" \
801 "$P_SRV debug_level=3 extended_ms=0" \
802 "$P_CLI debug_level=3 extended_ms=1" \
803 0 \
804 -c "client hello, adding extended_master_secret extension" \
805 -s "found extended master secret extension" \
806 -S "server hello, adding extended master secret extension" \
807 -C "found extended_master_secret extension" \
808 -C "using extended master secret" \
809 -S "using extended master secret"
810
811run_test "Extended Master Secret: client disabled, server enabled" \
812 "$P_SRV debug_level=3 extended_ms=1" \
813 "$P_CLI debug_level=3 extended_ms=0" \
814 0 \
815 -C "client hello, adding extended_master_secret extension" \
816 -S "found extended master secret extension" \
817 -S "server hello, adding extended master secret extension" \
818 -C "found extended_master_secret extension" \
819 -C "using extended master secret" \
820 -S "using extended master secret"
821
Janos Follathe2681a42016-03-07 15:57:05 +0000822requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200823run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100824 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200825 "$P_CLI debug_level=3 force_version=ssl3" \
826 0 \
827 -C "client hello, adding extended_master_secret extension" \
828 -S "found extended master secret extension" \
829 -S "server hello, adding extended master secret extension" \
830 -C "found extended_master_secret extension" \
831 -C "using extended master secret" \
832 -S "using extended master secret"
833
Janos Follathe2681a42016-03-07 15:57:05 +0000834requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200835run_test "Extended Master Secret: client enabled, server SSLv3" \
836 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100837 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200838 0 \
839 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100840 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200841 -S "server hello, adding extended master secret extension" \
842 -C "found extended_master_secret extension" \
843 -C "using extended master secret" \
844 -S "using extended master secret"
845
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200846# Tests for FALLBACK_SCSV
847
848run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200849 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200850 "$P_CLI debug_level=3 force_version=tls1_1" \
851 0 \
852 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200853 -S "received FALLBACK_SCSV" \
854 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200855 -C "is a fatal alert message (msg 86)"
856
857run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200858 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200859 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
860 0 \
861 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200862 -S "received FALLBACK_SCSV" \
863 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200864 -C "is a fatal alert message (msg 86)"
865
866run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200867 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200868 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200869 1 \
870 -c "adding FALLBACK_SCSV" \
871 -s "received FALLBACK_SCSV" \
872 -s "inapropriate fallback" \
873 -c "is a fatal alert message (msg 86)"
874
875run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200876 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200877 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200878 0 \
879 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200880 -s "received FALLBACK_SCSV" \
881 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200882 -C "is a fatal alert message (msg 86)"
883
884requires_openssl_with_fallback_scsv
885run_test "Fallback SCSV: default, openssl server" \
886 "$O_SRV" \
887 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
888 0 \
889 -C "adding FALLBACK_SCSV" \
890 -C "is a fatal alert message (msg 86)"
891
892requires_openssl_with_fallback_scsv
893run_test "Fallback SCSV: enabled, openssl server" \
894 "$O_SRV" \
895 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
896 1 \
897 -c "adding FALLBACK_SCSV" \
898 -c "is a fatal alert message (msg 86)"
899
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200900requires_openssl_with_fallback_scsv
901run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200902 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200903 "$O_CLI -tls1_1" \
904 0 \
905 -S "received FALLBACK_SCSV" \
906 -S "inapropriate fallback"
907
908requires_openssl_with_fallback_scsv
909run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200910 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200911 "$O_CLI -tls1_1 -fallback_scsv" \
912 1 \
913 -s "received FALLBACK_SCSV" \
914 -s "inapropriate fallback"
915
916requires_openssl_with_fallback_scsv
917run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200918 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200919 "$O_CLI -fallback_scsv" \
920 0 \
921 -s "received FALLBACK_SCSV" \
922 -S "inapropriate fallback"
923
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100924# Tests for CBC 1/n-1 record splitting
925
926run_test "CBC Record splitting: TLS 1.2, no splitting" \
927 "$P_SRV" \
928 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
929 request_size=123 force_version=tls1_2" \
930 0 \
931 -s "Read from client: 123 bytes read" \
932 -S "Read from client: 1 bytes read" \
933 -S "122 bytes read"
934
935run_test "CBC Record splitting: TLS 1.1, no splitting" \
936 "$P_SRV" \
937 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
938 request_size=123 force_version=tls1_1" \
939 0 \
940 -s "Read from client: 123 bytes read" \
941 -S "Read from client: 1 bytes read" \
942 -S "122 bytes read"
943
944run_test "CBC Record splitting: TLS 1.0, splitting" \
945 "$P_SRV" \
946 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
947 request_size=123 force_version=tls1" \
948 0 \
949 -S "Read from client: 123 bytes read" \
950 -s "Read from client: 1 bytes read" \
951 -s "122 bytes read"
952
Janos Follathe2681a42016-03-07 15:57:05 +0000953requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100954run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100955 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100956 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
957 request_size=123 force_version=ssl3" \
958 0 \
959 -S "Read from client: 123 bytes read" \
960 -s "Read from client: 1 bytes read" \
961 -s "122 bytes read"
962
963run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100964 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100965 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
966 request_size=123 force_version=tls1" \
967 0 \
968 -s "Read from client: 123 bytes read" \
969 -S "Read from client: 1 bytes read" \
970 -S "122 bytes read"
971
972run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
973 "$P_SRV" \
974 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
975 request_size=123 force_version=tls1 recsplit=0" \
976 0 \
977 -s "Read from client: 123 bytes read" \
978 -S "Read from client: 1 bytes read" \
979 -S "122 bytes read"
980
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100981run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
982 "$P_SRV nbio=2" \
983 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
984 request_size=123 force_version=tls1" \
985 0 \
986 -S "Read from client: 123 bytes read" \
987 -s "Read from client: 1 bytes read" \
988 -s "122 bytes read"
989
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100990# Tests for Session Tickets
991
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200992run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200993 "$P_SRV debug_level=3 tickets=1" \
994 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100995 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100996 -c "client hello, adding session ticket extension" \
997 -s "found session ticket extension" \
998 -s "server hello, adding session ticket extension" \
999 -c "found session_ticket extension" \
1000 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001001 -S "session successfully restored from cache" \
1002 -s "session successfully restored from ticket" \
1003 -s "a session has been resumed" \
1004 -c "a session has been resumed"
1005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001006run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001007 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1008 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001009 0 \
1010 -c "client hello, adding session ticket extension" \
1011 -s "found session ticket extension" \
1012 -s "server hello, adding session ticket extension" \
1013 -c "found session_ticket extension" \
1014 -c "parse new session ticket" \
1015 -S "session successfully restored from cache" \
1016 -s "session successfully restored from ticket" \
1017 -s "a session has been resumed" \
1018 -c "a session has been resumed"
1019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001020run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001021 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1022 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001023 0 \
1024 -c "client hello, adding session ticket extension" \
1025 -s "found session ticket extension" \
1026 -s "server hello, adding session ticket extension" \
1027 -c "found session_ticket extension" \
1028 -c "parse new session ticket" \
1029 -S "session successfully restored from cache" \
1030 -S "session successfully restored from ticket" \
1031 -S "a session has been resumed" \
1032 -C "a session has been resumed"
1033
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001034run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001035 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001036 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001037 0 \
1038 -c "client hello, adding session ticket extension" \
1039 -c "found session_ticket extension" \
1040 -c "parse new session ticket" \
1041 -c "a session has been resumed"
1042
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001043run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001044 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001045 "( $O_CLI -sess_out $SESSION; \
1046 $O_CLI -sess_in $SESSION; \
1047 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001048 0 \
1049 -s "found session ticket extension" \
1050 -s "server hello, adding session ticket extension" \
1051 -S "session successfully restored from cache" \
1052 -s "session successfully restored from ticket" \
1053 -s "a session has been resumed"
1054
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001055# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001056
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001057run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001058 "$P_SRV debug_level=3 tickets=0" \
1059 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001060 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001061 -c "client hello, adding session ticket extension" \
1062 -s "found session ticket extension" \
1063 -S "server hello, adding session ticket extension" \
1064 -C "found session_ticket extension" \
1065 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001066 -s "session successfully restored from cache" \
1067 -S "session successfully restored from ticket" \
1068 -s "a session has been resumed" \
1069 -c "a session has been resumed"
1070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001071run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001072 "$P_SRV debug_level=3 tickets=1" \
1073 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001074 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001075 -C "client hello, adding session ticket extension" \
1076 -S "found session ticket extension" \
1077 -S "server hello, adding session ticket extension" \
1078 -C "found session_ticket extension" \
1079 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001080 -s "session successfully restored from cache" \
1081 -S "session successfully restored from ticket" \
1082 -s "a session has been resumed" \
1083 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001085run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001086 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1087 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001088 0 \
1089 -S "session successfully restored from cache" \
1090 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001091 -S "a session has been resumed" \
1092 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001094run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001095 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1096 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001097 0 \
1098 -s "session successfully restored from cache" \
1099 -S "session successfully restored from ticket" \
1100 -s "a session has been resumed" \
1101 -c "a session has been resumed"
1102
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001103run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001104 "$P_SRV debug_level=3 tickets=0" \
1105 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001106 0 \
1107 -s "session successfully restored from cache" \
1108 -S "session successfully restored from ticket" \
1109 -s "a session has been resumed" \
1110 -c "a session has been resumed"
1111
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001112run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001113 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1114 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001115 0 \
1116 -S "session successfully restored from cache" \
1117 -S "session successfully restored from ticket" \
1118 -S "a session has been resumed" \
1119 -C "a session has been resumed"
1120
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001121run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001122 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1123 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001124 0 \
1125 -s "session successfully restored from cache" \
1126 -S "session successfully restored from ticket" \
1127 -s "a session has been resumed" \
1128 -c "a session has been resumed"
1129
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001130run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001131 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001132 "( $O_CLI -sess_out $SESSION; \
1133 $O_CLI -sess_in $SESSION; \
1134 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001135 0 \
1136 -s "found session ticket extension" \
1137 -S "server hello, adding session ticket extension" \
1138 -s "session successfully restored from cache" \
1139 -S "session successfully restored from ticket" \
1140 -s "a session has been resumed"
1141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001142run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001143 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001144 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001145 0 \
1146 -C "found session_ticket extension" \
1147 -C "parse new session ticket" \
1148 -c "a session has been resumed"
1149
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001150# Tests for Max Fragment Length extension
1151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001152run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001153 "$P_SRV debug_level=3" \
1154 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001155 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001156 -c "Maximum fragment length is 16384" \
1157 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001158 -C "client hello, adding max_fragment_length extension" \
1159 -S "found max fragment length extension" \
1160 -S "server hello, max_fragment_length extension" \
1161 -C "found max_fragment_length extension"
1162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001163run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001164 "$P_SRV debug_level=3" \
1165 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001166 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001167 -c "Maximum fragment length is 4096" \
1168 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001169 -c "client hello, adding max_fragment_length extension" \
1170 -s "found max fragment length extension" \
1171 -s "server hello, max_fragment_length extension" \
1172 -c "found max_fragment_length extension"
1173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001174run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001175 "$P_SRV debug_level=3 max_frag_len=4096" \
1176 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001177 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001178 -c "Maximum fragment length is 16384" \
1179 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001180 -C "client hello, adding max_fragment_length extension" \
1181 -S "found max fragment length extension" \
1182 -S "server hello, max_fragment_length extension" \
1183 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001185requires_gnutls
1186run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001187 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001188 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001189 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001190 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001191 -c "client hello, adding max_fragment_length extension" \
1192 -c "found max_fragment_length extension"
1193
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001194run_test "Max fragment length: client, message just fits" \
1195 "$P_SRV debug_level=3" \
1196 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1197 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001198 -c "Maximum fragment length is 2048" \
1199 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001200 -c "client hello, adding max_fragment_length extension" \
1201 -s "found max fragment length extension" \
1202 -s "server hello, max_fragment_length extension" \
1203 -c "found max_fragment_length extension" \
1204 -c "2048 bytes written in 1 fragments" \
1205 -s "2048 bytes read"
1206
1207run_test "Max fragment length: client, larger message" \
1208 "$P_SRV debug_level=3" \
1209 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
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 "2345 bytes written in 2 fragments" \
1218 -s "2048 bytes read" \
1219 -s "297 bytes read"
1220
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001221run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001222 "$P_SRV debug_level=3 dtls=1" \
1223 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1224 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001225 -c "Maximum fragment length is 2048" \
1226 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001227 -c "client hello, adding max_fragment_length extension" \
1228 -s "found max fragment length extension" \
1229 -s "server hello, max_fragment_length extension" \
1230 -c "found max_fragment_length extension" \
1231 -c "fragment larger than.*maximum"
1232
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001233# Tests for renegotiation
1234
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001235run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001236 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001237 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001238 0 \
1239 -C "client hello, adding renegotiation extension" \
1240 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1241 -S "found renegotiation extension" \
1242 -s "server hello, secure renegotiation extension" \
1243 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001244 -C "=> renegotiate" \
1245 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001246 -S "write hello request"
1247
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001248run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001249 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001250 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
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: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001262 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001263 "$P_CLI debug_level=3 exchanges=2 renegotiation=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: double" \
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 renegotiate=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: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001288 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
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 1 \
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é-Gonnardfae355e2014-07-04 14:32:27 +02001298 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001299 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001300 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001302run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001303 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001304 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001305 0 \
1306 -C "client hello, adding renegotiation extension" \
1307 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1308 -S "found renegotiation extension" \
1309 -s "server hello, secure renegotiation extension" \
1310 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001311 -C "=> renegotiate" \
1312 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001313 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001314 -S "SSL - An unexpected message was received from our peer" \
1315 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001317run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001318 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001319 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001320 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001321 0 \
1322 -C "client hello, adding renegotiation extension" \
1323 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1324 -S "found renegotiation extension" \
1325 -s "server hello, secure renegotiation extension" \
1326 -c "found renegotiation extension" \
1327 -C "=> renegotiate" \
1328 -S "=> renegotiate" \
1329 -s "write hello request" \
1330 -S "SSL - An unexpected message was received from our peer" \
1331 -S "failed"
1332
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001333# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001334run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001335 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001336 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001337 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001338 0 \
1339 -C "client hello, adding renegotiation extension" \
1340 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1341 -S "found renegotiation extension" \
1342 -s "server hello, secure renegotiation extension" \
1343 -c "found renegotiation extension" \
1344 -C "=> renegotiate" \
1345 -S "=> renegotiate" \
1346 -s "write hello request" \
1347 -S "SSL - An unexpected message was received from our peer" \
1348 -S "failed"
1349
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001350run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001351 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001352 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001353 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001354 0 \
1355 -C "client hello, adding renegotiation extension" \
1356 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1357 -S "found renegotiation extension" \
1358 -s "server hello, secure renegotiation extension" \
1359 -c "found renegotiation extension" \
1360 -C "=> renegotiate" \
1361 -S "=> renegotiate" \
1362 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001363 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001364
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001365run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001366 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001367 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001368 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001369 0 \
1370 -c "client hello, adding renegotiation extension" \
1371 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1372 -s "found renegotiation extension" \
1373 -s "server hello, secure renegotiation extension" \
1374 -c "found renegotiation extension" \
1375 -c "=> renegotiate" \
1376 -s "=> renegotiate" \
1377 -s "write hello request" \
1378 -S "SSL - An unexpected message was received from our peer" \
1379 -S "failed"
1380
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001381run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001382 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001383 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1384 0 \
1385 -C "client hello, adding renegotiation extension" \
1386 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1387 -S "found renegotiation extension" \
1388 -s "server hello, secure renegotiation extension" \
1389 -c "found renegotiation extension" \
1390 -S "record counter limit reached: renegotiate" \
1391 -C "=> renegotiate" \
1392 -S "=> renegotiate" \
1393 -S "write hello request" \
1394 -S "SSL - An unexpected message was received from our peer" \
1395 -S "failed"
1396
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001397# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001398run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001399 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001400 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001401 0 \
1402 -c "client hello, adding renegotiation extension" \
1403 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1404 -s "found renegotiation extension" \
1405 -s "server hello, secure renegotiation extension" \
1406 -c "found renegotiation extension" \
1407 -s "record counter limit reached: renegotiate" \
1408 -c "=> renegotiate" \
1409 -s "=> renegotiate" \
1410 -s "write hello request" \
1411 -S "SSL - An unexpected message was received from our peer" \
1412 -S "failed"
1413
1414run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001415 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001416 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001417 0 \
1418 -c "client hello, adding renegotiation extension" \
1419 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1420 -s "found renegotiation extension" \
1421 -s "server hello, secure renegotiation extension" \
1422 -c "found renegotiation extension" \
1423 -s "record counter limit reached: renegotiate" \
1424 -c "=> renegotiate" \
1425 -s "=> renegotiate" \
1426 -s "write hello request" \
1427 -S "SSL - An unexpected message was received from our peer" \
1428 -S "failed"
1429
1430run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001431 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001432 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1433 0 \
1434 -C "client hello, adding renegotiation extension" \
1435 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1436 -S "found renegotiation extension" \
1437 -s "server hello, secure renegotiation extension" \
1438 -c "found renegotiation extension" \
1439 -S "record counter limit reached: renegotiate" \
1440 -C "=> renegotiate" \
1441 -S "=> renegotiate" \
1442 -S "write hello request" \
1443 -S "SSL - An unexpected message was received from our peer" \
1444 -S "failed"
1445
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001446run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001447 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001448 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001449 0 \
1450 -c "client hello, adding renegotiation extension" \
1451 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1452 -s "found renegotiation extension" \
1453 -s "server hello, secure renegotiation extension" \
1454 -c "found renegotiation extension" \
1455 -c "=> renegotiate" \
1456 -s "=> renegotiate" \
1457 -S "write hello request"
1458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001459run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001460 "$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 +02001461 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=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: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001473 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001474 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001475 0 \
1476 -c "client hello, adding renegotiation extension" \
1477 -c "found renegotiation extension" \
1478 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001479 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001480 -C "error" \
1481 -c "HTTP/1.0 200 [Oo][Kk]"
1482
Paul Bakker539d9722015-02-08 16:18:35 +01001483requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001484run_test "Renegotiation: gnutls server strict, client-initiated" \
1485 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001486 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001487 0 \
1488 -c "client hello, adding renegotiation extension" \
1489 -c "found renegotiation extension" \
1490 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001491 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001492 -C "error" \
1493 -c "HTTP/1.0 200 [Oo][Kk]"
1494
Paul Bakker539d9722015-02-08 16:18:35 +01001495requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001496run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1497 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1498 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1499 1 \
1500 -c "client hello, adding renegotiation extension" \
1501 -C "found renegotiation extension" \
1502 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001503 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001504 -c "error" \
1505 -C "HTTP/1.0 200 [Oo][Kk]"
1506
Paul Bakker539d9722015-02-08 16:18:35 +01001507requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001508run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1509 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1510 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1511 allow_legacy=0" \
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 legacy" \
1522 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1523 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1524 allow_legacy=1" \
1525 0 \
1526 -c "client hello, adding renegotiation extension" \
1527 -C "found renegotiation extension" \
1528 -c "=> renegotiate" \
1529 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001530 -C "error" \
1531 -c "HTTP/1.0 200 [Oo][Kk]"
1532
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001533run_test "Renegotiation: DTLS, client-initiated" \
1534 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1535 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1536 0 \
1537 -c "client hello, adding renegotiation extension" \
1538 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1539 -s "found renegotiation extension" \
1540 -s "server hello, secure renegotiation extension" \
1541 -c "found renegotiation extension" \
1542 -c "=> renegotiate" \
1543 -s "=> renegotiate" \
1544 -S "write hello request"
1545
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001546run_test "Renegotiation: DTLS, server-initiated" \
1547 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001548 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1549 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001550 0 \
1551 -c "client hello, adding renegotiation extension" \
1552 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1553 -s "found renegotiation extension" \
1554 -s "server hello, secure renegotiation extension" \
1555 -c "found renegotiation extension" \
1556 -c "=> renegotiate" \
1557 -s "=> renegotiate" \
1558 -s "write hello request"
1559
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001560requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001561run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1562 "$G_SRV -u --mtu 4096" \
1563 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1564 0 \
1565 -c "client hello, adding renegotiation extension" \
1566 -c "found renegotiation extension" \
1567 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001568 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001569 -C "error" \
1570 -s "Extra-header:"
1571
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001572# Test for the "secure renegotation" extension only (no actual renegotiation)
1573
Paul Bakker539d9722015-02-08 16:18:35 +01001574requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001575run_test "Renego ext: gnutls server strict, client default" \
1576 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1577 "$P_CLI debug_level=3" \
1578 0 \
1579 -c "found renegotiation extension" \
1580 -C "error" \
1581 -c "HTTP/1.0 200 [Oo][Kk]"
1582
Paul Bakker539d9722015-02-08 16:18:35 +01001583requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001584run_test "Renego ext: gnutls server unsafe, client default" \
1585 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1586 "$P_CLI debug_level=3" \
1587 0 \
1588 -C "found renegotiation extension" \
1589 -C "error" \
1590 -c "HTTP/1.0 200 [Oo][Kk]"
1591
Paul Bakker539d9722015-02-08 16:18:35 +01001592requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001593run_test "Renego ext: gnutls server unsafe, client break legacy" \
1594 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1595 "$P_CLI debug_level=3 allow_legacy=-1" \
1596 1 \
1597 -C "found renegotiation extension" \
1598 -c "error" \
1599 -C "HTTP/1.0 200 [Oo][Kk]"
1600
Paul Bakker539d9722015-02-08 16:18:35 +01001601requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001602run_test "Renego ext: gnutls client strict, server default" \
1603 "$P_SRV debug_level=3" \
1604 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1605 0 \
1606 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1607 -s "server hello, secure renegotiation extension"
1608
Paul Bakker539d9722015-02-08 16:18:35 +01001609requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001610run_test "Renego ext: gnutls client unsafe, server default" \
1611 "$P_SRV debug_level=3" \
1612 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1613 0 \
1614 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1615 -S "server hello, secure renegotiation extension"
1616
Paul Bakker539d9722015-02-08 16:18:35 +01001617requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001618run_test "Renego ext: gnutls client unsafe, server break legacy" \
1619 "$P_SRV debug_level=3 allow_legacy=-1" \
1620 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1621 1 \
1622 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1623 -S "server hello, secure renegotiation extension"
1624
Janos Follath0b242342016-02-17 10:11:21 +00001625# Tests for silently dropping trailing extra bytes in .der certificates
1626
1627requires_gnutls
1628run_test "DER format: no trailing bytes" \
1629 "$P_SRV crt_file=data_files/server5-der0.crt \
1630 key_file=data_files/server5.key" \
1631 "$G_CLI " \
1632 0 \
1633 -c "Handshake was completed" \
1634
1635requires_gnutls
1636run_test "DER format: with a trailing zero byte" \
1637 "$P_SRV crt_file=data_files/server5-der1a.crt \
1638 key_file=data_files/server5.key" \
1639 "$G_CLI " \
1640 0 \
1641 -c "Handshake was completed" \
1642
1643requires_gnutls
1644run_test "DER format: with a trailing random byte" \
1645 "$P_SRV crt_file=data_files/server5-der1b.crt \
1646 key_file=data_files/server5.key" \
1647 "$G_CLI " \
1648 0 \
1649 -c "Handshake was completed" \
1650
1651requires_gnutls
1652run_test "DER format: with 2 trailing random bytes" \
1653 "$P_SRV crt_file=data_files/server5-der2.crt \
1654 key_file=data_files/server5.key" \
1655 "$G_CLI " \
1656 0 \
1657 -c "Handshake was completed" \
1658
1659requires_gnutls
1660run_test "DER format: with 4 trailing random bytes" \
1661 "$P_SRV crt_file=data_files/server5-der4.crt \
1662 key_file=data_files/server5.key" \
1663 "$G_CLI " \
1664 0 \
1665 -c "Handshake was completed" \
1666
1667requires_gnutls
1668run_test "DER format: with 8 trailing random bytes" \
1669 "$P_SRV crt_file=data_files/server5-der8.crt \
1670 key_file=data_files/server5.key" \
1671 "$G_CLI " \
1672 0 \
1673 -c "Handshake was completed" \
1674
1675requires_gnutls
1676run_test "DER format: with 9 trailing random bytes" \
1677 "$P_SRV crt_file=data_files/server5-der9.crt \
1678 key_file=data_files/server5.key" \
1679 "$G_CLI " \
1680 0 \
1681 -c "Handshake was completed" \
1682
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001683# Tests for auth_mode
1684
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001685run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001686 "$P_SRV crt_file=data_files/server5-badsign.crt \
1687 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001688 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001689 1 \
1690 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001691 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001692 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001693 -c "X509 - Certificate verification failed"
1694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001695run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001696 "$P_SRV crt_file=data_files/server5-badsign.crt \
1697 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001698 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001699 0 \
1700 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001701 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001702 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001703 -C "X509 - Certificate verification failed"
1704
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001705run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001706 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001707 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001708 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001709 0 \
1710 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001711 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001712 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001713 -C "X509 - Certificate verification failed"
1714
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001715run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001716 "$P_SRV debug_level=3 auth_mode=required" \
1717 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001718 key_file=data_files/server5.key" \
1719 1 \
1720 -S "skip write certificate request" \
1721 -C "skip parse certificate request" \
1722 -c "got a certificate request" \
1723 -C "skip write certificate" \
1724 -C "skip write certificate verify" \
1725 -S "skip parse certificate verify" \
1726 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001727 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001728 -s "! mbedtls_ssl_handshake returned" \
1729 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001730 -s "X509 - Certificate verification failed"
1731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001732run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001733 "$P_SRV debug_level=3 auth_mode=optional" \
1734 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001735 key_file=data_files/server5.key" \
1736 0 \
1737 -S "skip write certificate request" \
1738 -C "skip parse certificate request" \
1739 -c "got a certificate request" \
1740 -C "skip write certificate" \
1741 -C "skip write certificate verify" \
1742 -S "skip parse certificate verify" \
1743 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001744 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001745 -S "! mbedtls_ssl_handshake returned" \
1746 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001747 -S "X509 - Certificate verification failed"
1748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001749run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001750 "$P_SRV debug_level=3 auth_mode=none" \
1751 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001752 key_file=data_files/server5.key" \
1753 0 \
1754 -s "skip write certificate request" \
1755 -C "skip parse certificate request" \
1756 -c "got no certificate request" \
1757 -c "skip write certificate" \
1758 -c "skip write certificate verify" \
1759 -s "skip parse certificate verify" \
1760 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001761 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001762 -S "! mbedtls_ssl_handshake returned" \
1763 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001764 -S "X509 - Certificate verification failed"
1765
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001766run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001767 "$P_SRV debug_level=3 auth_mode=optional" \
1768 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001769 0 \
1770 -S "skip write certificate request" \
1771 -C "skip parse certificate request" \
1772 -c "got a certificate request" \
1773 -C "skip write certificate$" \
1774 -C "got no certificate to send" \
1775 -S "SSLv3 client has no certificate" \
1776 -c "skip write certificate verify" \
1777 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001778 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001779 -S "! mbedtls_ssl_handshake returned" \
1780 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001781 -S "X509 - Certificate verification failed"
1782
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001783run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001784 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001785 "$O_CLI" \
1786 0 \
1787 -S "skip write certificate request" \
1788 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001789 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001790 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001791 -S "X509 - Certificate verification failed"
1792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001793run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001794 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001795 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001796 0 \
1797 -C "skip parse certificate request" \
1798 -c "got a certificate request" \
1799 -C "skip write certificate$" \
1800 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001801 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001802
Janos Follathe2681a42016-03-07 15:57:05 +00001803requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001804run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001805 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001806 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001807 0 \
1808 -S "skip write certificate request" \
1809 -C "skip parse certificate request" \
1810 -c "got a certificate request" \
1811 -C "skip write certificate$" \
1812 -c "skip write certificate verify" \
1813 -c "got no certificate to send" \
1814 -s "SSLv3 client has no certificate" \
1815 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001816 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001817 -S "! mbedtls_ssl_handshake returned" \
1818 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001819 -S "X509 - Certificate verification failed"
1820
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001821# Tests for certificate selection based on SHA verson
1822
1823run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1824 "$P_SRV crt_file=data_files/server5.crt \
1825 key_file=data_files/server5.key \
1826 crt_file2=data_files/server5-sha1.crt \
1827 key_file2=data_files/server5.key" \
1828 "$P_CLI force_version=tls1_2" \
1829 0 \
1830 -c "signed using.*ECDSA with SHA256" \
1831 -C "signed using.*ECDSA with SHA1"
1832
1833run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1834 "$P_SRV crt_file=data_files/server5.crt \
1835 key_file=data_files/server5.key \
1836 crt_file2=data_files/server5-sha1.crt \
1837 key_file2=data_files/server5.key" \
1838 "$P_CLI force_version=tls1_1" \
1839 0 \
1840 -C "signed using.*ECDSA with SHA256" \
1841 -c "signed using.*ECDSA with SHA1"
1842
1843run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1844 "$P_SRV crt_file=data_files/server5.crt \
1845 key_file=data_files/server5.key \
1846 crt_file2=data_files/server5-sha1.crt \
1847 key_file2=data_files/server5.key" \
1848 "$P_CLI force_version=tls1" \
1849 0 \
1850 -C "signed using.*ECDSA with SHA256" \
1851 -c "signed using.*ECDSA with SHA1"
1852
1853run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1854 "$P_SRV crt_file=data_files/server5.crt \
1855 key_file=data_files/server5.key \
1856 crt_file2=data_files/server6.crt \
1857 key_file2=data_files/server6.key" \
1858 "$P_CLI force_version=tls1_1" \
1859 0 \
1860 -c "serial number.*09" \
1861 -c "signed using.*ECDSA with SHA256" \
1862 -C "signed using.*ECDSA with SHA1"
1863
1864run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1865 "$P_SRV crt_file=data_files/server6.crt \
1866 key_file=data_files/server6.key \
1867 crt_file2=data_files/server5.crt \
1868 key_file2=data_files/server5.key" \
1869 "$P_CLI force_version=tls1_1" \
1870 0 \
1871 -c "serial number.*0A" \
1872 -c "signed using.*ECDSA with SHA256" \
1873 -C "signed using.*ECDSA with SHA1"
1874
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001875# tests for SNI
1876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001877run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001878 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001879 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001880 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001881 0 \
1882 -S "parse ServerName extension" \
1883 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1884 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001885
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001886run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001887 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001888 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001889 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 +02001890 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001891 0 \
1892 -s "parse ServerName extension" \
1893 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1894 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001896run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001897 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001898 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001899 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 +02001900 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001901 0 \
1902 -s "parse ServerName extension" \
1903 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1904 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001905
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001906run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001907 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001908 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001909 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 +02001910 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001911 1 \
1912 -s "parse ServerName extension" \
1913 -s "ssl_sni_wrapper() returned" \
1914 -s "mbedtls_ssl_handshake returned" \
1915 -c "mbedtls_ssl_handshake returned" \
1916 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001917
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001918run_test "SNI: client auth no override: optional" \
1919 "$P_SRV debug_level=3 auth_mode=optional \
1920 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1921 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1922 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001923 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001924 -S "skip write certificate request" \
1925 -C "skip parse certificate request" \
1926 -c "got a certificate request" \
1927 -C "skip write certificate" \
1928 -C "skip write certificate verify" \
1929 -S "skip parse certificate verify"
1930
1931run_test "SNI: client auth override: none -> optional" \
1932 "$P_SRV debug_level=3 auth_mode=none \
1933 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1934 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
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: optional -> none" \
1945 "$P_SRV debug_level=3 auth_mode=optional \
1946 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1947 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
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 no certificate request" \
1953 -c "skip write certificate" \
1954 -c "skip write certificate verify" \
1955 -s "skip parse certificate verify"
1956
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001957run_test "SNI: CA no override" \
1958 "$P_SRV debug_level=3 auth_mode=optional \
1959 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1960 ca_file=data_files/test-ca.crt \
1961 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1962 "$P_CLI debug_level=3 server_name=localhost \
1963 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1964 1 \
1965 -S "skip write certificate request" \
1966 -C "skip parse certificate request" \
1967 -c "got a certificate request" \
1968 -C "skip write certificate" \
1969 -C "skip write certificate verify" \
1970 -S "skip parse certificate verify" \
1971 -s "x509_verify_cert() returned" \
1972 -s "! The certificate is not correctly signed by the trusted CA" \
1973 -S "The certificate has been revoked (is on a CRL)"
1974
1975run_test "SNI: CA override" \
1976 "$P_SRV debug_level=3 auth_mode=optional \
1977 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1978 ca_file=data_files/test-ca.crt \
1979 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1980 "$P_CLI debug_level=3 server_name=localhost \
1981 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1982 0 \
1983 -S "skip write certificate request" \
1984 -C "skip parse certificate request" \
1985 -c "got a certificate request" \
1986 -C "skip write certificate" \
1987 -C "skip write certificate verify" \
1988 -S "skip parse certificate verify" \
1989 -S "x509_verify_cert() returned" \
1990 -S "! The certificate is not correctly signed by the trusted CA" \
1991 -S "The certificate has been revoked (is on a CRL)"
1992
1993run_test "SNI: CA override with CRL" \
1994 "$P_SRV debug_level=3 auth_mode=optional \
1995 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1996 ca_file=data_files/test-ca.crt \
1997 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1998 "$P_CLI debug_level=3 server_name=localhost \
1999 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2000 1 \
2001 -S "skip write certificate request" \
2002 -C "skip parse certificate request" \
2003 -c "got a certificate request" \
2004 -C "skip write certificate" \
2005 -C "skip write certificate verify" \
2006 -S "skip parse certificate verify" \
2007 -s "x509_verify_cert() returned" \
2008 -S "! The certificate is not correctly signed by the trusted CA" \
2009 -s "The certificate has been revoked (is on a CRL)"
2010
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002011# Tests for non-blocking I/O: exercise a variety of handshake flows
2012
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002013run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002014 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2015 "$P_CLI nbio=2 tickets=0" \
2016 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002017 -S "mbedtls_ssl_handshake returned" \
2018 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002019 -c "Read from server: .* bytes read"
2020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002021run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002022 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2023 "$P_CLI nbio=2 tickets=0" \
2024 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002025 -S "mbedtls_ssl_handshake returned" \
2026 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002027 -c "Read from server: .* bytes read"
2028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002029run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002030 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2031 "$P_CLI nbio=2 tickets=1" \
2032 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002033 -S "mbedtls_ssl_handshake returned" \
2034 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002035 -c "Read from server: .* bytes read"
2036
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002037run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002038 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2039 "$P_CLI nbio=2 tickets=1" \
2040 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002041 -S "mbedtls_ssl_handshake returned" \
2042 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002043 -c "Read from server: .* bytes read"
2044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002045run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002046 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2047 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2048 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002049 -S "mbedtls_ssl_handshake returned" \
2050 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002051 -c "Read from server: .* bytes read"
2052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002053run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002054 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2055 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2056 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002057 -S "mbedtls_ssl_handshake returned" \
2058 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002059 -c "Read from server: .* bytes read"
2060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002061run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002062 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2063 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2064 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002065 -S "mbedtls_ssl_handshake returned" \
2066 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002067 -c "Read from server: .* bytes read"
2068
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002069# Tests for version negotiation
2070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002071run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002072 "$P_SRV" \
2073 "$P_CLI" \
2074 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002075 -S "mbedtls_ssl_handshake returned" \
2076 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002077 -s "Protocol is TLSv1.2" \
2078 -c "Protocol is TLSv1.2"
2079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002080run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002081 "$P_SRV" \
2082 "$P_CLI max_version=tls1_1" \
2083 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002084 -S "mbedtls_ssl_handshake returned" \
2085 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002086 -s "Protocol is TLSv1.1" \
2087 -c "Protocol is TLSv1.1"
2088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002089run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002090 "$P_SRV max_version=tls1_1" \
2091 "$P_CLI" \
2092 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002093 -S "mbedtls_ssl_handshake returned" \
2094 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002095 -s "Protocol is TLSv1.1" \
2096 -c "Protocol is TLSv1.1"
2097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002098run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002099 "$P_SRV max_version=tls1_1" \
2100 "$P_CLI max_version=tls1_1" \
2101 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002102 -S "mbedtls_ssl_handshake returned" \
2103 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002104 -s "Protocol is TLSv1.1" \
2105 -c "Protocol is TLSv1.1"
2106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002107run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002108 "$P_SRV min_version=tls1_1" \
2109 "$P_CLI max_version=tls1_1" \
2110 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002111 -S "mbedtls_ssl_handshake returned" \
2112 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002113 -s "Protocol is TLSv1.1" \
2114 -c "Protocol is TLSv1.1"
2115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002116run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002117 "$P_SRV max_version=tls1_1" \
2118 "$P_CLI min_version=tls1_1" \
2119 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002120 -S "mbedtls_ssl_handshake returned" \
2121 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002122 -s "Protocol is TLSv1.1" \
2123 -c "Protocol is TLSv1.1"
2124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002125run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002126 "$P_SRV max_version=tls1_1" \
2127 "$P_CLI min_version=tls1_2" \
2128 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002129 -s "mbedtls_ssl_handshake returned" \
2130 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002131 -c "SSL - Handshake protocol not within min/max boundaries"
2132
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002133run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002134 "$P_SRV min_version=tls1_2" \
2135 "$P_CLI max_version=tls1_1" \
2136 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002137 -s "mbedtls_ssl_handshake returned" \
2138 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002139 -s "SSL - Handshake protocol not within min/max boundaries"
2140
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002141# Tests for ALPN extension
2142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002143run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002144 "$P_SRV debug_level=3" \
2145 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002146 0 \
2147 -C "client hello, adding alpn extension" \
2148 -S "found alpn extension" \
2149 -C "got an alert message, type: \\[2:120]" \
2150 -S "server hello, adding alpn extension" \
2151 -C "found alpn extension " \
2152 -C "Application Layer Protocol is" \
2153 -S "Application Layer Protocol is"
2154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002155run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002156 "$P_SRV debug_level=3" \
2157 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002158 0 \
2159 -c "client hello, adding alpn extension" \
2160 -s "found alpn extension" \
2161 -C "got an alert message, type: \\[2:120]" \
2162 -S "server hello, adding alpn extension" \
2163 -C "found alpn extension " \
2164 -c "Application Layer Protocol is (none)" \
2165 -S "Application Layer Protocol is"
2166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002167run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002168 "$P_SRV debug_level=3 alpn=abc,1234" \
2169 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002170 0 \
2171 -C "client hello, adding alpn extension" \
2172 -S "found alpn extension" \
2173 -C "got an alert message, type: \\[2:120]" \
2174 -S "server hello, adding alpn extension" \
2175 -C "found alpn extension " \
2176 -C "Application Layer Protocol is" \
2177 -s "Application Layer Protocol is (none)"
2178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002179run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002180 "$P_SRV debug_level=3 alpn=abc,1234" \
2181 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002182 0 \
2183 -c "client hello, adding alpn extension" \
2184 -s "found alpn extension" \
2185 -C "got an alert message, type: \\[2:120]" \
2186 -s "server hello, adding alpn extension" \
2187 -c "found alpn extension" \
2188 -c "Application Layer Protocol is abc" \
2189 -s "Application Layer Protocol is abc"
2190
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002191run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002192 "$P_SRV debug_level=3 alpn=abc,1234" \
2193 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002194 0 \
2195 -c "client hello, adding alpn extension" \
2196 -s "found alpn extension" \
2197 -C "got an alert message, type: \\[2:120]" \
2198 -s "server hello, adding alpn extension" \
2199 -c "found alpn extension" \
2200 -c "Application Layer Protocol is abc" \
2201 -s "Application Layer Protocol is abc"
2202
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002203run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002204 "$P_SRV debug_level=3 alpn=abc,1234" \
2205 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002206 0 \
2207 -c "client hello, adding alpn extension" \
2208 -s "found alpn extension" \
2209 -C "got an alert message, type: \\[2:120]" \
2210 -s "server hello, adding alpn extension" \
2211 -c "found alpn extension" \
2212 -c "Application Layer Protocol is 1234" \
2213 -s "Application Layer Protocol is 1234"
2214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002215run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002216 "$P_SRV debug_level=3 alpn=abc,123" \
2217 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002218 1 \
2219 -c "client hello, adding alpn extension" \
2220 -s "found alpn extension" \
2221 -c "got an alert message, type: \\[2:120]" \
2222 -S "server hello, adding alpn extension" \
2223 -C "found alpn extension" \
2224 -C "Application Layer Protocol is 1234" \
2225 -S "Application Layer Protocol is 1234"
2226
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002227
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002228# Tests for keyUsage in leaf certificates, part 1:
2229# server-side certificate/suite selection
2230
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002231run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002232 "$P_SRV key_file=data_files/server2.key \
2233 crt_file=data_files/server2.ku-ds.crt" \
2234 "$P_CLI" \
2235 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002236 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002237
2238
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002239run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002240 "$P_SRV key_file=data_files/server2.key \
2241 crt_file=data_files/server2.ku-ke.crt" \
2242 "$P_CLI" \
2243 0 \
2244 -c "Ciphersuite is TLS-RSA-WITH-"
2245
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002246run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002247 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002248 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002249 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002250 1 \
2251 -C "Ciphersuite is "
2252
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002253run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002254 "$P_SRV key_file=data_files/server5.key \
2255 crt_file=data_files/server5.ku-ds.crt" \
2256 "$P_CLI" \
2257 0 \
2258 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2259
2260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002261run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002262 "$P_SRV key_file=data_files/server5.key \
2263 crt_file=data_files/server5.ku-ka.crt" \
2264 "$P_CLI" \
2265 0 \
2266 -c "Ciphersuite is TLS-ECDH-"
2267
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002268run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002269 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002270 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002271 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002272 1 \
2273 -C "Ciphersuite is "
2274
2275# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002276# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002277
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002278run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002279 "$O_SRV -key data_files/server2.key \
2280 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002281 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002282 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2283 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002284 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002285 -C "Processing of the Certificate handshake message failed" \
2286 -c "Ciphersuite is TLS-"
2287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002288run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002289 "$O_SRV -key data_files/server2.key \
2290 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002291 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002292 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2293 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002294 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002295 -C "Processing of the Certificate handshake message failed" \
2296 -c "Ciphersuite is TLS-"
2297
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002298run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002299 "$O_SRV -key data_files/server2.key \
2300 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002301 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002302 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2303 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002304 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002305 -C "Processing of the Certificate handshake message failed" \
2306 -c "Ciphersuite is TLS-"
2307
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002308run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002309 "$O_SRV -key data_files/server2.key \
2310 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002311 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002312 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2313 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002314 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002315 -c "Processing of the Certificate handshake message failed" \
2316 -C "Ciphersuite is TLS-"
2317
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002318run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2319 "$O_SRV -key data_files/server2.key \
2320 -cert data_files/server2.ku-ke.crt" \
2321 "$P_CLI debug_level=1 auth_mode=optional \
2322 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2323 0 \
2324 -c "bad certificate (usage extensions)" \
2325 -C "Processing of the Certificate handshake message failed" \
2326 -c "Ciphersuite is TLS-" \
2327 -c "! Usage does not match the keyUsage extension"
2328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002329run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002330 "$O_SRV -key data_files/server2.key \
2331 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002332 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002333 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2334 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002335 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002336 -C "Processing of the Certificate handshake message failed" \
2337 -c "Ciphersuite is TLS-"
2338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002339run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002340 "$O_SRV -key data_files/server2.key \
2341 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002342 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002343 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2344 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002345 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002346 -c "Processing of the Certificate handshake message failed" \
2347 -C "Ciphersuite is TLS-"
2348
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002349run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2350 "$O_SRV -key data_files/server2.key \
2351 -cert data_files/server2.ku-ds.crt" \
2352 "$P_CLI debug_level=1 auth_mode=optional \
2353 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2354 0 \
2355 -c "bad certificate (usage extensions)" \
2356 -C "Processing of the Certificate handshake message failed" \
2357 -c "Ciphersuite is TLS-" \
2358 -c "! Usage does not match the keyUsage extension"
2359
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002360# Tests for keyUsage in leaf certificates, part 3:
2361# server-side checking of client cert
2362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002363run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002364 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002365 "$O_CLI -key data_files/server2.key \
2366 -cert data_files/server2.ku-ds.crt" \
2367 0 \
2368 -S "bad certificate (usage extensions)" \
2369 -S "Processing of the Certificate handshake message failed"
2370
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002371run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002372 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002373 "$O_CLI -key data_files/server2.key \
2374 -cert data_files/server2.ku-ke.crt" \
2375 0 \
2376 -s "bad certificate (usage extensions)" \
2377 -S "Processing of the Certificate handshake message failed"
2378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002379run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002380 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002381 "$O_CLI -key data_files/server2.key \
2382 -cert data_files/server2.ku-ke.crt" \
2383 1 \
2384 -s "bad certificate (usage extensions)" \
2385 -s "Processing of the Certificate handshake message failed"
2386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002387run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002388 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002389 "$O_CLI -key data_files/server5.key \
2390 -cert data_files/server5.ku-ds.crt" \
2391 0 \
2392 -S "bad certificate (usage extensions)" \
2393 -S "Processing of the Certificate handshake message failed"
2394
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002395run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002396 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002397 "$O_CLI -key data_files/server5.key \
2398 -cert data_files/server5.ku-ka.crt" \
2399 0 \
2400 -s "bad certificate (usage extensions)" \
2401 -S "Processing of the Certificate handshake message failed"
2402
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002403# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2404
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002405run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002406 "$P_SRV key_file=data_files/server5.key \
2407 crt_file=data_files/server5.eku-srv.crt" \
2408 "$P_CLI" \
2409 0
2410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002411run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002412 "$P_SRV key_file=data_files/server5.key \
2413 crt_file=data_files/server5.eku-srv.crt" \
2414 "$P_CLI" \
2415 0
2416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002417run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002418 "$P_SRV key_file=data_files/server5.key \
2419 crt_file=data_files/server5.eku-cs_any.crt" \
2420 "$P_CLI" \
2421 0
2422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002423run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002424 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002425 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002426 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002427 1
2428
2429# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002431run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002432 "$O_SRV -key data_files/server5.key \
2433 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002434 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002435 0 \
2436 -C "bad certificate (usage extensions)" \
2437 -C "Processing of the Certificate handshake message failed" \
2438 -c "Ciphersuite is TLS-"
2439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002440run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002441 "$O_SRV -key data_files/server5.key \
2442 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002443 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002444 0 \
2445 -C "bad certificate (usage extensions)" \
2446 -C "Processing of the Certificate handshake message failed" \
2447 -c "Ciphersuite is TLS-"
2448
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002449run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002450 "$O_SRV -key data_files/server5.key \
2451 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002452 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002453 0 \
2454 -C "bad certificate (usage extensions)" \
2455 -C "Processing of the Certificate handshake message failed" \
2456 -c "Ciphersuite is TLS-"
2457
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002458run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002459 "$O_SRV -key data_files/server5.key \
2460 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002461 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002462 1 \
2463 -c "bad certificate (usage extensions)" \
2464 -c "Processing of the Certificate handshake message failed" \
2465 -C "Ciphersuite is TLS-"
2466
2467# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2468
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002469run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002470 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002471 "$O_CLI -key data_files/server5.key \
2472 -cert data_files/server5.eku-cli.crt" \
2473 0 \
2474 -S "bad certificate (usage extensions)" \
2475 -S "Processing of the Certificate handshake message failed"
2476
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002477run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002478 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002479 "$O_CLI -key data_files/server5.key \
2480 -cert data_files/server5.eku-srv_cli.crt" \
2481 0 \
2482 -S "bad certificate (usage extensions)" \
2483 -S "Processing of the Certificate handshake message failed"
2484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002485run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002486 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002487 "$O_CLI -key data_files/server5.key \
2488 -cert data_files/server5.eku-cs_any.crt" \
2489 0 \
2490 -S "bad certificate (usage extensions)" \
2491 -S "Processing of the Certificate handshake message failed"
2492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002493run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002494 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002495 "$O_CLI -key data_files/server5.key \
2496 -cert data_files/server5.eku-cs.crt" \
2497 0 \
2498 -s "bad certificate (usage extensions)" \
2499 -S "Processing of the Certificate handshake message failed"
2500
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002501run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002502 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002503 "$O_CLI -key data_files/server5.key \
2504 -cert data_files/server5.eku-cs.crt" \
2505 1 \
2506 -s "bad certificate (usage extensions)" \
2507 -s "Processing of the Certificate handshake message failed"
2508
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002509# Tests for DHM parameters loading
2510
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002511run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002512 "$P_SRV" \
2513 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2514 debug_level=3" \
2515 0 \
2516 -c "value of 'DHM: P ' (2048 bits)" \
2517 -c "value of 'DHM: G ' (2048 bits)"
2518
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002519run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002520 "$P_SRV dhm_file=data_files/dhparams.pem" \
2521 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2522 debug_level=3" \
2523 0 \
2524 -c "value of 'DHM: P ' (1024 bits)" \
2525 -c "value of 'DHM: G ' (2 bits)"
2526
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002527# Tests for DHM client-side size checking
2528
2529run_test "DHM size: server default, client default, OK" \
2530 "$P_SRV" \
2531 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2532 debug_level=1" \
2533 0 \
2534 -C "DHM prime too short:"
2535
2536run_test "DHM size: server default, client 2048, OK" \
2537 "$P_SRV" \
2538 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2539 debug_level=1 dhmlen=2048" \
2540 0 \
2541 -C "DHM prime too short:"
2542
2543run_test "DHM size: server 1024, client default, OK" \
2544 "$P_SRV dhm_file=data_files/dhparams.pem" \
2545 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2546 debug_level=1" \
2547 0 \
2548 -C "DHM prime too short:"
2549
2550run_test "DHM size: server 1000, client default, rejected" \
2551 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2552 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2553 debug_level=1" \
2554 1 \
2555 -c "DHM prime too short:"
2556
2557run_test "DHM size: server default, client 2049, rejected" \
2558 "$P_SRV" \
2559 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2560 debug_level=1 dhmlen=2049" \
2561 1 \
2562 -c "DHM prime too short:"
2563
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002564# Tests for PSK callback
2565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002566run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002567 "$P_SRV psk=abc123 psk_identity=foo" \
2568 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2569 psk_identity=foo psk=abc123" \
2570 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002571 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002572 -S "SSL - Unknown identity received" \
2573 -S "SSL - Verification of the message MAC failed"
2574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002575run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002576 "$P_SRV" \
2577 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2578 psk_identity=foo psk=abc123" \
2579 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002580 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002581 -S "SSL - Unknown identity received" \
2582 -S "SSL - Verification of the message MAC failed"
2583
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002584run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002585 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2586 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2587 psk_identity=foo psk=abc123" \
2588 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002589 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002590 -s "SSL - Unknown identity received" \
2591 -S "SSL - Verification of the message MAC failed"
2592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002593run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002594 "$P_SRV psk_list=abc,dead,def,beef" \
2595 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2596 psk_identity=abc psk=dead" \
2597 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002598 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002599 -S "SSL - Unknown identity received" \
2600 -S "SSL - Verification of the message MAC failed"
2601
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002602run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002603 "$P_SRV psk_list=abc,dead,def,beef" \
2604 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2605 psk_identity=def psk=beef" \
2606 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002607 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002608 -S "SSL - Unknown identity received" \
2609 -S "SSL - Verification of the message MAC failed"
2610
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002611run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002612 "$P_SRV psk_list=abc,dead,def,beef" \
2613 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2614 psk_identity=ghi psk=beef" \
2615 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002616 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002617 -s "SSL - Unknown identity received" \
2618 -S "SSL - Verification of the message MAC failed"
2619
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002620run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002621 "$P_SRV psk_list=abc,dead,def,beef" \
2622 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2623 psk_identity=abc psk=beef" \
2624 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002625 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002626 -S "SSL - Unknown identity received" \
2627 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002628
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002629# Tests for EC J-PAKE
2630
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002631requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002632run_test "ECJPAKE: client not configured" \
2633 "$P_SRV debug_level=3" \
2634 "$P_CLI debug_level=3" \
2635 0 \
2636 -C "add ciphersuite: c0ff" \
2637 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002638 -S "found ecjpake kkpp extension" \
2639 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002640 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002641 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002642 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002643 -S "None of the common ciphersuites is usable"
2644
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002645requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002646run_test "ECJPAKE: server not configured" \
2647 "$P_SRV debug_level=3" \
2648 "$P_CLI debug_level=3 ecjpake_pw=bla \
2649 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2650 1 \
2651 -c "add ciphersuite: c0ff" \
2652 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002653 -s "found ecjpake kkpp extension" \
2654 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002655 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002656 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002657 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002658 -s "None of the common ciphersuites is usable"
2659
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002660requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002661run_test "ECJPAKE: working, TLS" \
2662 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2663 "$P_CLI debug_level=3 ecjpake_pw=bla \
2664 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002665 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002666 -c "add ciphersuite: c0ff" \
2667 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002668 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002669 -s "found ecjpake kkpp extension" \
2670 -S "skip ecjpake kkpp extension" \
2671 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002672 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002673 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002674 -S "None of the common ciphersuites is usable" \
2675 -S "SSL - Verification of the message MAC failed"
2676
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002677requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002678run_test "ECJPAKE: password mismatch, TLS" \
2679 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2680 "$P_CLI debug_level=3 ecjpake_pw=bad \
2681 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2682 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002683 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002684 -s "SSL - Verification of the message MAC failed"
2685
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002686requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002687run_test "ECJPAKE: working, DTLS" \
2688 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2689 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2690 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2691 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002692 -c "re-using cached ecjpake parameters" \
2693 -S "SSL - Verification of the message MAC failed"
2694
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002695requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002696run_test "ECJPAKE: working, DTLS, no cookie" \
2697 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2698 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2699 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2700 0 \
2701 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002702 -S "SSL - Verification of the message MAC failed"
2703
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002704requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002705run_test "ECJPAKE: password mismatch, DTLS" \
2706 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2707 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2708 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2709 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002710 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002711 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002712
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002713# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002714requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002715run_test "ECJPAKE: working, DTLS, nolog" \
2716 "$P_SRV dtls=1 ecjpake_pw=bla" \
2717 "$P_CLI dtls=1 ecjpake_pw=bla \
2718 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2719 0
2720
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002721# Tests for ciphersuites per version
2722
Janos Follathe2681a42016-03-07 15:57:05 +00002723requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002724run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002725 "$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 +02002726 "$P_CLI force_version=ssl3" \
2727 0 \
2728 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002730run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002731 "$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 +01002732 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002733 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002734 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002735
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002736run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002737 "$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 +02002738 "$P_CLI force_version=tls1_1" \
2739 0 \
2740 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2741
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002742run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002743 "$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 +02002744 "$P_CLI force_version=tls1_2" \
2745 0 \
2746 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2747
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002748# Test for ClientHello without extensions
2749
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002750requires_gnutls
2751run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002752 "$P_SRV debug_level=3" \
2753 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2754 0 \
2755 -s "dumping 'client hello extensions' (0 bytes)"
2756
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002757# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002758
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002759run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002760 "$P_SRV" \
2761 "$P_CLI request_size=100" \
2762 0 \
2763 -s "Read from client: 100 bytes read$"
2764
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002765run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002766 "$P_SRV" \
2767 "$P_CLI request_size=500" \
2768 0 \
2769 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002770
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002771# Tests for small packets
2772
Janos Follathe2681a42016-03-07 15:57:05 +00002773requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002774run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002775 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002776 "$P_CLI request_size=1 force_version=ssl3 \
2777 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2778 0 \
2779 -s "Read from client: 1 bytes read"
2780
Janos Follathe2681a42016-03-07 15:57:05 +00002781requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002782run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002783 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002784 "$P_CLI request_size=1 force_version=ssl3 \
2785 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2786 0 \
2787 -s "Read from client: 1 bytes read"
2788
2789run_test "Small packet TLS 1.0 BlockCipher" \
2790 "$P_SRV" \
2791 "$P_CLI request_size=1 force_version=tls1 \
2792 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2793 0 \
2794 -s "Read from client: 1 bytes read"
2795
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002796run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2797 "$P_SRV" \
2798 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2799 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2800 0 \
2801 -s "Read from client: 1 bytes read"
2802
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002803run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2804 "$P_SRV" \
2805 "$P_CLI request_size=1 force_version=tls1 \
2806 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2807 trunc_hmac=1" \
2808 0 \
2809 -s "Read from client: 1 bytes read"
2810
2811run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002812 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002813 "$P_CLI request_size=1 force_version=tls1 \
2814 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2815 trunc_hmac=1" \
2816 0 \
2817 -s "Read from client: 1 bytes read"
2818
2819run_test "Small packet TLS 1.1 BlockCipher" \
2820 "$P_SRV" \
2821 "$P_CLI request_size=1 force_version=tls1_1 \
2822 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2823 0 \
2824 -s "Read from client: 1 bytes read"
2825
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002826run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2827 "$P_SRV" \
2828 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2829 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2830 0 \
2831 -s "Read from client: 1 bytes read"
2832
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002833run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002834 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002835 "$P_CLI request_size=1 force_version=tls1_1 \
2836 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2837 0 \
2838 -s "Read from client: 1 bytes read"
2839
2840run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2841 "$P_SRV" \
2842 "$P_CLI request_size=1 force_version=tls1_1 \
2843 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2844 trunc_hmac=1" \
2845 0 \
2846 -s "Read from client: 1 bytes read"
2847
2848run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
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 trunc_hmac=1" \
2853 0 \
2854 -s "Read from client: 1 bytes read"
2855
2856run_test "Small packet TLS 1.2 BlockCipher" \
2857 "$P_SRV" \
2858 "$P_CLI request_size=1 force_version=tls1_2 \
2859 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2860 0 \
2861 -s "Read from client: 1 bytes read"
2862
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002863run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2864 "$P_SRV" \
2865 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2866 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2867 0 \
2868 -s "Read from client: 1 bytes read"
2869
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002870run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2871 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002872 "$P_CLI request_size=1 force_version=tls1_2 \
2873 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002874 0 \
2875 -s "Read from client: 1 bytes read"
2876
2877run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2878 "$P_SRV" \
2879 "$P_CLI request_size=1 force_version=tls1_2 \
2880 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2881 trunc_hmac=1" \
2882 0 \
2883 -s "Read from client: 1 bytes read"
2884
2885run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002886 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002887 "$P_CLI request_size=1 force_version=tls1_2 \
2888 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2889 0 \
2890 -s "Read from client: 1 bytes read"
2891
2892run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002893 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002894 "$P_CLI request_size=1 force_version=tls1_2 \
2895 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2896 trunc_hmac=1" \
2897 0 \
2898 -s "Read from client: 1 bytes read"
2899
2900run_test "Small packet TLS 1.2 AEAD" \
2901 "$P_SRV" \
2902 "$P_CLI request_size=1 force_version=tls1_2 \
2903 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2904 0 \
2905 -s "Read from client: 1 bytes read"
2906
2907run_test "Small packet TLS 1.2 AEAD shorter tag" \
2908 "$P_SRV" \
2909 "$P_CLI request_size=1 force_version=tls1_2 \
2910 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2911 0 \
2912 -s "Read from client: 1 bytes read"
2913
Janos Follath00efff72016-05-06 13:48:23 +01002914# A test for extensions in SSLv3
2915
2916requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2917run_test "SSLv3 with extensions, server side" \
2918 "$P_SRV min_version=ssl3 debug_level=3" \
2919 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2920 0 \
2921 -S "dumping 'client hello extensions'" \
2922 -S "server hello, total extension length:"
2923
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002924# Test for large packets
2925
Janos Follathe2681a42016-03-07 15:57:05 +00002926requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002927run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002928 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002929 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002930 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2931 0 \
2932 -s "Read from client: 16384 bytes read"
2933
Janos Follathe2681a42016-03-07 15:57:05 +00002934requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002935run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002936 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002937 "$P_CLI request_size=16384 force_version=ssl3 \
2938 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2939 0 \
2940 -s "Read from client: 16384 bytes read"
2941
2942run_test "Large packet TLS 1.0 BlockCipher" \
2943 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002944 "$P_CLI request_size=16384 force_version=tls1 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
2949run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2950 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002951 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002952 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2953 trunc_hmac=1" \
2954 0 \
2955 -s "Read from client: 16384 bytes read"
2956
2957run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002958 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002959 "$P_CLI request_size=16384 force_version=tls1 \
2960 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2961 trunc_hmac=1" \
2962 0 \
2963 -s "Read from client: 16384 bytes read"
2964
2965run_test "Large packet TLS 1.1 BlockCipher" \
2966 "$P_SRV" \
2967 "$P_CLI request_size=16384 force_version=tls1_1 \
2968 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2969 0 \
2970 -s "Read from client: 16384 bytes read"
2971
2972run_test "Large packet TLS 1.1 StreamCipher" \
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_1 \
2975 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2976 0 \
2977 -s "Read from client: 16384 bytes read"
2978
2979run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2980 "$P_SRV" \
2981 "$P_CLI request_size=16384 force_version=tls1_1 \
2982 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2983 trunc_hmac=1" \
2984 0 \
2985 -s "Read from client: 16384 bytes read"
2986
2987run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
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 trunc_hmac=1" \
2992 0 \
2993 -s "Read from client: 16384 bytes read"
2994
2995run_test "Large packet TLS 1.2 BlockCipher" \
2996 "$P_SRV" \
2997 "$P_CLI request_size=16384 force_version=tls1_2 \
2998 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2999 0 \
3000 -s "Read from client: 16384 bytes read"
3001
3002run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3003 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003004 "$P_CLI request_size=16384 force_version=tls1_2 \
3005 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003006 0 \
3007 -s "Read from client: 16384 bytes read"
3008
3009run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3010 "$P_SRV" \
3011 "$P_CLI request_size=16384 force_version=tls1_2 \
3012 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3013 trunc_hmac=1" \
3014 0 \
3015 -s "Read from client: 16384 bytes read"
3016
3017run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003018 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003019 "$P_CLI request_size=16384 force_version=tls1_2 \
3020 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3021 0 \
3022 -s "Read from client: 16384 bytes read"
3023
3024run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003025 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003026 "$P_CLI request_size=16384 force_version=tls1_2 \
3027 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3028 trunc_hmac=1" \
3029 0 \
3030 -s "Read from client: 16384 bytes read"
3031
3032run_test "Large packet TLS 1.2 AEAD" \
3033 "$P_SRV" \
3034 "$P_CLI request_size=16384 force_version=tls1_2 \
3035 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3036 0 \
3037 -s "Read from client: 16384 bytes read"
3038
3039run_test "Large packet TLS 1.2 AEAD shorter tag" \
3040 "$P_SRV" \
3041 "$P_CLI request_size=16384 force_version=tls1_2 \
3042 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3043 0 \
3044 -s "Read from client: 16384 bytes read"
3045
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003046# Tests for DTLS HelloVerifyRequest
3047
3048run_test "DTLS cookie: enabled" \
3049 "$P_SRV dtls=1 debug_level=2" \
3050 "$P_CLI dtls=1 debug_level=2" \
3051 0 \
3052 -s "cookie verification failed" \
3053 -s "cookie verification passed" \
3054 -S "cookie verification skipped" \
3055 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003056 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003057 -S "SSL - The requested feature is not available"
3058
3059run_test "DTLS cookie: disabled" \
3060 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3061 "$P_CLI dtls=1 debug_level=2" \
3062 0 \
3063 -S "cookie verification failed" \
3064 -S "cookie verification passed" \
3065 -s "cookie verification skipped" \
3066 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003067 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003068 -S "SSL - The requested feature is not available"
3069
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003070run_test "DTLS cookie: default (failing)" \
3071 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3072 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3073 1 \
3074 -s "cookie verification failed" \
3075 -S "cookie verification passed" \
3076 -S "cookie verification skipped" \
3077 -C "received hello verify request" \
3078 -S "hello verification requested" \
3079 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003080
3081requires_ipv6
3082run_test "DTLS cookie: enabled, IPv6" \
3083 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3084 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3085 0 \
3086 -s "cookie verification failed" \
3087 -s "cookie verification passed" \
3088 -S "cookie verification skipped" \
3089 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003090 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003091 -S "SSL - The requested feature is not available"
3092
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003093run_test "DTLS cookie: enabled, nbio" \
3094 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3095 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3096 0 \
3097 -s "cookie verification failed" \
3098 -s "cookie verification passed" \
3099 -S "cookie verification skipped" \
3100 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003101 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003102 -S "SSL - The requested feature is not available"
3103
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003104# Tests for client reconnecting from the same port with DTLS
3105
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003106not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003107run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003108 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3109 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003110 0 \
3111 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003112 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003113 -S "Client initiated reconnection from same port"
3114
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003115not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003116run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003117 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3118 "$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 +02003119 0 \
3120 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003121 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003122 -s "Client initiated reconnection from same port"
3123
Paul Bakker362689d2016-05-13 10:33:25 +01003124not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3125run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003126 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3127 "$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 +02003128 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003129 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003130 -s "Client initiated reconnection from same port"
3131
Paul Bakker362689d2016-05-13 10:33:25 +01003132only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3133run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3134 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3135 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3136 0 \
3137 -S "The operation timed out" \
3138 -s "Client initiated reconnection from same port"
3139
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003140run_test "DTLS client reconnect from same port: no cookies" \
3141 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003142 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3143 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003144 -s "The operation timed out" \
3145 -S "Client initiated reconnection from same port"
3146
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003147# Tests for various cases of client authentication with DTLS
3148# (focused on handshake flows and message parsing)
3149
3150run_test "DTLS client auth: required" \
3151 "$P_SRV dtls=1 auth_mode=required" \
3152 "$P_CLI dtls=1" \
3153 0 \
3154 -s "Verifying peer X.509 certificate... ok"
3155
3156run_test "DTLS client auth: optional, client has no cert" \
3157 "$P_SRV dtls=1 auth_mode=optional" \
3158 "$P_CLI dtls=1 crt_file=none key_file=none" \
3159 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003160 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003161
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003162run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003163 "$P_SRV dtls=1 auth_mode=none" \
3164 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3165 0 \
3166 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003167 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003168
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003169run_test "DTLS wrong PSK: badmac alert" \
3170 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3171 "$P_CLI dtls=1 psk=abc124" \
3172 1 \
3173 -s "SSL - Verification of the message MAC failed" \
3174 -c "SSL - A fatal alert message was received from our peer"
3175
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003176# Tests for receiving fragmented handshake messages with DTLS
3177
3178requires_gnutls
3179run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3180 "$G_SRV -u --mtu 2048 -a" \
3181 "$P_CLI dtls=1 debug_level=2" \
3182 0 \
3183 -C "found fragmented DTLS handshake message" \
3184 -C "error"
3185
3186requires_gnutls
3187run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3188 "$G_SRV -u --mtu 512" \
3189 "$P_CLI dtls=1 debug_level=2" \
3190 0 \
3191 -c "found fragmented DTLS handshake message" \
3192 -C "error"
3193
3194requires_gnutls
3195run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3196 "$G_SRV -u --mtu 128" \
3197 "$P_CLI dtls=1 debug_level=2" \
3198 0 \
3199 -c "found fragmented DTLS handshake message" \
3200 -C "error"
3201
3202requires_gnutls
3203run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3204 "$G_SRV -u --mtu 128" \
3205 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3206 0 \
3207 -c "found fragmented DTLS handshake message" \
3208 -C "error"
3209
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003210requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003211run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3212 "$G_SRV -u --mtu 256" \
3213 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3214 0 \
3215 -c "found fragmented DTLS handshake message" \
3216 -c "client hello, adding renegotiation extension" \
3217 -c "found renegotiation extension" \
3218 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003219 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003220 -C "error" \
3221 -s "Extra-header:"
3222
3223requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003224run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3225 "$G_SRV -u --mtu 256" \
3226 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3227 0 \
3228 -c "found fragmented DTLS handshake message" \
3229 -c "client hello, adding renegotiation extension" \
3230 -c "found renegotiation extension" \
3231 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003232 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003233 -C "error" \
3234 -s "Extra-header:"
3235
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003236run_test "DTLS reassembly: no fragmentation (openssl server)" \
3237 "$O_SRV -dtls1 -mtu 2048" \
3238 "$P_CLI dtls=1 debug_level=2" \
3239 0 \
3240 -C "found fragmented DTLS handshake message" \
3241 -C "error"
3242
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003243run_test "DTLS reassembly: some fragmentation (openssl server)" \
3244 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003245 "$P_CLI dtls=1 debug_level=2" \
3246 0 \
3247 -c "found fragmented DTLS handshake message" \
3248 -C "error"
3249
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003250run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003251 "$O_SRV -dtls1 -mtu 256" \
3252 "$P_CLI dtls=1 debug_level=2" \
3253 0 \
3254 -c "found fragmented DTLS handshake message" \
3255 -C "error"
3256
3257run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3258 "$O_SRV -dtls1 -mtu 256" \
3259 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3260 0 \
3261 -c "found fragmented DTLS handshake message" \
3262 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003263
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003264# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003265
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003266not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003267run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003268 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003269 "$P_SRV dtls=1 debug_level=2" \
3270 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003271 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003272 -C "replayed record" \
3273 -S "replayed record" \
3274 -C "record from another epoch" \
3275 -S "record from another epoch" \
3276 -C "discarding invalid record" \
3277 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003278 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003279 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003280 -c "HTTP/1.0 200 OK"
3281
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003282not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003283run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003284 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003285 "$P_SRV dtls=1 debug_level=2" \
3286 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003287 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003288 -c "replayed record" \
3289 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003290 -c "discarding invalid record" \
3291 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003292 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003293 -s "Extra-header:" \
3294 -c "HTTP/1.0 200 OK"
3295
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003296run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3297 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003298 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3299 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003300 0 \
3301 -c "replayed record" \
3302 -S "replayed record" \
3303 -c "discarding invalid record" \
3304 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003305 -c "resend" \
3306 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003307 -s "Extra-header:" \
3308 -c "HTTP/1.0 200 OK"
3309
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003310run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003311 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003312 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003313 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003314 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003315 -c "discarding invalid record (mac)" \
3316 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003317 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003318 -c "HTTP/1.0 200 OK" \
3319 -S "too many records with bad MAC" \
3320 -S "Verification of the message MAC failed"
3321
3322run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3323 -p "$P_PXY bad_ad=1" \
3324 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3325 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3326 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003327 -C "discarding invalid record (mac)" \
3328 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003329 -S "Extra-header:" \
3330 -C "HTTP/1.0 200 OK" \
3331 -s "too many records with bad MAC" \
3332 -s "Verification of the message MAC failed"
3333
3334run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3335 -p "$P_PXY bad_ad=1" \
3336 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3337 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3338 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003339 -c "discarding invalid record (mac)" \
3340 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003341 -s "Extra-header:" \
3342 -c "HTTP/1.0 200 OK" \
3343 -S "too many records with bad MAC" \
3344 -S "Verification of the message MAC failed"
3345
3346run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3347 -p "$P_PXY bad_ad=1" \
3348 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3349 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3350 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003351 -c "discarding invalid record (mac)" \
3352 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003353 -s "Extra-header:" \
3354 -c "HTTP/1.0 200 OK" \
3355 -s "too many records with bad MAC" \
3356 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003357
3358run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003359 -p "$P_PXY delay_ccs=1" \
3360 "$P_SRV dtls=1 debug_level=1" \
3361 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003362 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003363 -c "record from another epoch" \
3364 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003365 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003366 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003367 -s "Extra-header:" \
3368 -c "HTTP/1.0 200 OK"
3369
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003370# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003371
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003372needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003373run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003374 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003375 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3376 psk=abc123" \
3377 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003378 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3379 0 \
3380 -s "Extra-header:" \
3381 -c "HTTP/1.0 200 OK"
3382
3383needs_more_time 2
3384run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3385 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003386 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3387 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003388 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3389 0 \
3390 -s "Extra-header:" \
3391 -c "HTTP/1.0 200 OK"
3392
3393needs_more_time 2
3394run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3395 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003396 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3397 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003398 0 \
3399 -s "Extra-header:" \
3400 -c "HTTP/1.0 200 OK"
3401
3402needs_more_time 2
3403run_test "DTLS proxy: 3d, FS, client auth" \
3404 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003405 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3406 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003407 0 \
3408 -s "Extra-header:" \
3409 -c "HTTP/1.0 200 OK"
3410
3411needs_more_time 2
3412run_test "DTLS proxy: 3d, FS, ticket" \
3413 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003414 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3415 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003416 0 \
3417 -s "Extra-header:" \
3418 -c "HTTP/1.0 200 OK"
3419
3420needs_more_time 2
3421run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3422 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003423 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3424 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003425 0 \
3426 -s "Extra-header:" \
3427 -c "HTTP/1.0 200 OK"
3428
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003429needs_more_time 2
3430run_test "DTLS proxy: 3d, max handshake, nbio" \
3431 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003432 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3433 auth_mode=required" \
3434 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003435 0 \
3436 -s "Extra-header:" \
3437 -c "HTTP/1.0 200 OK"
3438
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003439needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003440run_test "DTLS proxy: 3d, min handshake, resumption" \
3441 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3442 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3443 psk=abc123 debug_level=3" \
3444 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3445 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3446 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3447 0 \
3448 -s "a session has been resumed" \
3449 -c "a session has been resumed" \
3450 -s "Extra-header:" \
3451 -c "HTTP/1.0 200 OK"
3452
3453needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003454run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3455 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3456 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3457 psk=abc123 debug_level=3 nbio=2" \
3458 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3459 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3460 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3461 0 \
3462 -s "a session has been resumed" \
3463 -c "a session has been resumed" \
3464 -s "Extra-header:" \
3465 -c "HTTP/1.0 200 OK"
3466
3467needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003468run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003469 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003470 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3471 psk=abc123 renegotiation=1 debug_level=2" \
3472 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3473 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003474 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3475 0 \
3476 -c "=> renegotiate" \
3477 -s "=> renegotiate" \
3478 -s "Extra-header:" \
3479 -c "HTTP/1.0 200 OK"
3480
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003481needs_more_time 4
3482run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3483 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003484 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3485 psk=abc123 renegotiation=1 debug_level=2" \
3486 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3487 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003488 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3489 0 \
3490 -c "=> renegotiate" \
3491 -s "=> renegotiate" \
3492 -s "Extra-header:" \
3493 -c "HTTP/1.0 200 OK"
3494
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003495needs_more_time 4
3496run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003497 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003498 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003499 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003500 debug_level=2" \
3501 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003502 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +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
3510needs_more_time 4
3511run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
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 nbio=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 nbio=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
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003525needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003526not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003527run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003528 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3529 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003530 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003531 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003532 -c "HTTP/1.0 200 OK"
3533
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003534needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003535not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003536run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3537 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3538 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003539 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003540 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003541 -c "HTTP/1.0 200 OK"
3542
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003543needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003544not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003545run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3546 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3547 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003548 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003549 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003550 -c "HTTP/1.0 200 OK"
3551
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003552requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003553needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003554not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003555run_test "DTLS proxy: 3d, gnutls server" \
3556 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3557 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003558 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003559 0 \
3560 -s "Extra-header:" \
3561 -c "Extra-header:"
3562
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003563requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003564needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003565not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003566run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3567 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3568 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003569 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003570 0 \
3571 -s "Extra-header:" \
3572 -c "Extra-header:"
3573
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003574requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003575needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003576not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003577run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3578 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3579 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003580 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003581 0 \
3582 -s "Extra-header:" \
3583 -c "Extra-header:"
3584
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003585# Final report
3586
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003587echo "------------------------------------------------------------------------"
3588
3589if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003590 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003591else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003592 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003593fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003594PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003595echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003596
3597exit $FAILS