blob: f0560ef34592336a758accfc47bd110f3702b8e9 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02009# Assumes a build with default options.
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010010
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020016: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010017: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020018: ${GNUTLS_CLI:=gnutls-cli}
19: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010020
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020021O_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 +010022O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020023G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
24G_CLI="$GNUTLS_CLI"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010025
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010026TESTS=0
27FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020028SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010029
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020030CONFIG_H='../include/polarssl/config.h'
31
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010032MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010033FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020034EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010035
36print_usage() {
37 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010038 echo -e " -h|--help\tPrint this help."
39 echo -e " -m|--memcheck\tCheck memory leaks and errors."
40 echo -e " -f|--filter\tOnly matching tests are executed (default: '$FILTER')"
41 echo -e " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010042}
43
44get_options() {
45 while [ $# -gt 0 ]; do
46 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010047 -f|--filter)
48 shift; FILTER=$1
49 ;;
50 -e|--exclude)
51 shift; EXCLUDE=$1
52 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010053 -m|--memcheck)
54 MEMCHECK=1
55 ;;
56 -h|--help)
57 print_usage
58 exit 0
59 ;;
60 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020061 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062 print_usage
63 exit 1
64 ;;
65 esac
66 shift
67 done
68}
69
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020070# skip next test if OpenSSL can't send SSLv2 ClientHello
71requires_openssl_with_sslv2() {
72 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020073 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020074 OPENSSL_HAS_SSL2="YES"
75 else
76 OPENSSL_HAS_SSL2="NO"
77 fi
78 fi
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +020079
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020080 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
81 SKIP_NEXT="YES"
82 fi
83}
84
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020085# skip next test if GnuTLS isn't available
86requires_gnutls() {
87 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
88 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
89 GNUTLS_AVAILABLE="YES"
90 else
91 GNUTLS_AVAILABLE="NO"
92 fi
93 fi
94 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
95 SKIP_NEXT="YES"
96 fi
97}
98
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +020099# skip next test if IPv6 isn't available on this host
100requires_ipv6() {
101 if [ -z "${HAS_IPV6:-}" ]; then
102 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
103 SRV_PID=$!
104 sleep 1
105 kill $SRV_PID >/dev/null 2>&1
106 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
107 HAS_IPV6="NO"
108 else
109 HAS_IPV6="YES"
110 fi
111 rm -r $SRV_OUT
112 fi
113
114 if [ "$HAS_IPV6" = "NO" ]; then
115 SKIP_NEXT="YES"
116 fi
117}
118
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200119# skip the next test if valgrind is in use
120not_with_valgrind() {
121 if [ "$MEMCHECK" -gt 0 ]; then
122 SKIP_NEXT="YES"
123 fi
124}
125
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200126# multiply the client timeout delay by the given factor for the next test
127needs_more_time() {
128 CLI_DELAY_FACTOR=$1
129}
130
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100131# print_name <name>
132print_name() {
133 echo -n "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200134 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100135 for i in `seq 1 $LEN`; do echo -n '.'; done
136 echo -n ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100137
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200138 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100139}
140
141# fail <message>
142fail() {
143 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100144 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100145
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200146 mv $SRV_OUT o-srv-${TESTS}.log
147 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200148 if [ -n "$PXY_CMD" ]; then
149 mv $PXY_OUT o-pxy-${TESTS}.log
150 fi
151 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100152
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200153 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
154 echo " ! server output:"
155 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200156 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200157 echo " ! client output:"
158 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200159 if [ -n "$PXY_CMD" ]; then
160 echo " ! ========================================================"
161 echo " ! proxy output:"
162 cat o-pxy-${TESTS}.log
163 fi
164 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200165 fi
166
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200167 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100168}
169
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100170# is_polar <cmd_line>
171is_polar() {
172 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
173}
174
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200175# openssl s_server doesn't have -www with DTLS
176check_osrv_dtls() {
177 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
178 NEEDS_INPUT=1
179 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
180 else
181 NEEDS_INPUT=0
182 fi
183}
184
185# provide input to commands that need it
186provide_input() {
187 if [ $NEEDS_INPUT -eq 0 ]; then
188 return
189 fi
190
191 while true; do
192 echo "HTTP/1.0 200 OK"
193 sleep 1
194 done
195}
196
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100197# has_mem_err <log_file_name>
198has_mem_err() {
199 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
200 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
201 then
202 return 1 # false: does not have errors
203 else
204 return 0 # true: has errors
205 fi
206}
207
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200208# wait for server to start: two versions depending on lsof availability
209wait_server_start() {
210 if which lsof >/dev/null; then
211 # make sure we don't loop forever
212 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200213 DOG_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200214
215 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200216 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200217 until lsof -nbi UDP:"$SRV_PORT" | grep UDP >/dev/null; do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200218 else
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200219 until lsof -nbi TCP:"$SRV_PORT" | grep LISTEN >/dev/null; do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200220 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200221
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200222 kill $DOG_PID >/dev/null 2>&1
223 wait $DOG_PID
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200224 else
225 sleep "$START_DELAY"
226 fi
227}
228
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200229# wait for client to terminate and set CLI_EXIT
230# must be called right after starting the client
231wait_client_done() {
232 CLI_PID=$!
233
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200234 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
235 CLI_DELAY_FACTOR=1
236
237 ( sleep $CLI_DELAY; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200238 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200239
240 wait $CLI_PID
241 CLI_EXIT=$?
242
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200243 kill $DOG_PID >/dev/null 2>&1
244 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200245
246 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
247}
248
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200249# check if the given command uses dtls and sets global variable DTLS
250detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200251 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200252 DTLS=1
253 else
254 DTLS=0
255 fi
256}
257
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200258# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100259# Options: -s pattern pattern that must be present in server output
260# -c pattern pattern that must be present in client output
261# -S pattern pattern that must be absent in server output
262# -C pattern pattern that must be absent in client output
263run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100264 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200265 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100266
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100267 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
268 else
269 return
270 fi
271
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100272 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100273
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200274 # should we skip?
275 if [ "X$SKIP_NEXT" = "XYES" ]; then
276 SKIP_NEXT="NO"
277 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200278 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200279 return
280 fi
281
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200282 # does this test use a proxy?
283 if [ "X$1" = "X-p" ]; then
284 PXY_CMD="$2"
285 shift 2
286 else
287 PXY_CMD=""
288 fi
289
290 # get commands and client output
291 SRV_CMD="$1"
292 CLI_CMD="$2"
293 CLI_EXPECT="$3"
294 shift 3
295
296 # fix client port
297 if [ -n "$PXY_CMD" ]; then
298 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
299 else
300 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
301 fi
302
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200303 # update DTLS variable
304 detect_dtls "$SRV_CMD"
305
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100306 # prepend valgrind to our commands if active
307 if [ "$MEMCHECK" -gt 0 ]; then
308 if is_polar "$SRV_CMD"; then
309 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
310 fi
311 if is_polar "$CLI_CMD"; then
312 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
313 fi
314 fi
315
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100316 # run the commands
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200317 if [ -n "$PXY_CMD" ]; then
318 echo "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200319 $PXY_CMD >> $PXY_OUT 2>&1 &
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200320 PXY_PID=$!
321 # assume proxy starts faster than server
322 fi
323
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200324 check_osrv_dtls
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200325 echo "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200326 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100327 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200328 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200329
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200330 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200331 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
332 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100333
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200334 # terminate the server (and the proxy)
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200335 kill $SRV_PID
336 wait $SRV_PID
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200337 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200338 kill $PXY_PID >/dev/null 2>&1
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200339 wait $PXY_PID
340 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100341
342 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200343 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100344 # expected client exit to incorrectly succeed in case of catastrophic
345 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100346 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200347 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100348 else
349 fail "server failed to start"
350 return
351 fi
352 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100353 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200354 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100355 else
356 fail "client failed to start"
357 return
358 fi
359 fi
360
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100361 # check server exit code
362 if [ $? != 0 ]; then
363 fail "server fail"
364 return
365 fi
366
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100367 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100368 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
369 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100370 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200371 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100372 return
373 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100374
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100375 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200376 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100377 while [ $# -gt 0 ]
378 do
379 case $1 in
380 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200381 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100382 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100383 return
384 fi
385 ;;
386
387 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200388 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100389 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100390 return
391 fi
392 ;;
393
394 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200395 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100396 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100397 return
398 fi
399 ;;
400
401 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200402 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100403 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100404 return
405 fi
406 ;;
407
408 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200409 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100410 exit 1
411 esac
412 shift 2
413 done
414
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100415 # check valgrind's results
416 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200417 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100418 fail "Server has memory errors"
419 return
420 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200421 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100422 fail "Client has memory errors"
423 return
424 fi
425 fi
426
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100427 # if we're here, everything is ok
428 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200429 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100430}
431
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100432cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200433 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200434 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
435 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
436 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
437 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100438 exit 1
439}
440
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100441#
442# MAIN
443#
444
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100445get_options "$@"
446
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100447# sanity checks, avoid an avalanche of errors
448if [ ! -x "$P_SRV" ]; then
449 echo "Command '$P_SRV' is not an executable file"
450 exit 1
451fi
452if [ ! -x "$P_CLI" ]; then
453 echo "Command '$P_CLI' is not an executable file"
454 exit 1
455fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200456if [ ! -x "$P_PXY" ]; then
457 echo "Command '$P_PXY' is not an executable file"
458 exit 1
459fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100460if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
461 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100462 exit 1
463fi
464
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200465# used by watchdog
466MAIN_PID="$$"
467
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200468# be more patient with valgrind
469if [ "$MEMCHECK" -gt 0 ]; then
470 START_DELAY=3
471 DOG_DELAY=30
472else
473 START_DELAY=1
474 DOG_DELAY=10
475fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200476CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200477
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200478# Pick a "unique" server port in the range 10000-19999, and a proxy port
479PORT_BASE="0000$$"
480PORT_BASE="$( echo -n $PORT_BASE | tail -c 4 )"
481SRV_PORT="1$PORT_BASE"
482PXY_PORT="2$PORT_BASE"
483unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200484
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200485# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200486P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
487P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
488P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
489O_SRV="$O_SRV -accept $SRV_PORT"
490O_CLI="$O_CLI -connect localhost:+SRV_PORT"
491G_SRV="$G_SRV -p $SRV_PORT"
492G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200493
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200494# Also pick a unique name for intermediate files
495SRV_OUT="srv_out.$$"
496CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200497PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200498SESSION="session.$$"
499
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200500SKIP_NEXT="NO"
501
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100502trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100503
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200504# Basic test
505
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200506# Checks that:
507# - things work with all ciphersuites active (used with config-full in all.sh)
508# - the expected (highest security) parameters are selected
509# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200510run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200511 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200512 "$P_CLI" \
513 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200514 -s "Protocol is TLSv1.2" \
515 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
516 -s "client hello v3, signature_algorithm ext: 6" \
517 -s "ECDHE curve: secp521r1" \
518 -S "error" \
519 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200520
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100521# Test for SSLv2 ClientHello
522
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200523requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200524run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100525 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100526 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100527 0 \
528 -S "parse client hello v2" \
529 -S "ssl_handshake returned"
530
531# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200532requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200533run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200534 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100535 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100536 0 \
537 -s "parse client hello v2" \
538 -S "ssl_handshake returned"
539
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100540# Tests for Truncated HMAC extension
541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200542run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200543 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100544 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100545 0 \
546 -s "dumping 'computed mac' (20 bytes)"
547
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200548run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200549 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100550 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100551 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100552 -s "dumping 'computed mac' (10 bytes)"
553
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100554# Tests for Session Tickets
555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200556run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200557 "$P_SRV debug_level=3 tickets=1" \
558 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100559 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100560 -c "client hello, adding session ticket extension" \
561 -s "found session ticket extension" \
562 -s "server hello, adding session ticket extension" \
563 -c "found session_ticket extension" \
564 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100565 -S "session successfully restored from cache" \
566 -s "session successfully restored from ticket" \
567 -s "a session has been resumed" \
568 -c "a session has been resumed"
569
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200570run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200571 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
572 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100573 0 \
574 -c "client hello, adding session ticket extension" \
575 -s "found session ticket extension" \
576 -s "server hello, adding session ticket extension" \
577 -c "found session_ticket extension" \
578 -c "parse new session ticket" \
579 -S "session successfully restored from cache" \
580 -s "session successfully restored from ticket" \
581 -s "a session has been resumed" \
582 -c "a session has been resumed"
583
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200584run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200585 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
586 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100587 0 \
588 -c "client hello, adding session ticket extension" \
589 -s "found session ticket extension" \
590 -s "server hello, adding session ticket extension" \
591 -c "found session_ticket extension" \
592 -c "parse new session ticket" \
593 -S "session successfully restored from cache" \
594 -S "session successfully restored from ticket" \
595 -S "a session has been resumed" \
596 -C "a session has been resumed"
597
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200598run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100599 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200600 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100601 0 \
602 -c "client hello, adding session ticket extension" \
603 -c "found session_ticket extension" \
604 -c "parse new session ticket" \
605 -c "a session has been resumed"
606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200607run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200608 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200609 "( $O_CLI -sess_out $SESSION; \
610 $O_CLI -sess_in $SESSION; \
611 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100612 0 \
613 -s "found session ticket extension" \
614 -s "server hello, adding session ticket extension" \
615 -S "session successfully restored from cache" \
616 -s "session successfully restored from ticket" \
617 -s "a session has been resumed"
618
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100619# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200621run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200622 "$P_SRV debug_level=3 tickets=0" \
623 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100624 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100625 -c "client hello, adding session ticket extension" \
626 -s "found session ticket extension" \
627 -S "server hello, adding session ticket extension" \
628 -C "found session_ticket extension" \
629 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100630 -s "session successfully restored from cache" \
631 -S "session successfully restored from ticket" \
632 -s "a session has been resumed" \
633 -c "a session has been resumed"
634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200635run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200636 "$P_SRV debug_level=3 tickets=1" \
637 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100638 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100639 -C "client hello, adding session ticket extension" \
640 -S "found session ticket extension" \
641 -S "server hello, adding session ticket extension" \
642 -C "found session_ticket extension" \
643 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100644 -s "session successfully restored from cache" \
645 -S "session successfully restored from ticket" \
646 -s "a session has been resumed" \
647 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100648
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200649run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200650 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
651 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100652 0 \
653 -S "session successfully restored from cache" \
654 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100655 -S "a session has been resumed" \
656 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100657
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200658run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200659 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
660 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100661 0 \
662 -s "session successfully restored from cache" \
663 -S "session successfully restored from ticket" \
664 -s "a session has been resumed" \
665 -c "a session has been resumed"
666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200667run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200668 "$P_SRV debug_level=3 tickets=0" \
669 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100670 0 \
671 -s "session successfully restored from cache" \
672 -S "session successfully restored from ticket" \
673 -s "a session has been resumed" \
674 -c "a session has been resumed"
675
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200676run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200677 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
678 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100679 0 \
680 -S "session successfully restored from cache" \
681 -S "session successfully restored from ticket" \
682 -S "a session has been resumed" \
683 -C "a session has been resumed"
684
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200685run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200686 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
687 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100688 0 \
689 -s "session successfully restored from cache" \
690 -S "session successfully restored from ticket" \
691 -s "a session has been resumed" \
692 -c "a session has been resumed"
693
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200694run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200695 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200696 "( $O_CLI -sess_out $SESSION; \
697 $O_CLI -sess_in $SESSION; \
698 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100699 0 \
700 -s "found session ticket extension" \
701 -S "server hello, adding session ticket extension" \
702 -s "session successfully restored from cache" \
703 -S "session successfully restored from ticket" \
704 -s "a session has been resumed"
705
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200706run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100707 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200708 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100709 0 \
710 -C "found session_ticket extension" \
711 -C "parse new session ticket" \
712 -c "a session has been resumed"
713
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100714# Tests for Max Fragment Length extension
715
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200716run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200717 "$P_SRV debug_level=3" \
718 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100719 0 \
720 -C "client hello, adding max_fragment_length extension" \
721 -S "found max fragment length extension" \
722 -S "server hello, max_fragment_length extension" \
723 -C "found max_fragment_length extension"
724
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200725run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200726 "$P_SRV debug_level=3" \
727 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100728 0 \
729 -c "client hello, adding max_fragment_length extension" \
730 -s "found max fragment length extension" \
731 -s "server hello, max_fragment_length extension" \
732 -c "found max_fragment_length extension"
733
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200734run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200735 "$P_SRV debug_level=3 max_frag_len=4096" \
736 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100737 0 \
738 -C "client hello, adding max_fragment_length extension" \
739 -S "found max fragment length extension" \
740 -S "server hello, max_fragment_length extension" \
741 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200743requires_gnutls
744run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200745 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200746 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200747 0 \
748 -c "client hello, adding max_fragment_length extension" \
749 -c "found max_fragment_length extension"
750
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +0200751run_test "Max fragment length: client, message just fits" \
752 "$P_SRV debug_level=3" \
753 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
754 0 \
755 -c "client hello, adding max_fragment_length extension" \
756 -s "found max fragment length extension" \
757 -s "server hello, max_fragment_length extension" \
758 -c "found max_fragment_length extension" \
759 -c "2048 bytes written in 1 fragments" \
760 -s "2048 bytes read"
761
762run_test "Max fragment length: client, larger message" \
763 "$P_SRV debug_level=3" \
764 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
765 0 \
766 -c "client hello, adding max_fragment_length extension" \
767 -s "found max fragment length extension" \
768 -s "server hello, max_fragment_length extension" \
769 -c "found max_fragment_length extension" \
770 -c "2345 bytes written in 2 fragments" \
771 -s "2048 bytes read" \
772 -s "297 bytes read"
773
774run_test "Max fragment length: client, larger message" \
775 "$P_SRV debug_level=3 dtls=1" \
776 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
777 1 \
778 -c "client hello, adding max_fragment_length extension" \
779 -s "found max fragment length extension" \
780 -s "server hello, max_fragment_length extension" \
781 -c "found max_fragment_length extension" \
782 -c "fragment larger than.*maximum"
783
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100784# Tests for renegotiation
785
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200786run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200787 "$P_SRV debug_level=3 exchanges=2" \
788 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100789 0 \
790 -C "client hello, adding renegotiation extension" \
791 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
792 -S "found renegotiation extension" \
793 -s "server hello, secure renegotiation extension" \
794 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100795 -C "=> renegotiate" \
796 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100797 -S "write hello request"
798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200799run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200800 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
801 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100802 0 \
803 -c "client hello, adding renegotiation extension" \
804 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
805 -s "found renegotiation extension" \
806 -s "server hello, secure renegotiation extension" \
807 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100808 -c "=> renegotiate" \
809 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100810 -S "write hello request"
811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200812run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200813 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
814 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100815 0 \
816 -c "client hello, adding renegotiation extension" \
817 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
818 -s "found renegotiation extension" \
819 -s "server hello, secure renegotiation extension" \
820 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100821 -c "=> renegotiate" \
822 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100823 -s "write hello request"
824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200825run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200826 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
827 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100828 0 \
829 -c "client hello, adding renegotiation extension" \
830 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
831 -s "found renegotiation extension" \
832 -s "server hello, secure renegotiation extension" \
833 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100834 -c "=> renegotiate" \
835 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100836 -s "write hello request"
837
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200838run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200839 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
840 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100841 1 \
842 -c "client hello, adding renegotiation extension" \
843 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
844 -S "found renegotiation extension" \
845 -s "server hello, secure renegotiation extension" \
846 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100847 -c "=> renegotiate" \
848 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200849 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200850 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200851 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100852
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200853run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200854 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
855 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100856 0 \
857 -C "client hello, adding renegotiation extension" \
858 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
859 -S "found renegotiation extension" \
860 -s "server hello, secure renegotiation extension" \
861 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100862 -C "=> renegotiate" \
863 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100864 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200865 -S "SSL - An unexpected message was received from our peer" \
866 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200868run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200869 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200870 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200871 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200872 0 \
873 -C "client hello, adding renegotiation extension" \
874 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
875 -S "found renegotiation extension" \
876 -s "server hello, secure renegotiation extension" \
877 -c "found renegotiation extension" \
878 -C "=> renegotiate" \
879 -S "=> renegotiate" \
880 -s "write hello request" \
881 -S "SSL - An unexpected message was received from our peer" \
882 -S "failed"
883
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200884# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200885run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200886 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200887 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200888 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200889 0 \
890 -C "client hello, adding renegotiation extension" \
891 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
892 -S "found renegotiation extension" \
893 -s "server hello, secure renegotiation extension" \
894 -c "found renegotiation extension" \
895 -C "=> renegotiate" \
896 -S "=> renegotiate" \
897 -s "write hello request" \
898 -S "SSL - An unexpected message was received from our peer" \
899 -S "failed"
900
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200901run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200902 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200903 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200904 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200905 0 \
906 -C "client hello, adding renegotiation extension" \
907 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
908 -S "found renegotiation extension" \
909 -s "server hello, secure renegotiation extension" \
910 -c "found renegotiation extension" \
911 -C "=> renegotiate" \
912 -S "=> renegotiate" \
913 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200914 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200916run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200917 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200918 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200919 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200920 0 \
921 -c "client hello, adding renegotiation extension" \
922 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
923 -s "found renegotiation extension" \
924 -s "server hello, secure renegotiation extension" \
925 -c "found renegotiation extension" \
926 -c "=> renegotiate" \
927 -s "=> renegotiate" \
928 -s "write hello request" \
929 -S "SSL - An unexpected message was received from our peer" \
930 -S "failed"
931
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200932run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200933 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
934 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200935 0 \
936 -c "client hello, adding renegotiation extension" \
937 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
938 -s "found renegotiation extension" \
939 -s "server hello, secure renegotiation extension" \
940 -c "found renegotiation extension" \
941 -c "=> renegotiate" \
942 -s "=> renegotiate" \
943 -S "write hello request"
944
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200945run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200946 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
947 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200948 0 \
949 -c "client hello, adding renegotiation extension" \
950 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
951 -s "found renegotiation extension" \
952 -s "server hello, secure renegotiation extension" \
953 -c "found renegotiation extension" \
954 -c "=> renegotiate" \
955 -s "=> renegotiate" \
956 -s "write hello request"
957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200958run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +0200959 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200960 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200961 0 \
962 -c "client hello, adding renegotiation extension" \
963 -c "found renegotiation extension" \
964 -c "=> renegotiate" \
965 -C "ssl_handshake returned" \
966 -C "error" \
967 -c "HTTP/1.0 200 [Oo][Kk]"
968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200969run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200970 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200971 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200972 0 \
973 -c "client hello, adding renegotiation extension" \
974 -c "found renegotiation extension" \
975 -c "=> renegotiate" \
976 -C "ssl_handshake returned" \
977 -C "error" \
978 -c "HTTP/1.0 200 [Oo][Kk]"
979
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +0200980run_test "Renegotiation: DTLS, client-initiated" \
981 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
982 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
983 0 \
984 -c "client hello, adding renegotiation extension" \
985 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
986 -s "found renegotiation extension" \
987 -s "server hello, secure renegotiation extension" \
988 -c "found renegotiation extension" \
989 -c "=> renegotiate" \
990 -s "=> renegotiate" \
991 -S "write hello request"
992
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +0200993run_test "Renegotiation: DTLS, server-initiated" \
994 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +0200995 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
996 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +0200997 0 \
998 -c "client hello, adding renegotiation extension" \
999 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1000 -s "found renegotiation extension" \
1001 -s "server hello, secure renegotiation extension" \
1002 -c "found renegotiation extension" \
1003 -c "=> renegotiate" \
1004 -s "=> renegotiate" \
1005 -s "write hello request"
1006
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001007run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1008 "$G_SRV -u --mtu 4096" \
1009 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1010 0 \
1011 -c "client hello, adding renegotiation extension" \
1012 -c "found renegotiation extension" \
1013 -c "=> renegotiate" \
1014 -C "ssl_handshake returned" \
1015 -C "error" \
1016 -s "Extra-header:"
1017
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001018# Tests for auth_mode
1019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001020run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001021 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001022 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001023 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001024 1 \
1025 -c "x509_verify_cert() returned" \
1026 -c "! self-signed or not signed by a trusted CA" \
1027 -c "! ssl_handshake returned" \
1028 -c "X509 - Certificate verification failed"
1029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001030run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001031 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001032 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001033 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001034 0 \
1035 -c "x509_verify_cert() returned" \
1036 -c "! self-signed or not signed by a trusted CA" \
1037 -C "! ssl_handshake returned" \
1038 -C "X509 - Certificate verification failed"
1039
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001040run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001041 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001042 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001043 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001044 0 \
1045 -C "x509_verify_cert() returned" \
1046 -C "! self-signed or not signed by a trusted CA" \
1047 -C "! ssl_handshake returned" \
1048 -C "X509 - Certificate verification failed"
1049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001050run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001051 "$P_SRV debug_level=3 auth_mode=required" \
1052 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001053 key_file=data_files/server5.key" \
1054 1 \
1055 -S "skip write certificate request" \
1056 -C "skip parse certificate request" \
1057 -c "got a certificate request" \
1058 -C "skip write certificate" \
1059 -C "skip write certificate verify" \
1060 -S "skip parse certificate verify" \
1061 -s "x509_verify_cert() returned" \
1062 -S "! self-signed or not signed by a trusted CA" \
1063 -s "! ssl_handshake returned" \
1064 -c "! ssl_handshake returned" \
1065 -s "X509 - Certificate verification failed"
1066
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001067run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001068 "$P_SRV debug_level=3 auth_mode=optional" \
1069 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001070 key_file=data_files/server5.key" \
1071 0 \
1072 -S "skip write certificate request" \
1073 -C "skip parse certificate request" \
1074 -c "got a certificate request" \
1075 -C "skip write certificate" \
1076 -C "skip write certificate verify" \
1077 -S "skip parse certificate verify" \
1078 -s "x509_verify_cert() returned" \
1079 -s "! self-signed or not signed by a trusted CA" \
1080 -S "! ssl_handshake returned" \
1081 -C "! ssl_handshake returned" \
1082 -S "X509 - Certificate verification failed"
1083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001084run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001085 "$P_SRV debug_level=3 auth_mode=none" \
1086 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001087 key_file=data_files/server5.key" \
1088 0 \
1089 -s "skip write certificate request" \
1090 -C "skip parse certificate request" \
1091 -c "got no certificate request" \
1092 -c "skip write certificate" \
1093 -c "skip write certificate verify" \
1094 -s "skip parse certificate verify" \
1095 -S "x509_verify_cert() returned" \
1096 -S "! self-signed or not signed by a trusted CA" \
1097 -S "! ssl_handshake returned" \
1098 -C "! ssl_handshake returned" \
1099 -S "X509 - Certificate verification failed"
1100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001101run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001102 "$P_SRV debug_level=3 auth_mode=optional" \
1103 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001104 0 \
1105 -S "skip write certificate request" \
1106 -C "skip parse certificate request" \
1107 -c "got a certificate request" \
1108 -C "skip write certificate$" \
1109 -C "got no certificate to send" \
1110 -S "SSLv3 client has no certificate" \
1111 -c "skip write certificate verify" \
1112 -s "skip parse certificate verify" \
1113 -s "! no client certificate sent" \
1114 -S "! ssl_handshake returned" \
1115 -C "! ssl_handshake returned" \
1116 -S "X509 - Certificate verification failed"
1117
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001118run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001119 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001120 "$O_CLI" \
1121 0 \
1122 -S "skip write certificate request" \
1123 -s "skip parse certificate verify" \
1124 -s "! no client certificate sent" \
1125 -S "! ssl_handshake returned" \
1126 -S "X509 - Certificate verification failed"
1127
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001128run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001129 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001130 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001131 0 \
1132 -C "skip parse certificate request" \
1133 -c "got a certificate request" \
1134 -C "skip write certificate$" \
1135 -c "skip write certificate verify" \
1136 -C "! ssl_handshake returned"
1137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001138run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001139 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1140 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001141 0 \
1142 -S "skip write certificate request" \
1143 -C "skip parse certificate request" \
1144 -c "got a certificate request" \
1145 -C "skip write certificate$" \
1146 -c "skip write certificate verify" \
1147 -c "got no certificate to send" \
1148 -s "SSLv3 client has no certificate" \
1149 -s "skip parse certificate verify" \
1150 -s "! no client certificate sent" \
1151 -S "! ssl_handshake returned" \
1152 -C "! ssl_handshake returned" \
1153 -S "X509 - Certificate verification failed"
1154
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001155# tests for SNI
1156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001157run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001158 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001159 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001160 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001161 0 \
1162 -S "parse ServerName extension" \
1163 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1164 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1165
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001166run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001167 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001168 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001169 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 +02001170 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001171 0 \
1172 -s "parse ServerName extension" \
1173 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1174 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1175
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001176run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001177 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001178 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001179 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 +02001180 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001181 0 \
1182 -s "parse ServerName extension" \
1183 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001184 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001185
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001186run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001187 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001188 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001189 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 +02001190 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001191 1 \
1192 -s "parse ServerName extension" \
1193 -s "ssl_sni_wrapper() returned" \
1194 -s "ssl_handshake returned" \
1195 -c "ssl_handshake returned" \
1196 -c "SSL - A fatal alert message was received from our peer"
1197
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001198# Tests for non-blocking I/O: exercise a variety of handshake flows
1199
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001200run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001201 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1202 "$P_CLI nbio=2 tickets=0" \
1203 0 \
1204 -S "ssl_handshake returned" \
1205 -C "ssl_handshake returned" \
1206 -c "Read from server: .* bytes read"
1207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001208run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001209 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1210 "$P_CLI nbio=2 tickets=0" \
1211 0 \
1212 -S "ssl_handshake returned" \
1213 -C "ssl_handshake returned" \
1214 -c "Read from server: .* bytes read"
1215
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001216run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001217 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1218 "$P_CLI nbio=2 tickets=1" \
1219 0 \
1220 -S "ssl_handshake returned" \
1221 -C "ssl_handshake returned" \
1222 -c "Read from server: .* bytes read"
1223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001224run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001225 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1226 "$P_CLI nbio=2 tickets=1" \
1227 0 \
1228 -S "ssl_handshake returned" \
1229 -C "ssl_handshake returned" \
1230 -c "Read from server: .* bytes read"
1231
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001232run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001233 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1234 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1235 0 \
1236 -S "ssl_handshake returned" \
1237 -C "ssl_handshake returned" \
1238 -c "Read from server: .* bytes read"
1239
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001240run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001241 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1242 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1243 0 \
1244 -S "ssl_handshake returned" \
1245 -C "ssl_handshake returned" \
1246 -c "Read from server: .* bytes read"
1247
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001248run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001249 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1250 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1251 0 \
1252 -S "ssl_handshake returned" \
1253 -C "ssl_handshake returned" \
1254 -c "Read from server: .* bytes read"
1255
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001256# Tests for version negotiation
1257
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001258run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001259 "$P_SRV" \
1260 "$P_CLI" \
1261 0 \
1262 -S "ssl_handshake returned" \
1263 -C "ssl_handshake returned" \
1264 -s "Protocol is TLSv1.2" \
1265 -c "Protocol is TLSv1.2"
1266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001267run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001268 "$P_SRV" \
1269 "$P_CLI max_version=tls1_1" \
1270 0 \
1271 -S "ssl_handshake returned" \
1272 -C "ssl_handshake returned" \
1273 -s "Protocol is TLSv1.1" \
1274 -c "Protocol is TLSv1.1"
1275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001276run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001277 "$P_SRV max_version=tls1_1" \
1278 "$P_CLI" \
1279 0 \
1280 -S "ssl_handshake returned" \
1281 -C "ssl_handshake returned" \
1282 -s "Protocol is TLSv1.1" \
1283 -c "Protocol is TLSv1.1"
1284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001285run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001286 "$P_SRV max_version=tls1_1" \
1287 "$P_CLI max_version=tls1_1" \
1288 0 \
1289 -S "ssl_handshake returned" \
1290 -C "ssl_handshake returned" \
1291 -s "Protocol is TLSv1.1" \
1292 -c "Protocol is TLSv1.1"
1293
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001294run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001295 "$P_SRV min_version=tls1_1" \
1296 "$P_CLI max_version=tls1_1" \
1297 0 \
1298 -S "ssl_handshake returned" \
1299 -C "ssl_handshake returned" \
1300 -s "Protocol is TLSv1.1" \
1301 -c "Protocol is TLSv1.1"
1302
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001303run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001304 "$P_SRV max_version=tls1_1" \
1305 "$P_CLI min_version=tls1_1" \
1306 0 \
1307 -S "ssl_handshake returned" \
1308 -C "ssl_handshake returned" \
1309 -s "Protocol is TLSv1.1" \
1310 -c "Protocol is TLSv1.1"
1311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001312run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001313 "$P_SRV max_version=tls1_1" \
1314 "$P_CLI min_version=tls1_2" \
1315 1 \
1316 -s "ssl_handshake returned" \
1317 -c "ssl_handshake returned" \
1318 -c "SSL - Handshake protocol not within min/max boundaries"
1319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001320run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001321 "$P_SRV min_version=tls1_2" \
1322 "$P_CLI max_version=tls1_1" \
1323 1 \
1324 -s "ssl_handshake returned" \
1325 -c "ssl_handshake returned" \
1326 -s "SSL - Handshake protocol not within min/max boundaries"
1327
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001328# Tests for ALPN extension
1329
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001330if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1331
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001332run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001333 "$P_SRV debug_level=3" \
1334 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001335 0 \
1336 -C "client hello, adding alpn extension" \
1337 -S "found alpn extension" \
1338 -C "got an alert message, type: \\[2:120]" \
1339 -S "server hello, adding alpn extension" \
1340 -C "found alpn extension " \
1341 -C "Application Layer Protocol is" \
1342 -S "Application Layer Protocol is"
1343
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001344run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001345 "$P_SRV debug_level=3" \
1346 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001347 0 \
1348 -c "client hello, adding alpn extension" \
1349 -s "found alpn extension" \
1350 -C "got an alert message, type: \\[2:120]" \
1351 -S "server hello, adding alpn extension" \
1352 -C "found alpn extension " \
1353 -c "Application Layer Protocol is (none)" \
1354 -S "Application Layer Protocol is"
1355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001356run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001357 "$P_SRV debug_level=3 alpn=abc,1234" \
1358 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001359 0 \
1360 -C "client hello, adding alpn extension" \
1361 -S "found alpn extension" \
1362 -C "got an alert message, type: \\[2:120]" \
1363 -S "server hello, adding alpn extension" \
1364 -C "found alpn extension " \
1365 -C "Application Layer Protocol is" \
1366 -s "Application Layer Protocol is (none)"
1367
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001368run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001369 "$P_SRV debug_level=3 alpn=abc,1234" \
1370 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001371 0 \
1372 -c "client hello, adding alpn extension" \
1373 -s "found alpn extension" \
1374 -C "got an alert message, type: \\[2:120]" \
1375 -s "server hello, adding alpn extension" \
1376 -c "found alpn extension" \
1377 -c "Application Layer Protocol is abc" \
1378 -s "Application Layer Protocol is abc"
1379
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001380run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001381 "$P_SRV debug_level=3 alpn=abc,1234" \
1382 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001383 0 \
1384 -c "client hello, adding alpn extension" \
1385 -s "found alpn extension" \
1386 -C "got an alert message, type: \\[2:120]" \
1387 -s "server hello, adding alpn extension" \
1388 -c "found alpn extension" \
1389 -c "Application Layer Protocol is abc" \
1390 -s "Application Layer Protocol is abc"
1391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001392run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001393 "$P_SRV debug_level=3 alpn=abc,1234" \
1394 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001395 0 \
1396 -c "client hello, adding alpn extension" \
1397 -s "found alpn extension" \
1398 -C "got an alert message, type: \\[2:120]" \
1399 -s "server hello, adding alpn extension" \
1400 -c "found alpn extension" \
1401 -c "Application Layer Protocol is 1234" \
1402 -s "Application Layer Protocol is 1234"
1403
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001404run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001405 "$P_SRV debug_level=3 alpn=abc,123" \
1406 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001407 1 \
1408 -c "client hello, adding alpn extension" \
1409 -s "found alpn extension" \
1410 -c "got an alert message, type: \\[2:120]" \
1411 -S "server hello, adding alpn extension" \
1412 -C "found alpn extension" \
1413 -C "Application Layer Protocol is 1234" \
1414 -S "Application Layer Protocol is 1234"
1415
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001416fi
1417
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001418# Tests for keyUsage in leaf certificates, part 1:
1419# server-side certificate/suite selection
1420
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001421run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001422 "$P_SRV key_file=data_files/server2.key \
1423 crt_file=data_files/server2.ku-ds.crt" \
1424 "$P_CLI" \
1425 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001426 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001427
1428
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001429run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001430 "$P_SRV key_file=data_files/server2.key \
1431 crt_file=data_files/server2.ku-ke.crt" \
1432 "$P_CLI" \
1433 0 \
1434 -c "Ciphersuite is TLS-RSA-WITH-"
1435
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001436run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001437 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001438 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001439 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001440 1 \
1441 -C "Ciphersuite is "
1442
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001443run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001444 "$P_SRV key_file=data_files/server5.key \
1445 crt_file=data_files/server5.ku-ds.crt" \
1446 "$P_CLI" \
1447 0 \
1448 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1449
1450
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001451run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001452 "$P_SRV key_file=data_files/server5.key \
1453 crt_file=data_files/server5.ku-ka.crt" \
1454 "$P_CLI" \
1455 0 \
1456 -c "Ciphersuite is TLS-ECDH-"
1457
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001458run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001459 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001460 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001461 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001462 1 \
1463 -C "Ciphersuite is "
1464
1465# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001466# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001467
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001468run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001469 "$O_SRV -key data_files/server2.key \
1470 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001471 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001472 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1473 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001474 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001475 -C "Processing of the Certificate handshake message failed" \
1476 -c "Ciphersuite is TLS-"
1477
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001478run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001479 "$O_SRV -key data_files/server2.key \
1480 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001481 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001482 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1483 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001484 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001485 -C "Processing of the Certificate handshake message failed" \
1486 -c "Ciphersuite is TLS-"
1487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001488run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001489 "$O_SRV -key data_files/server2.key \
1490 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001491 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001492 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1493 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001494 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001495 -C "Processing of the Certificate handshake message failed" \
1496 -c "Ciphersuite is TLS-"
1497
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001498run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001499 "$O_SRV -key data_files/server2.key \
1500 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001501 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001502 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1503 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001504 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001505 -c "Processing of the Certificate handshake message failed" \
1506 -C "Ciphersuite is TLS-"
1507
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001508run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001509 "$O_SRV -key data_files/server2.key \
1510 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001511 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001512 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1513 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001514 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001515 -C "Processing of the Certificate handshake message failed" \
1516 -c "Ciphersuite is TLS-"
1517
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001518run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001519 "$O_SRV -key data_files/server2.key \
1520 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001521 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001522 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1523 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001524 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001525 -c "Processing of the Certificate handshake message failed" \
1526 -C "Ciphersuite is TLS-"
1527
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001528# Tests for keyUsage in leaf certificates, part 3:
1529# server-side checking of client cert
1530
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001531run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001532 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001533 "$O_CLI -key data_files/server2.key \
1534 -cert data_files/server2.ku-ds.crt" \
1535 0 \
1536 -S "bad certificate (usage extensions)" \
1537 -S "Processing of the Certificate handshake message failed"
1538
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001539run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001540 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001541 "$O_CLI -key data_files/server2.key \
1542 -cert data_files/server2.ku-ke.crt" \
1543 0 \
1544 -s "bad certificate (usage extensions)" \
1545 -S "Processing of the Certificate handshake message failed"
1546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001547run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001548 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001549 "$O_CLI -key data_files/server2.key \
1550 -cert data_files/server2.ku-ke.crt" \
1551 1 \
1552 -s "bad certificate (usage extensions)" \
1553 -s "Processing of the Certificate handshake message failed"
1554
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001555run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001556 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001557 "$O_CLI -key data_files/server5.key \
1558 -cert data_files/server5.ku-ds.crt" \
1559 0 \
1560 -S "bad certificate (usage extensions)" \
1561 -S "Processing of the Certificate handshake message failed"
1562
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001563run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001564 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001565 "$O_CLI -key data_files/server5.key \
1566 -cert data_files/server5.ku-ka.crt" \
1567 0 \
1568 -s "bad certificate (usage extensions)" \
1569 -S "Processing of the Certificate handshake message failed"
1570
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001571# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1572
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001573run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001574 "$P_SRV key_file=data_files/server5.key \
1575 crt_file=data_files/server5.eku-srv.crt" \
1576 "$P_CLI" \
1577 0
1578
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001579run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001580 "$P_SRV key_file=data_files/server5.key \
1581 crt_file=data_files/server5.eku-srv.crt" \
1582 "$P_CLI" \
1583 0
1584
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001585run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001586 "$P_SRV key_file=data_files/server5.key \
1587 crt_file=data_files/server5.eku-cs_any.crt" \
1588 "$P_CLI" \
1589 0
1590
1591# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001592run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001593 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1594 crt_file=data_files/server5.eku-cli.crt" \
1595 "$P_CLI psk=badbad" \
1596 1
1597
1598# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001600run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001601 "$O_SRV -key data_files/server5.key \
1602 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001603 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001604 0 \
1605 -C "bad certificate (usage extensions)" \
1606 -C "Processing of the Certificate handshake message failed" \
1607 -c "Ciphersuite is TLS-"
1608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001609run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001610 "$O_SRV -key data_files/server5.key \
1611 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001612 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001613 0 \
1614 -C "bad certificate (usage extensions)" \
1615 -C "Processing of the Certificate handshake message failed" \
1616 -c "Ciphersuite is TLS-"
1617
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001618run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001619 "$O_SRV -key data_files/server5.key \
1620 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001621 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001622 0 \
1623 -C "bad certificate (usage extensions)" \
1624 -C "Processing of the Certificate handshake message failed" \
1625 -c "Ciphersuite is TLS-"
1626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001627run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001628 "$O_SRV -key data_files/server5.key \
1629 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001630 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001631 1 \
1632 -c "bad certificate (usage extensions)" \
1633 -c "Processing of the Certificate handshake message failed" \
1634 -C "Ciphersuite is TLS-"
1635
1636# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1637
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001638run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001639 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001640 "$O_CLI -key data_files/server5.key \
1641 -cert data_files/server5.eku-cli.crt" \
1642 0 \
1643 -S "bad certificate (usage extensions)" \
1644 -S "Processing of the Certificate handshake message failed"
1645
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001646run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001647 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001648 "$O_CLI -key data_files/server5.key \
1649 -cert data_files/server5.eku-srv_cli.crt" \
1650 0 \
1651 -S "bad certificate (usage extensions)" \
1652 -S "Processing of the Certificate handshake message failed"
1653
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001654run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001655 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001656 "$O_CLI -key data_files/server5.key \
1657 -cert data_files/server5.eku-cs_any.crt" \
1658 0 \
1659 -S "bad certificate (usage extensions)" \
1660 -S "Processing of the Certificate handshake message failed"
1661
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001662run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001663 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001664 "$O_CLI -key data_files/server5.key \
1665 -cert data_files/server5.eku-cs.crt" \
1666 0 \
1667 -s "bad certificate (usage extensions)" \
1668 -S "Processing of the Certificate handshake message failed"
1669
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001670run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001671 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001672 "$O_CLI -key data_files/server5.key \
1673 -cert data_files/server5.eku-cs.crt" \
1674 1 \
1675 -s "bad certificate (usage extensions)" \
1676 -s "Processing of the Certificate handshake message failed"
1677
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001678# Tests for DHM parameters loading
1679
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001680run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001681 "$P_SRV" \
1682 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1683 debug_level=3" \
1684 0 \
1685 -c "value of 'DHM: P ' (2048 bits)" \
1686 -c "value of 'DHM: G ' (2048 bits)"
1687
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001688run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001689 "$P_SRV dhm_file=data_files/dhparams.pem" \
1690 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1691 debug_level=3" \
1692 0 \
1693 -c "value of 'DHM: P ' (1024 bits)" \
1694 -c "value of 'DHM: G ' (2 bits)"
1695
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001696# Tests for PSK callback
1697
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001698run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001699 "$P_SRV psk=abc123 psk_identity=foo" \
1700 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1701 psk_identity=foo psk=abc123" \
1702 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001703 -S "SSL - The server has no ciphersuites in common" \
1704 -S "SSL - Unknown identity received" \
1705 -S "SSL - Verification of the message MAC failed"
1706
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001707run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001708 "$P_SRV" \
1709 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1710 psk_identity=foo psk=abc123" \
1711 1 \
1712 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001713 -S "SSL - Unknown identity received" \
1714 -S "SSL - Verification of the message MAC failed"
1715
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001716run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001717 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1718 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1719 psk_identity=foo psk=abc123" \
1720 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001721 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001722 -s "SSL - Unknown identity received" \
1723 -S "SSL - Verification of the message MAC failed"
1724
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001725run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001726 "$P_SRV psk_list=abc,dead,def,beef" \
1727 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1728 psk_identity=abc psk=dead" \
1729 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001730 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001731 -S "SSL - Unknown identity received" \
1732 -S "SSL - Verification of the message MAC failed"
1733
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001734run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001735 "$P_SRV psk_list=abc,dead,def,beef" \
1736 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1737 psk_identity=def psk=beef" \
1738 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001739 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001740 -S "SSL - Unknown identity received" \
1741 -S "SSL - Verification of the message MAC failed"
1742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001743run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001744 "$P_SRV psk_list=abc,dead,def,beef" \
1745 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1746 psk_identity=ghi psk=beef" \
1747 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001748 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001749 -s "SSL - Unknown identity received" \
1750 -S "SSL - Verification of the message MAC failed"
1751
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001752run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001753 "$P_SRV psk_list=abc,dead,def,beef" \
1754 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1755 psk_identity=abc psk=beef" \
1756 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001757 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001758 -S "SSL - Unknown identity received" \
1759 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001760
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001761# Tests for ciphersuites per version
1762
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001763run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001764 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
1765 "$P_CLI force_version=ssl3" \
1766 0 \
1767 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001769run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001770 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
1771 "$P_CLI force_version=tls1" \
1772 0 \
1773 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001775run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001776 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
1777 "$P_CLI force_version=tls1_1" \
1778 0 \
1779 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1780
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001781run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001782 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
1783 "$P_CLI force_version=tls1_2" \
1784 0 \
1785 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1786
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001787# Tests for ssl_get_bytes_avail()
1788
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001789run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001790 "$P_SRV" \
1791 "$P_CLI request_size=100" \
1792 0 \
1793 -s "Read from client: 100 bytes read$"
1794
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001795run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001796 "$P_SRV" \
1797 "$P_CLI request_size=500" \
1798 0 \
1799 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001800
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001801# Tests for small packets
1802
1803run_test "Small packet SSLv3 BlockCipher" \
1804 "$P_SRV" \
1805 "$P_CLI request_size=1 force_version=ssl3 \
1806 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1807 0 \
1808 -s "Read from client: 1 bytes read"
1809
1810run_test "Small packet SSLv3 StreamCipher" \
1811 "$P_SRV" \
1812 "$P_CLI request_size=1 force_version=ssl3 \
1813 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1814 0 \
1815 -s "Read from client: 1 bytes read"
1816
1817run_test "Small packet TLS 1.0 BlockCipher" \
1818 "$P_SRV" \
1819 "$P_CLI request_size=1 force_version=tls1 \
1820 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1821 0 \
1822 -s "Read from client: 1 bytes read"
1823
1824run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1825 "$P_SRV" \
1826 "$P_CLI request_size=1 force_version=tls1 \
1827 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1828 trunc_hmac=1" \
1829 0 \
1830 -s "Read from client: 1 bytes read"
1831
1832run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1833 "$P_SRV" \
1834 "$P_CLI request_size=1 force_version=tls1 \
1835 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1836 trunc_hmac=1" \
1837 0 \
1838 -s "Read from client: 1 bytes read"
1839
1840run_test "Small packet TLS 1.1 BlockCipher" \
1841 "$P_SRV" \
1842 "$P_CLI request_size=1 force_version=tls1_1 \
1843 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1844 0 \
1845 -s "Read from client: 1 bytes read"
1846
1847run_test "Small packet TLS 1.1 StreamCipher" \
1848 "$P_SRV" \
1849 "$P_CLI request_size=1 force_version=tls1_1 \
1850 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1851 0 \
1852 -s "Read from client: 1 bytes read"
1853
1854run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1855 "$P_SRV" \
1856 "$P_CLI request_size=1 force_version=tls1_1 \
1857 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1858 trunc_hmac=1" \
1859 0 \
1860 -s "Read from client: 1 bytes read"
1861
1862run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1863 "$P_SRV" \
1864 "$P_CLI request_size=1 force_version=tls1_1 \
1865 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1866 trunc_hmac=1" \
1867 0 \
1868 -s "Read from client: 1 bytes read"
1869
1870run_test "Small packet TLS 1.2 BlockCipher" \
1871 "$P_SRV" \
1872 "$P_CLI request_size=1 force_version=tls1_2 \
1873 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1874 0 \
1875 -s "Read from client: 1 bytes read"
1876
1877run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1878 "$P_SRV" \
1879 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1880 0 \
1881 -s "Read from client: 1 bytes read"
1882
1883run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1884 "$P_SRV" \
1885 "$P_CLI request_size=1 force_version=tls1_2 \
1886 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1887 trunc_hmac=1" \
1888 0 \
1889 -s "Read from client: 1 bytes read"
1890
1891run_test "Small packet TLS 1.2 StreamCipher" \
1892 "$P_SRV" \
1893 "$P_CLI request_size=1 force_version=tls1_2 \
1894 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1895 0 \
1896 -s "Read from client: 1 bytes read"
1897
1898run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1899 "$P_SRV" \
1900 "$P_CLI request_size=1 force_version=tls1_2 \
1901 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1902 trunc_hmac=1" \
1903 0 \
1904 -s "Read from client: 1 bytes read"
1905
1906run_test "Small packet TLS 1.2 AEAD" \
1907 "$P_SRV" \
1908 "$P_CLI request_size=1 force_version=tls1_2 \
1909 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1910 0 \
1911 -s "Read from client: 1 bytes read"
1912
1913run_test "Small packet TLS 1.2 AEAD shorter tag" \
1914 "$P_SRV" \
1915 "$P_CLI request_size=1 force_version=tls1_2 \
1916 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1917 0 \
1918 -s "Read from client: 1 bytes read"
1919
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001920# Test for large packets
1921
1922run_test "Large packet SSLv3 BlockCipher" \
1923 "$P_SRV" \
1924 "$P_CLI request_size=16384 force_version=ssl3 \
1925 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1926 0 \
1927 -s "Read from client: 16384 bytes read"
1928
1929run_test "Large packet SSLv3 StreamCipher" \
1930 "$P_SRV" \
1931 "$P_CLI request_size=16384 force_version=ssl3 \
1932 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1933 0 \
1934 -s "Read from client: 16384 bytes read"
1935
1936run_test "Large packet TLS 1.0 BlockCipher" \
1937 "$P_SRV" \
1938 "$P_CLI request_size=16384 force_version=tls1 \
1939 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1940 0 \
1941 -s "Read from client: 16384 bytes read"
1942
1943run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1944 "$P_SRV" \
1945 "$P_CLI request_size=16384 force_version=tls1 \
1946 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1947 trunc_hmac=1" \
1948 0 \
1949 -s "Read from client: 16384 bytes read"
1950
1951run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1952 "$P_SRV" \
1953 "$P_CLI request_size=16384 force_version=tls1 \
1954 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1955 trunc_hmac=1" \
1956 0 \
1957 -s "Read from client: 16384 bytes read"
1958
1959run_test "Large packet TLS 1.1 BlockCipher" \
1960 "$P_SRV" \
1961 "$P_CLI request_size=16384 force_version=tls1_1 \
1962 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1963 0 \
1964 -s "Read from client: 16384 bytes read"
1965
1966run_test "Large packet TLS 1.1 StreamCipher" \
1967 "$P_SRV" \
1968 "$P_CLI request_size=16384 force_version=tls1_1 \
1969 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1970 0 \
1971 -s "Read from client: 16384 bytes read"
1972
1973run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1974 "$P_SRV" \
1975 "$P_CLI request_size=16384 force_version=tls1_1 \
1976 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1977 trunc_hmac=1" \
1978 0 \
1979 -s "Read from client: 16384 bytes read"
1980
1981run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1982 "$P_SRV" \
1983 "$P_CLI request_size=16384 force_version=tls1_1 \
1984 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1985 trunc_hmac=1" \
1986 0 \
1987 -s "Read from client: 16384 bytes read"
1988
1989run_test "Large packet TLS 1.2 BlockCipher" \
1990 "$P_SRV" \
1991 "$P_CLI request_size=16384 force_version=tls1_2 \
1992 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1993 0 \
1994 -s "Read from client: 16384 bytes read"
1995
1996run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1997 "$P_SRV" \
1998 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1999 0 \
2000 -s "Read from client: 16384 bytes read"
2001
2002run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2003 "$P_SRV" \
2004 "$P_CLI request_size=16384 force_version=tls1_2 \
2005 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2006 trunc_hmac=1" \
2007 0 \
2008 -s "Read from client: 16384 bytes read"
2009
2010run_test "Large packet TLS 1.2 StreamCipher" \
2011 "$P_SRV" \
2012 "$P_CLI request_size=16384 force_version=tls1_2 \
2013 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2014 0 \
2015 -s "Read from client: 16384 bytes read"
2016
2017run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
2018 "$P_SRV" \
2019 "$P_CLI request_size=16384 force_version=tls1_2 \
2020 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2021 trunc_hmac=1" \
2022 0 \
2023 -s "Read from client: 16384 bytes read"
2024
2025run_test "Large packet TLS 1.2 AEAD" \
2026 "$P_SRV" \
2027 "$P_CLI request_size=16384 force_version=tls1_2 \
2028 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2029 0 \
2030 -s "Read from client: 16384 bytes read"
2031
2032run_test "Large packet TLS 1.2 AEAD shorter tag" \
2033 "$P_SRV" \
2034 "$P_CLI request_size=16384 force_version=tls1_2 \
2035 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2036 0 \
2037 -s "Read from client: 16384 bytes read"
2038
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002039# Tests for DTLS HelloVerifyRequest
2040
2041run_test "DTLS cookie: enabled" \
2042 "$P_SRV dtls=1 debug_level=2" \
2043 "$P_CLI dtls=1 debug_level=2" \
2044 0 \
2045 -s "cookie verification failed" \
2046 -s "cookie verification passed" \
2047 -S "cookie verification skipped" \
2048 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002049 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002050 -S "SSL - The requested feature is not available"
2051
2052run_test "DTLS cookie: disabled" \
2053 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2054 "$P_CLI dtls=1 debug_level=2" \
2055 0 \
2056 -S "cookie verification failed" \
2057 -S "cookie verification passed" \
2058 -s "cookie verification skipped" \
2059 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002060 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002061 -S "SSL - The requested feature is not available"
2062
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002063run_test "DTLS cookie: default (failing)" \
2064 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2065 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2066 1 \
2067 -s "cookie verification failed" \
2068 -S "cookie verification passed" \
2069 -S "cookie verification skipped" \
2070 -C "received hello verify request" \
2071 -S "hello verification requested" \
2072 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002073
2074requires_ipv6
2075run_test "DTLS cookie: enabled, IPv6" \
2076 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2077 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2078 0 \
2079 -s "cookie verification failed" \
2080 -s "cookie verification passed" \
2081 -S "cookie verification skipped" \
2082 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002083 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002084 -S "SSL - The requested feature is not available"
2085
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002086run_test "DTLS cookie: enabled, nbio" \
2087 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2088 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2089 0 \
2090 -s "cookie verification failed" \
2091 -s "cookie verification passed" \
2092 -S "cookie verification skipped" \
2093 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002094 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002095 -S "SSL - The requested feature is not available"
2096
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002097# Tests for various cases of client authentication with DTLS
2098# (focused on handshake flows and message parsing)
2099
2100run_test "DTLS client auth: required" \
2101 "$P_SRV dtls=1 auth_mode=required" \
2102 "$P_CLI dtls=1" \
2103 0 \
2104 -s "Verifying peer X.509 certificate... ok"
2105
2106run_test "DTLS client auth: optional, client has no cert" \
2107 "$P_SRV dtls=1 auth_mode=optional" \
2108 "$P_CLI dtls=1 crt_file=none key_file=none" \
2109 0 \
2110 -s "! no client certificate sent"
2111
2112run_test "DTLS client auth: optional, client has no cert" \
2113 "$P_SRV dtls=1 auth_mode=none" \
2114 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
2115 0 \
2116 -c "skip write certificate$" \
2117 -s "! no client certificate sent"
2118
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02002119# Tests for receiving fragmented handshake messages with DTLS
2120
2121requires_gnutls
2122run_test "DTLS reassembly: no fragmentation (gnutls server)" \
2123 "$G_SRV -u --mtu 2048 -a" \
2124 "$P_CLI dtls=1 debug_level=2" \
2125 0 \
2126 -C "found fragmented DTLS handshake message" \
2127 -C "error"
2128
2129requires_gnutls
2130run_test "DTLS reassembly: some fragmentation (gnutls server)" \
2131 "$G_SRV -u --mtu 512" \
2132 "$P_CLI dtls=1 debug_level=2" \
2133 0 \
2134 -c "found fragmented DTLS handshake message" \
2135 -C "error"
2136
2137requires_gnutls
2138run_test "DTLS reassembly: more fragmentation (gnutls server)" \
2139 "$G_SRV -u --mtu 128" \
2140 "$P_CLI dtls=1 debug_level=2" \
2141 0 \
2142 -c "found fragmented DTLS handshake message" \
2143 -C "error"
2144
2145requires_gnutls
2146run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
2147 "$G_SRV -u --mtu 128" \
2148 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2149 0 \
2150 -c "found fragmented DTLS handshake message" \
2151 -C "error"
2152
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002153requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002154run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
2155 "$G_SRV -u --mtu 256" \
2156 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
2157 0 \
2158 -c "found fragmented DTLS handshake message" \
2159 -c "client hello, adding renegotiation extension" \
2160 -c "found renegotiation extension" \
2161 -c "=> renegotiate" \
2162 -C "ssl_handshake returned" \
2163 -C "error" \
2164 -s "Extra-header:"
2165
2166requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002167run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
2168 "$G_SRV -u --mtu 256" \
2169 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
2170 0 \
2171 -c "found fragmented DTLS handshake message" \
2172 -c "client hello, adding renegotiation extension" \
2173 -c "found renegotiation extension" \
2174 -c "=> renegotiate" \
2175 -C "ssl_handshake returned" \
2176 -C "error" \
2177 -s "Extra-header:"
2178
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002179run_test "DTLS reassembly: no fragmentation (openssl server)" \
2180 "$O_SRV -dtls1 -mtu 2048" \
2181 "$P_CLI dtls=1 debug_level=2" \
2182 0 \
2183 -C "found fragmented DTLS handshake message" \
2184 -C "error"
2185
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002186run_test "DTLS reassembly: some fragmentation (openssl server)" \
2187 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002188 "$P_CLI dtls=1 debug_level=2" \
2189 0 \
2190 -c "found fragmented DTLS handshake message" \
2191 -C "error"
2192
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002193run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002194 "$O_SRV -dtls1 -mtu 256" \
2195 "$P_CLI dtls=1 debug_level=2" \
2196 0 \
2197 -c "found fragmented DTLS handshake message" \
2198 -C "error"
2199
2200run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2201 "$O_SRV -dtls1 -mtu 256" \
2202 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2203 0 \
2204 -c "found fragmented DTLS handshake message" \
2205 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002206
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002207# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002208
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002209not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002210run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002211 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002212 "$P_SRV dtls=1 debug_level=2" \
2213 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002214 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002215 -C "replayed record" \
2216 -S "replayed record" \
2217 -C "record from another epoch" \
2218 -S "record from another epoch" \
2219 -C "discarding invalid record" \
2220 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002221 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002222 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002223 -c "HTTP/1.0 200 OK"
2224
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002225not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002226run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002227 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002228 "$P_SRV dtls=1 debug_level=2" \
2229 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002230 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002231 -c "replayed record" \
2232 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002233 -c "discarding invalid record" \
2234 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002235 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002236 -s "Extra-header:" \
2237 -c "HTTP/1.0 200 OK"
2238
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002239run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
2240 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002241 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
2242 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002243 0 \
2244 -c "replayed record" \
2245 -S "replayed record" \
2246 -c "discarding invalid record" \
2247 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002248 -c "resend" \
2249 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002250 -s "Extra-header:" \
2251 -c "HTTP/1.0 200 OK"
2252
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002253run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002254 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002255 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002256 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002257 0 \
2258 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002259 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002260 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002261 -c "HTTP/1.0 200 OK" \
2262 -S "too many records with bad MAC" \
2263 -S "Verification of the message MAC failed"
2264
2265run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
2266 -p "$P_PXY bad_ad=1" \
2267 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
2268 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2269 1 \
2270 -C "discarding invalid record" \
2271 -S "discarding invalid record" \
2272 -S "Extra-header:" \
2273 -C "HTTP/1.0 200 OK" \
2274 -s "too many records with bad MAC" \
2275 -s "Verification of the message MAC failed"
2276
2277run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
2278 -p "$P_PXY bad_ad=1" \
2279 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
2280 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2281 0 \
2282 -c "discarding invalid record" \
2283 -s "discarding invalid record" \
2284 -s "Extra-header:" \
2285 -c "HTTP/1.0 200 OK" \
2286 -S "too many records with bad MAC" \
2287 -S "Verification of the message MAC failed"
2288
2289run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
2290 -p "$P_PXY bad_ad=1" \
2291 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
2292 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
2293 1 \
2294 -c "discarding invalid record" \
2295 -s "discarding invalid record" \
2296 -s "Extra-header:" \
2297 -c "HTTP/1.0 200 OK" \
2298 -s "too many records with bad MAC" \
2299 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002300
2301run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002302 -p "$P_PXY delay_ccs=1" \
2303 "$P_SRV dtls=1 debug_level=1" \
2304 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002305 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002306 -c "record from another epoch" \
2307 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002308 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002309 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002310 -s "Extra-header:" \
2311 -c "HTTP/1.0 200 OK"
2312
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002313# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002314
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002315needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002316run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002317 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002318 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2319 psk=abc123" \
2320 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002321 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2322 0 \
2323 -s "Extra-header:" \
2324 -c "HTTP/1.0 200 OK"
2325
2326needs_more_time 2
2327run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
2328 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002329 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2330 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002331 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2332 0 \
2333 -s "Extra-header:" \
2334 -c "HTTP/1.0 200 OK"
2335
2336needs_more_time 2
2337run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
2338 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002339 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2340 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002341 0 \
2342 -s "Extra-header:" \
2343 -c "HTTP/1.0 200 OK"
2344
2345needs_more_time 2
2346run_test "DTLS proxy: 3d, FS, client auth" \
2347 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002348 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
2349 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002350 0 \
2351 -s "Extra-header:" \
2352 -c "HTTP/1.0 200 OK"
2353
2354needs_more_time 2
2355run_test "DTLS proxy: 3d, FS, ticket" \
2356 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002357 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
2358 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002359 0 \
2360 -s "Extra-header:" \
2361 -c "HTTP/1.0 200 OK"
2362
2363needs_more_time 2
2364run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
2365 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002366 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
2367 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002368 0 \
2369 -s "Extra-header:" \
2370 -c "HTTP/1.0 200 OK"
2371
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002372needs_more_time 2
2373run_test "DTLS proxy: 3d, max handshake, nbio" \
2374 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002375 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
2376 auth_mode=required" \
2377 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002378 0 \
2379 -s "Extra-header:" \
2380 -c "HTTP/1.0 200 OK"
2381
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002382needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02002383run_test "DTLS proxy: 3d, min handshake, resumption" \
2384 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2385 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2386 psk=abc123 debug_level=3" \
2387 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2388 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
2389 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2390 0 \
2391 -s "a session has been resumed" \
2392 -c "a session has been resumed" \
2393 -s "Extra-header:" \
2394 -c "HTTP/1.0 200 OK"
2395
2396needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02002397run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
2398 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2399 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2400 psk=abc123 debug_level=3 nbio=2" \
2401 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2402 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
2403 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
2404 0 \
2405 -s "a session has been resumed" \
2406 -c "a session has been resumed" \
2407 -s "Extra-header:" \
2408 -c "HTTP/1.0 200 OK"
2409
2410needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002411run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002412 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002413 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2414 psk=abc123 renegotiation=1 debug_level=2" \
2415 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2416 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002417 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2418 0 \
2419 -c "=> renegotiate" \
2420 -s "=> renegotiate" \
2421 -s "Extra-header:" \
2422 -c "HTTP/1.0 200 OK"
2423
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002424needs_more_time 4
2425run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
2426 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002427 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2428 psk=abc123 renegotiation=1 debug_level=2" \
2429 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2430 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002431 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2432 0 \
2433 -c "=> renegotiate" \
2434 -s "=> renegotiate" \
2435 -s "Extra-header:" \
2436 -c "HTTP/1.0 200 OK"
2437
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02002438needs_more_time 4
2439run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
2440 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_len=41" \
2441 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2442 psk=abc123 renegotiate=1 renegotiation=1 exchanges=2 \
2443 debug_level=2" \
2444 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2445 renegotiation=1 exchanges=2 debug_level=2 \
2446 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2447 0 \
2448 -c "=> renegotiate" \
2449 -s "=> renegotiate" \
2450 -s "Extra-header:" \
2451 -c "HTTP/1.0 200 OK"
2452
2453needs_more_time 4
2454run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
2455 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_len=41" \
2456 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2457 psk=abc123 renegotiate=1 renegotiation=1 exchanges=2 \
2458 debug_level=2 nbio=2" \
2459 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2460 renegotiation=1 exchanges=2 debug_level=2 nbio=2 \
2461 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2462 0 \
2463 -c "=> renegotiate" \
2464 -s "=> renegotiate" \
2465 -s "Extra-header:" \
2466 -c "HTTP/1.0 200 OK"
2467
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002468needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002469run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02002470 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
2471 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002472 "$P_CLI dtls=1 hs_timeout=250-10000" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02002473 0 \
2474 -s "Extra-header:" \
2475 -c "HTTP/1.0 200 OK"
2476
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002477needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002478run_test "DTLS proxy: 3d, openssl server, fragmentation" \
2479 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
2480 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002481 "$P_CLI dtls=1 hs_timeout=250-10000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002482 0 \
2483 -s "Extra-header:" \
2484 -c "HTTP/1.0 200 OK"
2485
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002486needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002487run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
2488 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
2489 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002490 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002491 0 \
2492 -s "Extra-header:" \
2493 -c "HTTP/1.0 200 OK"
2494
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002495needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002496run_test "DTLS proxy: 3d, gnutls server" \
2497 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2498 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002499 "$P_CLI dtls=1 hs_timeout=250-10000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002500 0 \
2501 -s "Extra-header:" \
2502 -c "Extra-header:"
2503
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002504needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002505run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
2506 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2507 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002508 "$P_CLI dtls=1 hs_timeout=250-10000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002509 0 \
2510 -s "Extra-header:" \
2511 -c "Extra-header:"
2512
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002513needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002514run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
2515 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2516 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002517 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002518 0 \
2519 -s "Extra-header:" \
2520 -c "Extra-header:"
2521
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002522# Final report
2523
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002524echo "------------------------------------------------------------------------"
2525
2526if [ $FAILS = 0 ]; then
2527 echo -n "PASSED"
2528else
2529 echo -n "FAILED"
2530fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002531PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002532echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002533
2534exit $FAILS