blob: 0edb783f857fa3c88e7f28a2f6fb617d468d608c [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
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100554if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
555 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100556 exit 1
557fi
558
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200559# used by watchdog
560MAIN_PID="$$"
561
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200562# be more patient with valgrind
563if [ "$MEMCHECK" -gt 0 ]; then
564 START_DELAY=3
565 DOG_DELAY=30
566else
567 START_DELAY=1
568 DOG_DELAY=10
569fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200570CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200571
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200572# Pick a "unique" server port in the range 10000-19999, and a proxy port
573PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000574PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200575SRV_PORT="1$PORT_BASE"
576PXY_PORT="2$PORT_BASE"
577unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200578
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200579# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000580# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200581P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
582P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
583P_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 +0200584O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200585O_CLI="$O_CLI -connect localhost:+SRV_PORT"
586G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000587G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200588
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200589# Also pick a unique name for intermediate files
590SRV_OUT="srv_out.$$"
591CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200592PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200593SESSION="session.$$"
594
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200595SKIP_NEXT="NO"
596
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100597trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100598
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200599# Basic test
600
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200601# Checks that:
602# - things work with all ciphersuites active (used with config-full in all.sh)
603# - the expected (highest security) parameters are selected
604# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200605run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200606 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200607 "$P_CLI" \
608 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200609 -s "Protocol is TLSv1.2" \
610 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
611 -s "client hello v3, signature_algorithm ext: 6" \
612 -s "ECDHE curve: secp521r1" \
613 -S "error" \
614 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200615
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000616run_test "Default, DTLS" \
617 "$P_SRV dtls=1" \
618 "$P_CLI dtls=1" \
619 0 \
620 -s "Protocol is DTLSv1.2" \
621 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
622
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100623# Tests for rc4 option
624
Simon Butchera410af52016-05-19 22:12:18 +0100625requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100626run_test "RC4: server disabled, client enabled" \
627 "$P_SRV" \
628 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
629 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100630 -s "SSL - The server has no ciphersuites in common"
631
Simon Butchera410af52016-05-19 22:12:18 +0100632requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100633run_test "RC4: server half, client enabled" \
634 "$P_SRV arc4=1" \
635 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
636 1 \
637 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100638
639run_test "RC4: server enabled, client disabled" \
640 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
641 "$P_CLI" \
642 1 \
643 -s "SSL - The server has no ciphersuites in common"
644
645run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100646 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100647 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
648 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100649 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100650 -S "SSL - The server has no ciphersuites in common"
651
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100652# Tests for Truncated HMAC extension
653
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100654run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200655 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100656 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100657 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100658 -s "dumping 'computed mac' (20 bytes)" \
659 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100660
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100661run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200662 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100663 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
664 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100665 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100666 -s "dumping 'computed mac' (20 bytes)" \
667 -S "dumping 'computed mac' (10 bytes)"
668
669run_test "Truncated HMAC: client enabled, server default" \
670 "$P_SRV debug_level=4" \
671 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
672 trunc_hmac=1" \
673 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100674 -s "dumping 'computed mac' (20 bytes)" \
675 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100676
677run_test "Truncated HMAC: client enabled, server disabled" \
678 "$P_SRV debug_level=4 trunc_hmac=0" \
679 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
680 trunc_hmac=1" \
681 0 \
682 -s "dumping 'computed mac' (20 bytes)" \
683 -S "dumping 'computed mac' (10 bytes)"
684
685run_test "Truncated HMAC: client enabled, server enabled" \
686 "$P_SRV debug_level=4 trunc_hmac=1" \
687 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
688 trunc_hmac=1" \
689 0 \
690 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100691 -s "dumping 'computed mac' (10 bytes)"
692
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100693# Tests for Encrypt-then-MAC extension
694
695run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100696 "$P_SRV debug_level=3 \
697 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100698 "$P_CLI debug_level=3" \
699 0 \
700 -c "client hello, adding encrypt_then_mac extension" \
701 -s "found encrypt then mac extension" \
702 -s "server hello, adding encrypt then mac extension" \
703 -c "found encrypt_then_mac extension" \
704 -c "using encrypt then mac" \
705 -s "using encrypt then mac"
706
707run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100708 "$P_SRV debug_level=3 etm=0 \
709 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100710 "$P_CLI debug_level=3 etm=1" \
711 0 \
712 -c "client hello, adding encrypt_then_mac extension" \
713 -s "found encrypt then mac extension" \
714 -S "server hello, adding encrypt then mac extension" \
715 -C "found encrypt_then_mac extension" \
716 -C "using encrypt then mac" \
717 -S "using encrypt then mac"
718
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100719run_test "Encrypt then MAC: client enabled, aead cipher" \
720 "$P_SRV debug_level=3 etm=1 \
721 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
722 "$P_CLI debug_level=3 etm=1" \
723 0 \
724 -c "client hello, adding encrypt_then_mac extension" \
725 -s "found encrypt then mac extension" \
726 -S "server hello, adding encrypt then mac extension" \
727 -C "found encrypt_then_mac extension" \
728 -C "using encrypt then mac" \
729 -S "using encrypt then mac"
730
731run_test "Encrypt then MAC: client enabled, stream cipher" \
732 "$P_SRV debug_level=3 etm=1 \
733 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100734 "$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 +0100735 0 \
736 -c "client hello, adding encrypt_then_mac extension" \
737 -s "found encrypt then mac extension" \
738 -S "server hello, adding encrypt then mac extension" \
739 -C "found encrypt_then_mac extension" \
740 -C "using encrypt then mac" \
741 -S "using encrypt then mac"
742
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100743run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100744 "$P_SRV debug_level=3 etm=1 \
745 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100746 "$P_CLI debug_level=3 etm=0" \
747 0 \
748 -C "client hello, adding encrypt_then_mac extension" \
749 -S "found encrypt then mac extension" \
750 -S "server hello, adding encrypt then mac extension" \
751 -C "found encrypt_then_mac extension" \
752 -C "using encrypt then mac" \
753 -S "using encrypt then mac"
754
Janos Follathe2681a42016-03-07 15:57:05 +0000755requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100756run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100757 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100758 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100759 "$P_CLI debug_level=3 force_version=ssl3" \
760 0 \
761 -C "client hello, adding encrypt_then_mac extension" \
762 -S "found encrypt then mac extension" \
763 -S "server hello, adding encrypt then mac extension" \
764 -C "found encrypt_then_mac extension" \
765 -C "using encrypt then mac" \
766 -S "using encrypt then mac"
767
Janos Follathe2681a42016-03-07 15:57:05 +0000768requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100769run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100770 "$P_SRV debug_level=3 force_version=ssl3 \
771 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100772 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100773 0 \
774 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100775 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100776 -S "server hello, adding encrypt then mac extension" \
777 -C "found encrypt_then_mac extension" \
778 -C "using encrypt then mac" \
779 -S "using encrypt then mac"
780
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200781# Tests for Extended Master Secret extension
782
783run_test "Extended Master Secret: default" \
784 "$P_SRV debug_level=3" \
785 "$P_CLI debug_level=3" \
786 0 \
787 -c "client hello, adding extended_master_secret extension" \
788 -s "found extended master secret extension" \
789 -s "server hello, adding extended master secret extension" \
790 -c "found extended_master_secret extension" \
791 -c "using extended master secret" \
792 -s "using extended master secret"
793
794run_test "Extended Master Secret: client enabled, server disabled" \
795 "$P_SRV debug_level=3 extended_ms=0" \
796 "$P_CLI debug_level=3 extended_ms=1" \
797 0 \
798 -c "client hello, adding extended_master_secret extension" \
799 -s "found extended master secret extension" \
800 -S "server hello, adding extended master secret extension" \
801 -C "found extended_master_secret extension" \
802 -C "using extended master secret" \
803 -S "using extended master secret"
804
805run_test "Extended Master Secret: client disabled, server enabled" \
806 "$P_SRV debug_level=3 extended_ms=1" \
807 "$P_CLI debug_level=3 extended_ms=0" \
808 0 \
809 -C "client hello, adding extended_master_secret extension" \
810 -S "found extended master secret extension" \
811 -S "server hello, adding extended master secret extension" \
812 -C "found extended_master_secret extension" \
813 -C "using extended master secret" \
814 -S "using extended master secret"
815
Janos Follathe2681a42016-03-07 15:57:05 +0000816requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200817run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100818 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200819 "$P_CLI debug_level=3 force_version=ssl3" \
820 0 \
821 -C "client hello, adding extended_master_secret extension" \
822 -S "found extended master secret extension" \
823 -S "server hello, adding extended master secret extension" \
824 -C "found extended_master_secret extension" \
825 -C "using extended master secret" \
826 -S "using extended master secret"
827
Janos Follathe2681a42016-03-07 15:57:05 +0000828requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200829run_test "Extended Master Secret: client enabled, server SSLv3" \
830 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100831 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200832 0 \
833 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100834 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200835 -S "server hello, adding extended master secret extension" \
836 -C "found extended_master_secret extension" \
837 -C "using extended master secret" \
838 -S "using extended master secret"
839
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200840# Tests for FALLBACK_SCSV
841
842run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200843 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200844 "$P_CLI debug_level=3 force_version=tls1_1" \
845 0 \
846 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200847 -S "received FALLBACK_SCSV" \
848 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200849 -C "is a fatal alert message (msg 86)"
850
851run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200852 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200853 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
854 0 \
855 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200856 -S "received FALLBACK_SCSV" \
857 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200858 -C "is a fatal alert message (msg 86)"
859
860run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200861 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200862 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200863 1 \
864 -c "adding FALLBACK_SCSV" \
865 -s "received FALLBACK_SCSV" \
866 -s "inapropriate fallback" \
867 -c "is a fatal alert message (msg 86)"
868
869run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200870 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200871 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200872 0 \
873 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200874 -s "received FALLBACK_SCSV" \
875 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200876 -C "is a fatal alert message (msg 86)"
877
878requires_openssl_with_fallback_scsv
879run_test "Fallback SCSV: default, openssl server" \
880 "$O_SRV" \
881 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
882 0 \
883 -C "adding FALLBACK_SCSV" \
884 -C "is a fatal alert message (msg 86)"
885
886requires_openssl_with_fallback_scsv
887run_test "Fallback SCSV: enabled, openssl server" \
888 "$O_SRV" \
889 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
890 1 \
891 -c "adding FALLBACK_SCSV" \
892 -c "is a fatal alert message (msg 86)"
893
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200894requires_openssl_with_fallback_scsv
895run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200896 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200897 "$O_CLI -tls1_1" \
898 0 \
899 -S "received FALLBACK_SCSV" \
900 -S "inapropriate fallback"
901
902requires_openssl_with_fallback_scsv
903run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200904 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200905 "$O_CLI -tls1_1 -fallback_scsv" \
906 1 \
907 -s "received FALLBACK_SCSV" \
908 -s "inapropriate fallback"
909
910requires_openssl_with_fallback_scsv
911run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200912 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200913 "$O_CLI -fallback_scsv" \
914 0 \
915 -s "received FALLBACK_SCSV" \
916 -S "inapropriate fallback"
917
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100918# Tests for CBC 1/n-1 record splitting
919
920run_test "CBC Record splitting: TLS 1.2, no splitting" \
921 "$P_SRV" \
922 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
923 request_size=123 force_version=tls1_2" \
924 0 \
925 -s "Read from client: 123 bytes read" \
926 -S "Read from client: 1 bytes read" \
927 -S "122 bytes read"
928
929run_test "CBC Record splitting: TLS 1.1, no splitting" \
930 "$P_SRV" \
931 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
932 request_size=123 force_version=tls1_1" \
933 0 \
934 -s "Read from client: 123 bytes read" \
935 -S "Read from client: 1 bytes read" \
936 -S "122 bytes read"
937
938run_test "CBC Record splitting: TLS 1.0, splitting" \
939 "$P_SRV" \
940 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
941 request_size=123 force_version=tls1" \
942 0 \
943 -S "Read from client: 123 bytes read" \
944 -s "Read from client: 1 bytes read" \
945 -s "122 bytes read"
946
Janos Follathe2681a42016-03-07 15:57:05 +0000947requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100948run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100949 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100950 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
951 request_size=123 force_version=ssl3" \
952 0 \
953 -S "Read from client: 123 bytes read" \
954 -s "Read from client: 1 bytes read" \
955 -s "122 bytes read"
956
957run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100958 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100959 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
960 request_size=123 force_version=tls1" \
961 0 \
962 -s "Read from client: 123 bytes read" \
963 -S "Read from client: 1 bytes read" \
964 -S "122 bytes read"
965
966run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
967 "$P_SRV" \
968 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
969 request_size=123 force_version=tls1 recsplit=0" \
970 0 \
971 -s "Read from client: 123 bytes read" \
972 -S "Read from client: 1 bytes read" \
973 -S "122 bytes read"
974
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100975run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
976 "$P_SRV nbio=2" \
977 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
978 request_size=123 force_version=tls1" \
979 0 \
980 -S "Read from client: 123 bytes read" \
981 -s "Read from client: 1 bytes read" \
982 -s "122 bytes read"
983
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100984# Tests for Session Tickets
985
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200986run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200987 "$P_SRV debug_level=3 tickets=1" \
988 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100989 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100990 -c "client hello, adding session ticket extension" \
991 -s "found session ticket extension" \
992 -s "server hello, adding session ticket extension" \
993 -c "found session_ticket extension" \
994 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100995 -S "session successfully restored from cache" \
996 -s "session successfully restored from ticket" \
997 -s "a session has been resumed" \
998 -c "a session has been resumed"
999
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001000run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001001 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1002 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001003 0 \
1004 -c "client hello, adding session ticket extension" \
1005 -s "found session ticket extension" \
1006 -s "server hello, adding session ticket extension" \
1007 -c "found session_ticket extension" \
1008 -c "parse new session ticket" \
1009 -S "session successfully restored from cache" \
1010 -s "session successfully restored from ticket" \
1011 -s "a session has been resumed" \
1012 -c "a session has been resumed"
1013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001014run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001015 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1016 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001017 0 \
1018 -c "client hello, adding session ticket extension" \
1019 -s "found session ticket extension" \
1020 -s "server hello, adding session ticket extension" \
1021 -c "found session_ticket extension" \
1022 -c "parse new session ticket" \
1023 -S "session successfully restored from cache" \
1024 -S "session successfully restored from ticket" \
1025 -S "a session has been resumed" \
1026 -C "a session has been resumed"
1027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001028run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001029 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001030 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001031 0 \
1032 -c "client hello, adding session ticket extension" \
1033 -c "found session_ticket extension" \
1034 -c "parse new session ticket" \
1035 -c "a session has been resumed"
1036
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001037run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001038 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001039 "( $O_CLI -sess_out $SESSION; \
1040 $O_CLI -sess_in $SESSION; \
1041 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001042 0 \
1043 -s "found session ticket extension" \
1044 -s "server hello, adding session ticket extension" \
1045 -S "session successfully restored from cache" \
1046 -s "session successfully restored from ticket" \
1047 -s "a session has been resumed"
1048
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001049# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001051run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001052 "$P_SRV debug_level=3 tickets=0" \
1053 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001054 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001055 -c "client hello, adding session ticket extension" \
1056 -s "found session ticket extension" \
1057 -S "server hello, adding session ticket extension" \
1058 -C "found session_ticket extension" \
1059 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001060 -s "session successfully restored from cache" \
1061 -S "session successfully restored from ticket" \
1062 -s "a session has been resumed" \
1063 -c "a session has been resumed"
1064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001065run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001066 "$P_SRV debug_level=3 tickets=1" \
1067 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001068 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001069 -C "client hello, adding session ticket extension" \
1070 -S "found session ticket extension" \
1071 -S "server hello, adding session ticket extension" \
1072 -C "found session_ticket extension" \
1073 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001074 -s "session successfully restored from cache" \
1075 -S "session successfully restored from ticket" \
1076 -s "a session has been resumed" \
1077 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001078
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001079run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001080 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1081 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001082 0 \
1083 -S "session successfully restored from cache" \
1084 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001085 -S "a session has been resumed" \
1086 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001087
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001088run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001089 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1090 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001091 0 \
1092 -s "session successfully restored from cache" \
1093 -S "session successfully restored from ticket" \
1094 -s "a session has been resumed" \
1095 -c "a session has been resumed"
1096
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001097run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001098 "$P_SRV debug_level=3 tickets=0" \
1099 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001100 0 \
1101 -s "session successfully restored from cache" \
1102 -S "session successfully restored from ticket" \
1103 -s "a session has been resumed" \
1104 -c "a session has been resumed"
1105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001106run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001107 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1108 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001109 0 \
1110 -S "session successfully restored from cache" \
1111 -S "session successfully restored from ticket" \
1112 -S "a session has been resumed" \
1113 -C "a session has been resumed"
1114
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001115run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001116 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1117 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001118 0 \
1119 -s "session successfully restored from cache" \
1120 -S "session successfully restored from ticket" \
1121 -s "a session has been resumed" \
1122 -c "a session has been resumed"
1123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001124run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001125 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001126 "( $O_CLI -sess_out $SESSION; \
1127 $O_CLI -sess_in $SESSION; \
1128 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001129 0 \
1130 -s "found session ticket extension" \
1131 -S "server hello, adding session ticket extension" \
1132 -s "session successfully restored from cache" \
1133 -S "session successfully restored from ticket" \
1134 -s "a session has been resumed"
1135
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001136run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001137 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001138 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001139 0 \
1140 -C "found session_ticket extension" \
1141 -C "parse new session ticket" \
1142 -c "a session has been resumed"
1143
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001144# Tests for Max Fragment Length extension
1145
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001146run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001147 "$P_SRV debug_level=3" \
1148 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001149 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001150 -c "Maximum fragment length is 16384" \
1151 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001152 -C "client hello, adding max_fragment_length extension" \
1153 -S "found max fragment length extension" \
1154 -S "server hello, max_fragment_length extension" \
1155 -C "found max_fragment_length extension"
1156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001157run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001158 "$P_SRV debug_level=3" \
1159 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001160 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001161 -c "Maximum fragment length is 4096" \
1162 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001163 -c "client hello, adding max_fragment_length extension" \
1164 -s "found max fragment length extension" \
1165 -s "server hello, max_fragment_length extension" \
1166 -c "found max_fragment_length extension"
1167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001168run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001169 "$P_SRV debug_level=3 max_frag_len=4096" \
1170 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001171 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001172 -c "Maximum fragment length is 16384" \
1173 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001174 -C "client hello, adding max_fragment_length extension" \
1175 -S "found max fragment length extension" \
1176 -S "server hello, max_fragment_length extension" \
1177 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001179requires_gnutls
1180run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001181 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001182 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001183 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001184 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001185 -c "client hello, adding max_fragment_length extension" \
1186 -c "found max_fragment_length extension"
1187
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001188run_test "Max fragment length: client, message just fits" \
1189 "$P_SRV debug_level=3" \
1190 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1191 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001192 -c "Maximum fragment length is 2048" \
1193 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001194 -c "client hello, adding max_fragment_length extension" \
1195 -s "found max fragment length extension" \
1196 -s "server hello, max_fragment_length extension" \
1197 -c "found max_fragment_length extension" \
1198 -c "2048 bytes written in 1 fragments" \
1199 -s "2048 bytes read"
1200
1201run_test "Max fragment length: client, larger message" \
1202 "$P_SRV debug_level=3" \
1203 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1204 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001205 -c "Maximum fragment length is 2048" \
1206 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001207 -c "client hello, adding max_fragment_length extension" \
1208 -s "found max fragment length extension" \
1209 -s "server hello, max_fragment_length extension" \
1210 -c "found max_fragment_length extension" \
1211 -c "2345 bytes written in 2 fragments" \
1212 -s "2048 bytes read" \
1213 -s "297 bytes read"
1214
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001215run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001216 "$P_SRV debug_level=3 dtls=1" \
1217 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1218 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001219 -c "Maximum fragment length is 2048" \
1220 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001221 -c "client hello, adding max_fragment_length extension" \
1222 -s "found max fragment length extension" \
1223 -s "server hello, max_fragment_length extension" \
1224 -c "found max_fragment_length extension" \
1225 -c "fragment larger than.*maximum"
1226
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001227# Tests for renegotiation
1228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001229run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001230 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001231 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001232 0 \
1233 -C "client hello, adding renegotiation extension" \
1234 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1235 -S "found renegotiation extension" \
1236 -s "server hello, secure renegotiation extension" \
1237 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001238 -C "=> renegotiate" \
1239 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001240 -S "write hello request"
1241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001242run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001243 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001244 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001245 0 \
1246 -c "client hello, adding renegotiation extension" \
1247 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1248 -s "found renegotiation extension" \
1249 -s "server hello, secure renegotiation extension" \
1250 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001251 -c "=> renegotiate" \
1252 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001253 -S "write hello request"
1254
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001255run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001256 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001258 0 \
1259 -c "client hello, adding renegotiation extension" \
1260 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1261 -s "found renegotiation extension" \
1262 -s "server hello, secure renegotiation extension" \
1263 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001264 -c "=> renegotiate" \
1265 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001266 -s "write hello request"
1267
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001268run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001269 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001270 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001271 0 \
1272 -c "client hello, adding renegotiation extension" \
1273 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1274 -s "found renegotiation extension" \
1275 -s "server hello, secure renegotiation extension" \
1276 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001277 -c "=> renegotiate" \
1278 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001279 -s "write hello request"
1280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001281run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001282 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001283 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001284 1 \
1285 -c "client hello, adding renegotiation extension" \
1286 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1287 -S "found renegotiation extension" \
1288 -s "server hello, secure renegotiation extension" \
1289 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001290 -c "=> renegotiate" \
1291 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001292 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001293 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001294 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001296run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001297 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001298 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001299 0 \
1300 -C "client hello, adding renegotiation extension" \
1301 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1302 -S "found renegotiation extension" \
1303 -s "server hello, secure renegotiation extension" \
1304 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001305 -C "=> renegotiate" \
1306 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001307 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001308 -S "SSL - An unexpected message was received from our peer" \
1309 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001311run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001312 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001313 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001314 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001315 0 \
1316 -C "client hello, adding renegotiation extension" \
1317 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1318 -S "found renegotiation extension" \
1319 -s "server hello, secure renegotiation extension" \
1320 -c "found renegotiation extension" \
1321 -C "=> renegotiate" \
1322 -S "=> renegotiate" \
1323 -s "write hello request" \
1324 -S "SSL - An unexpected message was received from our peer" \
1325 -S "failed"
1326
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001327# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001328run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001329 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001330 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001331 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001332 0 \
1333 -C "client hello, adding renegotiation extension" \
1334 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1335 -S "found renegotiation extension" \
1336 -s "server hello, secure renegotiation extension" \
1337 -c "found renegotiation extension" \
1338 -C "=> renegotiate" \
1339 -S "=> renegotiate" \
1340 -s "write hello request" \
1341 -S "SSL - An unexpected message was received from our peer" \
1342 -S "failed"
1343
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001344run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001345 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001346 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001347 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001348 0 \
1349 -C "client hello, adding renegotiation extension" \
1350 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1351 -S "found renegotiation extension" \
1352 -s "server hello, secure renegotiation extension" \
1353 -c "found renegotiation extension" \
1354 -C "=> renegotiate" \
1355 -S "=> renegotiate" \
1356 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001357 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001358
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001359run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001360 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001361 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001362 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001363 0 \
1364 -c "client hello, adding renegotiation extension" \
1365 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1366 -s "found renegotiation extension" \
1367 -s "server hello, secure renegotiation extension" \
1368 -c "found renegotiation extension" \
1369 -c "=> renegotiate" \
1370 -s "=> renegotiate" \
1371 -s "write hello request" \
1372 -S "SSL - An unexpected message was received from our peer" \
1373 -S "failed"
1374
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001375run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001376 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001377 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1378 0 \
1379 -C "client hello, adding renegotiation extension" \
1380 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1381 -S "found renegotiation extension" \
1382 -s "server hello, secure renegotiation extension" \
1383 -c "found renegotiation extension" \
1384 -S "record counter limit reached: renegotiate" \
1385 -C "=> renegotiate" \
1386 -S "=> renegotiate" \
1387 -S "write hello request" \
1388 -S "SSL - An unexpected message was received from our peer" \
1389 -S "failed"
1390
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001391# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001392run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001393 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001394 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001395 0 \
1396 -c "client hello, adding renegotiation extension" \
1397 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1398 -s "found renegotiation extension" \
1399 -s "server hello, secure renegotiation extension" \
1400 -c "found renegotiation extension" \
1401 -s "record counter limit reached: renegotiate" \
1402 -c "=> renegotiate" \
1403 -s "=> renegotiate" \
1404 -s "write hello request" \
1405 -S "SSL - An unexpected message was received from our peer" \
1406 -S "failed"
1407
1408run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001409 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001410 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001411 0 \
1412 -c "client hello, adding renegotiation extension" \
1413 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1414 -s "found renegotiation extension" \
1415 -s "server hello, secure renegotiation extension" \
1416 -c "found renegotiation extension" \
1417 -s "record counter limit reached: renegotiate" \
1418 -c "=> renegotiate" \
1419 -s "=> renegotiate" \
1420 -s "write hello request" \
1421 -S "SSL - An unexpected message was received from our peer" \
1422 -S "failed"
1423
1424run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001425 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001426 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1427 0 \
1428 -C "client hello, adding renegotiation extension" \
1429 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1430 -S "found renegotiation extension" \
1431 -s "server hello, secure renegotiation extension" \
1432 -c "found renegotiation extension" \
1433 -S "record counter limit reached: renegotiate" \
1434 -C "=> renegotiate" \
1435 -S "=> renegotiate" \
1436 -S "write hello request" \
1437 -S "SSL - An unexpected message was received from our peer" \
1438 -S "failed"
1439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001440run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001441 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001442 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001443 0 \
1444 -c "client hello, adding renegotiation extension" \
1445 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1446 -s "found renegotiation extension" \
1447 -s "server hello, secure renegotiation extension" \
1448 -c "found renegotiation extension" \
1449 -c "=> renegotiate" \
1450 -s "=> renegotiate" \
1451 -S "write hello request"
1452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001453run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001454 "$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 +02001455 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001456 0 \
1457 -c "client hello, adding renegotiation extension" \
1458 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1459 -s "found renegotiation extension" \
1460 -s "server hello, secure renegotiation extension" \
1461 -c "found renegotiation extension" \
1462 -c "=> renegotiate" \
1463 -s "=> renegotiate" \
1464 -s "write hello request"
1465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001466run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001467 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001468 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001469 0 \
1470 -c "client hello, adding renegotiation extension" \
1471 -c "found renegotiation extension" \
1472 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001473 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001474 -C "error" \
1475 -c "HTTP/1.0 200 [Oo][Kk]"
1476
Paul Bakker539d9722015-02-08 16:18:35 +01001477requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001478run_test "Renegotiation: gnutls server strict, client-initiated" \
1479 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001480 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001481 0 \
1482 -c "client hello, adding renegotiation extension" \
1483 -c "found renegotiation extension" \
1484 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001485 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001486 -C "error" \
1487 -c "HTTP/1.0 200 [Oo][Kk]"
1488
Paul Bakker539d9722015-02-08 16:18:35 +01001489requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001490run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1491 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1492 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1493 1 \
1494 -c "client hello, adding renegotiation extension" \
1495 -C "found renegotiation extension" \
1496 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001497 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001498 -c "error" \
1499 -C "HTTP/1.0 200 [Oo][Kk]"
1500
Paul Bakker539d9722015-02-08 16:18:35 +01001501requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001502run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1503 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1504 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1505 allow_legacy=0" \
1506 1 \
1507 -c "client hello, adding renegotiation extension" \
1508 -C "found renegotiation extension" \
1509 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001510 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001511 -c "error" \
1512 -C "HTTP/1.0 200 [Oo][Kk]"
1513
Paul Bakker539d9722015-02-08 16:18:35 +01001514requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001515run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1516 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1517 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1518 allow_legacy=1" \
1519 0 \
1520 -c "client hello, adding renegotiation extension" \
1521 -C "found renegotiation extension" \
1522 -c "=> renegotiate" \
1523 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001524 -C "error" \
1525 -c "HTTP/1.0 200 [Oo][Kk]"
1526
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001527run_test "Renegotiation: DTLS, client-initiated" \
1528 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1529 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1530 0 \
1531 -c "client hello, adding renegotiation extension" \
1532 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1533 -s "found renegotiation extension" \
1534 -s "server hello, secure renegotiation extension" \
1535 -c "found renegotiation extension" \
1536 -c "=> renegotiate" \
1537 -s "=> renegotiate" \
1538 -S "write hello request"
1539
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001540run_test "Renegotiation: DTLS, server-initiated" \
1541 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001542 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1543 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001544 0 \
1545 -c "client hello, adding renegotiation extension" \
1546 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1547 -s "found renegotiation extension" \
1548 -s "server hello, secure renegotiation extension" \
1549 -c "found renegotiation extension" \
1550 -c "=> renegotiate" \
1551 -s "=> renegotiate" \
1552 -s "write hello request"
1553
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001554requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001555run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1556 "$G_SRV -u --mtu 4096" \
1557 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1558 0 \
1559 -c "client hello, adding renegotiation extension" \
1560 -c "found renegotiation extension" \
1561 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001562 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001563 -C "error" \
1564 -s "Extra-header:"
1565
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001566# Test for the "secure renegotation" extension only (no actual renegotiation)
1567
Paul Bakker539d9722015-02-08 16:18:35 +01001568requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001569run_test "Renego ext: gnutls server strict, client default" \
1570 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1571 "$P_CLI debug_level=3" \
1572 0 \
1573 -c "found renegotiation extension" \
1574 -C "error" \
1575 -c "HTTP/1.0 200 [Oo][Kk]"
1576
Paul Bakker539d9722015-02-08 16:18:35 +01001577requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001578run_test "Renego ext: gnutls server unsafe, client default" \
1579 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1580 "$P_CLI debug_level=3" \
1581 0 \
1582 -C "found renegotiation extension" \
1583 -C "error" \
1584 -c "HTTP/1.0 200 [Oo][Kk]"
1585
Paul Bakker539d9722015-02-08 16:18:35 +01001586requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001587run_test "Renego ext: gnutls server unsafe, client break legacy" \
1588 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1589 "$P_CLI debug_level=3 allow_legacy=-1" \
1590 1 \
1591 -C "found renegotiation extension" \
1592 -c "error" \
1593 -C "HTTP/1.0 200 [Oo][Kk]"
1594
Paul Bakker539d9722015-02-08 16:18:35 +01001595requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001596run_test "Renego ext: gnutls client strict, server default" \
1597 "$P_SRV debug_level=3" \
1598 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1599 0 \
1600 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1601 -s "server hello, secure renegotiation extension"
1602
Paul Bakker539d9722015-02-08 16:18:35 +01001603requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001604run_test "Renego ext: gnutls client unsafe, server default" \
1605 "$P_SRV debug_level=3" \
1606 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1607 0 \
1608 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1609 -S "server hello, secure renegotiation extension"
1610
Paul Bakker539d9722015-02-08 16:18:35 +01001611requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001612run_test "Renego ext: gnutls client unsafe, server break legacy" \
1613 "$P_SRV debug_level=3 allow_legacy=-1" \
1614 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1615 1 \
1616 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1617 -S "server hello, secure renegotiation extension"
1618
Janos Follath0b242342016-02-17 10:11:21 +00001619# Tests for silently dropping trailing extra bytes in .der certificates
1620
1621requires_gnutls
1622run_test "DER format: no trailing bytes" \
1623 "$P_SRV crt_file=data_files/server5-der0.crt \
1624 key_file=data_files/server5.key" \
1625 "$G_CLI " \
1626 0 \
1627 -c "Handshake was completed" \
1628
1629requires_gnutls
1630run_test "DER format: with a trailing zero byte" \
1631 "$P_SRV crt_file=data_files/server5-der1a.crt \
1632 key_file=data_files/server5.key" \
1633 "$G_CLI " \
1634 0 \
1635 -c "Handshake was completed" \
1636
1637requires_gnutls
1638run_test "DER format: with a trailing random byte" \
1639 "$P_SRV crt_file=data_files/server5-der1b.crt \
1640 key_file=data_files/server5.key" \
1641 "$G_CLI " \
1642 0 \
1643 -c "Handshake was completed" \
1644
1645requires_gnutls
1646run_test "DER format: with 2 trailing random bytes" \
1647 "$P_SRV crt_file=data_files/server5-der2.crt \
1648 key_file=data_files/server5.key" \
1649 "$G_CLI " \
1650 0 \
1651 -c "Handshake was completed" \
1652
1653requires_gnutls
1654run_test "DER format: with 4 trailing random bytes" \
1655 "$P_SRV crt_file=data_files/server5-der4.crt \
1656 key_file=data_files/server5.key" \
1657 "$G_CLI " \
1658 0 \
1659 -c "Handshake was completed" \
1660
1661requires_gnutls
1662run_test "DER format: with 8 trailing random bytes" \
1663 "$P_SRV crt_file=data_files/server5-der8.crt \
1664 key_file=data_files/server5.key" \
1665 "$G_CLI " \
1666 0 \
1667 -c "Handshake was completed" \
1668
1669requires_gnutls
1670run_test "DER format: with 9 trailing random bytes" \
1671 "$P_SRV crt_file=data_files/server5-der9.crt \
1672 key_file=data_files/server5.key" \
1673 "$G_CLI " \
1674 0 \
1675 -c "Handshake was completed" \
1676
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001677# Tests for auth_mode
1678
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001679run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001680 "$P_SRV crt_file=data_files/server5-badsign.crt \
1681 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001682 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001683 1 \
1684 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001685 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001686 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001687 -c "X509 - Certificate verification failed"
1688
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001689run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001690 "$P_SRV crt_file=data_files/server5-badsign.crt \
1691 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001692 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001693 0 \
1694 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001695 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001696 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001697 -C "X509 - Certificate verification failed"
1698
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001699run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001700 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001701 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001702 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001703 0 \
1704 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001705 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001706 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001707 -C "X509 - Certificate verification failed"
1708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001709run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001710 "$P_SRV debug_level=3 auth_mode=required" \
1711 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001712 key_file=data_files/server5.key" \
1713 1 \
1714 -S "skip write certificate request" \
1715 -C "skip parse certificate request" \
1716 -c "got a certificate request" \
1717 -C "skip write certificate" \
1718 -C "skip write certificate verify" \
1719 -S "skip parse certificate verify" \
1720 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001721 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001722 -s "! mbedtls_ssl_handshake returned" \
1723 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001724 -s "X509 - Certificate verification failed"
1725
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001726run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001727 "$P_SRV debug_level=3 auth_mode=optional" \
1728 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001729 key_file=data_files/server5.key" \
1730 0 \
1731 -S "skip write certificate request" \
1732 -C "skip parse certificate request" \
1733 -c "got a certificate request" \
1734 -C "skip write certificate" \
1735 -C "skip write certificate verify" \
1736 -S "skip parse certificate verify" \
1737 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001738 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001739 -S "! mbedtls_ssl_handshake returned" \
1740 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001741 -S "X509 - Certificate verification failed"
1742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001743run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001744 "$P_SRV debug_level=3 auth_mode=none" \
1745 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001746 key_file=data_files/server5.key" \
1747 0 \
1748 -s "skip write certificate request" \
1749 -C "skip parse certificate request" \
1750 -c "got no certificate request" \
1751 -c "skip write certificate" \
1752 -c "skip write certificate verify" \
1753 -s "skip parse certificate verify" \
1754 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001755 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001756 -S "! mbedtls_ssl_handshake returned" \
1757 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001758 -S "X509 - Certificate verification failed"
1759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001760run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001761 "$P_SRV debug_level=3 auth_mode=optional" \
1762 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001763 0 \
1764 -S "skip write certificate request" \
1765 -C "skip parse certificate request" \
1766 -c "got a certificate request" \
1767 -C "skip write certificate$" \
1768 -C "got no certificate to send" \
1769 -S "SSLv3 client has no certificate" \
1770 -c "skip write certificate verify" \
1771 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001772 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001773 -S "! mbedtls_ssl_handshake returned" \
1774 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001775 -S "X509 - Certificate verification failed"
1776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001777run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001778 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001779 "$O_CLI" \
1780 0 \
1781 -S "skip write certificate request" \
1782 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001783 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001784 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001785 -S "X509 - Certificate verification failed"
1786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001787run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001788 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001789 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001790 0 \
1791 -C "skip parse certificate request" \
1792 -c "got a certificate request" \
1793 -C "skip write certificate$" \
1794 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001795 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001796
Janos Follathe2681a42016-03-07 15:57:05 +00001797requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001798run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001799 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001800 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001801 0 \
1802 -S "skip write certificate request" \
1803 -C "skip parse certificate request" \
1804 -c "got a certificate request" \
1805 -C "skip write certificate$" \
1806 -c "skip write certificate verify" \
1807 -c "got no certificate to send" \
1808 -s "SSLv3 client has no certificate" \
1809 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001810 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001811 -S "! mbedtls_ssl_handshake returned" \
1812 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001813 -S "X509 - Certificate verification failed"
1814
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001815# Tests for certificate selection based on SHA verson
1816
1817run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1818 "$P_SRV crt_file=data_files/server5.crt \
1819 key_file=data_files/server5.key \
1820 crt_file2=data_files/server5-sha1.crt \
1821 key_file2=data_files/server5.key" \
1822 "$P_CLI force_version=tls1_2" \
1823 0 \
1824 -c "signed using.*ECDSA with SHA256" \
1825 -C "signed using.*ECDSA with SHA1"
1826
1827run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1828 "$P_SRV crt_file=data_files/server5.crt \
1829 key_file=data_files/server5.key \
1830 crt_file2=data_files/server5-sha1.crt \
1831 key_file2=data_files/server5.key" \
1832 "$P_CLI force_version=tls1_1" \
1833 0 \
1834 -C "signed using.*ECDSA with SHA256" \
1835 -c "signed using.*ECDSA with SHA1"
1836
1837run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1838 "$P_SRV crt_file=data_files/server5.crt \
1839 key_file=data_files/server5.key \
1840 crt_file2=data_files/server5-sha1.crt \
1841 key_file2=data_files/server5.key" \
1842 "$P_CLI force_version=tls1" \
1843 0 \
1844 -C "signed using.*ECDSA with SHA256" \
1845 -c "signed using.*ECDSA with SHA1"
1846
1847run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1848 "$P_SRV crt_file=data_files/server5.crt \
1849 key_file=data_files/server5.key \
1850 crt_file2=data_files/server6.crt \
1851 key_file2=data_files/server6.key" \
1852 "$P_CLI force_version=tls1_1" \
1853 0 \
1854 -c "serial number.*09" \
1855 -c "signed using.*ECDSA with SHA256" \
1856 -C "signed using.*ECDSA with SHA1"
1857
1858run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1859 "$P_SRV crt_file=data_files/server6.crt \
1860 key_file=data_files/server6.key \
1861 crt_file2=data_files/server5.crt \
1862 key_file2=data_files/server5.key" \
1863 "$P_CLI force_version=tls1_1" \
1864 0 \
1865 -c "serial number.*0A" \
1866 -c "signed using.*ECDSA with SHA256" \
1867 -C "signed using.*ECDSA with SHA1"
1868
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001869# tests for SNI
1870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001871run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001872 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001873 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001874 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001875 0 \
1876 -S "parse ServerName extension" \
1877 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1878 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001880run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001881 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001882 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001883 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 +02001884 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001885 0 \
1886 -s "parse ServerName extension" \
1887 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1888 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001889
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001890run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001891 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001892 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001893 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 +02001894 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001895 0 \
1896 -s "parse ServerName extension" \
1897 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1898 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001900run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001901 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001902 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001903 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 +02001904 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001905 1 \
1906 -s "parse ServerName extension" \
1907 -s "ssl_sni_wrapper() returned" \
1908 -s "mbedtls_ssl_handshake returned" \
1909 -c "mbedtls_ssl_handshake returned" \
1910 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001911
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001912run_test "SNI: client auth no override: optional" \
1913 "$P_SRV debug_level=3 auth_mode=optional \
1914 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1915 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1916 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001917 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001918 -S "skip write certificate request" \
1919 -C "skip parse certificate request" \
1920 -c "got a certificate request" \
1921 -C "skip write certificate" \
1922 -C "skip write certificate verify" \
1923 -S "skip parse certificate verify"
1924
1925run_test "SNI: client auth override: none -> optional" \
1926 "$P_SRV debug_level=3 auth_mode=none \
1927 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1928 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1929 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001930 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001931 -S "skip write certificate request" \
1932 -C "skip parse certificate request" \
1933 -c "got a certificate request" \
1934 -C "skip write certificate" \
1935 -C "skip write certificate verify" \
1936 -S "skip parse certificate verify"
1937
1938run_test "SNI: client auth override: optional -> none" \
1939 "$P_SRV debug_level=3 auth_mode=optional \
1940 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1941 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1942 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001943 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001944 -s "skip write certificate request" \
1945 -C "skip parse certificate request" \
1946 -c "got no certificate request" \
1947 -c "skip write certificate" \
1948 -c "skip write certificate verify" \
1949 -s "skip parse certificate verify"
1950
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001951run_test "SNI: CA no override" \
1952 "$P_SRV debug_level=3 auth_mode=optional \
1953 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1954 ca_file=data_files/test-ca.crt \
1955 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1956 "$P_CLI debug_level=3 server_name=localhost \
1957 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1958 1 \
1959 -S "skip write certificate request" \
1960 -C "skip parse certificate request" \
1961 -c "got a certificate request" \
1962 -C "skip write certificate" \
1963 -C "skip write certificate verify" \
1964 -S "skip parse certificate verify" \
1965 -s "x509_verify_cert() returned" \
1966 -s "! The certificate is not correctly signed by the trusted CA" \
1967 -S "The certificate has been revoked (is on a CRL)"
1968
1969run_test "SNI: CA override" \
1970 "$P_SRV debug_level=3 auth_mode=optional \
1971 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1972 ca_file=data_files/test-ca.crt \
1973 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1974 "$P_CLI debug_level=3 server_name=localhost \
1975 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1976 0 \
1977 -S "skip write certificate request" \
1978 -C "skip parse certificate request" \
1979 -c "got a certificate request" \
1980 -C "skip write certificate" \
1981 -C "skip write certificate verify" \
1982 -S "skip parse certificate verify" \
1983 -S "x509_verify_cert() returned" \
1984 -S "! The certificate is not correctly signed by the trusted CA" \
1985 -S "The certificate has been revoked (is on a CRL)"
1986
1987run_test "SNI: CA override with CRL" \
1988 "$P_SRV debug_level=3 auth_mode=optional \
1989 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1990 ca_file=data_files/test-ca.crt \
1991 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1992 "$P_CLI debug_level=3 server_name=localhost \
1993 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1994 1 \
1995 -S "skip write certificate request" \
1996 -C "skip parse certificate request" \
1997 -c "got a certificate request" \
1998 -C "skip write certificate" \
1999 -C "skip write certificate verify" \
2000 -S "skip parse certificate verify" \
2001 -s "x509_verify_cert() returned" \
2002 -S "! The certificate is not correctly signed by the trusted CA" \
2003 -s "The certificate has been revoked (is on a CRL)"
2004
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002005# Tests for non-blocking I/O: exercise a variety of handshake flows
2006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002007run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002008 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2009 "$P_CLI nbio=2 tickets=0" \
2010 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002011 -S "mbedtls_ssl_handshake returned" \
2012 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002013 -c "Read from server: .* bytes read"
2014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002015run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002016 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2017 "$P_CLI nbio=2 tickets=0" \
2018 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002019 -S "mbedtls_ssl_handshake returned" \
2020 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002021 -c "Read from server: .* bytes read"
2022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002023run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002024 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2025 "$P_CLI nbio=2 tickets=1" \
2026 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002027 -S "mbedtls_ssl_handshake returned" \
2028 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002029 -c "Read from server: .* bytes read"
2030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002031run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002032 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2033 "$P_CLI nbio=2 tickets=1" \
2034 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002035 -S "mbedtls_ssl_handshake returned" \
2036 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002037 -c "Read from server: .* bytes read"
2038
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002039run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002040 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2041 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2042 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002043 -S "mbedtls_ssl_handshake returned" \
2044 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002045 -c "Read from server: .* bytes read"
2046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002047run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002048 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2049 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2050 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002051 -S "mbedtls_ssl_handshake returned" \
2052 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002053 -c "Read from server: .* bytes read"
2054
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002055run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002056 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2057 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2058 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002059 -S "mbedtls_ssl_handshake returned" \
2060 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002061 -c "Read from server: .* bytes read"
2062
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002063# Tests for version negotiation
2064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002065run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002066 "$P_SRV" \
2067 "$P_CLI" \
2068 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002069 -S "mbedtls_ssl_handshake returned" \
2070 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002071 -s "Protocol is TLSv1.2" \
2072 -c "Protocol is TLSv1.2"
2073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002074run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002075 "$P_SRV" \
2076 "$P_CLI max_version=tls1_1" \
2077 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002078 -S "mbedtls_ssl_handshake returned" \
2079 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002080 -s "Protocol is TLSv1.1" \
2081 -c "Protocol is TLSv1.1"
2082
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002083run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002084 "$P_SRV max_version=tls1_1" \
2085 "$P_CLI" \
2086 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002087 -S "mbedtls_ssl_handshake returned" \
2088 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002089 -s "Protocol is TLSv1.1" \
2090 -c "Protocol is TLSv1.1"
2091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002092run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002093 "$P_SRV max_version=tls1_1" \
2094 "$P_CLI max_version=tls1_1" \
2095 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002096 -S "mbedtls_ssl_handshake returned" \
2097 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002098 -s "Protocol is TLSv1.1" \
2099 -c "Protocol is TLSv1.1"
2100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002101run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002102 "$P_SRV min_version=tls1_1" \
2103 "$P_CLI max_version=tls1_1" \
2104 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002105 -S "mbedtls_ssl_handshake returned" \
2106 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002107 -s "Protocol is TLSv1.1" \
2108 -c "Protocol is TLSv1.1"
2109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002110run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002111 "$P_SRV max_version=tls1_1" \
2112 "$P_CLI min_version=tls1_1" \
2113 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002114 -S "mbedtls_ssl_handshake returned" \
2115 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002116 -s "Protocol is TLSv1.1" \
2117 -c "Protocol is TLSv1.1"
2118
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002119run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002120 "$P_SRV max_version=tls1_1" \
2121 "$P_CLI min_version=tls1_2" \
2122 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002123 -s "mbedtls_ssl_handshake returned" \
2124 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002125 -c "SSL - Handshake protocol not within min/max boundaries"
2126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002127run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002128 "$P_SRV min_version=tls1_2" \
2129 "$P_CLI max_version=tls1_1" \
2130 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002131 -s "mbedtls_ssl_handshake returned" \
2132 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002133 -s "SSL - Handshake protocol not within min/max boundaries"
2134
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002135# Tests for ALPN extension
2136
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002137run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002138 "$P_SRV debug_level=3" \
2139 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002140 0 \
2141 -C "client hello, adding alpn extension" \
2142 -S "found alpn extension" \
2143 -C "got an alert message, type: \\[2:120]" \
2144 -S "server hello, adding alpn extension" \
2145 -C "found alpn extension " \
2146 -C "Application Layer Protocol is" \
2147 -S "Application Layer Protocol is"
2148
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002149run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002150 "$P_SRV debug_level=3" \
2151 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002152 0 \
2153 -c "client hello, adding alpn extension" \
2154 -s "found alpn extension" \
2155 -C "got an alert message, type: \\[2:120]" \
2156 -S "server hello, adding alpn extension" \
2157 -C "found alpn extension " \
2158 -c "Application Layer Protocol is (none)" \
2159 -S "Application Layer Protocol is"
2160
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002161run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002162 "$P_SRV debug_level=3 alpn=abc,1234" \
2163 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002164 0 \
2165 -C "client hello, adding alpn extension" \
2166 -S "found alpn extension" \
2167 -C "got an alert message, type: \\[2:120]" \
2168 -S "server hello, adding alpn extension" \
2169 -C "found alpn extension " \
2170 -C "Application Layer Protocol is" \
2171 -s "Application Layer Protocol is (none)"
2172
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002173run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002174 "$P_SRV debug_level=3 alpn=abc,1234" \
2175 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002176 0 \
2177 -c "client hello, adding alpn extension" \
2178 -s "found alpn extension" \
2179 -C "got an alert message, type: \\[2:120]" \
2180 -s "server hello, adding alpn extension" \
2181 -c "found alpn extension" \
2182 -c "Application Layer Protocol is abc" \
2183 -s "Application Layer Protocol is abc"
2184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002185run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002186 "$P_SRV debug_level=3 alpn=abc,1234" \
2187 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002188 0 \
2189 -c "client hello, adding alpn extension" \
2190 -s "found alpn extension" \
2191 -C "got an alert message, type: \\[2:120]" \
2192 -s "server hello, adding alpn extension" \
2193 -c "found alpn extension" \
2194 -c "Application Layer Protocol is abc" \
2195 -s "Application Layer Protocol is abc"
2196
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002197run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002198 "$P_SRV debug_level=3 alpn=abc,1234" \
2199 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002200 0 \
2201 -c "client hello, adding alpn extension" \
2202 -s "found alpn extension" \
2203 -C "got an alert message, type: \\[2:120]" \
2204 -s "server hello, adding alpn extension" \
2205 -c "found alpn extension" \
2206 -c "Application Layer Protocol is 1234" \
2207 -s "Application Layer Protocol is 1234"
2208
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002209run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002210 "$P_SRV debug_level=3 alpn=abc,123" \
2211 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002212 1 \
2213 -c "client hello, adding alpn extension" \
2214 -s "found alpn extension" \
2215 -c "got an alert message, type: \\[2:120]" \
2216 -S "server hello, adding alpn extension" \
2217 -C "found alpn extension" \
2218 -C "Application Layer Protocol is 1234" \
2219 -S "Application Layer Protocol is 1234"
2220
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002221
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002222# Tests for keyUsage in leaf certificates, part 1:
2223# server-side certificate/suite selection
2224
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002225run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002226 "$P_SRV key_file=data_files/server2.key \
2227 crt_file=data_files/server2.ku-ds.crt" \
2228 "$P_CLI" \
2229 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002230 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002231
2232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002233run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002234 "$P_SRV key_file=data_files/server2.key \
2235 crt_file=data_files/server2.ku-ke.crt" \
2236 "$P_CLI" \
2237 0 \
2238 -c "Ciphersuite is TLS-RSA-WITH-"
2239
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002240run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002241 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002242 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002243 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002244 1 \
2245 -C "Ciphersuite is "
2246
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002247run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002248 "$P_SRV key_file=data_files/server5.key \
2249 crt_file=data_files/server5.ku-ds.crt" \
2250 "$P_CLI" \
2251 0 \
2252 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2253
2254
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002255run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002256 "$P_SRV key_file=data_files/server5.key \
2257 crt_file=data_files/server5.ku-ka.crt" \
2258 "$P_CLI" \
2259 0 \
2260 -c "Ciphersuite is TLS-ECDH-"
2261
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002262run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002263 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002264 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002265 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002266 1 \
2267 -C "Ciphersuite is "
2268
2269# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002270# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002271
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002272run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002273 "$O_SRV -key data_files/server2.key \
2274 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002275 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002276 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2277 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002278 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002279 -C "Processing of the Certificate handshake message failed" \
2280 -c "Ciphersuite is TLS-"
2281
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002282run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002283 "$O_SRV -key data_files/server2.key \
2284 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002285 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002286 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2287 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002288 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002289 -C "Processing of the Certificate handshake message failed" \
2290 -c "Ciphersuite is TLS-"
2291
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002292run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002293 "$O_SRV -key data_files/server2.key \
2294 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002295 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002296 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2297 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002298 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002299 -C "Processing of the Certificate handshake message failed" \
2300 -c "Ciphersuite is TLS-"
2301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002302run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002303 "$O_SRV -key data_files/server2.key \
2304 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002305 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002306 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2307 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002308 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002309 -c "Processing of the Certificate handshake message failed" \
2310 -C "Ciphersuite is TLS-"
2311
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002312run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2313 "$O_SRV -key data_files/server2.key \
2314 -cert data_files/server2.ku-ke.crt" \
2315 "$P_CLI debug_level=1 auth_mode=optional \
2316 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2317 0 \
2318 -c "bad certificate (usage extensions)" \
2319 -C "Processing of the Certificate handshake message failed" \
2320 -c "Ciphersuite is TLS-" \
2321 -c "! Usage does not match the keyUsage extension"
2322
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002323run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002324 "$O_SRV -key data_files/server2.key \
2325 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002326 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002327 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2328 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002329 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002330 -C "Processing of the Certificate handshake message failed" \
2331 -c "Ciphersuite is TLS-"
2332
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002333run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002334 "$O_SRV -key data_files/server2.key \
2335 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002336 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002337 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2338 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002339 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002340 -c "Processing of the Certificate handshake message failed" \
2341 -C "Ciphersuite is TLS-"
2342
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002343run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2344 "$O_SRV -key data_files/server2.key \
2345 -cert data_files/server2.ku-ds.crt" \
2346 "$P_CLI debug_level=1 auth_mode=optional \
2347 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2348 0 \
2349 -c "bad certificate (usage extensions)" \
2350 -C "Processing of the Certificate handshake message failed" \
2351 -c "Ciphersuite is TLS-" \
2352 -c "! Usage does not match the keyUsage extension"
2353
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002354# Tests for keyUsage in leaf certificates, part 3:
2355# server-side checking of client cert
2356
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002357run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002358 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002359 "$O_CLI -key data_files/server2.key \
2360 -cert data_files/server2.ku-ds.crt" \
2361 0 \
2362 -S "bad certificate (usage extensions)" \
2363 -S "Processing of the Certificate handshake message failed"
2364
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002365run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002366 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002367 "$O_CLI -key data_files/server2.key \
2368 -cert data_files/server2.ku-ke.crt" \
2369 0 \
2370 -s "bad certificate (usage extensions)" \
2371 -S "Processing of the Certificate handshake message failed"
2372
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002373run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002374 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002375 "$O_CLI -key data_files/server2.key \
2376 -cert data_files/server2.ku-ke.crt" \
2377 1 \
2378 -s "bad certificate (usage extensions)" \
2379 -s "Processing of the Certificate handshake message failed"
2380
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002381run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002382 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002383 "$O_CLI -key data_files/server5.key \
2384 -cert data_files/server5.ku-ds.crt" \
2385 0 \
2386 -S "bad certificate (usage extensions)" \
2387 -S "Processing of the Certificate handshake message failed"
2388
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002389run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002390 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002391 "$O_CLI -key data_files/server5.key \
2392 -cert data_files/server5.ku-ka.crt" \
2393 0 \
2394 -s "bad certificate (usage extensions)" \
2395 -S "Processing of the Certificate handshake message failed"
2396
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002397# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2398
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002399run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002400 "$P_SRV key_file=data_files/server5.key \
2401 crt_file=data_files/server5.eku-srv.crt" \
2402 "$P_CLI" \
2403 0
2404
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002405run_test "extKeyUsage srv: serverAuth,clientAuth -> 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: codeSign,anyEKU -> 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-cs_any.crt" \
2414 "$P_CLI" \
2415 0
2416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002417run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002418 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002419 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002420 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002421 1
2422
2423# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2424
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002425run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002426 "$O_SRV -key data_files/server5.key \
2427 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002428 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002429 0 \
2430 -C "bad certificate (usage extensions)" \
2431 -C "Processing of the Certificate handshake message failed" \
2432 -c "Ciphersuite is TLS-"
2433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002434run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002435 "$O_SRV -key data_files/server5.key \
2436 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002437 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002438 0 \
2439 -C "bad certificate (usage extensions)" \
2440 -C "Processing of the Certificate handshake message failed" \
2441 -c "Ciphersuite is TLS-"
2442
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002443run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002444 "$O_SRV -key data_files/server5.key \
2445 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002446 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002447 0 \
2448 -C "bad certificate (usage extensions)" \
2449 -C "Processing of the Certificate handshake message failed" \
2450 -c "Ciphersuite is TLS-"
2451
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002452run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002453 "$O_SRV -key data_files/server5.key \
2454 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002455 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002456 1 \
2457 -c "bad certificate (usage extensions)" \
2458 -c "Processing of the Certificate handshake message failed" \
2459 -C "Ciphersuite is TLS-"
2460
2461# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2462
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002463run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002464 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002465 "$O_CLI -key data_files/server5.key \
2466 -cert data_files/server5.eku-cli.crt" \
2467 0 \
2468 -S "bad certificate (usage extensions)" \
2469 -S "Processing of the Certificate handshake message failed"
2470
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002471run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002472 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002473 "$O_CLI -key data_files/server5.key \
2474 -cert data_files/server5.eku-srv_cli.crt" \
2475 0 \
2476 -S "bad certificate (usage extensions)" \
2477 -S "Processing of the Certificate handshake message failed"
2478
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002479run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002480 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002481 "$O_CLI -key data_files/server5.key \
2482 -cert data_files/server5.eku-cs_any.crt" \
2483 0 \
2484 -S "bad certificate (usage extensions)" \
2485 -S "Processing of the Certificate handshake message failed"
2486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002487run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002488 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002489 "$O_CLI -key data_files/server5.key \
2490 -cert data_files/server5.eku-cs.crt" \
2491 0 \
2492 -s "bad certificate (usage extensions)" \
2493 -S "Processing of the Certificate handshake message failed"
2494
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002495run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002496 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002497 "$O_CLI -key data_files/server5.key \
2498 -cert data_files/server5.eku-cs.crt" \
2499 1 \
2500 -s "bad certificate (usage extensions)" \
2501 -s "Processing of the Certificate handshake message failed"
2502
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002503# Tests for DHM parameters loading
2504
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002505run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002506 "$P_SRV" \
2507 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2508 debug_level=3" \
2509 0 \
2510 -c "value of 'DHM: P ' (2048 bits)" \
2511 -c "value of 'DHM: G ' (2048 bits)"
2512
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002513run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002514 "$P_SRV dhm_file=data_files/dhparams.pem" \
2515 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2516 debug_level=3" \
2517 0 \
2518 -c "value of 'DHM: P ' (1024 bits)" \
2519 -c "value of 'DHM: G ' (2 bits)"
2520
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002521# Tests for DHM client-side size checking
2522
2523run_test "DHM size: server default, client default, OK" \
2524 "$P_SRV" \
2525 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2526 debug_level=1" \
2527 0 \
2528 -C "DHM prime too short:"
2529
2530run_test "DHM size: server default, client 2048, OK" \
2531 "$P_SRV" \
2532 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2533 debug_level=1 dhmlen=2048" \
2534 0 \
2535 -C "DHM prime too short:"
2536
2537run_test "DHM size: server 1024, client default, OK" \
2538 "$P_SRV dhm_file=data_files/dhparams.pem" \
2539 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2540 debug_level=1" \
2541 0 \
2542 -C "DHM prime too short:"
2543
2544run_test "DHM size: server 1000, client default, rejected" \
2545 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2546 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2547 debug_level=1" \
2548 1 \
2549 -c "DHM prime too short:"
2550
2551run_test "DHM size: server default, client 2049, rejected" \
2552 "$P_SRV" \
2553 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2554 debug_level=1 dhmlen=2049" \
2555 1 \
2556 -c "DHM prime too short:"
2557
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002558# Tests for PSK callback
2559
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002560run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002561 "$P_SRV psk=abc123 psk_identity=foo" \
2562 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2563 psk_identity=foo psk=abc123" \
2564 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002565 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002566 -S "SSL - Unknown identity received" \
2567 -S "SSL - Verification of the message MAC failed"
2568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002569run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002570 "$P_SRV" \
2571 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2572 psk_identity=foo psk=abc123" \
2573 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002574 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002575 -S "SSL - Unknown identity received" \
2576 -S "SSL - Verification of the message MAC failed"
2577
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002578run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002579 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2580 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2581 psk_identity=foo psk=abc123" \
2582 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002583 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002584 -s "SSL - Unknown identity received" \
2585 -S "SSL - Verification of the message MAC failed"
2586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002587run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002588 "$P_SRV psk_list=abc,dead,def,beef" \
2589 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2590 psk_identity=abc psk=dead" \
2591 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002592 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002593 -S "SSL - Unknown identity received" \
2594 -S "SSL - Verification of the message MAC failed"
2595
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002596run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002597 "$P_SRV psk_list=abc,dead,def,beef" \
2598 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2599 psk_identity=def psk=beef" \
2600 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002601 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002602 -S "SSL - Unknown identity received" \
2603 -S "SSL - Verification of the message MAC failed"
2604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002605run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002606 "$P_SRV psk_list=abc,dead,def,beef" \
2607 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2608 psk_identity=ghi psk=beef" \
2609 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002610 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002611 -s "SSL - Unknown identity received" \
2612 -S "SSL - Verification of the message MAC failed"
2613
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002614run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002615 "$P_SRV psk_list=abc,dead,def,beef" \
2616 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2617 psk_identity=abc psk=beef" \
2618 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002619 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002620 -S "SSL - Unknown identity received" \
2621 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002622
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002623# Tests for EC J-PAKE
2624
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002625requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002626run_test "ECJPAKE: client not configured" \
2627 "$P_SRV debug_level=3" \
2628 "$P_CLI debug_level=3" \
2629 0 \
2630 -C "add ciphersuite: c0ff" \
2631 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002632 -S "found ecjpake kkpp extension" \
2633 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002634 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002635 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002636 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002637 -S "None of the common ciphersuites is usable"
2638
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002639requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002640run_test "ECJPAKE: server not configured" \
2641 "$P_SRV debug_level=3" \
2642 "$P_CLI debug_level=3 ecjpake_pw=bla \
2643 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2644 1 \
2645 -c "add ciphersuite: c0ff" \
2646 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002647 -s "found ecjpake kkpp extension" \
2648 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002649 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002650 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002651 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002652 -s "None of the common ciphersuites is usable"
2653
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002654requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002655run_test "ECJPAKE: working, TLS" \
2656 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2657 "$P_CLI debug_level=3 ecjpake_pw=bla \
2658 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002659 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002660 -c "add ciphersuite: c0ff" \
2661 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002662 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002663 -s "found ecjpake kkpp extension" \
2664 -S "skip ecjpake kkpp extension" \
2665 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002666 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002667 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002668 -S "None of the common ciphersuites is usable" \
2669 -S "SSL - Verification of the message MAC failed"
2670
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002671requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002672run_test "ECJPAKE: password mismatch, TLS" \
2673 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2674 "$P_CLI debug_level=3 ecjpake_pw=bad \
2675 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2676 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002677 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002678 -s "SSL - Verification of the message MAC failed"
2679
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002680requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002681run_test "ECJPAKE: working, DTLS" \
2682 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2683 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2684 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2685 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002686 -c "re-using cached ecjpake parameters" \
2687 -S "SSL - Verification of the message MAC failed"
2688
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002689requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002690run_test "ECJPAKE: working, DTLS, no cookie" \
2691 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2692 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2693 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2694 0 \
2695 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002696 -S "SSL - Verification of the message MAC failed"
2697
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002698requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002699run_test "ECJPAKE: password mismatch, DTLS" \
2700 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2701 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2702 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2703 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002704 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002705 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002706
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002707# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002708requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002709run_test "ECJPAKE: working, DTLS, nolog" \
2710 "$P_SRV dtls=1 ecjpake_pw=bla" \
2711 "$P_CLI dtls=1 ecjpake_pw=bla \
2712 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2713 0
2714
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002715# Tests for ciphersuites per version
2716
Janos Follathe2681a42016-03-07 15:57:05 +00002717requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002718run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002719 "$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 +02002720 "$P_CLI force_version=ssl3" \
2721 0 \
2722 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2723
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002724run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002725 "$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 +01002726 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002727 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002728 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002730run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002731 "$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 +02002732 "$P_CLI force_version=tls1_1" \
2733 0 \
2734 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2735
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002736run_test "Per-version suites: TLS 1.2" \
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_2" \
2739 0 \
2740 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2741
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002742# Test for ClientHello without extensions
2743
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002744requires_gnutls
2745run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002746 "$P_SRV debug_level=3" \
2747 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2748 0 \
2749 -s "dumping 'client hello extensions' (0 bytes)"
2750
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002751# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002752
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002753run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002754 "$P_SRV" \
2755 "$P_CLI request_size=100" \
2756 0 \
2757 -s "Read from client: 100 bytes read$"
2758
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002759run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002760 "$P_SRV" \
2761 "$P_CLI request_size=500" \
2762 0 \
2763 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002764
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002765# Tests for small packets
2766
Janos Follathe2681a42016-03-07 15:57:05 +00002767requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002768run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002769 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002770 "$P_CLI request_size=1 force_version=ssl3 \
2771 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2772 0 \
2773 -s "Read from client: 1 bytes read"
2774
Janos Follathe2681a42016-03-07 15:57:05 +00002775requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002776run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002777 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002778 "$P_CLI request_size=1 force_version=ssl3 \
2779 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2780 0 \
2781 -s "Read from client: 1 bytes read"
2782
2783run_test "Small packet TLS 1.0 BlockCipher" \
2784 "$P_SRV" \
2785 "$P_CLI request_size=1 force_version=tls1 \
2786 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2787 0 \
2788 -s "Read from client: 1 bytes read"
2789
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002790run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2791 "$P_SRV" \
2792 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2793 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2794 0 \
2795 -s "Read from client: 1 bytes read"
2796
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002797run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2798 "$P_SRV" \
2799 "$P_CLI request_size=1 force_version=tls1 \
2800 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2801 trunc_hmac=1" \
2802 0 \
2803 -s "Read from client: 1 bytes read"
2804
2805run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002806 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002807 "$P_CLI request_size=1 force_version=tls1 \
2808 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2809 trunc_hmac=1" \
2810 0 \
2811 -s "Read from client: 1 bytes read"
2812
2813run_test "Small packet TLS 1.1 BlockCipher" \
2814 "$P_SRV" \
2815 "$P_CLI request_size=1 force_version=tls1_1 \
2816 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2817 0 \
2818 -s "Read from client: 1 bytes read"
2819
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002820run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2821 "$P_SRV" \
2822 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2823 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2824 0 \
2825 -s "Read from client: 1 bytes read"
2826
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002827run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002828 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002829 "$P_CLI request_size=1 force_version=tls1_1 \
2830 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2831 0 \
2832 -s "Read from client: 1 bytes read"
2833
2834run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2835 "$P_SRV" \
2836 "$P_CLI request_size=1 force_version=tls1_1 \
2837 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2838 trunc_hmac=1" \
2839 0 \
2840 -s "Read from client: 1 bytes read"
2841
2842run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002843 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002844 "$P_CLI request_size=1 force_version=tls1_1 \
2845 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2846 trunc_hmac=1" \
2847 0 \
2848 -s "Read from client: 1 bytes read"
2849
2850run_test "Small packet TLS 1.2 BlockCipher" \
2851 "$P_SRV" \
2852 "$P_CLI request_size=1 force_version=tls1_2 \
2853 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2854 0 \
2855 -s "Read from client: 1 bytes read"
2856
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002857run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2858 "$P_SRV" \
2859 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2860 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2861 0 \
2862 -s "Read from client: 1 bytes read"
2863
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002864run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2865 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002866 "$P_CLI request_size=1 force_version=tls1_2 \
2867 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002868 0 \
2869 -s "Read from client: 1 bytes read"
2870
2871run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2872 "$P_SRV" \
2873 "$P_CLI request_size=1 force_version=tls1_2 \
2874 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2875 trunc_hmac=1" \
2876 0 \
2877 -s "Read from client: 1 bytes read"
2878
2879run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002880 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002881 "$P_CLI request_size=1 force_version=tls1_2 \
2882 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2883 0 \
2884 -s "Read from client: 1 bytes read"
2885
2886run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002887 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002888 "$P_CLI request_size=1 force_version=tls1_2 \
2889 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2890 trunc_hmac=1" \
2891 0 \
2892 -s "Read from client: 1 bytes read"
2893
2894run_test "Small packet TLS 1.2 AEAD" \
2895 "$P_SRV" \
2896 "$P_CLI request_size=1 force_version=tls1_2 \
2897 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2898 0 \
2899 -s "Read from client: 1 bytes read"
2900
2901run_test "Small packet TLS 1.2 AEAD shorter tag" \
2902 "$P_SRV" \
2903 "$P_CLI request_size=1 force_version=tls1_2 \
2904 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2905 0 \
2906 -s "Read from client: 1 bytes read"
2907
Janos Follath00efff72016-05-06 13:48:23 +01002908# A test for extensions in SSLv3
2909
2910requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2911run_test "SSLv3 with extensions, server side" \
2912 "$P_SRV min_version=ssl3 debug_level=3" \
2913 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2914 0 \
2915 -S "dumping 'client hello extensions'" \
2916 -S "server hello, total extension length:"
2917
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002918# Test for large packets
2919
Janos Follathe2681a42016-03-07 15:57:05 +00002920requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002921run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002922 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002923 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002924 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2925 0 \
2926 -s "Read from client: 16384 bytes read"
2927
Janos Follathe2681a42016-03-07 15:57:05 +00002928requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002929run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002930 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002931 "$P_CLI request_size=16384 force_version=ssl3 \
2932 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2933 0 \
2934 -s "Read from client: 16384 bytes read"
2935
2936run_test "Large packet TLS 1.0 BlockCipher" \
2937 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002938 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002939 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2940 0 \
2941 -s "Read from client: 16384 bytes read"
2942
2943run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2944 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002945 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002946 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2947 trunc_hmac=1" \
2948 0 \
2949 -s "Read from client: 16384 bytes read"
2950
2951run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002952 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002953 "$P_CLI request_size=16384 force_version=tls1 \
2954 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2955 trunc_hmac=1" \
2956 0 \
2957 -s "Read from client: 16384 bytes read"
2958
2959run_test "Large packet TLS 1.1 BlockCipher" \
2960 "$P_SRV" \
2961 "$P_CLI request_size=16384 force_version=tls1_1 \
2962 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2963 0 \
2964 -s "Read from client: 16384 bytes read"
2965
2966run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002967 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002968 "$P_CLI request_size=16384 force_version=tls1_1 \
2969 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2970 0 \
2971 -s "Read from client: 16384 bytes read"
2972
2973run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2974 "$P_SRV" \
2975 "$P_CLI request_size=16384 force_version=tls1_1 \
2976 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2977 trunc_hmac=1" \
2978 0 \
2979 -s "Read from client: 16384 bytes read"
2980
2981run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002982 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002983 "$P_CLI request_size=16384 force_version=tls1_1 \
2984 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2985 trunc_hmac=1" \
2986 0 \
2987 -s "Read from client: 16384 bytes read"
2988
2989run_test "Large packet TLS 1.2 BlockCipher" \
2990 "$P_SRV" \
2991 "$P_CLI request_size=16384 force_version=tls1_2 \
2992 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2993 0 \
2994 -s "Read from client: 16384 bytes read"
2995
2996run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2997 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002998 "$P_CLI request_size=16384 force_version=tls1_2 \
2999 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003000 0 \
3001 -s "Read from client: 16384 bytes read"
3002
3003run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3004 "$P_SRV" \
3005 "$P_CLI request_size=16384 force_version=tls1_2 \
3006 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3007 trunc_hmac=1" \
3008 0 \
3009 -s "Read from client: 16384 bytes read"
3010
3011run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003012 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003013 "$P_CLI request_size=16384 force_version=tls1_2 \
3014 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3015 0 \
3016 -s "Read from client: 16384 bytes read"
3017
3018run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003019 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003020 "$P_CLI request_size=16384 force_version=tls1_2 \
3021 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3022 trunc_hmac=1" \
3023 0 \
3024 -s "Read from client: 16384 bytes read"
3025
3026run_test "Large packet TLS 1.2 AEAD" \
3027 "$P_SRV" \
3028 "$P_CLI request_size=16384 force_version=tls1_2 \
3029 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3030 0 \
3031 -s "Read from client: 16384 bytes read"
3032
3033run_test "Large packet TLS 1.2 AEAD shorter tag" \
3034 "$P_SRV" \
3035 "$P_CLI request_size=16384 force_version=tls1_2 \
3036 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3037 0 \
3038 -s "Read from client: 16384 bytes read"
3039
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003040# Tests for DTLS HelloVerifyRequest
3041
3042run_test "DTLS cookie: enabled" \
3043 "$P_SRV dtls=1 debug_level=2" \
3044 "$P_CLI dtls=1 debug_level=2" \
3045 0 \
3046 -s "cookie verification failed" \
3047 -s "cookie verification passed" \
3048 -S "cookie verification skipped" \
3049 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003050 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003051 -S "SSL - The requested feature is not available"
3052
3053run_test "DTLS cookie: disabled" \
3054 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3055 "$P_CLI dtls=1 debug_level=2" \
3056 0 \
3057 -S "cookie verification failed" \
3058 -S "cookie verification passed" \
3059 -s "cookie verification skipped" \
3060 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003061 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003062 -S "SSL - The requested feature is not available"
3063
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003064run_test "DTLS cookie: default (failing)" \
3065 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3066 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3067 1 \
3068 -s "cookie verification failed" \
3069 -S "cookie verification passed" \
3070 -S "cookie verification skipped" \
3071 -C "received hello verify request" \
3072 -S "hello verification requested" \
3073 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003074
3075requires_ipv6
3076run_test "DTLS cookie: enabled, IPv6" \
3077 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3078 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3079 0 \
3080 -s "cookie verification failed" \
3081 -s "cookie verification passed" \
3082 -S "cookie verification skipped" \
3083 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003084 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003085 -S "SSL - The requested feature is not available"
3086
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003087run_test "DTLS cookie: enabled, nbio" \
3088 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3089 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3090 0 \
3091 -s "cookie verification failed" \
3092 -s "cookie verification passed" \
3093 -S "cookie verification skipped" \
3094 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003095 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003096 -S "SSL - The requested feature is not available"
3097
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003098# Tests for client reconnecting from the same port with DTLS
3099
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003100not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003101run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003102 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3103 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003104 0 \
3105 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003106 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003107 -S "Client initiated reconnection from same port"
3108
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003109not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003110run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003111 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3112 "$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 +02003113 0 \
3114 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003115 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003116 -s "Client initiated reconnection from same port"
3117
Paul Bakker362689d2016-05-13 10:33:25 +01003118not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3119run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003120 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3121 "$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 +02003122 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003123 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003124 -s "Client initiated reconnection from same port"
3125
Paul Bakker362689d2016-05-13 10:33:25 +01003126only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3127run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3128 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3129 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3130 0 \
3131 -S "The operation timed out" \
3132 -s "Client initiated reconnection from same port"
3133
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003134run_test "DTLS client reconnect from same port: no cookies" \
3135 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003136 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3137 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003138 -s "The operation timed out" \
3139 -S "Client initiated reconnection from same port"
3140
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003141# Tests for various cases of client authentication with DTLS
3142# (focused on handshake flows and message parsing)
3143
3144run_test "DTLS client auth: required" \
3145 "$P_SRV dtls=1 auth_mode=required" \
3146 "$P_CLI dtls=1" \
3147 0 \
3148 -s "Verifying peer X.509 certificate... ok"
3149
3150run_test "DTLS client auth: optional, client has no cert" \
3151 "$P_SRV dtls=1 auth_mode=optional" \
3152 "$P_CLI dtls=1 crt_file=none key_file=none" \
3153 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003154 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003155
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003156run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003157 "$P_SRV dtls=1 auth_mode=none" \
3158 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3159 0 \
3160 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003161 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003162
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003163run_test "DTLS wrong PSK: badmac alert" \
3164 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3165 "$P_CLI dtls=1 psk=abc124" \
3166 1 \
3167 -s "SSL - Verification of the message MAC failed" \
3168 -c "SSL - A fatal alert message was received from our peer"
3169
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003170# Tests for receiving fragmented handshake messages with DTLS
3171
3172requires_gnutls
3173run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3174 "$G_SRV -u --mtu 2048 -a" \
3175 "$P_CLI dtls=1 debug_level=2" \
3176 0 \
3177 -C "found fragmented DTLS handshake message" \
3178 -C "error"
3179
3180requires_gnutls
3181run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3182 "$G_SRV -u --mtu 512" \
3183 "$P_CLI dtls=1 debug_level=2" \
3184 0 \
3185 -c "found fragmented DTLS handshake message" \
3186 -C "error"
3187
3188requires_gnutls
3189run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3190 "$G_SRV -u --mtu 128" \
3191 "$P_CLI dtls=1 debug_level=2" \
3192 0 \
3193 -c "found fragmented DTLS handshake message" \
3194 -C "error"
3195
3196requires_gnutls
3197run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3198 "$G_SRV -u --mtu 128" \
3199 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3200 0 \
3201 -c "found fragmented DTLS handshake message" \
3202 -C "error"
3203
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003204requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003205run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3206 "$G_SRV -u --mtu 256" \
3207 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3208 0 \
3209 -c "found fragmented DTLS handshake message" \
3210 -c "client hello, adding renegotiation extension" \
3211 -c "found renegotiation extension" \
3212 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003213 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003214 -C "error" \
3215 -s "Extra-header:"
3216
3217requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003218run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3219 "$G_SRV -u --mtu 256" \
3220 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3221 0 \
3222 -c "found fragmented DTLS handshake message" \
3223 -c "client hello, adding renegotiation extension" \
3224 -c "found renegotiation extension" \
3225 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003226 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003227 -C "error" \
3228 -s "Extra-header:"
3229
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003230run_test "DTLS reassembly: no fragmentation (openssl server)" \
3231 "$O_SRV -dtls1 -mtu 2048" \
3232 "$P_CLI dtls=1 debug_level=2" \
3233 0 \
3234 -C "found fragmented DTLS handshake message" \
3235 -C "error"
3236
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003237run_test "DTLS reassembly: some fragmentation (openssl server)" \
3238 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003239 "$P_CLI dtls=1 debug_level=2" \
3240 0 \
3241 -c "found fragmented DTLS handshake message" \
3242 -C "error"
3243
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003244run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003245 "$O_SRV -dtls1 -mtu 256" \
3246 "$P_CLI dtls=1 debug_level=2" \
3247 0 \
3248 -c "found fragmented DTLS handshake message" \
3249 -C "error"
3250
3251run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3252 "$O_SRV -dtls1 -mtu 256" \
3253 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3254 0 \
3255 -c "found fragmented DTLS handshake message" \
3256 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003257
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003258# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003259
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003260not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003261run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003262 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003263 "$P_SRV dtls=1 debug_level=2" \
3264 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003265 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003266 -C "replayed record" \
3267 -S "replayed record" \
3268 -C "record from another epoch" \
3269 -S "record from another epoch" \
3270 -C "discarding invalid record" \
3271 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003272 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003273 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003274 -c "HTTP/1.0 200 OK"
3275
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003276not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003277run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003278 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003279 "$P_SRV dtls=1 debug_level=2" \
3280 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003281 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003282 -c "replayed record" \
3283 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003284 -c "discarding invalid record" \
3285 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003286 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003287 -s "Extra-header:" \
3288 -c "HTTP/1.0 200 OK"
3289
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003290run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3291 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003292 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3293 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003294 0 \
3295 -c "replayed record" \
3296 -S "replayed record" \
3297 -c "discarding invalid record" \
3298 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003299 -c "resend" \
3300 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003301 -s "Extra-header:" \
3302 -c "HTTP/1.0 200 OK"
3303
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003304run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003305 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003306 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003307 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003308 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003309 -c "discarding invalid record (mac)" \
3310 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003311 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003312 -c "HTTP/1.0 200 OK" \
3313 -S "too many records with bad MAC" \
3314 -S "Verification of the message MAC failed"
3315
3316run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3317 -p "$P_PXY bad_ad=1" \
3318 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3319 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3320 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003321 -C "discarding invalid record (mac)" \
3322 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003323 -S "Extra-header:" \
3324 -C "HTTP/1.0 200 OK" \
3325 -s "too many records with bad MAC" \
3326 -s "Verification of the message MAC failed"
3327
3328run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3329 -p "$P_PXY bad_ad=1" \
3330 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3331 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3332 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003333 -c "discarding invalid record (mac)" \
3334 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003335 -s "Extra-header:" \
3336 -c "HTTP/1.0 200 OK" \
3337 -S "too many records with bad MAC" \
3338 -S "Verification of the message MAC failed"
3339
3340run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3341 -p "$P_PXY bad_ad=1" \
3342 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3343 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3344 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003345 -c "discarding invalid record (mac)" \
3346 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003347 -s "Extra-header:" \
3348 -c "HTTP/1.0 200 OK" \
3349 -s "too many records with bad MAC" \
3350 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003351
3352run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003353 -p "$P_PXY delay_ccs=1" \
3354 "$P_SRV dtls=1 debug_level=1" \
3355 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003356 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003357 -c "record from another epoch" \
3358 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003359 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003360 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003361 -s "Extra-header:" \
3362 -c "HTTP/1.0 200 OK"
3363
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003364# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003365
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003366needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003367run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003368 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003369 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3370 psk=abc123" \
3371 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003372 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3373 0 \
3374 -s "Extra-header:" \
3375 -c "HTTP/1.0 200 OK"
3376
3377needs_more_time 2
3378run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3379 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003380 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3381 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003382 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3383 0 \
3384 -s "Extra-header:" \
3385 -c "HTTP/1.0 200 OK"
3386
3387needs_more_time 2
3388run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3389 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003390 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3391 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003392 0 \
3393 -s "Extra-header:" \
3394 -c "HTTP/1.0 200 OK"
3395
3396needs_more_time 2
3397run_test "DTLS proxy: 3d, FS, client auth" \
3398 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003399 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3400 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003401 0 \
3402 -s "Extra-header:" \
3403 -c "HTTP/1.0 200 OK"
3404
3405needs_more_time 2
3406run_test "DTLS proxy: 3d, FS, ticket" \
3407 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003408 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3409 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003410 0 \
3411 -s "Extra-header:" \
3412 -c "HTTP/1.0 200 OK"
3413
3414needs_more_time 2
3415run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3416 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003417 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3418 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003419 0 \
3420 -s "Extra-header:" \
3421 -c "HTTP/1.0 200 OK"
3422
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003423needs_more_time 2
3424run_test "DTLS proxy: 3d, max handshake, nbio" \
3425 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003426 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3427 auth_mode=required" \
3428 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003429 0 \
3430 -s "Extra-header:" \
3431 -c "HTTP/1.0 200 OK"
3432
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003433needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003434run_test "DTLS proxy: 3d, min handshake, resumption" \
3435 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3436 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3437 psk=abc123 debug_level=3" \
3438 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3439 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3440 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3441 0 \
3442 -s "a session has been resumed" \
3443 -c "a session has been resumed" \
3444 -s "Extra-header:" \
3445 -c "HTTP/1.0 200 OK"
3446
3447needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003448run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3449 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3450 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3451 psk=abc123 debug_level=3 nbio=2" \
3452 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3453 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3454 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3455 0 \
3456 -s "a session has been resumed" \
3457 -c "a session has been resumed" \
3458 -s "Extra-header:" \
3459 -c "HTTP/1.0 200 OK"
3460
3461needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003462run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003463 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003464 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3465 psk=abc123 renegotiation=1 debug_level=2" \
3466 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3467 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003468 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3469 0 \
3470 -c "=> renegotiate" \
3471 -s "=> renegotiate" \
3472 -s "Extra-header:" \
3473 -c "HTTP/1.0 200 OK"
3474
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003475needs_more_time 4
3476run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3477 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003478 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3479 psk=abc123 renegotiation=1 debug_level=2" \
3480 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3481 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003482 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3483 0 \
3484 -c "=> renegotiate" \
3485 -s "=> renegotiate" \
3486 -s "Extra-header:" \
3487 -c "HTTP/1.0 200 OK"
3488
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003489needs_more_time 4
3490run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003491 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003492 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003493 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003494 debug_level=2" \
3495 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003496 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003497 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3498 0 \
3499 -c "=> renegotiate" \
3500 -s "=> renegotiate" \
3501 -s "Extra-header:" \
3502 -c "HTTP/1.0 200 OK"
3503
3504needs_more_time 4
3505run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003506 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003507 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003508 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003509 debug_level=2 nbio=2" \
3510 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003511 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003512 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3513 0 \
3514 -c "=> renegotiate" \
3515 -s "=> renegotiate" \
3516 -s "Extra-header:" \
3517 -c "HTTP/1.0 200 OK"
3518
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003519needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003520not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003521run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003522 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3523 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003524 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003525 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003526 -c "HTTP/1.0 200 OK"
3527
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003528needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003529not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003530run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3531 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3532 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003533 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003534 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003535 -c "HTTP/1.0 200 OK"
3536
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003537needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003538not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003539run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3540 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3541 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003542 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003543 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003544 -c "HTTP/1.0 200 OK"
3545
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003546requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003547needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003548not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003549run_test "DTLS proxy: 3d, gnutls server" \
3550 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3551 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003552 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003553 0 \
3554 -s "Extra-header:" \
3555 -c "Extra-header:"
3556
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003557requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003558needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003559not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003560run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3561 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3562 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003563 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003564 0 \
3565 -s "Extra-header:" \
3566 -c "Extra-header:"
3567
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003568requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003569needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003570not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003571run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3572 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3573 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003574 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003575 0 \
3576 -s "Extra-header:" \
3577 -c "Extra-header:"
3578
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003579# Final report
3580
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003581echo "------------------------------------------------------------------------"
3582
3583if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003584 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003585else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003586 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003587fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003588PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003589echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003590
3591exit $FAILS