blob: ac78b1fbf1715efd2ca243700e3f0ba4a3288af1 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02009# Assumes a build with default options.
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010010
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020016: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010017: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020018: ${GNUTLS_CLI:=gnutls-cli}
19: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010020
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020021O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010022O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020023G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
24G_CLI="$GNUTLS_CLI"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010025
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010026TESTS=0
27FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020028SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010029
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020030CONFIG_H='../include/polarssl/config.h'
31
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010032MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010033FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020034EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010035
36print_usage() {
37 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010038 echo -e " -h|--help\tPrint this help."
39 echo -e " -m|--memcheck\tCheck memory leaks and errors."
40 echo -e " -f|--filter\tOnly matching tests are executed (default: '$FILTER')"
41 echo -e " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010042}
43
44get_options() {
45 while [ $# -gt 0 ]; do
46 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010047 -f|--filter)
48 shift; FILTER=$1
49 ;;
50 -e|--exclude)
51 shift; EXCLUDE=$1
52 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010053 -m|--memcheck)
54 MEMCHECK=1
55 ;;
56 -h|--help)
57 print_usage
58 exit 0
59 ;;
60 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020061 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062 print_usage
63 exit 1
64 ;;
65 esac
66 shift
67 done
68}
69
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020070# skip next test if OpenSSL can't send SSLv2 ClientHello
71requires_openssl_with_sslv2() {
72 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020073 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020074 OPENSSL_HAS_SSL2="YES"
75 else
76 OPENSSL_HAS_SSL2="NO"
77 fi
78 fi
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +020079
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020080 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
81 SKIP_NEXT="YES"
82 fi
83}
84
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020085# skip next test if GnuTLS isn't available
86requires_gnutls() {
87 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
88 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
89 GNUTLS_AVAILABLE="YES"
90 else
91 GNUTLS_AVAILABLE="NO"
92 fi
93 fi
94 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
95 SKIP_NEXT="YES"
96 fi
97}
98
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +020099# skip next test if IPv6 isn't available on this host
100requires_ipv6() {
101 if [ -z "${HAS_IPV6:-}" ]; then
102 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
103 SRV_PID=$!
104 sleep 1
105 kill $SRV_PID >/dev/null 2>&1
106 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
107 HAS_IPV6="NO"
108 else
109 HAS_IPV6="YES"
110 fi
111 rm -r $SRV_OUT
112 fi
113
114 if [ "$HAS_IPV6" = "NO" ]; then
115 SKIP_NEXT="YES"
116 fi
117}
118
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200119# skip the next test if valgrind is in use
120not_with_valgrind() {
121 if [ "$MEMCHECK" -gt 0 ]; then
122 SKIP_NEXT="YES"
123 fi
124}
125
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200126# multiply the client timeout delay by the given factor for the next test
127needs_more_time() {
128 CLI_DELAY_FACTOR=$1
129}
130
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100131# print_name <name>
132print_name() {
133 echo -n "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200134 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100135 for i in `seq 1 $LEN`; do echo -n '.'; done
136 echo -n ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100137
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200138 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100139}
140
141# fail <message>
142fail() {
143 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100144 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100145
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200146 mv $SRV_OUT o-srv-${TESTS}.log
147 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200148 if [ -n "$PXY_CMD" ]; then
149 mv $PXY_OUT o-pxy-${TESTS}.log
150 fi
151 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100152
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200153 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
154 echo " ! server output:"
155 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200156 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200157 echo " ! client output:"
158 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200159 if [ -n "$PXY_CMD" ]; then
160 echo " ! ========================================================"
161 echo " ! proxy output:"
162 cat o-pxy-${TESTS}.log
163 fi
164 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200165 fi
166
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200167 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100168}
169
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100170# is_polar <cmd_line>
171is_polar() {
172 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
173}
174
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200175# openssl s_server doesn't have -www with DTLS
176check_osrv_dtls() {
177 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
178 NEEDS_INPUT=1
179 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
180 else
181 NEEDS_INPUT=0
182 fi
183}
184
185# provide input to commands that need it
186provide_input() {
187 if [ $NEEDS_INPUT -eq 0 ]; then
188 return
189 fi
190
191 while true; do
192 echo "HTTP/1.0 200 OK"
193 sleep 1
194 done
195}
196
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100197# has_mem_err <log_file_name>
198has_mem_err() {
199 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
200 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
201 then
202 return 1 # false: does not have errors
203 else
204 return 0 # true: has errors
205 fi
206}
207
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200208# wait for server to start: two versions depending on lsof availability
209wait_server_start() {
210 if which lsof >/dev/null; then
211 # make sure we don't loop forever
212 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200213 DOG_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200214
215 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200216 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200217 until lsof -nbi UDP:"$SRV_PORT" | grep UDP >/dev/null; do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200218 else
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200219 until lsof -nbi TCP:"$SRV_PORT" | grep LISTEN >/dev/null; do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200220 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200221
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200222 kill $DOG_PID >/dev/null 2>&1
223 wait $DOG_PID
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200224 else
225 sleep "$START_DELAY"
226 fi
227}
228
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200229# wait for client to terminate and set CLI_EXIT
230# must be called right after starting the client
231wait_client_done() {
232 CLI_PID=$!
233
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200234 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
235 CLI_DELAY_FACTOR=1
236
237 ( sleep $CLI_DELAY; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200238 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200239
240 wait $CLI_PID
241 CLI_EXIT=$?
242
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200243 kill $DOG_PID >/dev/null 2>&1
244 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200245
246 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
247}
248
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200249# check if the given command uses dtls and sets global variable DTLS
250detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200251 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200252 DTLS=1
253 else
254 DTLS=0
255 fi
256}
257
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200258# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100259# Options: -s pattern pattern that must be present in server output
260# -c pattern pattern that must be present in client output
261# -S pattern pattern that must be absent in server output
262# -C pattern pattern that must be absent in client output
263run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100264 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200265 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100266
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100267 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
268 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200269 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100270 return
271 fi
272
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100273 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100274
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200275 # should we skip?
276 if [ "X$SKIP_NEXT" = "XYES" ]; then
277 SKIP_NEXT="NO"
278 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200279 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200280 return
281 fi
282
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200283 # does this test use a proxy?
284 if [ "X$1" = "X-p" ]; then
285 PXY_CMD="$2"
286 shift 2
287 else
288 PXY_CMD=""
289 fi
290
291 # get commands and client output
292 SRV_CMD="$1"
293 CLI_CMD="$2"
294 CLI_EXPECT="$3"
295 shift 3
296
297 # fix client port
298 if [ -n "$PXY_CMD" ]; then
299 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
300 else
301 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
302 fi
303
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200304 # update DTLS variable
305 detect_dtls "$SRV_CMD"
306
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100307 # prepend valgrind to our commands if active
308 if [ "$MEMCHECK" -gt 0 ]; then
309 if is_polar "$SRV_CMD"; then
310 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
311 fi
312 if is_polar "$CLI_CMD"; then
313 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
314 fi
315 fi
316
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100317 # run the commands
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200318 if [ -n "$PXY_CMD" ]; then
319 echo "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200320 $PXY_CMD >> $PXY_OUT 2>&1 &
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200321 PXY_PID=$!
322 # assume proxy starts faster than server
323 fi
324
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200325 check_osrv_dtls
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200326 echo "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200327 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100328 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200329 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200330
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200331 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200332 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
333 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100334
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200335 # terminate the server (and the proxy)
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200336 kill $SRV_PID
337 wait $SRV_PID
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200338 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200339 kill $PXY_PID >/dev/null 2>&1
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200340 wait $PXY_PID
341 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100342
343 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200344 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100345 # expected client exit to incorrectly succeed in case of catastrophic
346 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100347 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200348 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100349 else
350 fail "server failed to start"
351 return
352 fi
353 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100354 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200355 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100356 else
357 fail "client failed to start"
358 return
359 fi
360 fi
361
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100362 # check server exit code
363 if [ $? != 0 ]; then
364 fail "server fail"
365 return
366 fi
367
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100368 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100369 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
370 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100371 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200372 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100373 return
374 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100375
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100376 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200377 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100378 while [ $# -gt 0 ]
379 do
380 case $1 in
381 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200382 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100383 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100384 return
385 fi
386 ;;
387
388 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200389 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100390 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100391 return
392 fi
393 ;;
394
395 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200396 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100397 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100398 return
399 fi
400 ;;
401
402 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200403 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100404 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100405 return
406 fi
407 ;;
408
409 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200410 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100411 exit 1
412 esac
413 shift 2
414 done
415
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100416 # check valgrind's results
417 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200418 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100419 fail "Server has memory errors"
420 return
421 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200422 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100423 fail "Client has memory errors"
424 return
425 fi
426 fi
427
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100428 # if we're here, everything is ok
429 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200430 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100431}
432
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100433cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200434 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200435 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
436 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
437 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
438 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100439 exit 1
440}
441
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100442#
443# MAIN
444#
445
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100446get_options "$@"
447
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100448# sanity checks, avoid an avalanche of errors
449if [ ! -x "$P_SRV" ]; then
450 echo "Command '$P_SRV' is not an executable file"
451 exit 1
452fi
453if [ ! -x "$P_CLI" ]; then
454 echo "Command '$P_CLI' is not an executable file"
455 exit 1
456fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200457if [ ! -x "$P_PXY" ]; then
458 echo "Command '$P_PXY' is not an executable file"
459 exit 1
460fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100461if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
462 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100463 exit 1
464fi
465
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200466# used by watchdog
467MAIN_PID="$$"
468
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200469# be more patient with valgrind
470if [ "$MEMCHECK" -gt 0 ]; then
471 START_DELAY=3
472 DOG_DELAY=30
473else
474 START_DELAY=1
475 DOG_DELAY=10
476fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200477CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200478
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200479# Pick a "unique" server port in the range 10000-19999, and a proxy port
480PORT_BASE="0000$$"
481PORT_BASE="$( echo -n $PORT_BASE | tail -c 4 )"
482SRV_PORT="1$PORT_BASE"
483PXY_PORT="2$PORT_BASE"
484unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200485
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200486# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200487P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
488P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
489P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
490O_SRV="$O_SRV -accept $SRV_PORT"
491O_CLI="$O_CLI -connect localhost:+SRV_PORT"
492G_SRV="$G_SRV -p $SRV_PORT"
493G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200494
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200495# Also pick a unique name for intermediate files
496SRV_OUT="srv_out.$$"
497CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200498PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200499SESSION="session.$$"
500
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200501SKIP_NEXT="NO"
502
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100503trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100504
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200505# Basic test
506
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200507# Checks that:
508# - things work with all ciphersuites active (used with config-full in all.sh)
509# - the expected (highest security) parameters are selected
510# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200511run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200512 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200513 "$P_CLI" \
514 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200515 -s "Protocol is TLSv1.2" \
516 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
517 -s "client hello v3, signature_algorithm ext: 6" \
518 -s "ECDHE curve: secp521r1" \
519 -S "error" \
520 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200521
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100522# Test for SSLv2 ClientHello
523
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200524requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200525run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100526 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100527 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100528 0 \
529 -S "parse client hello v2" \
530 -S "ssl_handshake returned"
531
532# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200533requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200534run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200535 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100536 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100537 0 \
538 -s "parse client hello v2" \
539 -S "ssl_handshake returned"
540
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100541# Tests for Truncated HMAC extension
542
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200543run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200544 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100545 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100546 0 \
547 -s "dumping 'computed mac' (20 bytes)"
548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200549run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200550 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100551 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100552 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100553 -s "dumping 'computed mac' (10 bytes)"
554
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100555# Tests for Session Tickets
556
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200557run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200558 "$P_SRV debug_level=3 tickets=1" \
559 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100560 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100561 -c "client hello, adding session ticket extension" \
562 -s "found session ticket extension" \
563 -s "server hello, adding session ticket extension" \
564 -c "found session_ticket extension" \
565 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100566 -S "session successfully restored from cache" \
567 -s "session successfully restored from ticket" \
568 -s "a session has been resumed" \
569 -c "a session has been resumed"
570
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200571run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200572 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
573 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100574 0 \
575 -c "client hello, adding session ticket extension" \
576 -s "found session ticket extension" \
577 -s "server hello, adding session ticket extension" \
578 -c "found session_ticket extension" \
579 -c "parse new session ticket" \
580 -S "session successfully restored from cache" \
581 -s "session successfully restored from ticket" \
582 -s "a session has been resumed" \
583 -c "a session has been resumed"
584
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200585run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200586 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
587 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100588 0 \
589 -c "client hello, adding session ticket extension" \
590 -s "found session ticket extension" \
591 -s "server hello, adding session ticket extension" \
592 -c "found session_ticket extension" \
593 -c "parse new session ticket" \
594 -S "session successfully restored from cache" \
595 -S "session successfully restored from ticket" \
596 -S "a session has been resumed" \
597 -C "a session has been resumed"
598
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200599run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100600 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200601 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100602 0 \
603 -c "client hello, adding session ticket extension" \
604 -c "found session_ticket extension" \
605 -c "parse new session ticket" \
606 -c "a session has been resumed"
607
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200608run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200609 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200610 "( $O_CLI -sess_out $SESSION; \
611 $O_CLI -sess_in $SESSION; \
612 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100613 0 \
614 -s "found session ticket extension" \
615 -s "server hello, adding session ticket extension" \
616 -S "session successfully restored from cache" \
617 -s "session successfully restored from ticket" \
618 -s "a session has been resumed"
619
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100620# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100621
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200622run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200623 "$P_SRV debug_level=3 tickets=0" \
624 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100625 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100626 -c "client hello, adding session ticket extension" \
627 -s "found session ticket extension" \
628 -S "server hello, adding session ticket extension" \
629 -C "found session_ticket extension" \
630 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100631 -s "session successfully restored from cache" \
632 -S "session successfully restored from ticket" \
633 -s "a session has been resumed" \
634 -c "a session has been resumed"
635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200636run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200637 "$P_SRV debug_level=3 tickets=1" \
638 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100639 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100640 -C "client hello, adding session ticket extension" \
641 -S "found session ticket extension" \
642 -S "server hello, adding session ticket extension" \
643 -C "found session_ticket extension" \
644 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100645 -s "session successfully restored from cache" \
646 -S "session successfully restored from ticket" \
647 -s "a session has been resumed" \
648 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100649
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200650run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200651 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
652 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100653 0 \
654 -S "session successfully restored from cache" \
655 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100656 -S "a session has been resumed" \
657 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100658
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200659run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200660 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
661 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100662 0 \
663 -s "session successfully restored from cache" \
664 -S "session successfully restored from ticket" \
665 -s "a session has been resumed" \
666 -c "a session has been resumed"
667
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200668run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200669 "$P_SRV debug_level=3 tickets=0" \
670 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100671 0 \
672 -s "session successfully restored from cache" \
673 -S "session successfully restored from ticket" \
674 -s "a session has been resumed" \
675 -c "a session has been resumed"
676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200677run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200678 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
679 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100680 0 \
681 -S "session successfully restored from cache" \
682 -S "session successfully restored from ticket" \
683 -S "a session has been resumed" \
684 -C "a session has been resumed"
685
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200686run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200687 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
688 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100689 0 \
690 -s "session successfully restored from cache" \
691 -S "session successfully restored from ticket" \
692 -s "a session has been resumed" \
693 -c "a session has been resumed"
694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200695run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200696 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200697 "( $O_CLI -sess_out $SESSION; \
698 $O_CLI -sess_in $SESSION; \
699 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100700 0 \
701 -s "found session ticket extension" \
702 -S "server hello, adding session ticket extension" \
703 -s "session successfully restored from cache" \
704 -S "session successfully restored from ticket" \
705 -s "a session has been resumed"
706
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200707run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100708 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200709 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100710 0 \
711 -C "found session_ticket extension" \
712 -C "parse new session ticket" \
713 -c "a session has been resumed"
714
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100715# Tests for Max Fragment Length extension
716
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200717run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200718 "$P_SRV debug_level=3" \
719 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100720 0 \
721 -C "client hello, adding max_fragment_length extension" \
722 -S "found max fragment length extension" \
723 -S "server hello, max_fragment_length extension" \
724 -C "found max_fragment_length extension"
725
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200726run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200727 "$P_SRV debug_level=3" \
728 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100729 0 \
730 -c "client hello, adding max_fragment_length extension" \
731 -s "found max fragment length extension" \
732 -s "server hello, max_fragment_length extension" \
733 -c "found max_fragment_length extension"
734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200735run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200736 "$P_SRV debug_level=3 max_frag_len=4096" \
737 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100738 0 \
739 -C "client hello, adding max_fragment_length extension" \
740 -S "found max fragment length extension" \
741 -S "server hello, max_fragment_length extension" \
742 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100743
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200744requires_gnutls
745run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200746 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200747 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200748 0 \
749 -c "client hello, adding max_fragment_length extension" \
750 -c "found max_fragment_length extension"
751
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +0200752run_test "Max fragment length: client, message just fits" \
753 "$P_SRV debug_level=3" \
754 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
755 0 \
756 -c "client hello, adding max_fragment_length extension" \
757 -s "found max fragment length extension" \
758 -s "server hello, max_fragment_length extension" \
759 -c "found max_fragment_length extension" \
760 -c "2048 bytes written in 1 fragments" \
761 -s "2048 bytes read"
762
763run_test "Max fragment length: client, larger message" \
764 "$P_SRV debug_level=3" \
765 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
766 0 \
767 -c "client hello, adding max_fragment_length extension" \
768 -s "found max fragment length extension" \
769 -s "server hello, max_fragment_length extension" \
770 -c "found max_fragment_length extension" \
771 -c "2345 bytes written in 2 fragments" \
772 -s "2048 bytes read" \
773 -s "297 bytes read"
774
775run_test "Max fragment length: client, larger message" \
776 "$P_SRV debug_level=3 dtls=1" \
777 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
778 1 \
779 -c "client hello, adding max_fragment_length extension" \
780 -s "found max fragment length extension" \
781 -s "server hello, max_fragment_length extension" \
782 -c "found max_fragment_length extension" \
783 -c "fragment larger than.*maximum"
784
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100785# Tests for renegotiation
786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200787run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200788 "$P_SRV debug_level=3 exchanges=2" \
789 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100790 0 \
791 -C "client hello, adding renegotiation extension" \
792 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
793 -S "found renegotiation extension" \
794 -s "server hello, secure renegotiation extension" \
795 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100796 -C "=> renegotiate" \
797 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100798 -S "write hello request"
799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200800run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200801 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
802 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100803 0 \
804 -c "client hello, adding renegotiation extension" \
805 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
806 -s "found renegotiation extension" \
807 -s "server hello, secure renegotiation extension" \
808 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100809 -c "=> renegotiate" \
810 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100811 -S "write hello request"
812
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200813run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200814 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
815 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100816 0 \
817 -c "client hello, adding renegotiation extension" \
818 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
819 -s "found renegotiation extension" \
820 -s "server hello, secure renegotiation extension" \
821 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100822 -c "=> renegotiate" \
823 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100824 -s "write hello request"
825
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200826run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200827 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
828 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100829 0 \
830 -c "client hello, adding renegotiation extension" \
831 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
832 -s "found renegotiation extension" \
833 -s "server hello, secure renegotiation extension" \
834 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100835 -c "=> renegotiate" \
836 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100837 -s "write hello request"
838
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200839run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200840 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
841 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100842 1 \
843 -c "client hello, adding renegotiation extension" \
844 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
845 -S "found renegotiation extension" \
846 -s "server hello, secure renegotiation extension" \
847 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100848 -c "=> renegotiate" \
849 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200850 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200851 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200852 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100853
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200854run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200855 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
856 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100857 0 \
858 -C "client hello, adding renegotiation extension" \
859 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
860 -S "found renegotiation extension" \
861 -s "server hello, secure renegotiation extension" \
862 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100863 -C "=> renegotiate" \
864 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100865 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200866 -S "SSL - An unexpected message was received from our peer" \
867 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100868
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200869run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200870 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200871 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200872 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200873 0 \
874 -C "client hello, adding renegotiation extension" \
875 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
876 -S "found renegotiation extension" \
877 -s "server hello, secure renegotiation extension" \
878 -c "found renegotiation extension" \
879 -C "=> renegotiate" \
880 -S "=> renegotiate" \
881 -s "write hello request" \
882 -S "SSL - An unexpected message was received from our peer" \
883 -S "failed"
884
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200885# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200886run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200887 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200888 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200889 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200890 0 \
891 -C "client hello, adding renegotiation extension" \
892 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
893 -S "found renegotiation extension" \
894 -s "server hello, secure renegotiation extension" \
895 -c "found renegotiation extension" \
896 -C "=> renegotiate" \
897 -S "=> renegotiate" \
898 -s "write hello request" \
899 -S "SSL - An unexpected message was received from our peer" \
900 -S "failed"
901
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200902run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200903 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200904 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200905 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200906 0 \
907 -C "client hello, adding renegotiation extension" \
908 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
909 -S "found renegotiation extension" \
910 -s "server hello, secure renegotiation extension" \
911 -c "found renegotiation extension" \
912 -C "=> renegotiate" \
913 -S "=> renegotiate" \
914 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200915 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200916
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200917run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200918 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200919 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200920 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200921 0 \
922 -c "client hello, adding renegotiation extension" \
923 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
924 -s "found renegotiation extension" \
925 -s "server hello, secure renegotiation extension" \
926 -c "found renegotiation extension" \
927 -c "=> renegotiate" \
928 -s "=> renegotiate" \
929 -s "write hello request" \
930 -S "SSL - An unexpected message was received from our peer" \
931 -S "failed"
932
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200933run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200934 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
935 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200936 0 \
937 -c "client hello, adding renegotiation extension" \
938 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
939 -s "found renegotiation extension" \
940 -s "server hello, secure renegotiation extension" \
941 -c "found renegotiation extension" \
942 -c "=> renegotiate" \
943 -s "=> renegotiate" \
944 -S "write hello request"
945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200946run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200947 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
948 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200949 0 \
950 -c "client hello, adding renegotiation extension" \
951 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
952 -s "found renegotiation extension" \
953 -s "server hello, secure renegotiation extension" \
954 -c "found renegotiation extension" \
955 -c "=> renegotiate" \
956 -s "=> renegotiate" \
957 -s "write hello request"
958
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200959run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +0200960 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200961 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200962 0 \
963 -c "client hello, adding renegotiation extension" \
964 -c "found renegotiation extension" \
965 -c "=> renegotiate" \
966 -C "ssl_handshake returned" \
967 -C "error" \
968 -c "HTTP/1.0 200 [Oo][Kk]"
969
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200970run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200971 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200972 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200973 0 \
974 -c "client hello, adding renegotiation extension" \
975 -c "found renegotiation extension" \
976 -c "=> renegotiate" \
977 -C "ssl_handshake returned" \
978 -C "error" \
979 -c "HTTP/1.0 200 [Oo][Kk]"
980
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +0200981run_test "Renegotiation: DTLS, client-initiated" \
982 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
983 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
984 0 \
985 -c "client hello, adding renegotiation extension" \
986 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
987 -s "found renegotiation extension" \
988 -s "server hello, secure renegotiation extension" \
989 -c "found renegotiation extension" \
990 -c "=> renegotiate" \
991 -s "=> renegotiate" \
992 -S "write hello request"
993
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +0200994run_test "Renegotiation: DTLS, server-initiated" \
995 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +0200996 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
997 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +0200998 0 \
999 -c "client hello, adding renegotiation extension" \
1000 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1001 -s "found renegotiation extension" \
1002 -s "server hello, secure renegotiation extension" \
1003 -c "found renegotiation extension" \
1004 -c "=> renegotiate" \
1005 -s "=> renegotiate" \
1006 -s "write hello request"
1007
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001008run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1009 "$G_SRV -u --mtu 4096" \
1010 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1011 0 \
1012 -c "client hello, adding renegotiation extension" \
1013 -c "found renegotiation extension" \
1014 -c "=> renegotiate" \
1015 -C "ssl_handshake returned" \
1016 -C "error" \
1017 -s "Extra-header:"
1018
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001019# Tests for auth_mode
1020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001021run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001022 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001023 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001024 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001025 1 \
1026 -c "x509_verify_cert() returned" \
1027 -c "! self-signed or not signed by a trusted CA" \
1028 -c "! ssl_handshake returned" \
1029 -c "X509 - Certificate verification failed"
1030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001031run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001032 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001033 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001034 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001035 0 \
1036 -c "x509_verify_cert() returned" \
1037 -c "! self-signed or not signed by a trusted CA" \
1038 -C "! ssl_handshake returned" \
1039 -C "X509 - Certificate verification failed"
1040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001041run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001042 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001043 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001044 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001045 0 \
1046 -C "x509_verify_cert() returned" \
1047 -C "! self-signed or not signed by a trusted CA" \
1048 -C "! ssl_handshake returned" \
1049 -C "X509 - Certificate verification failed"
1050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001051run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001052 "$P_SRV debug_level=3 auth_mode=required" \
1053 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001054 key_file=data_files/server5.key" \
1055 1 \
1056 -S "skip write certificate request" \
1057 -C "skip parse certificate request" \
1058 -c "got a certificate request" \
1059 -C "skip write certificate" \
1060 -C "skip write certificate verify" \
1061 -S "skip parse certificate verify" \
1062 -s "x509_verify_cert() returned" \
1063 -S "! self-signed or not signed by a trusted CA" \
1064 -s "! ssl_handshake returned" \
1065 -c "! ssl_handshake returned" \
1066 -s "X509 - Certificate verification failed"
1067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001068run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001069 "$P_SRV debug_level=3 auth_mode=optional" \
1070 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001071 key_file=data_files/server5.key" \
1072 0 \
1073 -S "skip write certificate request" \
1074 -C "skip parse certificate request" \
1075 -c "got a certificate request" \
1076 -C "skip write certificate" \
1077 -C "skip write certificate verify" \
1078 -S "skip parse certificate verify" \
1079 -s "x509_verify_cert() returned" \
1080 -s "! self-signed or not signed by a trusted CA" \
1081 -S "! ssl_handshake returned" \
1082 -C "! ssl_handshake returned" \
1083 -S "X509 - Certificate verification failed"
1084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001085run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001086 "$P_SRV debug_level=3 auth_mode=none" \
1087 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001088 key_file=data_files/server5.key" \
1089 0 \
1090 -s "skip write certificate request" \
1091 -C "skip parse certificate request" \
1092 -c "got no certificate request" \
1093 -c "skip write certificate" \
1094 -c "skip write certificate verify" \
1095 -s "skip parse certificate verify" \
1096 -S "x509_verify_cert() returned" \
1097 -S "! self-signed or not signed by a trusted CA" \
1098 -S "! ssl_handshake returned" \
1099 -C "! ssl_handshake returned" \
1100 -S "X509 - Certificate verification failed"
1101
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001102run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001103 "$P_SRV debug_level=3 auth_mode=optional" \
1104 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001105 0 \
1106 -S "skip write certificate request" \
1107 -C "skip parse certificate request" \
1108 -c "got a certificate request" \
1109 -C "skip write certificate$" \
1110 -C "got no certificate to send" \
1111 -S "SSLv3 client has no certificate" \
1112 -c "skip write certificate verify" \
1113 -s "skip parse certificate verify" \
1114 -s "! no client certificate sent" \
1115 -S "! ssl_handshake returned" \
1116 -C "! ssl_handshake returned" \
1117 -S "X509 - Certificate verification failed"
1118
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001119run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001120 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001121 "$O_CLI" \
1122 0 \
1123 -S "skip write certificate request" \
1124 -s "skip parse certificate verify" \
1125 -s "! no client certificate sent" \
1126 -S "! ssl_handshake returned" \
1127 -S "X509 - Certificate verification failed"
1128
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001129run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001130 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001131 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001132 0 \
1133 -C "skip parse certificate request" \
1134 -c "got a certificate request" \
1135 -C "skip write certificate$" \
1136 -c "skip write certificate verify" \
1137 -C "! ssl_handshake returned"
1138
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001139run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001140 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1141 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001142 0 \
1143 -S "skip write certificate request" \
1144 -C "skip parse certificate request" \
1145 -c "got a certificate request" \
1146 -C "skip write certificate$" \
1147 -c "skip write certificate verify" \
1148 -c "got no certificate to send" \
1149 -s "SSLv3 client has no certificate" \
1150 -s "skip parse certificate verify" \
1151 -s "! no client certificate sent" \
1152 -S "! ssl_handshake returned" \
1153 -C "! ssl_handshake returned" \
1154 -S "X509 - Certificate verification failed"
1155
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001156# tests for SNI
1157
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001158run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001159 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001160 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001161 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001162 0 \
1163 -S "parse ServerName extension" \
1164 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1165 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001167run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001168 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001169 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001170 sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001171 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001172 0 \
1173 -s "parse ServerName extension" \
1174 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1175 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001177run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001178 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001179 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001180 sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001181 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001182 0 \
1183 -s "parse ServerName extension" \
1184 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001185 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001186
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001187run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001188 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001189 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001190 sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001191 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001192 1 \
1193 -s "parse ServerName extension" \
1194 -s "ssl_sni_wrapper() returned" \
1195 -s "ssl_handshake returned" \
1196 -c "ssl_handshake returned" \
1197 -c "SSL - A fatal alert message was received from our peer"
1198
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001199# Tests for non-blocking I/O: exercise a variety of handshake flows
1200
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001201run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001202 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1203 "$P_CLI nbio=2 tickets=0" \
1204 0 \
1205 -S "ssl_handshake returned" \
1206 -C "ssl_handshake returned" \
1207 -c "Read from server: .* bytes read"
1208
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001209run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001210 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1211 "$P_CLI nbio=2 tickets=0" \
1212 0 \
1213 -S "ssl_handshake returned" \
1214 -C "ssl_handshake returned" \
1215 -c "Read from server: .* bytes read"
1216
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001217run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001218 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1219 "$P_CLI nbio=2 tickets=1" \
1220 0 \
1221 -S "ssl_handshake returned" \
1222 -C "ssl_handshake returned" \
1223 -c "Read from server: .* bytes read"
1224
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001225run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001226 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1227 "$P_CLI nbio=2 tickets=1" \
1228 0 \
1229 -S "ssl_handshake returned" \
1230 -C "ssl_handshake returned" \
1231 -c "Read from server: .* bytes read"
1232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001233run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001234 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1235 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1236 0 \
1237 -S "ssl_handshake returned" \
1238 -C "ssl_handshake returned" \
1239 -c "Read from server: .* bytes read"
1240
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001241run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001242 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1243 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1244 0 \
1245 -S "ssl_handshake returned" \
1246 -C "ssl_handshake returned" \
1247 -c "Read from server: .* bytes read"
1248
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001249run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001250 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1251 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1252 0 \
1253 -S "ssl_handshake returned" \
1254 -C "ssl_handshake returned" \
1255 -c "Read from server: .* bytes read"
1256
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001257# Tests for version negotiation
1258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001259run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001260 "$P_SRV" \
1261 "$P_CLI" \
1262 0 \
1263 -S "ssl_handshake returned" \
1264 -C "ssl_handshake returned" \
1265 -s "Protocol is TLSv1.2" \
1266 -c "Protocol is TLSv1.2"
1267
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001268run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001269 "$P_SRV" \
1270 "$P_CLI max_version=tls1_1" \
1271 0 \
1272 -S "ssl_handshake returned" \
1273 -C "ssl_handshake returned" \
1274 -s "Protocol is TLSv1.1" \
1275 -c "Protocol is TLSv1.1"
1276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001277run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001278 "$P_SRV max_version=tls1_1" \
1279 "$P_CLI" \
1280 0 \
1281 -S "ssl_handshake returned" \
1282 -C "ssl_handshake returned" \
1283 -s "Protocol is TLSv1.1" \
1284 -c "Protocol is TLSv1.1"
1285
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001286run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001287 "$P_SRV max_version=tls1_1" \
1288 "$P_CLI max_version=tls1_1" \
1289 0 \
1290 -S "ssl_handshake returned" \
1291 -C "ssl_handshake returned" \
1292 -s "Protocol is TLSv1.1" \
1293 -c "Protocol is TLSv1.1"
1294
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001295run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001296 "$P_SRV min_version=tls1_1" \
1297 "$P_CLI max_version=tls1_1" \
1298 0 \
1299 -S "ssl_handshake returned" \
1300 -C "ssl_handshake returned" \
1301 -s "Protocol is TLSv1.1" \
1302 -c "Protocol is TLSv1.1"
1303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001304run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001305 "$P_SRV max_version=tls1_1" \
1306 "$P_CLI min_version=tls1_1" \
1307 0 \
1308 -S "ssl_handshake returned" \
1309 -C "ssl_handshake returned" \
1310 -s "Protocol is TLSv1.1" \
1311 -c "Protocol is TLSv1.1"
1312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001313run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001314 "$P_SRV max_version=tls1_1" \
1315 "$P_CLI min_version=tls1_2" \
1316 1 \
1317 -s "ssl_handshake returned" \
1318 -c "ssl_handshake returned" \
1319 -c "SSL - Handshake protocol not within min/max boundaries"
1320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001321run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001322 "$P_SRV min_version=tls1_2" \
1323 "$P_CLI max_version=tls1_1" \
1324 1 \
1325 -s "ssl_handshake returned" \
1326 -c "ssl_handshake returned" \
1327 -s "SSL - Handshake protocol not within min/max boundaries"
1328
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001329# Tests for ALPN extension
1330
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001331if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1332
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001333run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001334 "$P_SRV debug_level=3" \
1335 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001336 0 \
1337 -C "client hello, adding alpn extension" \
1338 -S "found alpn extension" \
1339 -C "got an alert message, type: \\[2:120]" \
1340 -S "server hello, adding alpn extension" \
1341 -C "found alpn extension " \
1342 -C "Application Layer Protocol is" \
1343 -S "Application Layer Protocol is"
1344
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001345run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001346 "$P_SRV debug_level=3" \
1347 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001348 0 \
1349 -c "client hello, adding alpn extension" \
1350 -s "found alpn extension" \
1351 -C "got an alert message, type: \\[2:120]" \
1352 -S "server hello, adding alpn extension" \
1353 -C "found alpn extension " \
1354 -c "Application Layer Protocol is (none)" \
1355 -S "Application Layer Protocol is"
1356
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001357run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001358 "$P_SRV debug_level=3 alpn=abc,1234" \
1359 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001360 0 \
1361 -C "client hello, adding alpn extension" \
1362 -S "found alpn extension" \
1363 -C "got an alert message, type: \\[2:120]" \
1364 -S "server hello, adding alpn extension" \
1365 -C "found alpn extension " \
1366 -C "Application Layer Protocol is" \
1367 -s "Application Layer Protocol is (none)"
1368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001369run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001370 "$P_SRV debug_level=3 alpn=abc,1234" \
1371 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001372 0 \
1373 -c "client hello, adding alpn extension" \
1374 -s "found alpn extension" \
1375 -C "got an alert message, type: \\[2:120]" \
1376 -s "server hello, adding alpn extension" \
1377 -c "found alpn extension" \
1378 -c "Application Layer Protocol is abc" \
1379 -s "Application Layer Protocol is abc"
1380
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001381run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001382 "$P_SRV debug_level=3 alpn=abc,1234" \
1383 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001384 0 \
1385 -c "client hello, adding alpn extension" \
1386 -s "found alpn extension" \
1387 -C "got an alert message, type: \\[2:120]" \
1388 -s "server hello, adding alpn extension" \
1389 -c "found alpn extension" \
1390 -c "Application Layer Protocol is abc" \
1391 -s "Application Layer Protocol is abc"
1392
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001393run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001394 "$P_SRV debug_level=3 alpn=abc,1234" \
1395 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001396 0 \
1397 -c "client hello, adding alpn extension" \
1398 -s "found alpn extension" \
1399 -C "got an alert message, type: \\[2:120]" \
1400 -s "server hello, adding alpn extension" \
1401 -c "found alpn extension" \
1402 -c "Application Layer Protocol is 1234" \
1403 -s "Application Layer Protocol is 1234"
1404
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001405run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001406 "$P_SRV debug_level=3 alpn=abc,123" \
1407 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001408 1 \
1409 -c "client hello, adding alpn extension" \
1410 -s "found alpn extension" \
1411 -c "got an alert message, type: \\[2:120]" \
1412 -S "server hello, adding alpn extension" \
1413 -C "found alpn extension" \
1414 -C "Application Layer Protocol is 1234" \
1415 -S "Application Layer Protocol is 1234"
1416
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001417fi
1418
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001419# Tests for keyUsage in leaf certificates, part 1:
1420# server-side certificate/suite selection
1421
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001422run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001423 "$P_SRV key_file=data_files/server2.key \
1424 crt_file=data_files/server2.ku-ds.crt" \
1425 "$P_CLI" \
1426 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001427 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001428
1429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001430run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001431 "$P_SRV key_file=data_files/server2.key \
1432 crt_file=data_files/server2.ku-ke.crt" \
1433 "$P_CLI" \
1434 0 \
1435 -c "Ciphersuite is TLS-RSA-WITH-"
1436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001437run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001438 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001439 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001440 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001441 1 \
1442 -C "Ciphersuite is "
1443
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001444run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001445 "$P_SRV key_file=data_files/server5.key \
1446 crt_file=data_files/server5.ku-ds.crt" \
1447 "$P_CLI" \
1448 0 \
1449 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1450
1451
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001452run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001453 "$P_SRV key_file=data_files/server5.key \
1454 crt_file=data_files/server5.ku-ka.crt" \
1455 "$P_CLI" \
1456 0 \
1457 -c "Ciphersuite is TLS-ECDH-"
1458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001459run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001460 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001461 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001462 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001463 1 \
1464 -C "Ciphersuite is "
1465
1466# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001467# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001468
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001469run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001470 "$O_SRV -key data_files/server2.key \
1471 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001472 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001473 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1474 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001475 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001476 -C "Processing of the Certificate handshake message failed" \
1477 -c "Ciphersuite is TLS-"
1478
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001479run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001480 "$O_SRV -key data_files/server2.key \
1481 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001482 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001483 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1484 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001485 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001486 -C "Processing of the Certificate handshake message failed" \
1487 -c "Ciphersuite is TLS-"
1488
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001489run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001490 "$O_SRV -key data_files/server2.key \
1491 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001492 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001493 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1494 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001495 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001496 -C "Processing of the Certificate handshake message failed" \
1497 -c "Ciphersuite is TLS-"
1498
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001499run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001500 "$O_SRV -key data_files/server2.key \
1501 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001502 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001503 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1504 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001505 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001506 -c "Processing of the Certificate handshake message failed" \
1507 -C "Ciphersuite is TLS-"
1508
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001509run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001510 "$O_SRV -key data_files/server2.key \
1511 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001512 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001513 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1514 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001515 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001516 -C "Processing of the Certificate handshake message failed" \
1517 -c "Ciphersuite is TLS-"
1518
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001519run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001520 "$O_SRV -key data_files/server2.key \
1521 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001522 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001523 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1524 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001525 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001526 -c "Processing of the Certificate handshake message failed" \
1527 -C "Ciphersuite is TLS-"
1528
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001529# Tests for keyUsage in leaf certificates, part 3:
1530# server-side checking of client cert
1531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001532run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001533 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001534 "$O_CLI -key data_files/server2.key \
1535 -cert data_files/server2.ku-ds.crt" \
1536 0 \
1537 -S "bad certificate (usage extensions)" \
1538 -S "Processing of the Certificate handshake message failed"
1539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001540run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001541 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001542 "$O_CLI -key data_files/server2.key \
1543 -cert data_files/server2.ku-ke.crt" \
1544 0 \
1545 -s "bad certificate (usage extensions)" \
1546 -S "Processing of the Certificate handshake message failed"
1547
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001548run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001549 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001550 "$O_CLI -key data_files/server2.key \
1551 -cert data_files/server2.ku-ke.crt" \
1552 1 \
1553 -s "bad certificate (usage extensions)" \
1554 -s "Processing of the Certificate handshake message failed"
1555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001556run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001557 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001558 "$O_CLI -key data_files/server5.key \
1559 -cert data_files/server5.ku-ds.crt" \
1560 0 \
1561 -S "bad certificate (usage extensions)" \
1562 -S "Processing of the Certificate handshake message failed"
1563
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001564run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001565 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001566 "$O_CLI -key data_files/server5.key \
1567 -cert data_files/server5.ku-ka.crt" \
1568 0 \
1569 -s "bad certificate (usage extensions)" \
1570 -S "Processing of the Certificate handshake message failed"
1571
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001572# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001574run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001575 "$P_SRV key_file=data_files/server5.key \
1576 crt_file=data_files/server5.eku-srv.crt" \
1577 "$P_CLI" \
1578 0
1579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001580run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001581 "$P_SRV key_file=data_files/server5.key \
1582 crt_file=data_files/server5.eku-srv.crt" \
1583 "$P_CLI" \
1584 0
1585
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001586run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001587 "$P_SRV key_file=data_files/server5.key \
1588 crt_file=data_files/server5.eku-cs_any.crt" \
1589 "$P_CLI" \
1590 0
1591
1592# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001593run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001594 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1595 crt_file=data_files/server5.eku-cli.crt" \
1596 "$P_CLI psk=badbad" \
1597 1
1598
1599# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001601run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001602 "$O_SRV -key data_files/server5.key \
1603 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001604 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001605 0 \
1606 -C "bad certificate (usage extensions)" \
1607 -C "Processing of the Certificate handshake message failed" \
1608 -c "Ciphersuite is TLS-"
1609
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001610run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001611 "$O_SRV -key data_files/server5.key \
1612 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001613 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001614 0 \
1615 -C "bad certificate (usage extensions)" \
1616 -C "Processing of the Certificate handshake message failed" \
1617 -c "Ciphersuite is TLS-"
1618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001619run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001620 "$O_SRV -key data_files/server5.key \
1621 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001622 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001623 0 \
1624 -C "bad certificate (usage extensions)" \
1625 -C "Processing of the Certificate handshake message failed" \
1626 -c "Ciphersuite is TLS-"
1627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001628run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001629 "$O_SRV -key data_files/server5.key \
1630 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001631 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001632 1 \
1633 -c "bad certificate (usage extensions)" \
1634 -c "Processing of the Certificate handshake message failed" \
1635 -C "Ciphersuite is TLS-"
1636
1637# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1638
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001639run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001640 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001641 "$O_CLI -key data_files/server5.key \
1642 -cert data_files/server5.eku-cli.crt" \
1643 0 \
1644 -S "bad certificate (usage extensions)" \
1645 -S "Processing of the Certificate handshake message failed"
1646
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001647run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001648 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001649 "$O_CLI -key data_files/server5.key \
1650 -cert data_files/server5.eku-srv_cli.crt" \
1651 0 \
1652 -S "bad certificate (usage extensions)" \
1653 -S "Processing of the Certificate handshake message failed"
1654
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001655run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001656 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001657 "$O_CLI -key data_files/server5.key \
1658 -cert data_files/server5.eku-cs_any.crt" \
1659 0 \
1660 -S "bad certificate (usage extensions)" \
1661 -S "Processing of the Certificate handshake message failed"
1662
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001663run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001664 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001665 "$O_CLI -key data_files/server5.key \
1666 -cert data_files/server5.eku-cs.crt" \
1667 0 \
1668 -s "bad certificate (usage extensions)" \
1669 -S "Processing of the Certificate handshake message failed"
1670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001671run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001672 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001673 "$O_CLI -key data_files/server5.key \
1674 -cert data_files/server5.eku-cs.crt" \
1675 1 \
1676 -s "bad certificate (usage extensions)" \
1677 -s "Processing of the Certificate handshake message failed"
1678
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001679# Tests for DHM parameters loading
1680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001681run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001682 "$P_SRV" \
1683 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1684 debug_level=3" \
1685 0 \
1686 -c "value of 'DHM: P ' (2048 bits)" \
1687 -c "value of 'DHM: G ' (2048 bits)"
1688
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001689run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001690 "$P_SRV dhm_file=data_files/dhparams.pem" \
1691 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1692 debug_level=3" \
1693 0 \
1694 -c "value of 'DHM: P ' (1024 bits)" \
1695 -c "value of 'DHM: G ' (2 bits)"
1696
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001697# Tests for PSK callback
1698
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001699run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001700 "$P_SRV psk=abc123 psk_identity=foo" \
1701 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1702 psk_identity=foo psk=abc123" \
1703 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001704 -S "SSL - The server has no ciphersuites in common" \
1705 -S "SSL - Unknown identity received" \
1706 -S "SSL - Verification of the message MAC failed"
1707
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001708run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001709 "$P_SRV" \
1710 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1711 psk_identity=foo psk=abc123" \
1712 1 \
1713 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001714 -S "SSL - Unknown identity received" \
1715 -S "SSL - Verification of the message MAC failed"
1716
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001717run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001718 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1719 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1720 psk_identity=foo psk=abc123" \
1721 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001722 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001723 -s "SSL - Unknown identity received" \
1724 -S "SSL - Verification of the message MAC failed"
1725
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001726run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001727 "$P_SRV psk_list=abc,dead,def,beef" \
1728 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1729 psk_identity=abc psk=dead" \
1730 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001731 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001732 -S "SSL - Unknown identity received" \
1733 -S "SSL - Verification of the message MAC failed"
1734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001735run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001736 "$P_SRV psk_list=abc,dead,def,beef" \
1737 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1738 psk_identity=def psk=beef" \
1739 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001740 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001741 -S "SSL - Unknown identity received" \
1742 -S "SSL - Verification of the message MAC failed"
1743
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001744run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001745 "$P_SRV psk_list=abc,dead,def,beef" \
1746 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1747 psk_identity=ghi psk=beef" \
1748 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001749 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001750 -s "SSL - Unknown identity received" \
1751 -S "SSL - Verification of the message MAC failed"
1752
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001753run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001754 "$P_SRV psk_list=abc,dead,def,beef" \
1755 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1756 psk_identity=abc psk=beef" \
1757 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001758 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001759 -S "SSL - Unknown identity received" \
1760 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001761
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001762# Tests for ciphersuites per version
1763
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001764run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001765 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
1766 "$P_CLI force_version=ssl3" \
1767 0 \
1768 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1769
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001770run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001771 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
1772 "$P_CLI force_version=tls1" \
1773 0 \
1774 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001776run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001777 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
1778 "$P_CLI force_version=tls1_1" \
1779 0 \
1780 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1781
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001782run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001783 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
1784 "$P_CLI force_version=tls1_2" \
1785 0 \
1786 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1787
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001788# Tests for ssl_get_bytes_avail()
1789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001790run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001791 "$P_SRV" \
1792 "$P_CLI request_size=100" \
1793 0 \
1794 -s "Read from client: 100 bytes read$"
1795
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001796run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001797 "$P_SRV" \
1798 "$P_CLI request_size=500" \
1799 0 \
1800 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001801
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001802# Tests for small packets
1803
1804run_test "Small packet SSLv3 BlockCipher" \
1805 "$P_SRV" \
1806 "$P_CLI request_size=1 force_version=ssl3 \
1807 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1808 0 \
1809 -s "Read from client: 1 bytes read"
1810
1811run_test "Small packet SSLv3 StreamCipher" \
1812 "$P_SRV" \
1813 "$P_CLI request_size=1 force_version=ssl3 \
1814 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1815 0 \
1816 -s "Read from client: 1 bytes read"
1817
1818run_test "Small packet TLS 1.0 BlockCipher" \
1819 "$P_SRV" \
1820 "$P_CLI request_size=1 force_version=tls1 \
1821 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1822 0 \
1823 -s "Read from client: 1 bytes read"
1824
1825run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1826 "$P_SRV" \
1827 "$P_CLI request_size=1 force_version=tls1 \
1828 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1829 trunc_hmac=1" \
1830 0 \
1831 -s "Read from client: 1 bytes read"
1832
1833run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1834 "$P_SRV" \
1835 "$P_CLI request_size=1 force_version=tls1 \
1836 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1837 trunc_hmac=1" \
1838 0 \
1839 -s "Read from client: 1 bytes read"
1840
1841run_test "Small packet TLS 1.1 BlockCipher" \
1842 "$P_SRV" \
1843 "$P_CLI request_size=1 force_version=tls1_1 \
1844 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1845 0 \
1846 -s "Read from client: 1 bytes read"
1847
1848run_test "Small packet TLS 1.1 StreamCipher" \
1849 "$P_SRV" \
1850 "$P_CLI request_size=1 force_version=tls1_1 \
1851 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1852 0 \
1853 -s "Read from client: 1 bytes read"
1854
1855run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1856 "$P_SRV" \
1857 "$P_CLI request_size=1 force_version=tls1_1 \
1858 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1859 trunc_hmac=1" \
1860 0 \
1861 -s "Read from client: 1 bytes read"
1862
1863run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1864 "$P_SRV" \
1865 "$P_CLI request_size=1 force_version=tls1_1 \
1866 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1867 trunc_hmac=1" \
1868 0 \
1869 -s "Read from client: 1 bytes read"
1870
1871run_test "Small packet TLS 1.2 BlockCipher" \
1872 "$P_SRV" \
1873 "$P_CLI request_size=1 force_version=tls1_2 \
1874 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1875 0 \
1876 -s "Read from client: 1 bytes read"
1877
1878run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1879 "$P_SRV" \
1880 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1881 0 \
1882 -s "Read from client: 1 bytes read"
1883
1884run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1885 "$P_SRV" \
1886 "$P_CLI request_size=1 force_version=tls1_2 \
1887 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1888 trunc_hmac=1" \
1889 0 \
1890 -s "Read from client: 1 bytes read"
1891
1892run_test "Small packet TLS 1.2 StreamCipher" \
1893 "$P_SRV" \
1894 "$P_CLI request_size=1 force_version=tls1_2 \
1895 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1896 0 \
1897 -s "Read from client: 1 bytes read"
1898
1899run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1900 "$P_SRV" \
1901 "$P_CLI request_size=1 force_version=tls1_2 \
1902 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1903 trunc_hmac=1" \
1904 0 \
1905 -s "Read from client: 1 bytes read"
1906
1907run_test "Small packet TLS 1.2 AEAD" \
1908 "$P_SRV" \
1909 "$P_CLI request_size=1 force_version=tls1_2 \
1910 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1911 0 \
1912 -s "Read from client: 1 bytes read"
1913
1914run_test "Small packet TLS 1.2 AEAD shorter tag" \
1915 "$P_SRV" \
1916 "$P_CLI request_size=1 force_version=tls1_2 \
1917 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1918 0 \
1919 -s "Read from client: 1 bytes read"
1920
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001921# Test for large packets
1922
1923run_test "Large packet SSLv3 BlockCipher" \
1924 "$P_SRV" \
1925 "$P_CLI request_size=16384 force_version=ssl3 \
1926 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1927 0 \
1928 -s "Read from client: 16384 bytes read"
1929
1930run_test "Large packet SSLv3 StreamCipher" \
1931 "$P_SRV" \
1932 "$P_CLI request_size=16384 force_version=ssl3 \
1933 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1934 0 \
1935 -s "Read from client: 16384 bytes read"
1936
1937run_test "Large packet TLS 1.0 BlockCipher" \
1938 "$P_SRV" \
1939 "$P_CLI request_size=16384 force_version=tls1 \
1940 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1941 0 \
1942 -s "Read from client: 16384 bytes read"
1943
1944run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1945 "$P_SRV" \
1946 "$P_CLI request_size=16384 force_version=tls1 \
1947 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1948 trunc_hmac=1" \
1949 0 \
1950 -s "Read from client: 16384 bytes read"
1951
1952run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1953 "$P_SRV" \
1954 "$P_CLI request_size=16384 force_version=tls1 \
1955 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1956 trunc_hmac=1" \
1957 0 \
1958 -s "Read from client: 16384 bytes read"
1959
1960run_test "Large packet TLS 1.1 BlockCipher" \
1961 "$P_SRV" \
1962 "$P_CLI request_size=16384 force_version=tls1_1 \
1963 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1964 0 \
1965 -s "Read from client: 16384 bytes read"
1966
1967run_test "Large packet TLS 1.1 StreamCipher" \
1968 "$P_SRV" \
1969 "$P_CLI request_size=16384 force_version=tls1_1 \
1970 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1971 0 \
1972 -s "Read from client: 16384 bytes read"
1973
1974run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1975 "$P_SRV" \
1976 "$P_CLI request_size=16384 force_version=tls1_1 \
1977 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1978 trunc_hmac=1" \
1979 0 \
1980 -s "Read from client: 16384 bytes read"
1981
1982run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1983 "$P_SRV" \
1984 "$P_CLI request_size=16384 force_version=tls1_1 \
1985 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1986 trunc_hmac=1" \
1987 0 \
1988 -s "Read from client: 16384 bytes read"
1989
1990run_test "Large packet TLS 1.2 BlockCipher" \
1991 "$P_SRV" \
1992 "$P_CLI request_size=16384 force_version=tls1_2 \
1993 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1994 0 \
1995 -s "Read from client: 16384 bytes read"
1996
1997run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1998 "$P_SRV" \
1999 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
2000 0 \
2001 -s "Read from client: 16384 bytes read"
2002
2003run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2004 "$P_SRV" \
2005 "$P_CLI request_size=16384 force_version=tls1_2 \
2006 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2007 trunc_hmac=1" \
2008 0 \
2009 -s "Read from client: 16384 bytes read"
2010
2011run_test "Large packet TLS 1.2 StreamCipher" \
2012 "$P_SRV" \
2013 "$P_CLI request_size=16384 force_version=tls1_2 \
2014 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2015 0 \
2016 -s "Read from client: 16384 bytes read"
2017
2018run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
2019 "$P_SRV" \
2020 "$P_CLI request_size=16384 force_version=tls1_2 \
2021 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2022 trunc_hmac=1" \
2023 0 \
2024 -s "Read from client: 16384 bytes read"
2025
2026run_test "Large packet TLS 1.2 AEAD" \
2027 "$P_SRV" \
2028 "$P_CLI request_size=16384 force_version=tls1_2 \
2029 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2030 0 \
2031 -s "Read from client: 16384 bytes read"
2032
2033run_test "Large packet TLS 1.2 AEAD shorter tag" \
2034 "$P_SRV" \
2035 "$P_CLI request_size=16384 force_version=tls1_2 \
2036 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2037 0 \
2038 -s "Read from client: 16384 bytes read"
2039
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002040# Tests for DTLS HelloVerifyRequest
2041
2042run_test "DTLS cookie: enabled" \
2043 "$P_SRV dtls=1 debug_level=2" \
2044 "$P_CLI dtls=1 debug_level=2" \
2045 0 \
2046 -s "cookie verification failed" \
2047 -s "cookie verification passed" \
2048 -S "cookie verification skipped" \
2049 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002050 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002051 -S "SSL - The requested feature is not available"
2052
2053run_test "DTLS cookie: disabled" \
2054 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2055 "$P_CLI dtls=1 debug_level=2" \
2056 0 \
2057 -S "cookie verification failed" \
2058 -S "cookie verification passed" \
2059 -s "cookie verification skipped" \
2060 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002061 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002062 -S "SSL - The requested feature is not available"
2063
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002064run_test "DTLS cookie: default (failing)" \
2065 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2066 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2067 1 \
2068 -s "cookie verification failed" \
2069 -S "cookie verification passed" \
2070 -S "cookie verification skipped" \
2071 -C "received hello verify request" \
2072 -S "hello verification requested" \
2073 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002074
2075requires_ipv6
2076run_test "DTLS cookie: enabled, IPv6" \
2077 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2078 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2079 0 \
2080 -s "cookie verification failed" \
2081 -s "cookie verification passed" \
2082 -S "cookie verification skipped" \
2083 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002084 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002085 -S "SSL - The requested feature is not available"
2086
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002087run_test "DTLS cookie: enabled, nbio" \
2088 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2089 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2090 0 \
2091 -s "cookie verification failed" \
2092 -s "cookie verification passed" \
2093 -S "cookie verification skipped" \
2094 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002095 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002096 -S "SSL - The requested feature is not available"
2097
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002098# Tests for various cases of client authentication with DTLS
2099# (focused on handshake flows and message parsing)
2100
2101run_test "DTLS client auth: required" \
2102 "$P_SRV dtls=1 auth_mode=required" \
2103 "$P_CLI dtls=1" \
2104 0 \
2105 -s "Verifying peer X.509 certificate... ok"
2106
2107run_test "DTLS client auth: optional, client has no cert" \
2108 "$P_SRV dtls=1 auth_mode=optional" \
2109 "$P_CLI dtls=1 crt_file=none key_file=none" \
2110 0 \
2111 -s "! no client certificate sent"
2112
2113run_test "DTLS client auth: optional, client has no cert" \
2114 "$P_SRV dtls=1 auth_mode=none" \
2115 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
2116 0 \
2117 -c "skip write certificate$" \
2118 -s "! no client certificate sent"
2119
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02002120# Tests for receiving fragmented handshake messages with DTLS
2121
2122requires_gnutls
2123run_test "DTLS reassembly: no fragmentation (gnutls server)" \
2124 "$G_SRV -u --mtu 2048 -a" \
2125 "$P_CLI dtls=1 debug_level=2" \
2126 0 \
2127 -C "found fragmented DTLS handshake message" \
2128 -C "error"
2129
2130requires_gnutls
2131run_test "DTLS reassembly: some fragmentation (gnutls server)" \
2132 "$G_SRV -u --mtu 512" \
2133 "$P_CLI dtls=1 debug_level=2" \
2134 0 \
2135 -c "found fragmented DTLS handshake message" \
2136 -C "error"
2137
2138requires_gnutls
2139run_test "DTLS reassembly: more fragmentation (gnutls server)" \
2140 "$G_SRV -u --mtu 128" \
2141 "$P_CLI dtls=1 debug_level=2" \
2142 0 \
2143 -c "found fragmented DTLS handshake message" \
2144 -C "error"
2145
2146requires_gnutls
2147run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
2148 "$G_SRV -u --mtu 128" \
2149 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2150 0 \
2151 -c "found fragmented DTLS handshake message" \
2152 -C "error"
2153
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002154requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002155run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
2156 "$G_SRV -u --mtu 256" \
2157 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
2158 0 \
2159 -c "found fragmented DTLS handshake message" \
2160 -c "client hello, adding renegotiation extension" \
2161 -c "found renegotiation extension" \
2162 -c "=> renegotiate" \
2163 -C "ssl_handshake returned" \
2164 -C "error" \
2165 -s "Extra-header:"
2166
2167requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002168run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
2169 "$G_SRV -u --mtu 256" \
2170 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
2171 0 \
2172 -c "found fragmented DTLS handshake message" \
2173 -c "client hello, adding renegotiation extension" \
2174 -c "found renegotiation extension" \
2175 -c "=> renegotiate" \
2176 -C "ssl_handshake returned" \
2177 -C "error" \
2178 -s "Extra-header:"
2179
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002180run_test "DTLS reassembly: no fragmentation (openssl server)" \
2181 "$O_SRV -dtls1 -mtu 2048" \
2182 "$P_CLI dtls=1 debug_level=2" \
2183 0 \
2184 -C "found fragmented DTLS handshake message" \
2185 -C "error"
2186
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002187run_test "DTLS reassembly: some fragmentation (openssl server)" \
2188 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002189 "$P_CLI dtls=1 debug_level=2" \
2190 0 \
2191 -c "found fragmented DTLS handshake message" \
2192 -C "error"
2193
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002194run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002195 "$O_SRV -dtls1 -mtu 256" \
2196 "$P_CLI dtls=1 debug_level=2" \
2197 0 \
2198 -c "found fragmented DTLS handshake message" \
2199 -C "error"
2200
2201run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2202 "$O_SRV -dtls1 -mtu 256" \
2203 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2204 0 \
2205 -c "found fragmented DTLS handshake message" \
2206 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002207
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002208# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002209
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002210not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002211run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002212 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002213 "$P_SRV dtls=1 debug_level=2" \
2214 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002215 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002216 -C "replayed record" \
2217 -S "replayed record" \
2218 -C "record from another epoch" \
2219 -S "record from another epoch" \
2220 -C "discarding invalid record" \
2221 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002222 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002223 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002224 -c "HTTP/1.0 200 OK"
2225
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002226not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002227run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002228 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002229 "$P_SRV dtls=1 debug_level=2" \
2230 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002231 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002232 -c "replayed record" \
2233 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002234 -c "discarding invalid record" \
2235 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002236 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002237 -s "Extra-header:" \
2238 -c "HTTP/1.0 200 OK"
2239
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002240run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
2241 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002242 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
2243 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002244 0 \
2245 -c "replayed record" \
2246 -S "replayed record" \
2247 -c "discarding invalid record" \
2248 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002249 -c "resend" \
2250 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002251 -s "Extra-header:" \
2252 -c "HTTP/1.0 200 OK"
2253
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002254run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002255 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002256 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002257 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002258 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002259 -c "discarding invalid record (mac)" \
2260 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002261 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002262 -c "HTTP/1.0 200 OK" \
2263 -S "too many records with bad MAC" \
2264 -S "Verification of the message MAC failed"
2265
2266run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
2267 -p "$P_PXY bad_ad=1" \
2268 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
2269 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2270 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002271 -C "discarding invalid record (mac)" \
2272 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002273 -S "Extra-header:" \
2274 -C "HTTP/1.0 200 OK" \
2275 -s "too many records with bad MAC" \
2276 -s "Verification of the message MAC failed"
2277
2278run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
2279 -p "$P_PXY bad_ad=1" \
2280 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
2281 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2282 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002283 -c "discarding invalid record (mac)" \
2284 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002285 -s "Extra-header:" \
2286 -c "HTTP/1.0 200 OK" \
2287 -S "too many records with bad MAC" \
2288 -S "Verification of the message MAC failed"
2289
2290run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
2291 -p "$P_PXY bad_ad=1" \
2292 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
2293 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
2294 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002295 -c "discarding invalid record (mac)" \
2296 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002297 -s "Extra-header:" \
2298 -c "HTTP/1.0 200 OK" \
2299 -s "too many records with bad MAC" \
2300 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002301
2302run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002303 -p "$P_PXY delay_ccs=1" \
2304 "$P_SRV dtls=1 debug_level=1" \
2305 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002306 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002307 -c "record from another epoch" \
2308 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002309 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002310 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002311 -s "Extra-header:" \
2312 -c "HTTP/1.0 200 OK"
2313
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002314# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002315
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002316needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002317run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002318 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002319 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2320 psk=abc123" \
2321 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002322 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2323 0 \
2324 -s "Extra-header:" \
2325 -c "HTTP/1.0 200 OK"
2326
2327needs_more_time 2
2328run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
2329 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002330 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2331 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002332 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2333 0 \
2334 -s "Extra-header:" \
2335 -c "HTTP/1.0 200 OK"
2336
2337needs_more_time 2
2338run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
2339 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002340 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2341 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002342 0 \
2343 -s "Extra-header:" \
2344 -c "HTTP/1.0 200 OK"
2345
2346needs_more_time 2
2347run_test "DTLS proxy: 3d, FS, client auth" \
2348 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002349 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
2350 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002351 0 \
2352 -s "Extra-header:" \
2353 -c "HTTP/1.0 200 OK"
2354
2355needs_more_time 2
2356run_test "DTLS proxy: 3d, FS, ticket" \
2357 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002358 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
2359 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002360 0 \
2361 -s "Extra-header:" \
2362 -c "HTTP/1.0 200 OK"
2363
2364needs_more_time 2
2365run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
2366 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002367 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
2368 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002369 0 \
2370 -s "Extra-header:" \
2371 -c "HTTP/1.0 200 OK"
2372
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002373needs_more_time 2
2374run_test "DTLS proxy: 3d, max handshake, nbio" \
2375 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002376 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
2377 auth_mode=required" \
2378 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002379 0 \
2380 -s "Extra-header:" \
2381 -c "HTTP/1.0 200 OK"
2382
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002383needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02002384run_test "DTLS proxy: 3d, min handshake, resumption" \
2385 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2386 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2387 psk=abc123 debug_level=3" \
2388 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2389 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
2390 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2391 0 \
2392 -s "a session has been resumed" \
2393 -c "a session has been resumed" \
2394 -s "Extra-header:" \
2395 -c "HTTP/1.0 200 OK"
2396
2397needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02002398run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
2399 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2400 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2401 psk=abc123 debug_level=3 nbio=2" \
2402 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2403 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
2404 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
2405 0 \
2406 -s "a session has been resumed" \
2407 -c "a session has been resumed" \
2408 -s "Extra-header:" \
2409 -c "HTTP/1.0 200 OK"
2410
2411needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002412run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002413 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002414 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2415 psk=abc123 renegotiation=1 debug_level=2" \
2416 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2417 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002418 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2419 0 \
2420 -c "=> renegotiate" \
2421 -s "=> renegotiate" \
2422 -s "Extra-header:" \
2423 -c "HTTP/1.0 200 OK"
2424
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002425needs_more_time 4
2426run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
2427 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002428 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2429 psk=abc123 renegotiation=1 debug_level=2" \
2430 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2431 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002432 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2433 0 \
2434 -c "=> renegotiate" \
2435 -s "=> renegotiate" \
2436 -s "Extra-header:" \
2437 -c "HTTP/1.0 200 OK"
2438
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02002439needs_more_time 4
2440run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
2441 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_len=41" \
2442 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2443 psk=abc123 renegotiate=1 renegotiation=1 exchanges=2 \
2444 debug_level=2" \
2445 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2446 renegotiation=1 exchanges=2 debug_level=2 \
2447 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2448 0 \
2449 -c "=> renegotiate" \
2450 -s "=> renegotiate" \
2451 -s "Extra-header:" \
2452 -c "HTTP/1.0 200 OK"
2453
2454needs_more_time 4
2455run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
2456 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_len=41" \
2457 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2458 psk=abc123 renegotiate=1 renegotiation=1 exchanges=2 \
2459 debug_level=2 nbio=2" \
2460 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2461 renegotiation=1 exchanges=2 debug_level=2 nbio=2 \
2462 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2463 0 \
2464 -c "=> renegotiate" \
2465 -s "=> renegotiate" \
2466 -s "Extra-header:" \
2467 -c "HTTP/1.0 200 OK"
2468
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002469needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002470run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02002471 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
2472 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002473 "$P_CLI dtls=1 hs_timeout=250-10000" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02002474 0 \
2475 -s "Extra-header:" \
2476 -c "HTTP/1.0 200 OK"
2477
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002478needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002479run_test "DTLS proxy: 3d, openssl server, fragmentation" \
2480 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
2481 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002482 "$P_CLI dtls=1 hs_timeout=250-10000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002483 0 \
2484 -s "Extra-header:" \
2485 -c "HTTP/1.0 200 OK"
2486
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002487needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002488run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
2489 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
2490 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002491 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002492 0 \
2493 -s "Extra-header:" \
2494 -c "HTTP/1.0 200 OK"
2495
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002496needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002497run_test "DTLS proxy: 3d, gnutls server" \
2498 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2499 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002500 "$P_CLI dtls=1 hs_timeout=250-10000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002501 0 \
2502 -s "Extra-header:" \
2503 -c "Extra-header:"
2504
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002505needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002506run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
2507 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2508 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002509 "$P_CLI dtls=1 hs_timeout=250-10000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02002510 0 \
2511 -s "Extra-header:" \
2512 -c "Extra-header:"
2513
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02002514needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002515run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
2516 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2517 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002518 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002519 0 \
2520 -s "Extra-header:" \
2521 -c "Extra-header:"
2522
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002523# Final report
2524
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002525echo "------------------------------------------------------------------------"
2526
2527if [ $FAILS = 0 ]; then
2528 echo -n "PASSED"
2529else
2530 echo -n "FAILED"
2531fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002532PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002533echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002534
2535exit $FAILS