This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

source: ps/trunk/build/premake/premake5/contrib/mbedtls/tests/ssl-opt.sh

Last change on this file was 20366, checked in by Itms, 7 years ago

Alpha 12 version of Premake 5, including prebuilt binary for Windows.
Directly taken from https://premake.github.io/.

Refs #3729.

File size: 134.4 KB
Line 
1#!/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#
9# Assumes a build with default options.
10
11set -u
12
13# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
16: ${P_PXY:=../programs/test/udp_proxy}
17: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
18: ${GNUTLS_CLI:=gnutls-cli}
19: ${GNUTLS_SERV:=gnutls-serv}
20
21O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
22O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
23G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
24G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
25
26TESTS=0
27FAILS=0
28SKIPS=0
29
30CONFIG_H='../include/mbedtls/config.h'
31
32MEMCHECK=0
33FILTER='.*'
34EXCLUDE='^$'
35
36print_usage() {
37 echo "Usage: $0 [options]"
38 printf " -h|--help\tPrint this help.\n"
39 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
40 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
41 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
42}
43
44get_options() {
45 while [ $# -gt 0 ]; do
46 case "$1" in
47 -f|--filter)
48 shift; FILTER=$1
49 ;;
50 -e|--exclude)
51 shift; EXCLUDE=$1
52 ;;
53 -m|--memcheck)
54 MEMCHECK=1
55 ;;
56 -h|--help)
57 print_usage
58 exit 0
59 ;;
60 *)
61 echo "Unknown argument: '$1'"
62 print_usage
63 exit 1
64 ;;
65 esac
66 shift
67 done
68}
69
70# skip next test if the flag is not enabled in config.h
71requires_config_enabled() {
72 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
73 SKIP_NEXT="YES"
74 fi
75}
76
77# skip next test if OpenSSL doesn't support FALLBACK_SCSV
78requires_openssl_with_fallback_scsv() {
79 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
80 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
81 then
82 OPENSSL_HAS_FBSCSV="YES"
83 else
84 OPENSSL_HAS_FBSCSV="NO"
85 fi
86 fi
87 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
88 SKIP_NEXT="YES"
89 fi
90}
91
92# skip next test if GnuTLS isn't available
93requires_gnutls() {
94 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
95 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
96 GNUTLS_AVAILABLE="YES"
97 else
98 GNUTLS_AVAILABLE="NO"
99 fi
100 fi
101 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
102 SKIP_NEXT="YES"
103 fi
104}
105
106# skip next test if IPv6 isn't available on this host
107requires_ipv6() {
108 if [ -z "${HAS_IPV6:-}" ]; then
109 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
110 SRV_PID=$!
111 sleep 1
112 kill $SRV_PID >/dev/null 2>&1
113 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
114 HAS_IPV6="NO"
115 else
116 HAS_IPV6="YES"
117 fi
118 rm -r $SRV_OUT
119 fi
120
121 if [ "$HAS_IPV6" = "NO" ]; then
122 SKIP_NEXT="YES"
123 fi
124}
125
126# skip the next test if valgrind is in use
127not_with_valgrind() {
128 if [ "$MEMCHECK" -gt 0 ]; then
129 SKIP_NEXT="YES"
130 fi
131}
132
133# multiply the client timeout delay by the given factor for the next test
134needs_more_time() {
135 CLI_DELAY_FACTOR=$1
136}
137
138# print_name <name>
139print_name() {
140 printf "$1 "
141 LEN=$(( 72 - `echo "$1" | wc -c` ))
142 for i in `seq 1 $LEN`; do printf '.'; done
143 printf ' '
144
145 TESTS=$(( $TESTS + 1 ))
146}
147
148# fail <message>
149fail() {
150 echo "FAIL"
151 echo " ! $1"
152
153 mv $SRV_OUT o-srv-${TESTS}.log
154 mv $CLI_OUT o-cli-${TESTS}.log
155 if [ -n "$PXY_CMD" ]; then
156 mv $PXY_OUT o-pxy-${TESTS}.log
157 fi
158 echo " ! outputs saved to o-XXX-${TESTS}.log"
159
160 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
161 echo " ! server output:"
162 cat o-srv-${TESTS}.log
163 echo " ! ========================================================"
164 echo " ! client output:"
165 cat o-cli-${TESTS}.log
166 if [ -n "$PXY_CMD" ]; then
167 echo " ! ========================================================"
168 echo " ! proxy output:"
169 cat o-pxy-${TESTS}.log
170 fi
171 echo ""
172 fi
173
174 FAILS=$(( $FAILS + 1 ))
175}
176
177# is_polar <cmd_line>
178is_polar() {
179 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
180}
181
182# openssl s_server doesn't have -www with DTLS
183check_osrv_dtls() {
184 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
185 NEEDS_INPUT=1
186 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
187 else
188 NEEDS_INPUT=0
189 fi
190}
191
192# provide input to commands that need it
193provide_input() {
194 if [ $NEEDS_INPUT -eq 0 ]; then
195 return
196 fi
197
198 while true; do
199 echo "HTTP/1.0 200 OK"
200 sleep 1
201 done
202}
203
204# has_mem_err <log_file_name>
205has_mem_err() {
206 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
207 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
208 then
209 return 1 # false: does not have errors
210 else
211 return 0 # true: has errors
212 fi
213}
214
215# wait for server to start: two versions depending on lsof availability
216wait_server_start() {
217 if which lsof >/dev/null 2>&1; then
218 START_TIME=$( date +%s )
219 DONE=0
220
221 # make a tight loop, server usually takes less than 1 sec to start
222 if [ "$DTLS" -eq 1 ]; then
223 while [ $DONE -eq 0 ]; do
224 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
225 then
226 DONE=1
227 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
228 echo "SERVERSTART TIMEOUT"
229 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
230 DONE=1
231 fi
232 done
233 else
234 while [ $DONE -eq 0 ]; do
235 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
236 then
237 DONE=1
238 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
239 echo "SERVERSTART TIMEOUT"
240 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
241 DONE=1
242 fi
243 done
244 fi
245 else
246 sleep "$START_DELAY"
247 fi
248}
249
250# wait for client to terminate and set CLI_EXIT
251# must be called right after starting the client
252wait_client_done() {
253 CLI_PID=$!
254
255 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
256 CLI_DELAY_FACTOR=1
257
258 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
259 DOG_PID=$!
260
261 wait $CLI_PID
262 CLI_EXIT=$?
263
264 kill $DOG_PID >/dev/null 2>&1
265 wait $DOG_PID
266
267 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
268}
269
270# check if the given command uses dtls and sets global variable DTLS
271detect_dtls() {
272 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
273 DTLS=1
274 else
275 DTLS=0
276 fi
277}
278
279# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
280# Options: -s pattern pattern that must be present in server output
281# -c pattern pattern that must be present in client output
282# -S pattern pattern that must be absent in server output
283# -C pattern pattern that must be absent in client output
284run_test() {
285 NAME="$1"
286 shift 1
287
288 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
289 else
290 SKIP_NEXT="NO"
291 return
292 fi
293
294 print_name "$NAME"
295
296 # should we skip?
297 if [ "X$SKIP_NEXT" = "XYES" ]; then
298 SKIP_NEXT="NO"
299 echo "SKIP"
300 SKIPS=$(( $SKIPS + 1 ))
301 return
302 fi
303
304 # does this test use a proxy?
305 if [ "X$1" = "X-p" ]; then
306 PXY_CMD="$2"
307 shift 2
308 else
309 PXY_CMD=""
310 fi
311
312 # get commands and client output
313 SRV_CMD="$1"
314 CLI_CMD="$2"
315 CLI_EXPECT="$3"
316 shift 3
317
318 # fix client port
319 if [ -n "$PXY_CMD" ]; then
320 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
321 else
322 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
323 fi
324
325 # update DTLS variable
326 detect_dtls "$SRV_CMD"
327
328 # prepend valgrind to our commands if active
329 if [ "$MEMCHECK" -gt 0 ]; then
330 if is_polar "$SRV_CMD"; then
331 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
332 fi
333 if is_polar "$CLI_CMD"; then
334 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
335 fi
336 fi
337
338 TIMES_LEFT=2
339 while [ $TIMES_LEFT -gt 0 ]; do
340 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
341
342 # run the commands
343 if [ -n "$PXY_CMD" ]; then
344 echo "$PXY_CMD" > $PXY_OUT
345 $PXY_CMD >> $PXY_OUT 2>&1 &
346 PXY_PID=$!
347 # assume proxy starts faster than server
348 fi
349
350 check_osrv_dtls
351 echo "$SRV_CMD" > $SRV_OUT
352 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
353 SRV_PID=$!
354 wait_server_start
355
356 echo "$CLI_CMD" > $CLI_OUT
357 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
358 wait_client_done
359
360 # terminate the server (and the proxy)
361 kill $SRV_PID
362 wait $SRV_PID
363 if [ -n "$PXY_CMD" ]; then
364 kill $PXY_PID >/dev/null 2>&1
365 wait $PXY_PID
366 fi
367
368 # retry only on timeouts
369 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
370 printf "RETRY "
371 else
372 TIMES_LEFT=0
373 fi
374 done
375
376 # check if the client and server went at least to the handshake stage
377 # (useful to avoid tests with only negative assertions and non-zero
378 # expected client exit to incorrectly succeed in case of catastrophic
379 # failure)
380 if is_polar "$SRV_CMD"; then
381 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
382 else
383 fail "server or client failed to reach handshake stage"
384 return
385 fi
386 fi
387 if is_polar "$CLI_CMD"; then
388 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
389 else
390 fail "server or client failed to reach handshake stage"
391 return
392 fi
393 fi
394
395 # check server exit code
396 if [ $? != 0 ]; then
397 fail "server fail"
398 return
399 fi
400
401 # check client exit code
402 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
403 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
404 then
405 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
406 return
407 fi
408
409 # check other assertions
410 # lines beginning with == are added by valgrind, ignore them
411 while [ $# -gt 0 ]
412 do
413 case $1 in
414 "-s")
415 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
416 fail "-s $2"
417 return
418 fi
419 ;;
420
421 "-c")
422 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
423 fail "-c $2"
424 return
425 fi
426 ;;
427
428 "-S")
429 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
430 fail "-S $2"
431 return
432 fi
433 ;;
434
435 "-C")
436 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
437 fail "-C $2"
438 return
439 fi
440 ;;
441
442 *)
443 echo "Unknown test: $1" >&2
444 exit 1
445 esac
446 shift 2
447 done
448
449 # check valgrind's results
450 if [ "$MEMCHECK" -gt 0 ]; then
451 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
452 fail "Server has memory errors"
453 return
454 fi
455 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
456 fail "Client has memory errors"
457 return
458 fi
459 fi
460
461 # if we're here, everything is ok
462 echo "PASS"
463 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
464}
465
466cleanup() {
467 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
468 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
469 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
470 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
471 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
472 exit 1
473}
474
475#
476# MAIN
477#
478
479if cd $( dirname $0 ); then :; else
480 echo "cd $( dirname $0 ) failed" >&2
481 exit 1
482fi
483
484get_options "$@"
485
486# sanity checks, avoid an avalanche of errors
487if [ ! -x "$P_SRV" ]; then
488 echo "Command '$P_SRV' is not an executable file"
489 exit 1
490fi
491if [ ! -x "$P_CLI" ]; then
492 echo "Command '$P_CLI' is not an executable file"
493 exit 1
494fi
495if [ ! -x "$P_PXY" ]; then
496 echo "Command '$P_PXY' is not an executable file"
497 exit 1
498fi
499if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
500 echo "Command '$OPENSSL_CMD' not found"
501 exit 1
502fi
503
504# used by watchdog
505MAIN_PID="$$"
506
507# be more patient with valgrind
508if [ "$MEMCHECK" -gt 0 ]; then
509 START_DELAY=3
510 DOG_DELAY=30
511else
512 START_DELAY=1
513 DOG_DELAY=10
514fi
515CLI_DELAY_FACTOR=1
516
517# Pick a "unique" server port in the range 10000-19999, and a proxy port
518PORT_BASE="0000$$"
519PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
520SRV_PORT="1$PORT_BASE"
521PXY_PORT="2$PORT_BASE"
522unset PORT_BASE
523
524# fix commands to use this port, force IPv4 while at it
525# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
526P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
527P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
528P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
529O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
530O_CLI="$O_CLI -connect localhost:+SRV_PORT"
531G_SRV="$G_SRV -p $SRV_PORT"
532G_CLI="$G_CLI -p +SRV_PORT localhost"
533
534# Also pick a unique name for intermediate files
535SRV_OUT="srv_out.$$"
536CLI_OUT="cli_out.$$"
537PXY_OUT="pxy_out.$$"
538SESSION="session.$$"
539
540SKIP_NEXT="NO"
541
542trap cleanup INT TERM HUP
543
544# Basic test
545
546# Checks that:
547# - things work with all ciphersuites active (used with config-full in all.sh)
548# - the expected (highest security) parameters are selected
549# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
550run_test "Default" \
551 "$P_SRV debug_level=3" \
552 "$P_CLI" \
553 0 \
554 -s "Protocol is TLSv1.2" \
555 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
556 -s "client hello v3, signature_algorithm ext: 6" \
557 -s "ECDHE curve: secp521r1" \
558 -S "error" \
559 -C "error"
560
561run_test "Default, DTLS" \
562 "$P_SRV dtls=1" \
563 "$P_CLI dtls=1" \
564 0 \
565 -s "Protocol is DTLSv1.2" \
566 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
567
568# Tests for rc4 option
569
570run_test "RC4: server disabled, client enabled" \
571 "$P_SRV" \
572 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
573 1 \
574 -s "SSL - The server has no ciphersuites in common"
575
576run_test "RC4: server half, client enabled" \
577 "$P_SRV arc4=1" \
578 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
579 1 \
580 -s "SSL - The server has no ciphersuites in common"
581
582run_test "RC4: server enabled, client disabled" \
583 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
584 "$P_CLI" \
585 1 \
586 -s "SSL - The server has no ciphersuites in common"
587
588run_test "RC4: both enabled" \
589 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
590 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
591 0 \
592 -S "SSL - None of the common ciphersuites is usable" \
593 -S "SSL - The server has no ciphersuites in common"
594
595# Tests for Truncated HMAC extension
596
597run_test "Truncated HMAC: client default, server default" \
598 "$P_SRV debug_level=4" \
599 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
600 0 \
601 -s "dumping 'computed mac' (20 bytes)" \
602 -S "dumping 'computed mac' (10 bytes)"
603
604run_test "Truncated HMAC: client disabled, server default" \
605 "$P_SRV debug_level=4" \
606 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
607 trunc_hmac=0" \
608 0 \
609 -s "dumping 'computed mac' (20 bytes)" \
610 -S "dumping 'computed mac' (10 bytes)"
611
612run_test "Truncated HMAC: client enabled, server default" \
613 "$P_SRV debug_level=4" \
614 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
615 trunc_hmac=1" \
616 0 \
617 -s "dumping 'computed mac' (20 bytes)" \
618 -S "dumping 'computed mac' (10 bytes)"
619
620run_test "Truncated HMAC: client enabled, server disabled" \
621 "$P_SRV debug_level=4 trunc_hmac=0" \
622 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
623 trunc_hmac=1" \
624 0 \
625 -s "dumping 'computed mac' (20 bytes)" \
626 -S "dumping 'computed mac' (10 bytes)"
627
628run_test "Truncated HMAC: client enabled, server enabled" \
629 "$P_SRV debug_level=4 trunc_hmac=1" \
630 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
631 trunc_hmac=1" \
632 0 \
633 -S "dumping 'computed mac' (20 bytes)" \
634 -s "dumping 'computed mac' (10 bytes)"
635
636# Tests for Encrypt-then-MAC extension
637
638run_test "Encrypt then MAC: default" \
639 "$P_SRV debug_level=3 \
640 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
641 "$P_CLI debug_level=3" \
642 0 \
643 -c "client hello, adding encrypt_then_mac extension" \
644 -s "found encrypt then mac extension" \
645 -s "server hello, adding encrypt then mac extension" \
646 -c "found encrypt_then_mac extension" \
647 -c "using encrypt then mac" \
648 -s "using encrypt then mac"
649
650run_test "Encrypt then MAC: client enabled, server disabled" \
651 "$P_SRV debug_level=3 etm=0 \
652 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
653 "$P_CLI debug_level=3 etm=1" \
654 0 \
655 -c "client hello, adding encrypt_then_mac extension" \
656 -s "found encrypt then mac extension" \
657 -S "server hello, adding encrypt then mac extension" \
658 -C "found encrypt_then_mac extension" \
659 -C "using encrypt then mac" \
660 -S "using encrypt then mac"
661
662run_test "Encrypt then MAC: client enabled, aead cipher" \
663 "$P_SRV debug_level=3 etm=1 \
664 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
665 "$P_CLI debug_level=3 etm=1" \
666 0 \
667 -c "client hello, adding encrypt_then_mac extension" \
668 -s "found encrypt then mac extension" \
669 -S "server hello, adding encrypt then mac extension" \
670 -C "found encrypt_then_mac extension" \
671 -C "using encrypt then mac" \
672 -S "using encrypt then mac"
673
674run_test "Encrypt then MAC: client enabled, stream cipher" \
675 "$P_SRV debug_level=3 etm=1 \
676 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
677 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
678 0 \
679 -c "client hello, adding encrypt_then_mac extension" \
680 -s "found encrypt then mac extension" \
681 -S "server hello, adding encrypt then mac extension" \
682 -C "found encrypt_then_mac extension" \
683 -C "using encrypt then mac" \
684 -S "using encrypt then mac"
685
686run_test "Encrypt then MAC: client disabled, server enabled" \
687 "$P_SRV debug_level=3 etm=1 \
688 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
689 "$P_CLI debug_level=3 etm=0" \
690 0 \
691 -C "client hello, adding encrypt_then_mac extension" \
692 -S "found encrypt then mac extension" \
693 -S "server hello, adding encrypt then mac extension" \
694 -C "found encrypt_then_mac extension" \
695 -C "using encrypt then mac" \
696 -S "using encrypt then mac"
697
698run_test "Encrypt then MAC: client SSLv3, server enabled" \
699 "$P_SRV debug_level=3 min_version=ssl3 \
700 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
701 "$P_CLI debug_level=3 force_version=ssl3" \
702 0 \
703 -C "client hello, adding encrypt_then_mac extension" \
704 -S "found encrypt then mac extension" \
705 -S "server hello, adding encrypt then mac extension" \
706 -C "found encrypt_then_mac extension" \
707 -C "using encrypt then mac" \
708 -S "using encrypt then mac"
709
710run_test "Encrypt then MAC: client enabled, server SSLv3" \
711 "$P_SRV debug_level=3 force_version=ssl3 \
712 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
713 "$P_CLI debug_level=3 min_version=ssl3" \
714 0 \
715 -c "client hello, adding encrypt_then_mac extension" \
716 -s "found encrypt then mac extension" \
717 -S "server hello, adding encrypt then mac extension" \
718 -C "found encrypt_then_mac extension" \
719 -C "using encrypt then mac" \
720 -S "using encrypt then mac"
721
722# Tests for Extended Master Secret extension
723
724run_test "Extended Master Secret: default" \
725 "$P_SRV debug_level=3" \
726 "$P_CLI debug_level=3" \
727 0 \
728 -c "client hello, adding extended_master_secret extension" \
729 -s "found extended master secret extension" \
730 -s "server hello, adding extended master secret extension" \
731 -c "found extended_master_secret extension" \
732 -c "using extended master secret" \
733 -s "using extended master secret"
734
735run_test "Extended Master Secret: client enabled, server disabled" \
736 "$P_SRV debug_level=3 extended_ms=0" \
737 "$P_CLI debug_level=3 extended_ms=1" \
738 0 \
739 -c "client hello, adding extended_master_secret extension" \
740 -s "found extended master secret extension" \
741 -S "server hello, adding extended master secret extension" \
742 -C "found extended_master_secret extension" \
743 -C "using extended master secret" \
744 -S "using extended master secret"
745
746run_test "Extended Master Secret: client disabled, server enabled" \
747 "$P_SRV debug_level=3 extended_ms=1" \
748 "$P_CLI debug_level=3 extended_ms=0" \
749 0 \
750 -C "client hello, adding extended_master_secret extension" \
751 -S "found extended master secret extension" \
752 -S "server hello, adding extended master secret extension" \
753 -C "found extended_master_secret extension" \
754 -C "using extended master secret" \
755 -S "using extended master secret"
756
757run_test "Extended Master Secret: client SSLv3, server enabled" \
758 "$P_SRV debug_level=3 min_version=ssl3" \
759 "$P_CLI debug_level=3 force_version=ssl3" \
760 0 \
761 -C "client hello, adding extended_master_secret extension" \
762 -S "found extended master secret extension" \
763 -S "server hello, adding extended master secret extension" \
764 -C "found extended_master_secret extension" \
765 -C "using extended master secret" \
766 -S "using extended master secret"
767
768run_test "Extended Master Secret: client enabled, server SSLv3" \
769 "$P_SRV debug_level=3 force_version=ssl3" \
770 "$P_CLI debug_level=3 min_version=ssl3" \
771 0 \
772 -c "client hello, adding extended_master_secret extension" \
773 -s "found extended master secret extension" \
774 -S "server hello, adding extended master secret extension" \
775 -C "found extended_master_secret extension" \
776 -C "using extended master secret" \
777 -S "using extended master secret"
778
779# Tests for FALLBACK_SCSV
780
781run_test "Fallback SCSV: default" \
782 "$P_SRV debug_level=2" \
783 "$P_CLI debug_level=3 force_version=tls1_1" \
784 0 \
785 -C "adding FALLBACK_SCSV" \
786 -S "received FALLBACK_SCSV" \
787 -S "inapropriate fallback" \
788 -C "is a fatal alert message (msg 86)"
789
790run_test "Fallback SCSV: explicitly disabled" \
791 "$P_SRV debug_level=2" \
792 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
793 0 \
794 -C "adding FALLBACK_SCSV" \
795 -S "received FALLBACK_SCSV" \
796 -S "inapropriate fallback" \
797 -C "is a fatal alert message (msg 86)"
798
799run_test "Fallback SCSV: enabled" \
800 "$P_SRV debug_level=2" \
801 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
802 1 \
803 -c "adding FALLBACK_SCSV" \
804 -s "received FALLBACK_SCSV" \
805 -s "inapropriate fallback" \
806 -c "is a fatal alert message (msg 86)"
807
808run_test "Fallback SCSV: enabled, max version" \
809 "$P_SRV debug_level=2" \
810 "$P_CLI debug_level=3 fallback=1" \
811 0 \
812 -c "adding FALLBACK_SCSV" \
813 -s "received FALLBACK_SCSV" \
814 -S "inapropriate fallback" \
815 -C "is a fatal alert message (msg 86)"
816
817requires_openssl_with_fallback_scsv
818run_test "Fallback SCSV: default, openssl server" \
819 "$O_SRV" \
820 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
821 0 \
822 -C "adding FALLBACK_SCSV" \
823 -C "is a fatal alert message (msg 86)"
824
825requires_openssl_with_fallback_scsv
826run_test "Fallback SCSV: enabled, openssl server" \
827 "$O_SRV" \
828 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
829 1 \
830 -c "adding FALLBACK_SCSV" \
831 -c "is a fatal alert message (msg 86)"
832
833requires_openssl_with_fallback_scsv
834run_test "Fallback SCSV: disabled, openssl client" \
835 "$P_SRV debug_level=2" \
836 "$O_CLI -tls1_1" \
837 0 \
838 -S "received FALLBACK_SCSV" \
839 -S "inapropriate fallback"
840
841requires_openssl_with_fallback_scsv
842run_test "Fallback SCSV: enabled, openssl client" \
843 "$P_SRV debug_level=2" \
844 "$O_CLI -tls1_1 -fallback_scsv" \
845 1 \
846 -s "received FALLBACK_SCSV" \
847 -s "inapropriate fallback"
848
849requires_openssl_with_fallback_scsv
850run_test "Fallback SCSV: enabled, max version, openssl client" \
851 "$P_SRV debug_level=2" \
852 "$O_CLI -fallback_scsv" \
853 0 \
854 -s "received FALLBACK_SCSV" \
855 -S "inapropriate fallback"
856
857# Tests for CBC 1/n-1 record splitting
858
859run_test "CBC Record splitting: TLS 1.2, no splitting" \
860 "$P_SRV" \
861 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
862 request_size=123 force_version=tls1_2" \
863 0 \
864 -s "Read from client: 123 bytes read" \
865 -S "Read from client: 1 bytes read" \
866 -S "122 bytes read"
867
868run_test "CBC Record splitting: TLS 1.1, no splitting" \
869 "$P_SRV" \
870 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
871 request_size=123 force_version=tls1_1" \
872 0 \
873 -s "Read from client: 123 bytes read" \
874 -S "Read from client: 1 bytes read" \
875 -S "122 bytes read"
876
877run_test "CBC Record splitting: TLS 1.0, splitting" \
878 "$P_SRV" \
879 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
880 request_size=123 force_version=tls1" \
881 0 \
882 -S "Read from client: 123 bytes read" \
883 -s "Read from client: 1 bytes read" \
884 -s "122 bytes read"
885
886run_test "CBC Record splitting: SSLv3, splitting" \
887 "$P_SRV min_version=ssl3" \
888 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
889 request_size=123 force_version=ssl3" \
890 0 \
891 -S "Read from client: 123 bytes read" \
892 -s "Read from client: 1 bytes read" \
893 -s "122 bytes read"
894
895run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
896 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
897 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
898 request_size=123 force_version=tls1" \
899 0 \
900 -s "Read from client: 123 bytes read" \
901 -S "Read from client: 1 bytes read" \
902 -S "122 bytes read"
903
904run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
905 "$P_SRV" \
906 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
907 request_size=123 force_version=tls1 recsplit=0" \
908 0 \
909 -s "Read from client: 123 bytes read" \
910 -S "Read from client: 1 bytes read" \
911 -S "122 bytes read"
912
913run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
914 "$P_SRV nbio=2" \
915 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
916 request_size=123 force_version=tls1" \
917 0 \
918 -S "Read from client: 123 bytes read" \
919 -s "Read from client: 1 bytes read" \
920 -s "122 bytes read"
921
922# Tests for Session Tickets
923
924run_test "Session resume using tickets: basic" \
925 "$P_SRV debug_level=3 tickets=1" \
926 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
927 0 \
928 -c "client hello, adding session ticket extension" \
929 -s "found session ticket extension" \
930 -s "server hello, adding session ticket extension" \
931 -c "found session_ticket extension" \
932 -c "parse new session ticket" \
933 -S "session successfully restored from cache" \
934 -s "session successfully restored from ticket" \
935 -s "a session has been resumed" \
936 -c "a session has been resumed"
937
938run_test "Session resume using tickets: cache disabled" \
939 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
940 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
941 0 \
942 -c "client hello, adding session ticket extension" \
943 -s "found session ticket extension" \
944 -s "server hello, adding session ticket extension" \
945 -c "found session_ticket extension" \
946 -c "parse new session ticket" \
947 -S "session successfully restored from cache" \
948 -s "session successfully restored from ticket" \
949 -s "a session has been resumed" \
950 -c "a session has been resumed"
951
952run_test "Session resume using tickets: timeout" \
953 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
954 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
955 0 \
956 -c "client hello, adding session ticket extension" \
957 -s "found session ticket extension" \
958 -s "server hello, adding session ticket extension" \
959 -c "found session_ticket extension" \
960 -c "parse new session ticket" \
961 -S "session successfully restored from cache" \
962 -S "session successfully restored from ticket" \
963 -S "a session has been resumed" \
964 -C "a session has been resumed"
965
966run_test "Session resume using tickets: openssl server" \
967 "$O_SRV" \
968 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
969 0 \
970 -c "client hello, adding session ticket extension" \
971 -c "found session_ticket extension" \
972 -c "parse new session ticket" \
973 -c "a session has been resumed"
974
975run_test "Session resume using tickets: openssl client" \
976 "$P_SRV debug_level=3 tickets=1" \
977 "( $O_CLI -sess_out $SESSION; \
978 $O_CLI -sess_in $SESSION; \
979 rm -f $SESSION )" \
980 0 \
981 -s "found session ticket extension" \
982 -s "server hello, adding session ticket extension" \
983 -S "session successfully restored from cache" \
984 -s "session successfully restored from ticket" \
985 -s "a session has been resumed"
986
987# Tests for Session Resume based on session-ID and cache
988
989run_test "Session resume using cache: tickets enabled on client" \
990 "$P_SRV debug_level=3 tickets=0" \
991 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
992 0 \
993 -c "client hello, adding session ticket extension" \
994 -s "found session ticket extension" \
995 -S "server hello, adding session ticket extension" \
996 -C "found session_ticket extension" \
997 -C "parse new session ticket" \
998 -s "session successfully restored from cache" \
999 -S "session successfully restored from ticket" \
1000 -s "a session has been resumed" \
1001 -c "a session has been resumed"
1002
1003run_test "Session resume using cache: tickets enabled on server" \
1004 "$P_SRV debug_level=3 tickets=1" \
1005 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
1006 0 \
1007 -C "client hello, adding session ticket extension" \
1008 -S "found session ticket extension" \
1009 -S "server hello, adding session ticket extension" \
1010 -C "found session_ticket extension" \
1011 -C "parse new session ticket" \
1012 -s "session successfully restored from cache" \
1013 -S "session successfully restored from ticket" \
1014 -s "a session has been resumed" \
1015 -c "a session has been resumed"
1016
1017run_test "Session resume using cache: cache_max=0" \
1018 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1019 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
1020 0 \
1021 -S "session successfully restored from cache" \
1022 -S "session successfully restored from ticket" \
1023 -S "a session has been resumed" \
1024 -C "a session has been resumed"
1025
1026run_test "Session resume using cache: cache_max=1" \
1027 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1028 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
1029 0 \
1030 -s "session successfully restored from cache" \
1031 -S "session successfully restored from ticket" \
1032 -s "a session has been resumed" \
1033 -c "a session has been resumed"
1034
1035run_test "Session resume using cache: timeout > delay" \
1036 "$P_SRV debug_level=3 tickets=0" \
1037 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
1038 0 \
1039 -s "session successfully restored from cache" \
1040 -S "session successfully restored from ticket" \
1041 -s "a session has been resumed" \
1042 -c "a session has been resumed"
1043
1044run_test "Session resume using cache: timeout < delay" \
1045 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1046 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
1047 0 \
1048 -S "session successfully restored from cache" \
1049 -S "session successfully restored from ticket" \
1050 -S "a session has been resumed" \
1051 -C "a session has been resumed"
1052
1053run_test "Session resume using cache: no timeout" \
1054 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1055 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
1056 0 \
1057 -s "session successfully restored from cache" \
1058 -S "session successfully restored from ticket" \
1059 -s "a session has been resumed" \
1060 -c "a session has been resumed"
1061
1062run_test "Session resume using cache: openssl client" \
1063 "$P_SRV debug_level=3 tickets=0" \
1064 "( $O_CLI -sess_out $SESSION; \
1065 $O_CLI -sess_in $SESSION; \
1066 rm -f $SESSION )" \
1067 0 \
1068 -s "found session ticket extension" \
1069 -S "server hello, adding session ticket extension" \
1070 -s "session successfully restored from cache" \
1071 -S "session successfully restored from ticket" \
1072 -s "a session has been resumed"
1073
1074run_test "Session resume using cache: openssl server" \
1075 "$O_SRV" \
1076 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
1077 0 \
1078 -C "found session_ticket extension" \
1079 -C "parse new session ticket" \
1080 -c "a session has been resumed"
1081
1082# Tests for Max Fragment Length extension
1083
1084run_test "Max fragment length: not used, reference" \
1085 "$P_SRV debug_level=3" \
1086 "$P_CLI debug_level=3" \
1087 0 \
1088 -c "Maximum fragment length is 16384" \
1089 -s "Maximum fragment length is 16384" \
1090 -C "client hello, adding max_fragment_length extension" \
1091 -S "found max fragment length extension" \
1092 -S "server hello, max_fragment_length extension" \
1093 -C "found max_fragment_length extension"
1094
1095run_test "Max fragment length: used by client" \
1096 "$P_SRV debug_level=3" \
1097 "$P_CLI debug_level=3 max_frag_len=4096" \
1098 0 \
1099 -c "Maximum fragment length is 4096" \
1100 -s "Maximum fragment length is 4096" \
1101 -c "client hello, adding max_fragment_length extension" \
1102 -s "found max fragment length extension" \
1103 -s "server hello, max_fragment_length extension" \
1104 -c "found max_fragment_length extension"
1105
1106run_test "Max fragment length: used by server" \
1107 "$P_SRV debug_level=3 max_frag_len=4096" \
1108 "$P_CLI debug_level=3" \
1109 0 \
1110 -c "Maximum fragment length is 16384" \
1111 -s "Maximum fragment length is 4096" \
1112 -C "client hello, adding max_fragment_length extension" \
1113 -S "found max fragment length extension" \
1114 -S "server hello, max_fragment_length extension" \
1115 -C "found max_fragment_length extension"
1116
1117requires_gnutls
1118run_test "Max fragment length: gnutls server" \
1119 "$G_SRV" \
1120 "$P_CLI debug_level=3 max_frag_len=4096" \
1121 0 \
1122 -c "Maximum fragment length is 4096" \
1123 -c "client hello, adding max_fragment_length extension" \
1124 -c "found max_fragment_length extension"
1125
1126run_test "Max fragment length: client, message just fits" \
1127 "$P_SRV debug_level=3" \
1128 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1129 0 \
1130 -c "Maximum fragment length is 2048" \
1131 -s "Maximum fragment length is 2048" \
1132 -c "client hello, adding max_fragment_length extension" \
1133 -s "found max fragment length extension" \
1134 -s "server hello, max_fragment_length extension" \
1135 -c "found max_fragment_length extension" \
1136 -c "2048 bytes written in 1 fragments" \
1137 -s "2048 bytes read"
1138
1139run_test "Max fragment length: client, larger message" \
1140 "$P_SRV debug_level=3" \
1141 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1142 0 \
1143 -c "Maximum fragment length is 2048" \
1144 -s "Maximum fragment length is 2048" \
1145 -c "client hello, adding max_fragment_length extension" \
1146 -s "found max fragment length extension" \
1147 -s "server hello, max_fragment_length extension" \
1148 -c "found max_fragment_length extension" \
1149 -c "2345 bytes written in 2 fragments" \
1150 -s "2048 bytes read" \
1151 -s "297 bytes read"
1152
1153run_test "Max fragment length: DTLS client, larger message" \
1154 "$P_SRV debug_level=3 dtls=1" \
1155 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1156 1 \
1157 -c "Maximum fragment length is 2048" \
1158 -s "Maximum fragment length is 2048" \
1159 -c "client hello, adding max_fragment_length extension" \
1160 -s "found max fragment length extension" \
1161 -s "server hello, max_fragment_length extension" \
1162 -c "found max_fragment_length extension" \
1163 -c "fragment larger than.*maximum"
1164
1165# Tests for renegotiation
1166
1167run_test "Renegotiation: none, for reference" \
1168 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
1169 "$P_CLI debug_level=3 exchanges=2" \
1170 0 \
1171 -C "client hello, adding renegotiation extension" \
1172 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1173 -S "found renegotiation extension" \
1174 -s "server hello, secure renegotiation extension" \
1175 -c "found renegotiation extension" \
1176 -C "=> renegotiate" \
1177 -S "=> renegotiate" \
1178 -S "write hello request"
1179
1180run_test "Renegotiation: client-initiated" \
1181 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1182 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1183 0 \
1184 -c "client hello, adding renegotiation extension" \
1185 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1186 -s "found renegotiation extension" \
1187 -s "server hello, secure renegotiation extension" \
1188 -c "found renegotiation extension" \
1189 -c "=> renegotiate" \
1190 -s "=> renegotiate" \
1191 -S "write hello request"
1192
1193run_test "Renegotiation: server-initiated" \
1194 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1195 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1196 0 \
1197 -c "client hello, adding renegotiation extension" \
1198 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1199 -s "found renegotiation extension" \
1200 -s "server hello, secure renegotiation extension" \
1201 -c "found renegotiation extension" \
1202 -c "=> renegotiate" \
1203 -s "=> renegotiate" \
1204 -s "write hello request"
1205
1206run_test "Renegotiation: double" \
1207 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1208 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1209 0 \
1210 -c "client hello, adding renegotiation extension" \
1211 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1212 -s "found renegotiation extension" \
1213 -s "server hello, secure renegotiation extension" \
1214 -c "found renegotiation extension" \
1215 -c "=> renegotiate" \
1216 -s "=> renegotiate" \
1217 -s "write hello request"
1218
1219run_test "Renegotiation: client-initiated, server-rejected" \
1220 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
1221 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1222 1 \
1223 -c "client hello, adding renegotiation extension" \
1224 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1225 -S "found renegotiation extension" \
1226 -s "server hello, secure renegotiation extension" \
1227 -c "found renegotiation extension" \
1228 -c "=> renegotiate" \
1229 -S "=> renegotiate" \
1230 -S "write hello request" \
1231 -c "SSL - Unexpected message at ServerHello in renegotiation" \
1232 -c "failed"
1233
1234run_test "Renegotiation: server-initiated, client-rejected, default" \
1235 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
1236 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
1237 0 \
1238 -C "client hello, adding renegotiation extension" \
1239 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1240 -S "found renegotiation extension" \
1241 -s "server hello, secure renegotiation extension" \
1242 -c "found renegotiation extension" \
1243 -C "=> renegotiate" \
1244 -S "=> renegotiate" \
1245 -s "write hello request" \
1246 -S "SSL - An unexpected message was received from our peer" \
1247 -S "failed"
1248
1249run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
1250 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
1251 renego_delay=-1 auth_mode=optional" \
1252 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
1253 0 \
1254 -C "client hello, adding renegotiation extension" \
1255 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1256 -S "found renegotiation extension" \
1257 -s "server hello, secure renegotiation extension" \
1258 -c "found renegotiation extension" \
1259 -C "=> renegotiate" \
1260 -S "=> renegotiate" \
1261 -s "write hello request" \
1262 -S "SSL - An unexpected message was received from our peer" \
1263 -S "failed"
1264
1265# delay 2 for 1 alert record + 1 application data record
1266run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
1267 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
1268 renego_delay=2 auth_mode=optional" \
1269 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
1270 0 \
1271 -C "client hello, adding renegotiation extension" \
1272 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1273 -S "found renegotiation extension" \
1274 -s "server hello, secure renegotiation extension" \
1275 -c "found renegotiation extension" \
1276 -C "=> renegotiate" \
1277 -S "=> renegotiate" \
1278 -s "write hello request" \
1279 -S "SSL - An unexpected message was received from our peer" \
1280 -S "failed"
1281
1282run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
1283 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
1284 renego_delay=0 auth_mode=optional" \
1285 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
1286 0 \
1287 -C "client hello, adding renegotiation extension" \
1288 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1289 -S "found renegotiation extension" \
1290 -s "server hello, secure renegotiation extension" \
1291 -c "found renegotiation extension" \
1292 -C "=> renegotiate" \
1293 -S "=> renegotiate" \
1294 -s "write hello request" \
1295 -s "SSL - An unexpected message was received from our peer"
1296
1297run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
1298 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
1299 renego_delay=0 auth_mode=optional" \
1300 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1301 0 \
1302 -c "client hello, adding renegotiation extension" \
1303 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1304 -s "found renegotiation extension" \
1305 -s "server hello, secure renegotiation extension" \
1306 -c "found renegotiation extension" \
1307 -c "=> renegotiate" \
1308 -s "=> renegotiate" \
1309 -s "write hello request" \
1310 -S "SSL - An unexpected message was received from our peer" \
1311 -S "failed"
1312
1313run_test "Renegotiation: periodic, just below period" \
1314 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
1315 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1316 0 \
1317 -C "client hello, adding renegotiation extension" \
1318 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1319 -S "found renegotiation extension" \
1320 -s "server hello, secure renegotiation extension" \
1321 -c "found renegotiation extension" \
1322 -S "record counter limit reached: renegotiate" \
1323 -C "=> renegotiate" \
1324 -S "=> renegotiate" \
1325 -S "write hello request" \
1326 -S "SSL - An unexpected message was received from our peer" \
1327 -S "failed"
1328
1329# one extra exchange to be able to complete renego
1330run_test "Renegotiation: periodic, just above period" \
1331 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
1332 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1333 0 \
1334 -c "client hello, adding renegotiation extension" \
1335 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1336 -s "found renegotiation extension" \
1337 -s "server hello, secure renegotiation extension" \
1338 -c "found renegotiation extension" \
1339 -s "record counter limit reached: renegotiate" \
1340 -c "=> renegotiate" \
1341 -s "=> renegotiate" \
1342 -s "write hello request" \
1343 -S "SSL - An unexpected message was received from our peer" \
1344 -S "failed"
1345
1346run_test "Renegotiation: periodic, two times period" \
1347 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
1348 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
1349 0 \
1350 -c "client hello, adding renegotiation extension" \
1351 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1352 -s "found renegotiation extension" \
1353 -s "server hello, secure renegotiation extension" \
1354 -c "found renegotiation extension" \
1355 -s "record counter limit reached: renegotiate" \
1356 -c "=> renegotiate" \
1357 -s "=> renegotiate" \
1358 -s "write hello request" \
1359 -S "SSL - An unexpected message was received from our peer" \
1360 -S "failed"
1361
1362run_test "Renegotiation: periodic, above period, disabled" \
1363 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
1364 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1365 0 \
1366 -C "client hello, adding renegotiation extension" \
1367 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1368 -S "found renegotiation extension" \
1369 -s "server hello, secure renegotiation extension" \
1370 -c "found renegotiation extension" \
1371 -S "record counter limit reached: renegotiate" \
1372 -C "=> renegotiate" \
1373 -S "=> renegotiate" \
1374 -S "write hello request" \
1375 -S "SSL - An unexpected message was received from our peer" \
1376 -S "failed"
1377
1378run_test "Renegotiation: nbio, client-initiated" \
1379 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
1380 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1381 0 \
1382 -c "client hello, adding renegotiation extension" \
1383 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1384 -s "found renegotiation extension" \
1385 -s "server hello, secure renegotiation extension" \
1386 -c "found renegotiation extension" \
1387 -c "=> renegotiate" \
1388 -s "=> renegotiate" \
1389 -S "write hello request"
1390
1391run_test "Renegotiation: nbio, server-initiated" \
1392 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
1393 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1394 0 \
1395 -c "client hello, adding renegotiation extension" \
1396 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1397 -s "found renegotiation extension" \
1398 -s "server hello, secure renegotiation extension" \
1399 -c "found renegotiation extension" \
1400 -c "=> renegotiate" \
1401 -s "=> renegotiate" \
1402 -s "write hello request"
1403
1404run_test "Renegotiation: openssl server, client-initiated" \
1405 "$O_SRV -www" \
1406 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1407 0 \
1408 -c "client hello, adding renegotiation extension" \
1409 -c "found renegotiation extension" \
1410 -c "=> renegotiate" \
1411 -C "ssl_hanshake() returned" \
1412 -C "error" \
1413 -c "HTTP/1.0 200 [Oo][Kk]"
1414
1415requires_gnutls
1416run_test "Renegotiation: gnutls server strict, client-initiated" \
1417 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1418 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1419 0 \
1420 -c "client hello, adding renegotiation extension" \
1421 -c "found renegotiation extension" \
1422 -c "=> renegotiate" \
1423 -C "ssl_hanshake() returned" \
1424 -C "error" \
1425 -c "HTTP/1.0 200 [Oo][Kk]"
1426
1427requires_gnutls
1428run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1429 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1430 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1431 1 \
1432 -c "client hello, adding renegotiation extension" \
1433 -C "found renegotiation extension" \
1434 -c "=> renegotiate" \
1435 -c "mbedtls_ssl_handshake() returned" \
1436 -c "error" \
1437 -C "HTTP/1.0 200 [Oo][Kk]"
1438
1439requires_gnutls
1440run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1441 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1442 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1443 allow_legacy=0" \
1444 1 \
1445 -c "client hello, adding renegotiation extension" \
1446 -C "found renegotiation extension" \
1447 -c "=> renegotiate" \
1448 -c "mbedtls_ssl_handshake() returned" \
1449 -c "error" \
1450 -C "HTTP/1.0 200 [Oo][Kk]"
1451
1452requires_gnutls
1453run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1454 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1455 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1456 allow_legacy=1" \
1457 0 \
1458 -c "client hello, adding renegotiation extension" \
1459 -C "found renegotiation extension" \
1460 -c "=> renegotiate" \
1461 -C "ssl_hanshake() returned" \
1462 -C "error" \
1463 -c "HTTP/1.0 200 [Oo][Kk]"
1464
1465run_test "Renegotiation: DTLS, client-initiated" \
1466 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1467 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1468 0 \
1469 -c "client hello, adding renegotiation extension" \
1470 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1471 -s "found renegotiation extension" \
1472 -s "server hello, secure renegotiation extension" \
1473 -c "found renegotiation extension" \
1474 -c "=> renegotiate" \
1475 -s "=> renegotiate" \
1476 -S "write hello request"
1477
1478run_test "Renegotiation: DTLS, server-initiated" \
1479 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1480 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1481 read_timeout=1000 max_resend=2" \
1482 0 \
1483 -c "client hello, adding renegotiation extension" \
1484 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1485 -s "found renegotiation extension" \
1486 -s "server hello, secure renegotiation extension" \
1487 -c "found renegotiation extension" \
1488 -c "=> renegotiate" \
1489 -s "=> renegotiate" \
1490 -s "write hello request"
1491
1492requires_gnutls
1493run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1494 "$G_SRV -u --mtu 4096" \
1495 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1496 0 \
1497 -c "client hello, adding renegotiation extension" \
1498 -c "found renegotiation extension" \
1499 -c "=> renegotiate" \
1500 -C "mbedtls_ssl_handshake returned" \
1501 -C "error" \
1502 -s "Extra-header:"
1503
1504# Test for the "secure renegotation" extension only (no actual renegotiation)
1505
1506requires_gnutls
1507run_test "Renego ext: gnutls server strict, client default" \
1508 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1509 "$P_CLI debug_level=3" \
1510 0 \
1511 -c "found renegotiation extension" \
1512 -C "error" \
1513 -c "HTTP/1.0 200 [Oo][Kk]"
1514
1515requires_gnutls
1516run_test "Renego ext: gnutls server unsafe, client default" \
1517 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1518 "$P_CLI debug_level=3" \
1519 0 \
1520 -C "found renegotiation extension" \
1521 -C "error" \
1522 -c "HTTP/1.0 200 [Oo][Kk]"
1523
1524requires_gnutls
1525run_test "Renego ext: gnutls server unsafe, client break legacy" \
1526 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1527 "$P_CLI debug_level=3 allow_legacy=-1" \
1528 1 \
1529 -C "found renegotiation extension" \
1530 -c "error" \
1531 -C "HTTP/1.0 200 [Oo][Kk]"
1532
1533requires_gnutls
1534run_test "Renego ext: gnutls client strict, server default" \
1535 "$P_SRV debug_level=3" \
1536 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1537 0 \
1538 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1539 -s "server hello, secure renegotiation extension"
1540
1541requires_gnutls
1542run_test "Renego ext: gnutls client unsafe, server default" \
1543 "$P_SRV debug_level=3" \
1544 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1545 0 \
1546 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1547 -S "server hello, secure renegotiation extension"
1548
1549requires_gnutls
1550run_test "Renego ext: gnutls client unsafe, server break legacy" \
1551 "$P_SRV debug_level=3 allow_legacy=-1" \
1552 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1553 1 \
1554 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1555 -S "server hello, secure renegotiation extension"
1556
1557# Tests for auth_mode
1558
1559run_test "Authentication: server badcert, client required" \
1560 "$P_SRV crt_file=data_files/server5-badsign.crt \
1561 key_file=data_files/server5.key" \
1562 "$P_CLI debug_level=1 auth_mode=required" \
1563 1 \
1564 -c "x509_verify_cert() returned" \
1565 -c "! The certificate is not correctly signed by the trusted CA" \
1566 -c "! mbedtls_ssl_handshake returned" \
1567 -c "X509 - Certificate verification failed"
1568
1569run_test "Authentication: server badcert, client optional" \
1570 "$P_SRV crt_file=data_files/server5-badsign.crt \
1571 key_file=data_files/server5.key" \
1572 "$P_CLI debug_level=1 auth_mode=optional" \
1573 0 \
1574 -c "x509_verify_cert() returned" \
1575 -c "! The certificate is not correctly signed by the trusted CA" \
1576 -C "! mbedtls_ssl_handshake returned" \
1577 -C "X509 - Certificate verification failed"
1578
1579run_test "Authentication: server badcert, client none" \
1580 "$P_SRV crt_file=data_files/server5-badsign.crt \
1581 key_file=data_files/server5.key" \
1582 "$P_CLI debug_level=1 auth_mode=none" \
1583 0 \
1584 -C "x509_verify_cert() returned" \
1585 -C "! The certificate is not correctly signed by the trusted CA" \
1586 -C "! mbedtls_ssl_handshake returned" \
1587 -C "X509 - Certificate verification failed"
1588
1589run_test "Authentication: client badcert, server required" \
1590 "$P_SRV debug_level=3 auth_mode=required" \
1591 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
1592 key_file=data_files/server5.key" \
1593 1 \
1594 -S "skip write certificate request" \
1595 -C "skip parse certificate request" \
1596 -c "got a certificate request" \
1597 -C "skip write certificate" \
1598 -C "skip write certificate verify" \
1599 -S "skip parse certificate verify" \
1600 -s "x509_verify_cert() returned" \
1601 -s "! The certificate is not correctly signed by the trusted CA" \
1602 -s "! mbedtls_ssl_handshake returned" \
1603 -c "! mbedtls_ssl_handshake returned" \
1604 -s "X509 - Certificate verification failed"
1605
1606run_test "Authentication: client badcert, server optional" \
1607 "$P_SRV debug_level=3 auth_mode=optional" \
1608 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
1609 key_file=data_files/server5.key" \
1610 0 \
1611 -S "skip write certificate request" \
1612 -C "skip parse certificate request" \
1613 -c "got a certificate request" \
1614 -C "skip write certificate" \
1615 -C "skip write certificate verify" \
1616 -S "skip parse certificate verify" \
1617 -s "x509_verify_cert() returned" \
1618 -s "! The certificate is not correctly signed by the trusted CA" \
1619 -S "! mbedtls_ssl_handshake returned" \
1620 -C "! mbedtls_ssl_handshake returned" \
1621 -S "X509 - Certificate verification failed"
1622
1623run_test "Authentication: client badcert, server none" \
1624 "$P_SRV debug_level=3 auth_mode=none" \
1625 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
1626 key_file=data_files/server5.key" \
1627 0 \
1628 -s "skip write certificate request" \
1629 -C "skip parse certificate request" \
1630 -c "got no certificate request" \
1631 -c "skip write certificate" \
1632 -c "skip write certificate verify" \
1633 -s "skip parse certificate verify" \
1634 -S "x509_verify_cert() returned" \
1635 -S "! The certificate is not correctly signed by the trusted CA" \
1636 -S "! mbedtls_ssl_handshake returned" \
1637 -C "! mbedtls_ssl_handshake returned" \
1638 -S "X509 - Certificate verification failed"
1639
1640run_test "Authentication: client no cert, server optional" \
1641 "$P_SRV debug_level=3 auth_mode=optional" \
1642 "$P_CLI debug_level=3 crt_file=none key_file=none" \
1643 0 \
1644 -S "skip write certificate request" \
1645 -C "skip parse certificate request" \
1646 -c "got a certificate request" \
1647 -C "skip write certificate$" \
1648 -C "got no certificate to send" \
1649 -S "SSLv3 client has no certificate" \
1650 -c "skip write certificate verify" \
1651 -s "skip parse certificate verify" \
1652 -s "! Certificate was missing" \
1653 -S "! mbedtls_ssl_handshake returned" \
1654 -C "! mbedtls_ssl_handshake returned" \
1655 -S "X509 - Certificate verification failed"
1656
1657run_test "Authentication: openssl client no cert, server optional" \
1658 "$P_SRV debug_level=3 auth_mode=optional" \
1659 "$O_CLI" \
1660 0 \
1661 -S "skip write certificate request" \
1662 -s "skip parse certificate verify" \
1663 -s "! Certificate was missing" \
1664 -S "! mbedtls_ssl_handshake returned" \
1665 -S "X509 - Certificate verification failed"
1666
1667run_test "Authentication: client no cert, openssl server optional" \
1668 "$O_SRV -verify 10" \
1669 "$P_CLI debug_level=3 crt_file=none key_file=none" \
1670 0 \
1671 -C "skip parse certificate request" \
1672 -c "got a certificate request" \
1673 -C "skip write certificate$" \
1674 -c "skip write certificate verify" \
1675 -C "! mbedtls_ssl_handshake returned"
1676
1677run_test "Authentication: client no cert, ssl3" \
1678 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1679 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
1680 0 \
1681 -S "skip write certificate request" \
1682 -C "skip parse certificate request" \
1683 -c "got a certificate request" \
1684 -C "skip write certificate$" \
1685 -c "skip write certificate verify" \
1686 -c "got no certificate to send" \
1687 -s "SSLv3 client has no certificate" \
1688 -s "skip parse certificate verify" \
1689 -s "! Certificate was missing" \
1690 -S "! mbedtls_ssl_handshake returned" \
1691 -C "! mbedtls_ssl_handshake returned" \
1692 -S "X509 - Certificate verification failed"
1693
1694# Tests for certificate selection based on SHA verson
1695
1696run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1697 "$P_SRV crt_file=data_files/server5.crt \
1698 key_file=data_files/server5.key \
1699 crt_file2=data_files/server5-sha1.crt \
1700 key_file2=data_files/server5.key" \
1701 "$P_CLI force_version=tls1_2" \
1702 0 \
1703 -c "signed using.*ECDSA with SHA256" \
1704 -C "signed using.*ECDSA with SHA1"
1705
1706run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1707 "$P_SRV crt_file=data_files/server5.crt \
1708 key_file=data_files/server5.key \
1709 crt_file2=data_files/server5-sha1.crt \
1710 key_file2=data_files/server5.key" \
1711 "$P_CLI force_version=tls1_1" \
1712 0 \
1713 -C "signed using.*ECDSA with SHA256" \
1714 -c "signed using.*ECDSA with SHA1"
1715
1716run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1717 "$P_SRV crt_file=data_files/server5.crt \
1718 key_file=data_files/server5.key \
1719 crt_file2=data_files/server5-sha1.crt \
1720 key_file2=data_files/server5.key" \
1721 "$P_CLI force_version=tls1" \
1722 0 \
1723 -C "signed using.*ECDSA with SHA256" \
1724 -c "signed using.*ECDSA with SHA1"
1725
1726run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1727 "$P_SRV crt_file=data_files/server5.crt \
1728 key_file=data_files/server5.key \
1729 crt_file2=data_files/server6.crt \
1730 key_file2=data_files/server6.key" \
1731 "$P_CLI force_version=tls1_1" \
1732 0 \
1733 -c "serial number.*09" \
1734 -c "signed using.*ECDSA with SHA256" \
1735 -C "signed using.*ECDSA with SHA1"
1736
1737run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1738 "$P_SRV crt_file=data_files/server6.crt \
1739 key_file=data_files/server6.key \
1740 crt_file2=data_files/server5.crt \
1741 key_file2=data_files/server5.key" \
1742 "$P_CLI force_version=tls1_1" \
1743 0 \
1744 -c "serial number.*0A" \
1745 -c "signed using.*ECDSA with SHA256" \
1746 -C "signed using.*ECDSA with SHA1"
1747
1748# tests for SNI
1749
1750run_test "SNI: no SNI callback" \
1751 "$P_SRV debug_level=3 \
1752 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
1753 "$P_CLI server_name=localhost" \
1754 0 \
1755 -S "parse ServerName extension" \
1756 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1757 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1758
1759run_test "SNI: matching cert 1" \
1760 "$P_SRV debug_level=3 \
1761 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1762 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
1763 "$P_CLI server_name=localhost" \
1764 0 \
1765 -s "parse ServerName extension" \
1766 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1767 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1768
1769run_test "SNI: matching cert 2" \
1770 "$P_SRV debug_level=3 \
1771 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1772 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
1773 "$P_CLI server_name=polarssl.example" \
1774 0 \
1775 -s "parse ServerName extension" \
1776 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1777 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
1778
1779run_test "SNI: no matching cert" \
1780 "$P_SRV debug_level=3 \
1781 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1782 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
1783 "$P_CLI server_name=nonesuch.example" \
1784 1 \
1785 -s "parse ServerName extension" \
1786 -s "ssl_sni_wrapper() returned" \
1787 -s "mbedtls_ssl_handshake returned" \
1788 -c "mbedtls_ssl_handshake returned" \
1789 -c "SSL - A fatal alert message was received from our peer"
1790
1791run_test "SNI: client auth no override: optional" \
1792 "$P_SRV debug_level=3 auth_mode=optional \
1793 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1794 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1795 "$P_CLI debug_level=3 server_name=localhost" \
1796 0 \
1797 -S "skip write certificate request" \
1798 -C "skip parse certificate request" \
1799 -c "got a certificate request" \
1800 -C "skip write certificate" \
1801 -C "skip write certificate verify" \
1802 -S "skip parse certificate verify"
1803
1804run_test "SNI: client auth override: none -> optional" \
1805 "$P_SRV debug_level=3 auth_mode=none \
1806 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1807 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1808 "$P_CLI debug_level=3 server_name=localhost" \
1809 0 \
1810 -S "skip write certificate request" \
1811 -C "skip parse certificate request" \
1812 -c "got a certificate request" \
1813 -C "skip write certificate" \
1814 -C "skip write certificate verify" \
1815 -S "skip parse certificate verify"
1816
1817run_test "SNI: client auth override: optional -> none" \
1818 "$P_SRV debug_level=3 auth_mode=optional \
1819 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1820 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1821 "$P_CLI debug_level=3 server_name=localhost" \
1822 0 \
1823 -s "skip write certificate request" \
1824 -C "skip parse certificate request" \
1825 -c "got no certificate request" \
1826 -c "skip write certificate" \
1827 -c "skip write certificate verify" \
1828 -s "skip parse certificate verify"
1829
1830run_test "SNI: CA no override" \
1831 "$P_SRV debug_level=3 auth_mode=optional \
1832 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1833 ca_file=data_files/test-ca.crt \
1834 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1835 "$P_CLI debug_level=3 server_name=localhost \
1836 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1837 1 \
1838 -S "skip write certificate request" \
1839 -C "skip parse certificate request" \
1840 -c "got a certificate request" \
1841 -C "skip write certificate" \
1842 -C "skip write certificate verify" \
1843 -S "skip parse certificate verify" \
1844 -s "x509_verify_cert() returned" \
1845 -s "! The certificate is not correctly signed by the trusted CA" \
1846 -S "The certificate has been revoked (is on a CRL)"
1847
1848run_test "SNI: CA override" \
1849 "$P_SRV debug_level=3 auth_mode=optional \
1850 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1851 ca_file=data_files/test-ca.crt \
1852 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1853 "$P_CLI debug_level=3 server_name=localhost \
1854 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1855 0 \
1856 -S "skip write certificate request" \
1857 -C "skip parse certificate request" \
1858 -c "got a certificate request" \
1859 -C "skip write certificate" \
1860 -C "skip write certificate verify" \
1861 -S "skip parse certificate verify" \
1862 -S "x509_verify_cert() returned" \
1863 -S "! The certificate is not correctly signed by the trusted CA" \
1864 -S "The certificate has been revoked (is on a CRL)"
1865
1866run_test "SNI: CA override with CRL" \
1867 "$P_SRV debug_level=3 auth_mode=optional \
1868 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1869 ca_file=data_files/test-ca.crt \
1870 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1871 "$P_CLI debug_level=3 server_name=localhost \
1872 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1873 1 \
1874 -S "skip write certificate request" \
1875 -C "skip parse certificate request" \
1876 -c "got a certificate request" \
1877 -C "skip write certificate" \
1878 -C "skip write certificate verify" \
1879 -S "skip parse certificate verify" \
1880 -s "x509_verify_cert() returned" \
1881 -S "! The certificate is not correctly signed by the trusted CA" \
1882 -s "The certificate has been revoked (is on a CRL)"
1883
1884# Tests for non-blocking I/O: exercise a variety of handshake flows
1885
1886run_test "Non-blocking I/O: basic handshake" \
1887 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1888 "$P_CLI nbio=2 tickets=0" \
1889 0 \
1890 -S "mbedtls_ssl_handshake returned" \
1891 -C "mbedtls_ssl_handshake returned" \
1892 -c "Read from server: .* bytes read"
1893
1894run_test "Non-blocking I/O: client auth" \
1895 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1896 "$P_CLI nbio=2 tickets=0" \
1897 0 \
1898 -S "mbedtls_ssl_handshake returned" \
1899 -C "mbedtls_ssl_handshake returned" \
1900 -c "Read from server: .* bytes read"
1901
1902run_test "Non-blocking I/O: ticket" \
1903 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1904 "$P_CLI nbio=2 tickets=1" \
1905 0 \
1906 -S "mbedtls_ssl_handshake returned" \
1907 -C "mbedtls_ssl_handshake returned" \
1908 -c "Read from server: .* bytes read"
1909
1910run_test "Non-blocking I/O: ticket + client auth" \
1911 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1912 "$P_CLI nbio=2 tickets=1" \
1913 0 \
1914 -S "mbedtls_ssl_handshake returned" \
1915 -C "mbedtls_ssl_handshake returned" \
1916 -c "Read from server: .* bytes read"
1917
1918run_test "Non-blocking I/O: ticket + client auth + resume" \
1919 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1920 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1921 0 \
1922 -S "mbedtls_ssl_handshake returned" \
1923 -C "mbedtls_ssl_handshake returned" \
1924 -c "Read from server: .* bytes read"
1925
1926run_test "Non-blocking I/O: ticket + resume" \
1927 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1928 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1929 0 \
1930 -S "mbedtls_ssl_handshake returned" \
1931 -C "mbedtls_ssl_handshake returned" \
1932 -c "Read from server: .* bytes read"
1933
1934run_test "Non-blocking I/O: session-id resume" \
1935 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1936 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1937 0 \
1938 -S "mbedtls_ssl_handshake returned" \
1939 -C "mbedtls_ssl_handshake returned" \
1940 -c "Read from server: .* bytes read"
1941
1942# Tests for version negotiation
1943
1944run_test "Version check: all -> 1.2" \
1945 "$P_SRV" \
1946 "$P_CLI" \
1947 0 \
1948 -S "mbedtls_ssl_handshake returned" \
1949 -C "mbedtls_ssl_handshake returned" \
1950 -s "Protocol is TLSv1.2" \
1951 -c "Protocol is TLSv1.2"
1952
1953run_test "Version check: cli max 1.1 -> 1.1" \
1954 "$P_SRV" \
1955 "$P_CLI max_version=tls1_1" \
1956 0 \
1957 -S "mbedtls_ssl_handshake returned" \
1958 -C "mbedtls_ssl_handshake returned" \
1959 -s "Protocol is TLSv1.1" \
1960 -c "Protocol is TLSv1.1"
1961
1962run_test "Version check: srv max 1.1 -> 1.1" \
1963 "$P_SRV max_version=tls1_1" \
1964 "$P_CLI" \
1965 0 \
1966 -S "mbedtls_ssl_handshake returned" \
1967 -C "mbedtls_ssl_handshake returned" \
1968 -s "Protocol is TLSv1.1" \
1969 -c "Protocol is TLSv1.1"
1970
1971run_test "Version check: cli+srv max 1.1 -> 1.1" \
1972 "$P_SRV max_version=tls1_1" \
1973 "$P_CLI max_version=tls1_1" \
1974 0 \
1975 -S "mbedtls_ssl_handshake returned" \
1976 -C "mbedtls_ssl_handshake returned" \
1977 -s "Protocol is TLSv1.1" \
1978 -c "Protocol is TLSv1.1"
1979
1980run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
1981 "$P_SRV min_version=tls1_1" \
1982 "$P_CLI max_version=tls1_1" \
1983 0 \
1984 -S "mbedtls_ssl_handshake returned" \
1985 -C "mbedtls_ssl_handshake returned" \
1986 -s "Protocol is TLSv1.1" \
1987 -c "Protocol is TLSv1.1"
1988
1989run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
1990 "$P_SRV max_version=tls1_1" \
1991 "$P_CLI min_version=tls1_1" \
1992 0 \
1993 -S "mbedtls_ssl_handshake returned" \
1994 -C "mbedtls_ssl_handshake returned" \
1995 -s "Protocol is TLSv1.1" \
1996 -c "Protocol is TLSv1.1"
1997
1998run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
1999 "$P_SRV max_version=tls1_1" \
2000 "$P_CLI min_version=tls1_2" \
2001 1 \
2002 -s "mbedtls_ssl_handshake returned" \
2003 -c "mbedtls_ssl_handshake returned" \
2004 -c "SSL - Handshake protocol not within min/max boundaries"
2005
2006run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
2007 "$P_SRV min_version=tls1_2" \
2008 "$P_CLI max_version=tls1_1" \
2009 1 \
2010 -s "mbedtls_ssl_handshake returned" \
2011 -c "mbedtls_ssl_handshake returned" \
2012 -s "SSL - Handshake protocol not within min/max boundaries"
2013
2014# Tests for ALPN extension
2015
2016run_test "ALPN: none" \
2017 "$P_SRV debug_level=3" \
2018 "$P_CLI debug_level=3" \
2019 0 \
2020 -C "client hello, adding alpn extension" \
2021 -S "found alpn extension" \
2022 -C "got an alert message, type: \\[2:120]" \
2023 -S "server hello, adding alpn extension" \
2024 -C "found alpn extension " \
2025 -C "Application Layer Protocol is" \
2026 -S "Application Layer Protocol is"
2027
2028run_test "ALPN: client only" \
2029 "$P_SRV debug_level=3" \
2030 "$P_CLI debug_level=3 alpn=abc,1234" \
2031 0 \
2032 -c "client hello, adding alpn extension" \
2033 -s "found alpn extension" \
2034 -C "got an alert message, type: \\[2:120]" \
2035 -S "server hello, adding alpn extension" \
2036 -C "found alpn extension " \
2037 -c "Application Layer Protocol is (none)" \
2038 -S "Application Layer Protocol is"
2039
2040run_test "ALPN: server only" \
2041 "$P_SRV debug_level=3 alpn=abc,1234" \
2042 "$P_CLI debug_level=3" \
2043 0 \
2044 -C "client hello, adding alpn extension" \
2045 -S "found alpn extension" \
2046 -C "got an alert message, type: \\[2:120]" \
2047 -S "server hello, adding alpn extension" \
2048 -C "found alpn extension " \
2049 -C "Application Layer Protocol is" \
2050 -s "Application Layer Protocol is (none)"
2051
2052run_test "ALPN: both, common cli1-srv1" \
2053 "$P_SRV debug_level=3 alpn=abc,1234" \
2054 "$P_CLI debug_level=3 alpn=abc,1234" \
2055 0 \
2056 -c "client hello, adding alpn extension" \
2057 -s "found alpn extension" \
2058 -C "got an alert message, type: \\[2:120]" \
2059 -s "server hello, adding alpn extension" \
2060 -c "found alpn extension" \
2061 -c "Application Layer Protocol is abc" \
2062 -s "Application Layer Protocol is abc"
2063
2064run_test "ALPN: both, common cli2-srv1" \
2065 "$P_SRV debug_level=3 alpn=abc,1234" \
2066 "$P_CLI debug_level=3 alpn=1234,abc" \
2067 0 \
2068 -c "client hello, adding alpn extension" \
2069 -s "found alpn extension" \
2070 -C "got an alert message, type: \\[2:120]" \
2071 -s "server hello, adding alpn extension" \
2072 -c "found alpn extension" \
2073 -c "Application Layer Protocol is abc" \
2074 -s "Application Layer Protocol is abc"
2075
2076run_test "ALPN: both, common cli1-srv2" \
2077 "$P_SRV debug_level=3 alpn=abc,1234" \
2078 "$P_CLI debug_level=3 alpn=1234,abcde" \
2079 0 \
2080 -c "client hello, adding alpn extension" \
2081 -s "found alpn extension" \
2082 -C "got an alert message, type: \\[2:120]" \
2083 -s "server hello, adding alpn extension" \
2084 -c "found alpn extension" \
2085 -c "Application Layer Protocol is 1234" \
2086 -s "Application Layer Protocol is 1234"
2087
2088run_test "ALPN: both, no common" \
2089 "$P_SRV debug_level=3 alpn=abc,123" \
2090 "$P_CLI debug_level=3 alpn=1234,abcde" \
2091 1 \
2092 -c "client hello, adding alpn extension" \
2093 -s "found alpn extension" \
2094 -c "got an alert message, type: \\[2:120]" \
2095 -S "server hello, adding alpn extension" \
2096 -C "found alpn extension" \
2097 -C "Application Layer Protocol is 1234" \
2098 -S "Application Layer Protocol is 1234"
2099
2100
2101# Tests for keyUsage in leaf certificates, part 1:
2102# server-side certificate/suite selection
2103
2104run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
2105 "$P_SRV key_file=data_files/server2.key \
2106 crt_file=data_files/server2.ku-ds.crt" \
2107 "$P_CLI" \
2108 0 \
2109 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
2110
2111
2112run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
2113 "$P_SRV key_file=data_files/server2.key \
2114 crt_file=data_files/server2.ku-ke.crt" \
2115 "$P_CLI" \
2116 0 \
2117 -c "Ciphersuite is TLS-RSA-WITH-"
2118
2119run_test "keyUsage srv: RSA, keyAgreement -> fail" \
2120 "$P_SRV key_file=data_files/server2.key \
2121 crt_file=data_files/server2.ku-ka.crt" \
2122 "$P_CLI" \
2123 1 \
2124 -C "Ciphersuite is "
2125
2126run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
2127 "$P_SRV key_file=data_files/server5.key \
2128 crt_file=data_files/server5.ku-ds.crt" \
2129 "$P_CLI" \
2130 0 \
2131 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2132
2133
2134run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
2135 "$P_SRV key_file=data_files/server5.key \
2136 crt_file=data_files/server5.ku-ka.crt" \
2137 "$P_CLI" \
2138 0 \
2139 -c "Ciphersuite is TLS-ECDH-"
2140
2141run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
2142 "$P_SRV key_file=data_files/server5.key \
2143 crt_file=data_files/server5.ku-ke.crt" \
2144 "$P_CLI" \
2145 1 \
2146 -C "Ciphersuite is "
2147
2148# Tests for keyUsage in leaf certificates, part 2:
2149# client-side checking of server cert
2150
2151run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
2152 "$O_SRV -key data_files/server2.key \
2153 -cert data_files/server2.ku-ds_ke.crt" \
2154 "$P_CLI debug_level=1 \
2155 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2156 0 \
2157 -C "bad certificate (usage extensions)" \
2158 -C "Processing of the Certificate handshake message failed" \
2159 -c "Ciphersuite is TLS-"
2160
2161run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
2162 "$O_SRV -key data_files/server2.key \
2163 -cert data_files/server2.ku-ds_ke.crt" \
2164 "$P_CLI debug_level=1 \
2165 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2166 0 \
2167 -C "bad certificate (usage extensions)" \
2168 -C "Processing of the Certificate handshake message failed" \
2169 -c "Ciphersuite is TLS-"
2170
2171run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
2172 "$O_SRV -key data_files/server2.key \
2173 -cert data_files/server2.ku-ke.crt" \
2174 "$P_CLI debug_level=1 \
2175 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2176 0 \
2177 -C "bad certificate (usage extensions)" \
2178 -C "Processing of the Certificate handshake message failed" \
2179 -c "Ciphersuite is TLS-"
2180
2181run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
2182 "$O_SRV -key data_files/server2.key \
2183 -cert data_files/server2.ku-ke.crt" \
2184 "$P_CLI debug_level=1 \
2185 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2186 1 \
2187 -c "bad certificate (usage extensions)" \
2188 -c "Processing of the Certificate handshake message failed" \
2189 -C "Ciphersuite is TLS-"
2190
2191run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2192 "$O_SRV -key data_files/server2.key \
2193 -cert data_files/server2.ku-ke.crt" \
2194 "$P_CLI debug_level=1 auth_mode=optional \
2195 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2196 0 \
2197 -c "bad certificate (usage extensions)" \
2198 -C "Processing of the Certificate handshake message failed" \
2199 -c "Ciphersuite is TLS-" \
2200 -c "! Usage does not match the keyUsage extension"
2201
2202run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
2203 "$O_SRV -key data_files/server2.key \
2204 -cert data_files/server2.ku-ds.crt" \
2205 "$P_CLI debug_level=1 \
2206 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2207 0 \
2208 -C "bad certificate (usage extensions)" \
2209 -C "Processing of the Certificate handshake message failed" \
2210 -c "Ciphersuite is TLS-"
2211
2212run_test "keyUsage cli: DigitalSignature, RSA: fail" \
2213 "$O_SRV -key data_files/server2.key \
2214 -cert data_files/server2.ku-ds.crt" \
2215 "$P_CLI debug_level=1 \
2216 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2217 1 \
2218 -c "bad certificate (usage extensions)" \
2219 -c "Processing of the Certificate handshake message failed" \
2220 -C "Ciphersuite is TLS-"
2221
2222run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2223 "$O_SRV -key data_files/server2.key \
2224 -cert data_files/server2.ku-ds.crt" \
2225 "$P_CLI debug_level=1 auth_mode=optional \
2226 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2227 0 \
2228 -c "bad certificate (usage extensions)" \
2229 -C "Processing of the Certificate handshake message failed" \
2230 -c "Ciphersuite is TLS-" \
2231 -c "! Usage does not match the keyUsage extension"
2232
2233# Tests for keyUsage in leaf certificates, part 3:
2234# server-side checking of client cert
2235
2236run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
2237 "$P_SRV debug_level=1 auth_mode=optional" \
2238 "$O_CLI -key data_files/server2.key \
2239 -cert data_files/server2.ku-ds.crt" \
2240 0 \
2241 -S "bad certificate (usage extensions)" \
2242 -S "Processing of the Certificate handshake message failed"
2243
2244run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
2245 "$P_SRV debug_level=1 auth_mode=optional" \
2246 "$O_CLI -key data_files/server2.key \
2247 -cert data_files/server2.ku-ke.crt" \
2248 0 \
2249 -s "bad certificate (usage extensions)" \
2250 -S "Processing of the Certificate handshake message failed"
2251
2252run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
2253 "$P_SRV debug_level=1 auth_mode=required" \
2254 "$O_CLI -key data_files/server2.key \
2255 -cert data_files/server2.ku-ke.crt" \
2256 1 \
2257 -s "bad certificate (usage extensions)" \
2258 -s "Processing of the Certificate handshake message failed"
2259
2260run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
2261 "$P_SRV debug_level=1 auth_mode=optional" \
2262 "$O_CLI -key data_files/server5.key \
2263 -cert data_files/server5.ku-ds.crt" \
2264 0 \
2265 -S "bad certificate (usage extensions)" \
2266 -S "Processing of the Certificate handshake message failed"
2267
2268run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
2269 "$P_SRV debug_level=1 auth_mode=optional" \
2270 "$O_CLI -key data_files/server5.key \
2271 -cert data_files/server5.ku-ka.crt" \
2272 0 \
2273 -s "bad certificate (usage extensions)" \
2274 -S "Processing of the Certificate handshake message failed"
2275
2276# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2277
2278run_test "extKeyUsage srv: serverAuth -> OK" \
2279 "$P_SRV key_file=data_files/server5.key \
2280 crt_file=data_files/server5.eku-srv.crt" \
2281 "$P_CLI" \
2282 0
2283
2284run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
2285 "$P_SRV key_file=data_files/server5.key \
2286 crt_file=data_files/server5.eku-srv.crt" \
2287 "$P_CLI" \
2288 0
2289
2290run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
2291 "$P_SRV key_file=data_files/server5.key \
2292 crt_file=data_files/server5.eku-cs_any.crt" \
2293 "$P_CLI" \
2294 0
2295
2296run_test "extKeyUsage srv: codeSign -> fail" \
2297 "$P_SRV key_file=data_files/server5.key \
2298 crt_file=data_files/server5.eku-cli.crt" \
2299 "$P_CLI" \
2300 1
2301
2302# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2303
2304run_test "extKeyUsage cli: serverAuth -> OK" \
2305 "$O_SRV -key data_files/server5.key \
2306 -cert data_files/server5.eku-srv.crt" \
2307 "$P_CLI debug_level=1" \
2308 0 \
2309 -C "bad certificate (usage extensions)" \
2310 -C "Processing of the Certificate handshake message failed" \
2311 -c "Ciphersuite is TLS-"
2312
2313run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
2314 "$O_SRV -key data_files/server5.key \
2315 -cert data_files/server5.eku-srv_cli.crt" \
2316 "$P_CLI debug_level=1" \
2317 0 \
2318 -C "bad certificate (usage extensions)" \
2319 -C "Processing of the Certificate handshake message failed" \
2320 -c "Ciphersuite is TLS-"
2321
2322run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
2323 "$O_SRV -key data_files/server5.key \
2324 -cert data_files/server5.eku-cs_any.crt" \
2325 "$P_CLI debug_level=1" \
2326 0 \
2327 -C "bad certificate (usage extensions)" \
2328 -C "Processing of the Certificate handshake message failed" \
2329 -c "Ciphersuite is TLS-"
2330
2331run_test "extKeyUsage cli: codeSign -> fail" \
2332 "$O_SRV -key data_files/server5.key \
2333 -cert data_files/server5.eku-cs.crt" \
2334 "$P_CLI debug_level=1" \
2335 1 \
2336 -c "bad certificate (usage extensions)" \
2337 -c "Processing of the Certificate handshake message failed" \
2338 -C "Ciphersuite is TLS-"
2339
2340# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2341
2342run_test "extKeyUsage cli-auth: clientAuth -> OK" \
2343 "$P_SRV debug_level=1 auth_mode=optional" \
2344 "$O_CLI -key data_files/server5.key \
2345 -cert data_files/server5.eku-cli.crt" \
2346 0 \
2347 -S "bad certificate (usage extensions)" \
2348 -S "Processing of the Certificate handshake message failed"
2349
2350run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
2351 "$P_SRV debug_level=1 auth_mode=optional" \
2352 "$O_CLI -key data_files/server5.key \
2353 -cert data_files/server5.eku-srv_cli.crt" \
2354 0 \
2355 -S "bad certificate (usage extensions)" \
2356 -S "Processing of the Certificate handshake message failed"
2357
2358run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
2359 "$P_SRV debug_level=1 auth_mode=optional" \
2360 "$O_CLI -key data_files/server5.key \
2361 -cert data_files/server5.eku-cs_any.crt" \
2362 0 \
2363 -S "bad certificate (usage extensions)" \
2364 -S "Processing of the Certificate handshake message failed"
2365
2366run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
2367 "$P_SRV debug_level=1 auth_mode=optional" \
2368 "$O_CLI -key data_files/server5.key \
2369 -cert data_files/server5.eku-cs.crt" \
2370 0 \
2371 -s "bad certificate (usage extensions)" \
2372 -S "Processing of the Certificate handshake message failed"
2373
2374run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
2375 "$P_SRV debug_level=1 auth_mode=required" \
2376 "$O_CLI -key data_files/server5.key \
2377 -cert data_files/server5.eku-cs.crt" \
2378 1 \
2379 -s "bad certificate (usage extensions)" \
2380 -s "Processing of the Certificate handshake message failed"
2381
2382# Tests for DHM parameters loading
2383
2384run_test "DHM parameters: reference" \
2385 "$P_SRV" \
2386 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2387 debug_level=3" \
2388 0 \
2389 -c "value of 'DHM: P ' (2048 bits)" \
2390 -c "value of 'DHM: G ' (2048 bits)"
2391
2392run_test "DHM parameters: other parameters" \
2393 "$P_SRV dhm_file=data_files/dhparams.pem" \
2394 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2395 debug_level=3" \
2396 0 \
2397 -c "value of 'DHM: P ' (1024 bits)" \
2398 -c "value of 'DHM: G ' (2 bits)"
2399
2400# Tests for DHM client-side size checking
2401
2402run_test "DHM size: server default, client default, OK" \
2403 "$P_SRV" \
2404 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2405 debug_level=1" \
2406 0 \
2407 -C "DHM prime too short:"
2408
2409run_test "DHM size: server default, client 2048, OK" \
2410 "$P_SRV" \
2411 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2412 debug_level=1 dhmlen=2048" \
2413 0 \
2414 -C "DHM prime too short:"
2415
2416run_test "DHM size: server 1024, client default, OK" \
2417 "$P_SRV dhm_file=data_files/dhparams.pem" \
2418 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2419 debug_level=1" \
2420 0 \
2421 -C "DHM prime too short:"
2422
2423run_test "DHM size: server 1000, client default, rejected" \
2424 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2425 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2426 debug_level=1" \
2427 1 \
2428 -c "DHM prime too short:"
2429
2430run_test "DHM size: server default, client 2049, rejected" \
2431 "$P_SRV" \
2432 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2433 debug_level=1 dhmlen=2049" \
2434 1 \
2435 -c "DHM prime too short:"
2436
2437# Tests for PSK callback
2438
2439run_test "PSK callback: psk, no callback" \
2440 "$P_SRV psk=abc123 psk_identity=foo" \
2441 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2442 psk_identity=foo psk=abc123" \
2443 0 \
2444 -S "SSL - None of the common ciphersuites is usable" \
2445 -S "SSL - Unknown identity received" \
2446 -S "SSL - Verification of the message MAC failed"
2447
2448run_test "PSK callback: no psk, no callback" \
2449 "$P_SRV" \
2450 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2451 psk_identity=foo psk=abc123" \
2452 1 \
2453 -s "SSL - None of the common ciphersuites is usable" \
2454 -S "SSL - Unknown identity received" \
2455 -S "SSL - Verification of the message MAC failed"
2456
2457run_test "PSK callback: callback overrides other settings" \
2458 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2459 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2460 psk_identity=foo psk=abc123" \
2461 1 \
2462 -S "SSL - None of the common ciphersuites is usable" \
2463 -s "SSL - Unknown identity received" \
2464 -S "SSL - Verification of the message MAC failed"
2465
2466run_test "PSK callback: first id matches" \
2467 "$P_SRV psk_list=abc,dead,def,beef" \
2468 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2469 psk_identity=abc psk=dead" \
2470 0 \
2471 -S "SSL - None of the common ciphersuites is usable" \
2472 -S "SSL - Unknown identity received" \
2473 -S "SSL - Verification of the message MAC failed"
2474
2475run_test "PSK callback: second id matches" \
2476 "$P_SRV psk_list=abc,dead,def,beef" \
2477 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2478 psk_identity=def psk=beef" \
2479 0 \
2480 -S "SSL - None of the common ciphersuites is usable" \
2481 -S "SSL - Unknown identity received" \
2482 -S "SSL - Verification of the message MAC failed"
2483
2484run_test "PSK callback: no match" \
2485 "$P_SRV psk_list=abc,dead,def,beef" \
2486 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2487 psk_identity=ghi psk=beef" \
2488 1 \
2489 -S "SSL - None of the common ciphersuites is usable" \
2490 -s "SSL - Unknown identity received" \
2491 -S "SSL - Verification of the message MAC failed"
2492
2493run_test "PSK callback: wrong key" \
2494 "$P_SRV psk_list=abc,dead,def,beef" \
2495 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2496 psk_identity=abc psk=beef" \
2497 1 \
2498 -S "SSL - None of the common ciphersuites is usable" \
2499 -S "SSL - Unknown identity received" \
2500 -s "SSL - Verification of the message MAC failed"
2501
2502# Tests for EC J-PAKE
2503
2504requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
2505run_test "ECJPAKE: client not configured" \
2506 "$P_SRV debug_level=3" \
2507 "$P_CLI debug_level=3" \
2508 0 \
2509 -C "add ciphersuite: c0ff" \
2510 -C "adding ecjpake_kkpp extension" \
2511 -S "found ecjpake kkpp extension" \
2512 -S "skip ecjpake kkpp extension" \
2513 -S "ciphersuite mismatch: ecjpake not configured" \
2514 -S "server hello, ecjpake kkpp extension" \
2515 -C "found ecjpake_kkpp extension" \
2516 -S "None of the common ciphersuites is usable"
2517
2518requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
2519run_test "ECJPAKE: server not configured" \
2520 "$P_SRV debug_level=3" \
2521 "$P_CLI debug_level=3 ecjpake_pw=bla \
2522 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2523 1 \
2524 -c "add ciphersuite: c0ff" \
2525 -c "adding ecjpake_kkpp extension" \
2526 -s "found ecjpake kkpp extension" \
2527 -s "skip ecjpake kkpp extension" \
2528 -s "ciphersuite mismatch: ecjpake not configured" \
2529 -S "server hello, ecjpake kkpp extension" \
2530 -C "found ecjpake_kkpp extension" \
2531 -s "None of the common ciphersuites is usable"
2532
2533requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
2534run_test "ECJPAKE: working, TLS" \
2535 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2536 "$P_CLI debug_level=3 ecjpake_pw=bla \
2537 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2538 0 \
2539 -c "add ciphersuite: c0ff" \
2540 -c "adding ecjpake_kkpp extension" \
2541 -C "re-using cached ecjpake parameters" \
2542 -s "found ecjpake kkpp extension" \
2543 -S "skip ecjpake kkpp extension" \
2544 -S "ciphersuite mismatch: ecjpake not configured" \
2545 -s "server hello, ecjpake kkpp extension" \
2546 -c "found ecjpake_kkpp extension" \
2547 -S "None of the common ciphersuites is usable" \
2548 -S "SSL - Verification of the message MAC failed"
2549
2550requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
2551run_test "ECJPAKE: password mismatch, TLS" \
2552 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2553 "$P_CLI debug_level=3 ecjpake_pw=bad \
2554 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2555 1 \
2556 -C "re-using cached ecjpake parameters" \
2557 -s "SSL - Verification of the message MAC failed"
2558
2559requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
2560run_test "ECJPAKE: working, DTLS" \
2561 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2562 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2563 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2564 0 \
2565 -c "re-using cached ecjpake parameters" \
2566 -S "SSL - Verification of the message MAC failed"
2567
2568requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
2569run_test "ECJPAKE: working, DTLS, no cookie" \
2570 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2571 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2572 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2573 0 \
2574 -C "re-using cached ecjpake parameters" \
2575 -S "SSL - Verification of the message MAC failed"
2576
2577requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
2578run_test "ECJPAKE: password mismatch, DTLS" \
2579 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2580 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2581 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2582 1 \
2583 -c "re-using cached ecjpake parameters" \
2584 -s "SSL - Verification of the message MAC failed"
2585
2586# for tests with configs/config-thread.h
2587requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
2588run_test "ECJPAKE: working, DTLS, nolog" \
2589 "$P_SRV dtls=1 ecjpake_pw=bla" \
2590 "$P_CLI dtls=1 ecjpake_pw=bla \
2591 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2592 0
2593
2594# Tests for ciphersuites per version
2595
2596run_test "Per-version suites: SSL3" \
2597 "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
2598 "$P_CLI force_version=ssl3" \
2599 0 \
2600 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2601
2602run_test "Per-version suites: TLS 1.0" \
2603 "$P_SRV arc4=1 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
2604 "$P_CLI force_version=tls1 arc4=1" \
2605 0 \
2606 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
2607
2608run_test "Per-version suites: TLS 1.1" \
2609 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
2610 "$P_CLI force_version=tls1_1" \
2611 0 \
2612 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2613
2614run_test "Per-version suites: TLS 1.2" \
2615 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
2616 "$P_CLI force_version=tls1_2" \
2617 0 \
2618 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2619
2620# Test for ClientHello without extensions
2621
2622requires_gnutls
2623run_test "ClientHello without extensions" \
2624 "$P_SRV debug_level=3" \
2625 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2626 0 \
2627 -s "dumping 'client hello extensions' (0 bytes)"
2628
2629# Tests for mbedtls_ssl_get_bytes_avail()
2630
2631run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
2632 "$P_SRV" \
2633 "$P_CLI request_size=100" \
2634 0 \
2635 -s "Read from client: 100 bytes read$"
2636
2637run_test "mbedtls_ssl_get_bytes_avail: extra data" \
2638 "$P_SRV" \
2639 "$P_CLI request_size=500" \
2640 0 \
2641 -s "Read from client: 500 bytes read (.*+.*)"
2642
2643# Tests for small packets
2644
2645run_test "Small packet SSLv3 BlockCipher" \
2646 "$P_SRV min_version=ssl3" \
2647 "$P_CLI request_size=1 force_version=ssl3 \
2648 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2649 0 \
2650 -s "Read from client: 1 bytes read"
2651
2652run_test "Small packet SSLv3 StreamCipher" \
2653 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2654 "$P_CLI request_size=1 force_version=ssl3 \
2655 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2656 0 \
2657 -s "Read from client: 1 bytes read"
2658
2659run_test "Small packet TLS 1.0 BlockCipher" \
2660 "$P_SRV" \
2661 "$P_CLI request_size=1 force_version=tls1 \
2662 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2663 0 \
2664 -s "Read from client: 1 bytes read"
2665
2666run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2667 "$P_SRV" \
2668 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2669 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2670 0 \
2671 -s "Read from client: 1 bytes read"
2672
2673run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2674 "$P_SRV" \
2675 "$P_CLI request_size=1 force_version=tls1 \
2676 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2677 trunc_hmac=1" \
2678 0 \
2679 -s "Read from client: 1 bytes read"
2680
2681run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
2682 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2683 "$P_CLI request_size=1 force_version=tls1 \
2684 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2685 trunc_hmac=1" \
2686 0 \
2687 -s "Read from client: 1 bytes read"
2688
2689run_test "Small packet TLS 1.1 BlockCipher" \
2690 "$P_SRV" \
2691 "$P_CLI request_size=1 force_version=tls1_1 \
2692 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2693 0 \
2694 -s "Read from client: 1 bytes read"
2695
2696run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2697 "$P_SRV" \
2698 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2699 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2700 0 \
2701 -s "Read from client: 1 bytes read"
2702
2703run_test "Small packet TLS 1.1 StreamCipher" \
2704 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2705 "$P_CLI request_size=1 force_version=tls1_1 \
2706 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2707 0 \
2708 -s "Read from client: 1 bytes read"
2709
2710run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2711 "$P_SRV" \
2712 "$P_CLI request_size=1 force_version=tls1_1 \
2713 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2714 trunc_hmac=1" \
2715 0 \
2716 -s "Read from client: 1 bytes read"
2717
2718run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
2719 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2720 "$P_CLI request_size=1 force_version=tls1_1 \
2721 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2722 trunc_hmac=1" \
2723 0 \
2724 -s "Read from client: 1 bytes read"
2725
2726run_test "Small packet TLS 1.2 BlockCipher" \
2727 "$P_SRV" \
2728 "$P_CLI request_size=1 force_version=tls1_2 \
2729 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2730 0 \
2731 -s "Read from client: 1 bytes read"
2732
2733run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2734 "$P_SRV" \
2735 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2736 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2737 0 \
2738 -s "Read from client: 1 bytes read"
2739
2740run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2741 "$P_SRV" \
2742 "$P_CLI request_size=1 force_version=tls1_2 \
2743 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
2744 0 \
2745 -s "Read from client: 1 bytes read"
2746
2747run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2748 "$P_SRV" \
2749 "$P_CLI request_size=1 force_version=tls1_2 \
2750 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2751 trunc_hmac=1" \
2752 0 \
2753 -s "Read from client: 1 bytes read"
2754
2755run_test "Small packet TLS 1.2 StreamCipher" \
2756 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2757 "$P_CLI request_size=1 force_version=tls1_2 \
2758 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2759 0 \
2760 -s "Read from client: 1 bytes read"
2761
2762run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
2763 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2764 "$P_CLI request_size=1 force_version=tls1_2 \
2765 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2766 trunc_hmac=1" \
2767 0 \
2768 -s "Read from client: 1 bytes read"
2769
2770run_test "Small packet TLS 1.2 AEAD" \
2771 "$P_SRV" \
2772 "$P_CLI request_size=1 force_version=tls1_2 \
2773 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2774 0 \
2775 -s "Read from client: 1 bytes read"
2776
2777run_test "Small packet TLS 1.2 AEAD shorter tag" \
2778 "$P_SRV" \
2779 "$P_CLI request_size=1 force_version=tls1_2 \
2780 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2781 0 \
2782 -s "Read from client: 1 bytes read"
2783
2784# Test for large packets
2785
2786run_test "Large packet SSLv3 BlockCipher" \
2787 "$P_SRV min_version=ssl3" \
2788 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
2789 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2790 0 \
2791 -s "Read from client: 16384 bytes read"
2792
2793run_test "Large packet SSLv3 StreamCipher" \
2794 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2795 "$P_CLI request_size=16384 force_version=ssl3 \
2796 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2797 0 \
2798 -s "Read from client: 16384 bytes read"
2799
2800run_test "Large packet TLS 1.0 BlockCipher" \
2801 "$P_SRV" \
2802 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
2803 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2804 0 \
2805 -s "Read from client: 16384 bytes read"
2806
2807run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2808 "$P_SRV" \
2809 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
2810 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2811 trunc_hmac=1" \
2812 0 \
2813 -s "Read from client: 16384 bytes read"
2814
2815run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
2816 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2817 "$P_CLI request_size=16384 force_version=tls1 \
2818 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2819 trunc_hmac=1" \
2820 0 \
2821 -s "Read from client: 16384 bytes read"
2822
2823run_test "Large packet TLS 1.1 BlockCipher" \
2824 "$P_SRV" \
2825 "$P_CLI request_size=16384 force_version=tls1_1 \
2826 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2827 0 \
2828 -s "Read from client: 16384 bytes read"
2829
2830run_test "Large packet TLS 1.1 StreamCipher" \
2831 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2832 "$P_CLI request_size=16384 force_version=tls1_1 \
2833 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2834 0 \
2835 -s "Read from client: 16384 bytes read"
2836
2837run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2838 "$P_SRV" \
2839 "$P_CLI request_size=16384 force_version=tls1_1 \
2840 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2841 trunc_hmac=1" \
2842 0 \
2843 -s "Read from client: 16384 bytes read"
2844
2845run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
2846 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2847 "$P_CLI request_size=16384 force_version=tls1_1 \
2848 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2849 trunc_hmac=1" \
2850 0 \
2851 -s "Read from client: 16384 bytes read"
2852
2853run_test "Large packet TLS 1.2 BlockCipher" \
2854 "$P_SRV" \
2855 "$P_CLI request_size=16384 force_version=tls1_2 \
2856 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2857 0 \
2858 -s "Read from client: 16384 bytes read"
2859
2860run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2861 "$P_SRV" \
2862 "$P_CLI request_size=16384 force_version=tls1_2 \
2863 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
2864 0 \
2865 -s "Read from client: 16384 bytes read"
2866
2867run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2868 "$P_SRV" \
2869 "$P_CLI request_size=16384 force_version=tls1_2 \
2870 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2871 trunc_hmac=1" \
2872 0 \
2873 -s "Read from client: 16384 bytes read"
2874
2875run_test "Large packet TLS 1.2 StreamCipher" \
2876 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2877 "$P_CLI request_size=16384 force_version=tls1_2 \
2878 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2879 0 \
2880 -s "Read from client: 16384 bytes read"
2881
2882run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
2883 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2884 "$P_CLI request_size=16384 force_version=tls1_2 \
2885 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2886 trunc_hmac=1" \
2887 0 \
2888 -s "Read from client: 16384 bytes read"
2889
2890run_test "Large packet TLS 1.2 AEAD" \
2891 "$P_SRV" \
2892 "$P_CLI request_size=16384 force_version=tls1_2 \
2893 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2894 0 \
2895 -s "Read from client: 16384 bytes read"
2896
2897run_test "Large packet TLS 1.2 AEAD shorter tag" \
2898 "$P_SRV" \
2899 "$P_CLI request_size=16384 force_version=tls1_2 \
2900 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2901 0 \
2902 -s "Read from client: 16384 bytes read"
2903
2904# Tests for DTLS HelloVerifyRequest
2905
2906run_test "DTLS cookie: enabled" \
2907 "$P_SRV dtls=1 debug_level=2" \
2908 "$P_CLI dtls=1 debug_level=2" \
2909 0 \
2910 -s "cookie verification failed" \
2911 -s "cookie verification passed" \
2912 -S "cookie verification skipped" \
2913 -c "received hello verify request" \
2914 -s "hello verification requested" \
2915 -S "SSL - The requested feature is not available"
2916
2917run_test "DTLS cookie: disabled" \
2918 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2919 "$P_CLI dtls=1 debug_level=2" \
2920 0 \
2921 -S "cookie verification failed" \
2922 -S "cookie verification passed" \
2923 -s "cookie verification skipped" \
2924 -C "received hello verify request" \
2925 -S "hello verification requested" \
2926 -S "SSL - The requested feature is not available"
2927
2928run_test "DTLS cookie: default (failing)" \
2929 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2930 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2931 1 \
2932 -s "cookie verification failed" \
2933 -S "cookie verification passed" \
2934 -S "cookie verification skipped" \
2935 -C "received hello verify request" \
2936 -S "hello verification requested" \
2937 -s "SSL - The requested feature is not available"
2938
2939requires_ipv6
2940run_test "DTLS cookie: enabled, IPv6" \
2941 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2942 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2943 0 \
2944 -s "cookie verification failed" \
2945 -s "cookie verification passed" \
2946 -S "cookie verification skipped" \
2947 -c "received hello verify request" \
2948 -s "hello verification requested" \
2949 -S "SSL - The requested feature is not available"
2950
2951run_test "DTLS cookie: enabled, nbio" \
2952 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2953 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2954 0 \
2955 -s "cookie verification failed" \
2956 -s "cookie verification passed" \
2957 -S "cookie verification skipped" \
2958 -c "received hello verify request" \
2959 -s "hello verification requested" \
2960 -S "SSL - The requested feature is not available"
2961
2962# Tests for client reconnecting from the same port with DTLS
2963
2964not_with_valgrind # spurious resend
2965run_test "DTLS client reconnect from same port: reference" \
2966 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
2967 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
2968 0 \
2969 -C "resend" \
2970 -S "The operation timed out" \
2971 -S "Client initiated reconnection from same port"
2972
2973not_with_valgrind # spurious resend
2974run_test "DTLS client reconnect from same port: reconnect" \
2975 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
2976 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
2977 0 \
2978 -C "resend" \
2979 -S "The operation timed out" \
2980 -s "Client initiated reconnection from same port"
2981
2982run_test "DTLS client reconnect from same port: reconnect, nbio" \
2983 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
2984 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
2985 0 \
2986 -S "The operation timed out" \
2987 -s "Client initiated reconnection from same port"
2988
2989run_test "DTLS client reconnect from same port: no cookies" \
2990 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
2991 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
2992 0 \
2993 -s "The operation timed out" \
2994 -S "Client initiated reconnection from same port"
2995
2996# Tests for various cases of client authentication with DTLS
2997# (focused on handshake flows and message parsing)
2998
2999run_test "DTLS client auth: required" \
3000 "$P_SRV dtls=1 auth_mode=required" \
3001 "$P_CLI dtls=1" \
3002 0 \
3003 -s "Verifying peer X.509 certificate... ok"
3004
3005run_test "DTLS client auth: optional, client has no cert" \
3006 "$P_SRV dtls=1 auth_mode=optional" \
3007 "$P_CLI dtls=1 crt_file=none key_file=none" \
3008 0 \
3009 -s "! Certificate was missing"
3010
3011run_test "DTLS client auth: none, client has no cert" \
3012 "$P_SRV dtls=1 auth_mode=none" \
3013 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3014 0 \
3015 -c "skip write certificate$" \
3016 -s "! Certificate verification was skipped"
3017
3018run_test "DTLS wrong PSK: badmac alert" \
3019 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3020 "$P_CLI dtls=1 psk=abc124" \
3021 1 \
3022 -s "SSL - Verification of the message MAC failed" \
3023 -c "SSL - A fatal alert message was received from our peer"
3024
3025# Tests for receiving fragmented handshake messages with DTLS
3026
3027requires_gnutls
3028run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3029 "$G_SRV -u --mtu 2048 -a" \
3030 "$P_CLI dtls=1 debug_level=2" \
3031 0 \
3032 -C "found fragmented DTLS handshake message" \
3033 -C "error"
3034
3035requires_gnutls
3036run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3037 "$G_SRV -u --mtu 512" \
3038 "$P_CLI dtls=1 debug_level=2" \
3039 0 \
3040 -c "found fragmented DTLS handshake message" \
3041 -C "error"
3042
3043requires_gnutls
3044run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3045 "$G_SRV -u --mtu 128" \
3046 "$P_CLI dtls=1 debug_level=2" \
3047 0 \
3048 -c "found fragmented DTLS handshake message" \
3049 -C "error"
3050
3051requires_gnutls
3052run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3053 "$G_SRV -u --mtu 128" \
3054 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3055 0 \
3056 -c "found fragmented DTLS handshake message" \
3057 -C "error"
3058
3059requires_gnutls
3060run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3061 "$G_SRV -u --mtu 256" \
3062 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3063 0 \
3064 -c "found fragmented DTLS handshake message" \
3065 -c "client hello, adding renegotiation extension" \
3066 -c "found renegotiation extension" \
3067 -c "=> renegotiate" \
3068 -C "mbedtls_ssl_handshake returned" \
3069 -C "error" \
3070 -s "Extra-header:"
3071
3072requires_gnutls
3073run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3074 "$G_SRV -u --mtu 256" \
3075 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3076 0 \
3077 -c "found fragmented DTLS handshake message" \
3078 -c "client hello, adding renegotiation extension" \
3079 -c "found renegotiation extension" \
3080 -c "=> renegotiate" \
3081 -C "mbedtls_ssl_handshake returned" \
3082 -C "error" \
3083 -s "Extra-header:"
3084
3085run_test "DTLS reassembly: no fragmentation (openssl server)" \
3086 "$O_SRV -dtls1 -mtu 2048" \
3087 "$P_CLI dtls=1 debug_level=2" \
3088 0 \
3089 -C "found fragmented DTLS handshake message" \
3090 -C "error"
3091
3092run_test "DTLS reassembly: some fragmentation (openssl server)" \
3093 "$O_SRV -dtls1 -mtu 768" \
3094 "$P_CLI dtls=1 debug_level=2" \
3095 0 \
3096 -c "found fragmented DTLS handshake message" \
3097 -C "error"
3098
3099run_test "DTLS reassembly: more fragmentation (openssl server)" \
3100 "$O_SRV -dtls1 -mtu 256" \
3101 "$P_CLI dtls=1 debug_level=2" \
3102 0 \
3103 -c "found fragmented DTLS handshake message" \
3104 -C "error"
3105
3106run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3107 "$O_SRV -dtls1 -mtu 256" \
3108 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3109 0 \
3110 -c "found fragmented DTLS handshake message" \
3111 -C "error"
3112
3113# Tests for specific things with "unreliable" UDP connection
3114
3115not_with_valgrind # spurious resend due to timeout
3116run_test "DTLS proxy: reference" \
3117 -p "$P_PXY" \
3118 "$P_SRV dtls=1 debug_level=2" \
3119 "$P_CLI dtls=1 debug_level=2" \
3120 0 \
3121 -C "replayed record" \
3122 -S "replayed record" \
3123 -C "record from another epoch" \
3124 -S "record from another epoch" \
3125 -C "discarding invalid record" \
3126 -S "discarding invalid record" \
3127 -S "resend" \
3128 -s "Extra-header:" \
3129 -c "HTTP/1.0 200 OK"
3130
3131not_with_valgrind # spurious resend due to timeout
3132run_test "DTLS proxy: duplicate every packet" \
3133 -p "$P_PXY duplicate=1" \
3134 "$P_SRV dtls=1 debug_level=2" \
3135 "$P_CLI dtls=1 debug_level=2" \
3136 0 \
3137 -c "replayed record" \
3138 -s "replayed record" \
3139 -c "discarding invalid record" \
3140 -s "discarding invalid record" \
3141 -S "resend" \
3142 -s "Extra-header:" \
3143 -c "HTTP/1.0 200 OK"
3144
3145run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3146 -p "$P_PXY duplicate=1" \
3147 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3148 "$P_CLI dtls=1 debug_level=2" \
3149 0 \
3150 -c "replayed record" \
3151 -S "replayed record" \
3152 -c "discarding invalid record" \
3153 -s "discarding invalid record" \
3154 -c "resend" \
3155 -s "resend" \
3156 -s "Extra-header:" \
3157 -c "HTTP/1.0 200 OK"
3158
3159run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
3160 -p "$P_PXY bad_ad=1" \
3161 "$P_SRV dtls=1 debug_level=1" \
3162 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3163 0 \
3164 -c "discarding invalid record (mac)" \
3165 -s "discarding invalid record (mac)" \
3166 -s "Extra-header:" \
3167 -c "HTTP/1.0 200 OK" \
3168 -S "too many records with bad MAC" \
3169 -S "Verification of the message MAC failed"
3170
3171run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3172 -p "$P_PXY bad_ad=1" \
3173 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3174 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3175 1 \
3176 -C "discarding invalid record (mac)" \
3177 -S "discarding invalid record (mac)" \
3178 -S "Extra-header:" \
3179 -C "HTTP/1.0 200 OK" \
3180 -s "too many records with bad MAC" \
3181 -s "Verification of the message MAC failed"
3182
3183run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3184 -p "$P_PXY bad_ad=1" \
3185 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3186 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3187 0 \
3188 -c "discarding invalid record (mac)" \
3189 -s "discarding invalid record (mac)" \
3190 -s "Extra-header:" \
3191 -c "HTTP/1.0 200 OK" \
3192 -S "too many records with bad MAC" \
3193 -S "Verification of the message MAC failed"
3194
3195run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3196 -p "$P_PXY bad_ad=1" \
3197 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3198 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3199 1 \
3200 -c "discarding invalid record (mac)" \
3201 -s "discarding invalid record (mac)" \
3202 -s "Extra-header:" \
3203 -c "HTTP/1.0 200 OK" \
3204 -s "too many records with bad MAC" \
3205 -s "Verification of the message MAC failed"
3206
3207run_test "DTLS proxy: delay ChangeCipherSpec" \
3208 -p "$P_PXY delay_ccs=1" \
3209 "$P_SRV dtls=1 debug_level=1" \
3210 "$P_CLI dtls=1 debug_level=1" \
3211 0 \
3212 -c "record from another epoch" \
3213 -s "record from another epoch" \
3214 -c "discarding invalid record" \
3215 -s "discarding invalid record" \
3216 -s "Extra-header:" \
3217 -c "HTTP/1.0 200 OK"
3218
3219# Tests for "randomly unreliable connection": try a variety of flows and peers
3220
3221needs_more_time 2
3222run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
3223 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3224 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3225 psk=abc123" \
3226 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3227 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3228 0 \
3229 -s "Extra-header:" \
3230 -c "HTTP/1.0 200 OK"
3231
3232needs_more_time 2
3233run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3234 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3235 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3236 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
3237 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3238 0 \
3239 -s "Extra-header:" \
3240 -c "HTTP/1.0 200 OK"
3241
3242needs_more_time 2
3243run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3244 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3245 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3246 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
3247 0 \
3248 -s "Extra-header:" \
3249 -c "HTTP/1.0 200 OK"
3250
3251needs_more_time 2
3252run_test "DTLS proxy: 3d, FS, client auth" \
3253 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3254 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3255 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
3256 0 \
3257 -s "Extra-header:" \
3258 -c "HTTP/1.0 200 OK"
3259
3260needs_more_time 2
3261run_test "DTLS proxy: 3d, FS, ticket" \
3262 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3263 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3264 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
3265 0 \
3266 -s "Extra-header:" \
3267 -c "HTTP/1.0 200 OK"
3268
3269needs_more_time 2
3270run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3271 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3272 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3273 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
3274 0 \
3275 -s "Extra-header:" \
3276 -c "HTTP/1.0 200 OK"
3277
3278needs_more_time 2
3279run_test "DTLS proxy: 3d, max handshake, nbio" \
3280 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3281 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3282 auth_mode=required" \
3283 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
3284 0 \
3285 -s "Extra-header:" \
3286 -c "HTTP/1.0 200 OK"
3287
3288needs_more_time 4
3289run_test "DTLS proxy: 3d, min handshake, resumption" \
3290 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3291 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3292 psk=abc123 debug_level=3" \
3293 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3294 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3295 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3296 0 \
3297 -s "a session has been resumed" \
3298 -c "a session has been resumed" \
3299 -s "Extra-header:" \
3300 -c "HTTP/1.0 200 OK"
3301
3302needs_more_time 4
3303run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3304 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3305 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3306 psk=abc123 debug_level=3 nbio=2" \
3307 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3308 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3309 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3310 0 \
3311 -s "a session has been resumed" \
3312 -c "a session has been resumed" \
3313 -s "Extra-header:" \
3314 -c "HTTP/1.0 200 OK"
3315
3316needs_more_time 4
3317run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
3318 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3319 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3320 psk=abc123 renegotiation=1 debug_level=2" \
3321 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3322 renegotiate=1 debug_level=2 \
3323 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3324 0 \
3325 -c "=> renegotiate" \
3326 -s "=> renegotiate" \
3327 -s "Extra-header:" \
3328 -c "HTTP/1.0 200 OK"
3329
3330needs_more_time 4
3331run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3332 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3333 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3334 psk=abc123 renegotiation=1 debug_level=2" \
3335 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3336 renegotiate=1 debug_level=2 \
3337 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3338 0 \
3339 -c "=> renegotiate" \
3340 -s "=> renegotiate" \
3341 -s "Extra-header:" \
3342 -c "HTTP/1.0 200 OK"
3343
3344needs_more_time 4
3345run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
3346 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3347 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3348 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
3349 debug_level=2" \
3350 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3351 renegotiation=1 exchanges=4 debug_level=2 \
3352 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3353 0 \
3354 -c "=> renegotiate" \
3355 -s "=> renegotiate" \
3356 -s "Extra-header:" \
3357 -c "HTTP/1.0 200 OK"
3358
3359needs_more_time 4
3360run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
3361 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3362 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3363 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
3364 debug_level=2 nbio=2" \
3365 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3366 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
3367 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3368 0 \
3369 -c "=> renegotiate" \
3370 -s "=> renegotiate" \
3371 -s "Extra-header:" \
3372 -c "HTTP/1.0 200 OK"
3373
3374needs_more_time 6
3375not_with_valgrind # risk of non-mbedtls peer timing out
3376run_test "DTLS proxy: 3d, openssl server" \
3377 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3378 "$O_SRV -dtls1 -mtu 2048" \
3379 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
3380 0 \
3381 -c "HTTP/1.0 200 OK"
3382
3383needs_more_time 8
3384not_with_valgrind # risk of non-mbedtls peer timing out
3385run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3386 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3387 "$O_SRV -dtls1 -mtu 768" \
3388 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
3389 0 \
3390 -c "HTTP/1.0 200 OK"
3391
3392needs_more_time 8
3393not_with_valgrind # risk of non-mbedtls peer timing out
3394run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3395 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3396 "$O_SRV -dtls1 -mtu 768" \
3397 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
3398 0 \
3399 -c "HTTP/1.0 200 OK"
3400
3401requires_gnutls
3402needs_more_time 6
3403not_with_valgrind # risk of non-mbedtls peer timing out
3404run_test "DTLS proxy: 3d, gnutls server" \
3405 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3406 "$G_SRV -u --mtu 2048 -a" \
3407 "$P_CLI dtls=1 hs_timeout=250-60000" \
3408 0 \
3409 -s "Extra-header:" \
3410 -c "Extra-header:"
3411
3412requires_gnutls
3413needs_more_time 8
3414not_with_valgrind # risk of non-mbedtls peer timing out
3415run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3416 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3417 "$G_SRV -u --mtu 512" \
3418 "$P_CLI dtls=1 hs_timeout=250-60000" \
3419 0 \
3420 -s "Extra-header:" \
3421 -c "Extra-header:"
3422
3423requires_gnutls
3424needs_more_time 8
3425not_with_valgrind # risk of non-mbedtls peer timing out
3426run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3427 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3428 "$G_SRV -u --mtu 512" \
3429 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
3430 0 \
3431 -s "Extra-header:" \
3432 -c "Extra-header:"
3433
3434# Final report
3435
3436echo "------------------------------------------------------------------------"
3437
3438if [ $FAILS = 0 ]; then
3439 printf "PASSED"
3440else
3441 printf "FAILED"
3442fi
3443PASSES=$(( $TESTS - $FAILS ))
3444echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
3445
3446exit $FAILS
Note: See TracBrowser for help on using the repository browser.