blob: ed88326928c8302e31ae4e19916a65e7f49ee967 [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é-Gonnarda7756172014-08-31 18:37:01 +020021O_SRV="$OPENSSL_CMD s_server -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é-Gonnardc73339f2014-02-26 16:35:27 +0100175# has_mem_err <log_file_name>
176has_mem_err() {
177 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
178 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
179 then
180 return 1 # false: does not have errors
181 else
182 return 0 # true: has errors
183 fi
184}
185
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200186# wait for server to start: two versions depending on lsof availability
187wait_server_start() {
188 if which lsof >/dev/null; then
189 # make sure we don't loop forever
190 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200191 DOG_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200192
193 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200194 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200195 until lsof -nbi UDP:"$SRV_PORT" | grep UDP >/dev/null; do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200196 else
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200197 until lsof -nbi TCP:"$SRV_PORT" | grep LISTEN >/dev/null; do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200198 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200199
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200200 kill $DOG_PID >/dev/null 2>&1
201 wait $DOG_PID
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200202 else
203 sleep "$START_DELAY"
204 fi
205}
206
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200207# wait for client to terminate and set CLI_EXIT
208# must be called right after starting the client
209wait_client_done() {
210 CLI_PID=$!
211
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200212 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
213 CLI_DELAY_FACTOR=1
214
215 ( sleep $CLI_DELAY; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200216 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200217
218 wait $CLI_PID
219 CLI_EXIT=$?
220
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200221 kill $DOG_PID >/dev/null 2>&1
222 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200223
224 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
225}
226
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200227# check if the given command uses dtls and sets global variable DTLS
228detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200229 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200230 DTLS=1
231 else
232 DTLS=0
233 fi
234}
235
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200236# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100237# Options: -s pattern pattern that must be present in server output
238# -c pattern pattern that must be present in client output
239# -S pattern pattern that must be absent in server output
240# -C pattern pattern that must be absent in client output
241run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100242 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200243 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100244
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100245 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
246 else
247 return
248 fi
249
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100250 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100251
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200252 # should we skip?
253 if [ "X$SKIP_NEXT" = "XYES" ]; then
254 SKIP_NEXT="NO"
255 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200256 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200257 return
258 fi
259
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200260 # does this test use a proxy?
261 if [ "X$1" = "X-p" ]; then
262 PXY_CMD="$2"
263 shift 2
264 else
265 PXY_CMD=""
266 fi
267
268 # get commands and client output
269 SRV_CMD="$1"
270 CLI_CMD="$2"
271 CLI_EXPECT="$3"
272 shift 3
273
274 # fix client port
275 if [ -n "$PXY_CMD" ]; then
276 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
277 else
278 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
279 fi
280
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200281 # update DTLS variable
282 detect_dtls "$SRV_CMD"
283
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100284 # prepend valgrind to our commands if active
285 if [ "$MEMCHECK" -gt 0 ]; then
286 if is_polar "$SRV_CMD"; then
287 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
288 fi
289 if is_polar "$CLI_CMD"; then
290 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
291 fi
292 fi
293
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100294 # run the commands
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200295 if [ -n "$PXY_CMD" ]; then
296 echo "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200297 $PXY_CMD >> $PXY_OUT 2>&1 &
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200298 PXY_PID=$!
299 # assume proxy starts faster than server
300 fi
301
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200302 echo "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200303 # "yes" is for servers without -www (openssl with DTLS)
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +0200304 yes "HTTP/1.0 200 OK" | $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100305 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200306 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200307
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200308 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200309 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
310 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100311
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200312 # terminate the server (and the proxy)
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200313 kill $SRV_PID
314 wait $SRV_PID
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200315 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200316 kill $PXY_PID >/dev/null 2>&1
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200317 wait $PXY_PID
318 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100319
320 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200321 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100322 # expected client exit to incorrectly succeed in case of catastrophic
323 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100324 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200325 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100326 else
327 fail "server failed to start"
328 return
329 fi
330 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100331 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200332 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100333 else
334 fail "client failed to start"
335 return
336 fi
337 fi
338
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100339 # check server exit code
340 if [ $? != 0 ]; then
341 fail "server fail"
342 return
343 fi
344
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100345 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100346 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
347 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100348 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200349 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100350 return
351 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100352
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100353 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200354 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100355 while [ $# -gt 0 ]
356 do
357 case $1 in
358 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200359 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100360 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100361 return
362 fi
363 ;;
364
365 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200366 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100367 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100368 return
369 fi
370 ;;
371
372 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200373 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100374 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100375 return
376 fi
377 ;;
378
379 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200380 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100381 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100382 return
383 fi
384 ;;
385
386 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200387 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100388 exit 1
389 esac
390 shift 2
391 done
392
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100393 # check valgrind's results
394 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200395 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100396 fail "Server has memory errors"
397 return
398 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200399 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100400 fail "Client has memory errors"
401 return
402 fi
403 fi
404
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100405 # if we're here, everything is ok
406 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200407 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100408}
409
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100410cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200411 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200412 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
413 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
414 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
415 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100416 exit 1
417}
418
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100419#
420# MAIN
421#
422
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100423get_options "$@"
424
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100425# sanity checks, avoid an avalanche of errors
426if [ ! -x "$P_SRV" ]; then
427 echo "Command '$P_SRV' is not an executable file"
428 exit 1
429fi
430if [ ! -x "$P_CLI" ]; then
431 echo "Command '$P_CLI' is not an executable file"
432 exit 1
433fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200434if [ ! -x "$P_PXY" ]; then
435 echo "Command '$P_PXY' is not an executable file"
436 exit 1
437fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100438if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
439 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100440 exit 1
441fi
442
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200443# used by watchdog
444MAIN_PID="$$"
445
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200446# be more patient with valgrind
447if [ "$MEMCHECK" -gt 0 ]; then
448 START_DELAY=3
449 DOG_DELAY=30
450else
451 START_DELAY=1
452 DOG_DELAY=10
453fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200454CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200455
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200456# Pick a "unique" server port in the range 10000-19999, and a proxy port
457PORT_BASE="0000$$"
458PORT_BASE="$( echo -n $PORT_BASE | tail -c 4 )"
459SRV_PORT="1$PORT_BASE"
460PXY_PORT="2$PORT_BASE"
461unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200462
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200463# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200464P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
465P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
466P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
467O_SRV="$O_SRV -accept $SRV_PORT"
468O_CLI="$O_CLI -connect localhost:+SRV_PORT"
469G_SRV="$G_SRV -p $SRV_PORT"
470G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200471
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200472# Also pick a unique name for intermediate files
473SRV_OUT="srv_out.$$"
474CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200475PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200476SESSION="session.$$"
477
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200478SKIP_NEXT="NO"
479
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100480trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100481
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200482# Basic test
483
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200484# Checks that:
485# - things work with all ciphersuites active (used with config-full in all.sh)
486# - the expected (highest security) parameters are selected
487# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200488run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200489 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200490 "$P_CLI" \
491 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200492 -s "Protocol is TLSv1.2" \
493 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
494 -s "client hello v3, signature_algorithm ext: 6" \
495 -s "ECDHE curve: secp521r1" \
496 -S "error" \
497 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200498
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100499# Test for SSLv2 ClientHello
500
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200501requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200502run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100503 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100504 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100505 0 \
506 -S "parse client hello v2" \
507 -S "ssl_handshake returned"
508
509# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200510requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200511run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200512 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100513 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100514 0 \
515 -s "parse client hello v2" \
516 -S "ssl_handshake returned"
517
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100518# Tests for Truncated HMAC extension
519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200520run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200521 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100522 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100523 0 \
524 -s "dumping 'computed mac' (20 bytes)"
525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200526run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200527 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100528 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100529 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100530 -s "dumping 'computed mac' (10 bytes)"
531
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100532# Tests for Session Tickets
533
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200534run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200535 "$P_SRV debug_level=3 tickets=1" \
536 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100537 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100538 -c "client hello, adding session ticket extension" \
539 -s "found session ticket extension" \
540 -s "server hello, adding session ticket extension" \
541 -c "found session_ticket extension" \
542 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100543 -S "session successfully restored from cache" \
544 -s "session successfully restored from ticket" \
545 -s "a session has been resumed" \
546 -c "a session has been resumed"
547
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200548run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200549 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
550 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100551 0 \
552 -c "client hello, adding session ticket extension" \
553 -s "found session ticket extension" \
554 -s "server hello, adding session ticket extension" \
555 -c "found session_ticket extension" \
556 -c "parse new session ticket" \
557 -S "session successfully restored from cache" \
558 -s "session successfully restored from ticket" \
559 -s "a session has been resumed" \
560 -c "a session has been resumed"
561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200562run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200563 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
564 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100565 0 \
566 -c "client hello, adding session ticket extension" \
567 -s "found session ticket extension" \
568 -s "server hello, adding session ticket extension" \
569 -c "found session_ticket extension" \
570 -c "parse new session ticket" \
571 -S "session successfully restored from cache" \
572 -S "session successfully restored from ticket" \
573 -S "a session has been resumed" \
574 -C "a session has been resumed"
575
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200576run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100577 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200578 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100579 0 \
580 -c "client hello, adding session ticket extension" \
581 -c "found session_ticket extension" \
582 -c "parse new session ticket" \
583 -c "a session has been resumed"
584
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200585run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200586 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200587 "( $O_CLI -sess_out $SESSION; \
588 $O_CLI -sess_in $SESSION; \
589 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100590 0 \
591 -s "found session ticket extension" \
592 -s "server hello, adding session ticket extension" \
593 -S "session successfully restored from cache" \
594 -s "session successfully restored from ticket" \
595 -s "a session has been resumed"
596
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100597# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100598
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200599run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200600 "$P_SRV debug_level=3 tickets=0" \
601 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100602 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100603 -c "client hello, adding session ticket extension" \
604 -s "found session ticket extension" \
605 -S "server hello, adding session ticket extension" \
606 -C "found session_ticket extension" \
607 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100608 -s "session successfully restored from cache" \
609 -S "session successfully restored from ticket" \
610 -s "a session has been resumed" \
611 -c "a session has been resumed"
612
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200613run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200614 "$P_SRV debug_level=3 tickets=1" \
615 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100616 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100617 -C "client hello, adding session ticket extension" \
618 -S "found session ticket extension" \
619 -S "server hello, adding session ticket extension" \
620 -C "found session_ticket extension" \
621 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100622 -s "session successfully restored from cache" \
623 -S "session successfully restored from ticket" \
624 -s "a session has been resumed" \
625 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200627run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200628 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
629 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100630 0 \
631 -S "session successfully restored from cache" \
632 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100633 -S "a session has been resumed" \
634 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200636run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200637 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
638 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100639 0 \
640 -s "session successfully restored from cache" \
641 -S "session successfully restored from ticket" \
642 -s "a session has been resumed" \
643 -c "a session has been resumed"
644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200645run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200646 "$P_SRV debug_level=3 tickets=0" \
647 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100648 0 \
649 -s "session successfully restored from cache" \
650 -S "session successfully restored from ticket" \
651 -s "a session has been resumed" \
652 -c "a session has been resumed"
653
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200654run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200655 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
656 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100657 0 \
658 -S "session successfully restored from cache" \
659 -S "session successfully restored from ticket" \
660 -S "a session has been resumed" \
661 -C "a session has been resumed"
662
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200663run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200664 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
665 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100666 0 \
667 -s "session successfully restored from cache" \
668 -S "session successfully restored from ticket" \
669 -s "a session has been resumed" \
670 -c "a session has been resumed"
671
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200672run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200673 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200674 "( $O_CLI -sess_out $SESSION; \
675 $O_CLI -sess_in $SESSION; \
676 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100677 0 \
678 -s "found session ticket extension" \
679 -S "server hello, adding session ticket extension" \
680 -s "session successfully restored from cache" \
681 -S "session successfully restored from ticket" \
682 -s "a session has been resumed"
683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200684run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100685 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200686 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100687 0 \
688 -C "found session_ticket extension" \
689 -C "parse new session ticket" \
690 -c "a session has been resumed"
691
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100692# Tests for Max Fragment Length extension
693
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200694run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200695 "$P_SRV debug_level=3" \
696 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100697 0 \
698 -C "client hello, adding max_fragment_length extension" \
699 -S "found max fragment length extension" \
700 -S "server hello, max_fragment_length extension" \
701 -C "found max_fragment_length extension"
702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200703run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200704 "$P_SRV debug_level=3" \
705 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100706 0 \
707 -c "client hello, adding max_fragment_length extension" \
708 -s "found max fragment length extension" \
709 -s "server hello, max_fragment_length extension" \
710 -c "found max_fragment_length extension"
711
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200712run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200713 "$P_SRV debug_level=3 max_frag_len=4096" \
714 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100715 0 \
716 -C "client hello, adding max_fragment_length extension" \
717 -S "found max fragment length extension" \
718 -S "server hello, max_fragment_length extension" \
719 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200721requires_gnutls
722run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200723 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200724 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200725 0 \
726 -c "client hello, adding max_fragment_length extension" \
727 -c "found max_fragment_length extension"
728
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100729# Tests for renegotiation
730
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200731run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200732 "$P_SRV debug_level=3 exchanges=2" \
733 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100734 0 \
735 -C "client hello, adding renegotiation extension" \
736 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
737 -S "found renegotiation extension" \
738 -s "server hello, secure renegotiation extension" \
739 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100740 -C "=> renegotiate" \
741 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100742 -S "write hello request"
743
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200744run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200745 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
746 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100747 0 \
748 -c "client hello, adding renegotiation extension" \
749 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
750 -s "found renegotiation extension" \
751 -s "server hello, secure renegotiation extension" \
752 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100753 -c "=> renegotiate" \
754 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100755 -S "write hello request"
756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200757run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200758 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
759 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100760 0 \
761 -c "client hello, adding renegotiation extension" \
762 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
763 -s "found renegotiation extension" \
764 -s "server hello, secure renegotiation extension" \
765 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100766 -c "=> renegotiate" \
767 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100768 -s "write hello request"
769
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200770run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200771 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
772 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100773 0 \
774 -c "client hello, adding renegotiation extension" \
775 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
776 -s "found renegotiation extension" \
777 -s "server hello, secure renegotiation extension" \
778 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100779 -c "=> renegotiate" \
780 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100781 -s "write hello request"
782
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200783run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200784 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
785 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100786 1 \
787 -c "client hello, adding renegotiation extension" \
788 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
789 -S "found renegotiation extension" \
790 -s "server hello, secure renegotiation extension" \
791 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100792 -c "=> renegotiate" \
793 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200794 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200795 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200796 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100797
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200798run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200799 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
800 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100801 0 \
802 -C "client hello, adding renegotiation extension" \
803 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
804 -S "found renegotiation extension" \
805 -s "server hello, secure renegotiation extension" \
806 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100807 -C "=> renegotiate" \
808 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100809 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200810 -S "SSL - An unexpected message was received from our peer" \
811 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100812
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200813run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200814 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200815 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200816 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200817 0 \
818 -C "client hello, adding renegotiation extension" \
819 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
820 -S "found renegotiation extension" \
821 -s "server hello, secure renegotiation extension" \
822 -c "found renegotiation extension" \
823 -C "=> renegotiate" \
824 -S "=> renegotiate" \
825 -s "write hello request" \
826 -S "SSL - An unexpected message was received from our peer" \
827 -S "failed"
828
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200829# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200830run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200831 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200832 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200833 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200834 0 \
835 -C "client hello, adding renegotiation extension" \
836 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
837 -S "found renegotiation extension" \
838 -s "server hello, secure renegotiation extension" \
839 -c "found renegotiation extension" \
840 -C "=> renegotiate" \
841 -S "=> renegotiate" \
842 -s "write hello request" \
843 -S "SSL - An unexpected message was received from our peer" \
844 -S "failed"
845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200846run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200847 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200848 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200849 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200850 0 \
851 -C "client hello, adding renegotiation extension" \
852 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
853 -S "found renegotiation extension" \
854 -s "server hello, secure renegotiation extension" \
855 -c "found renegotiation extension" \
856 -C "=> renegotiate" \
857 -S "=> renegotiate" \
858 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200859 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200860
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200861run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200862 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200863 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200864 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200865 0 \
866 -c "client hello, adding renegotiation extension" \
867 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
868 -s "found renegotiation extension" \
869 -s "server hello, secure renegotiation extension" \
870 -c "found renegotiation extension" \
871 -c "=> renegotiate" \
872 -s "=> renegotiate" \
873 -s "write hello request" \
874 -S "SSL - An unexpected message was received from our peer" \
875 -S "failed"
876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200877run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200878 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
879 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200880 0 \
881 -c "client hello, adding renegotiation extension" \
882 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
883 -s "found renegotiation extension" \
884 -s "server hello, secure renegotiation extension" \
885 -c "found renegotiation extension" \
886 -c "=> renegotiate" \
887 -s "=> renegotiate" \
888 -S "write hello request"
889
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200890run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200891 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
892 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200893 0 \
894 -c "client hello, adding renegotiation extension" \
895 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
896 -s "found renegotiation extension" \
897 -s "server hello, secure renegotiation extension" \
898 -c "found renegotiation extension" \
899 -c "=> renegotiate" \
900 -s "=> renegotiate" \
901 -s "write hello request"
902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200903run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +0200904 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200905 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200906 0 \
907 -c "client hello, adding renegotiation extension" \
908 -c "found renegotiation extension" \
909 -c "=> renegotiate" \
910 -C "ssl_handshake returned" \
911 -C "error" \
912 -c "HTTP/1.0 200 [Oo][Kk]"
913
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200914run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200915 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200916 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200917 0 \
918 -c "client hello, adding renegotiation extension" \
919 -c "found renegotiation extension" \
920 -c "=> renegotiate" \
921 -C "ssl_handshake returned" \
922 -C "error" \
923 -c "HTTP/1.0 200 [Oo][Kk]"
924
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +0200925run_test "Renegotiation: DTLS, client-initiated" \
926 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
927 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
928 0 \
929 -c "client hello, adding renegotiation extension" \
930 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
931 -s "found renegotiation extension" \
932 -s "server hello, secure renegotiation extension" \
933 -c "found renegotiation extension" \
934 -c "=> renegotiate" \
935 -s "=> renegotiate" \
936 -S "write hello request"
937
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +0200938run_test "Renegotiation: DTLS, server-initiated" \
939 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
940 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
941 0 \
942 -c "client hello, adding renegotiation extension" \
943 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
944 -s "found renegotiation extension" \
945 -s "server hello, secure renegotiation extension" \
946 -c "found renegotiation extension" \
947 -c "=> renegotiate" \
948 -s "=> renegotiate" \
949 -s "write hello request"
950
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +0200951run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
952 "$G_SRV -u --mtu 4096" \
953 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
954 0 \
955 -c "client hello, adding renegotiation extension" \
956 -c "found renegotiation extension" \
957 -c "=> renegotiate" \
958 -C "ssl_handshake returned" \
959 -C "error" \
960 -s "Extra-header:"
961
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100962# Tests for auth_mode
963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200964run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100965 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100966 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200967 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100968 1 \
969 -c "x509_verify_cert() returned" \
970 -c "! self-signed or not signed by a trusted CA" \
971 -c "! ssl_handshake returned" \
972 -c "X509 - Certificate verification failed"
973
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200974run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100975 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100976 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200977 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100978 0 \
979 -c "x509_verify_cert() returned" \
980 -c "! self-signed or not signed by a trusted CA" \
981 -C "! ssl_handshake returned" \
982 -C "X509 - Certificate verification failed"
983
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200984run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100985 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100986 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200987 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100988 0 \
989 -C "x509_verify_cert() returned" \
990 -C "! self-signed or not signed by a trusted CA" \
991 -C "! ssl_handshake returned" \
992 -C "X509 - Certificate verification failed"
993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200994run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200995 "$P_SRV debug_level=3 auth_mode=required" \
996 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100997 key_file=data_files/server5.key" \
998 1 \
999 -S "skip write certificate request" \
1000 -C "skip parse certificate request" \
1001 -c "got a certificate request" \
1002 -C "skip write certificate" \
1003 -C "skip write certificate verify" \
1004 -S "skip parse certificate verify" \
1005 -s "x509_verify_cert() returned" \
1006 -S "! self-signed or not signed by a trusted CA" \
1007 -s "! ssl_handshake returned" \
1008 -c "! ssl_handshake returned" \
1009 -s "X509 - Certificate verification failed"
1010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001011run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001012 "$P_SRV debug_level=3 auth_mode=optional" \
1013 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001014 key_file=data_files/server5.key" \
1015 0 \
1016 -S "skip write certificate request" \
1017 -C "skip parse certificate request" \
1018 -c "got a certificate request" \
1019 -C "skip write certificate" \
1020 -C "skip write certificate verify" \
1021 -S "skip parse certificate verify" \
1022 -s "x509_verify_cert() returned" \
1023 -s "! self-signed or not signed by a trusted CA" \
1024 -S "! ssl_handshake returned" \
1025 -C "! ssl_handshake returned" \
1026 -S "X509 - Certificate verification failed"
1027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001028run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001029 "$P_SRV debug_level=3 auth_mode=none" \
1030 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001031 key_file=data_files/server5.key" \
1032 0 \
1033 -s "skip write certificate request" \
1034 -C "skip parse certificate request" \
1035 -c "got no certificate request" \
1036 -c "skip write certificate" \
1037 -c "skip write certificate verify" \
1038 -s "skip parse certificate verify" \
1039 -S "x509_verify_cert() returned" \
1040 -S "! self-signed or not signed by a trusted CA" \
1041 -S "! ssl_handshake returned" \
1042 -C "! ssl_handshake returned" \
1043 -S "X509 - Certificate verification failed"
1044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001045run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001046 "$P_SRV debug_level=3 auth_mode=optional" \
1047 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001048 0 \
1049 -S "skip write certificate request" \
1050 -C "skip parse certificate request" \
1051 -c "got a certificate request" \
1052 -C "skip write certificate$" \
1053 -C "got no certificate to send" \
1054 -S "SSLv3 client has no certificate" \
1055 -c "skip write certificate verify" \
1056 -s "skip parse certificate verify" \
1057 -s "! no client certificate sent" \
1058 -S "! ssl_handshake returned" \
1059 -C "! ssl_handshake returned" \
1060 -S "X509 - Certificate verification failed"
1061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001062run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001063 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001064 "$O_CLI" \
1065 0 \
1066 -S "skip write certificate request" \
1067 -s "skip parse certificate verify" \
1068 -s "! no client certificate sent" \
1069 -S "! ssl_handshake returned" \
1070 -S "X509 - Certificate verification failed"
1071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001072run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001073 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001074 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001075 0 \
1076 -C "skip parse certificate request" \
1077 -c "got a certificate request" \
1078 -C "skip write certificate$" \
1079 -c "skip write certificate verify" \
1080 -C "! ssl_handshake returned"
1081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001082run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001083 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1084 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001085 0 \
1086 -S "skip write certificate request" \
1087 -C "skip parse certificate request" \
1088 -c "got a certificate request" \
1089 -C "skip write certificate$" \
1090 -c "skip write certificate verify" \
1091 -c "got no certificate to send" \
1092 -s "SSLv3 client has no certificate" \
1093 -s "skip parse certificate verify" \
1094 -s "! no client certificate sent" \
1095 -S "! ssl_handshake returned" \
1096 -C "! ssl_handshake returned" \
1097 -S "X509 - Certificate verification failed"
1098
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001099# tests for SNI
1100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001101run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001102 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001103 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001104 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001105 0 \
1106 -S "parse ServerName extension" \
1107 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1108 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001110run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001111 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001112 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001113 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 +02001114 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001115 0 \
1116 -s "parse ServerName extension" \
1117 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1118 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001120run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001121 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001122 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001123 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 +02001124 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001125 0 \
1126 -s "parse ServerName extension" \
1127 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001128 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001129
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001130run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001131 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001132 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001133 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 +02001134 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001135 1 \
1136 -s "parse ServerName extension" \
1137 -s "ssl_sni_wrapper() returned" \
1138 -s "ssl_handshake returned" \
1139 -c "ssl_handshake returned" \
1140 -c "SSL - A fatal alert message was received from our peer"
1141
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001142# Tests for non-blocking I/O: exercise a variety of handshake flows
1143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001144run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001145 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1146 "$P_CLI nbio=2 tickets=0" \
1147 0 \
1148 -S "ssl_handshake returned" \
1149 -C "ssl_handshake returned" \
1150 -c "Read from server: .* bytes read"
1151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001152run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001153 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1154 "$P_CLI nbio=2 tickets=0" \
1155 0 \
1156 -S "ssl_handshake returned" \
1157 -C "ssl_handshake returned" \
1158 -c "Read from server: .* bytes read"
1159
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001160run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001161 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1162 "$P_CLI nbio=2 tickets=1" \
1163 0 \
1164 -S "ssl_handshake returned" \
1165 -C "ssl_handshake returned" \
1166 -c "Read from server: .* bytes read"
1167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001168run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001169 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1170 "$P_CLI nbio=2 tickets=1" \
1171 0 \
1172 -S "ssl_handshake returned" \
1173 -C "ssl_handshake returned" \
1174 -c "Read from server: .* bytes read"
1175
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001176run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001177 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1178 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1179 0 \
1180 -S "ssl_handshake returned" \
1181 -C "ssl_handshake returned" \
1182 -c "Read from server: .* bytes read"
1183
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001184run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001185 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1186 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1187 0 \
1188 -S "ssl_handshake returned" \
1189 -C "ssl_handshake returned" \
1190 -c "Read from server: .* bytes read"
1191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001192run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001193 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1194 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1195 0 \
1196 -S "ssl_handshake returned" \
1197 -C "ssl_handshake returned" \
1198 -c "Read from server: .* bytes read"
1199
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001200# Tests for version negotiation
1201
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001202run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001203 "$P_SRV" \
1204 "$P_CLI" \
1205 0 \
1206 -S "ssl_handshake returned" \
1207 -C "ssl_handshake returned" \
1208 -s "Protocol is TLSv1.2" \
1209 -c "Protocol is TLSv1.2"
1210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001211run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001212 "$P_SRV" \
1213 "$P_CLI max_version=tls1_1" \
1214 0 \
1215 -S "ssl_handshake returned" \
1216 -C "ssl_handshake returned" \
1217 -s "Protocol is TLSv1.1" \
1218 -c "Protocol is TLSv1.1"
1219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001220run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001221 "$P_SRV max_version=tls1_1" \
1222 "$P_CLI" \
1223 0 \
1224 -S "ssl_handshake returned" \
1225 -C "ssl_handshake returned" \
1226 -s "Protocol is TLSv1.1" \
1227 -c "Protocol is TLSv1.1"
1228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001229run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001230 "$P_SRV max_version=tls1_1" \
1231 "$P_CLI max_version=tls1_1" \
1232 0 \
1233 -S "ssl_handshake returned" \
1234 -C "ssl_handshake returned" \
1235 -s "Protocol is TLSv1.1" \
1236 -c "Protocol is TLSv1.1"
1237
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001238run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001239 "$P_SRV min_version=tls1_1" \
1240 "$P_CLI max_version=tls1_1" \
1241 0 \
1242 -S "ssl_handshake returned" \
1243 -C "ssl_handshake returned" \
1244 -s "Protocol is TLSv1.1" \
1245 -c "Protocol is TLSv1.1"
1246
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001247run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001248 "$P_SRV max_version=tls1_1" \
1249 "$P_CLI min_version=tls1_1" \
1250 0 \
1251 -S "ssl_handshake returned" \
1252 -C "ssl_handshake returned" \
1253 -s "Protocol is TLSv1.1" \
1254 -c "Protocol is TLSv1.1"
1255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001256run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001257 "$P_SRV max_version=tls1_1" \
1258 "$P_CLI min_version=tls1_2" \
1259 1 \
1260 -s "ssl_handshake returned" \
1261 -c "ssl_handshake returned" \
1262 -c "SSL - Handshake protocol not within min/max boundaries"
1263
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001264run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001265 "$P_SRV min_version=tls1_2" \
1266 "$P_CLI max_version=tls1_1" \
1267 1 \
1268 -s "ssl_handshake returned" \
1269 -c "ssl_handshake returned" \
1270 -s "SSL - Handshake protocol not within min/max boundaries"
1271
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001272# Tests for ALPN extension
1273
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001274if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001276run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001277 "$P_SRV debug_level=3" \
1278 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001279 0 \
1280 -C "client hello, adding alpn extension" \
1281 -S "found alpn extension" \
1282 -C "got an alert message, type: \\[2:120]" \
1283 -S "server hello, adding alpn extension" \
1284 -C "found alpn extension " \
1285 -C "Application Layer Protocol is" \
1286 -S "Application Layer Protocol is"
1287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001288run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001289 "$P_SRV debug_level=3" \
1290 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001291 0 \
1292 -c "client hello, adding alpn extension" \
1293 -s "found alpn extension" \
1294 -C "got an alert message, type: \\[2:120]" \
1295 -S "server hello, adding alpn extension" \
1296 -C "found alpn extension " \
1297 -c "Application Layer Protocol is (none)" \
1298 -S "Application Layer Protocol is"
1299
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001300run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001301 "$P_SRV debug_level=3 alpn=abc,1234" \
1302 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001303 0 \
1304 -C "client hello, adding alpn extension" \
1305 -S "found alpn extension" \
1306 -C "got an alert message, type: \\[2:120]" \
1307 -S "server hello, adding alpn extension" \
1308 -C "found alpn extension " \
1309 -C "Application Layer Protocol is" \
1310 -s "Application Layer Protocol is (none)"
1311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001312run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001313 "$P_SRV debug_level=3 alpn=abc,1234" \
1314 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001315 0 \
1316 -c "client hello, adding alpn extension" \
1317 -s "found alpn extension" \
1318 -C "got an alert message, type: \\[2:120]" \
1319 -s "server hello, adding alpn extension" \
1320 -c "found alpn extension" \
1321 -c "Application Layer Protocol is abc" \
1322 -s "Application Layer Protocol is abc"
1323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001324run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001325 "$P_SRV debug_level=3 alpn=abc,1234" \
1326 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001327 0 \
1328 -c "client hello, adding alpn extension" \
1329 -s "found alpn extension" \
1330 -C "got an alert message, type: \\[2:120]" \
1331 -s "server hello, adding alpn extension" \
1332 -c "found alpn extension" \
1333 -c "Application Layer Protocol is abc" \
1334 -s "Application Layer Protocol is abc"
1335
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001336run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001337 "$P_SRV debug_level=3 alpn=abc,1234" \
1338 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001339 0 \
1340 -c "client hello, adding alpn extension" \
1341 -s "found alpn extension" \
1342 -C "got an alert message, type: \\[2:120]" \
1343 -s "server hello, adding alpn extension" \
1344 -c "found alpn extension" \
1345 -c "Application Layer Protocol is 1234" \
1346 -s "Application Layer Protocol is 1234"
1347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001348run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001349 "$P_SRV debug_level=3 alpn=abc,123" \
1350 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001351 1 \
1352 -c "client hello, adding alpn extension" \
1353 -s "found alpn extension" \
1354 -c "got an alert message, type: \\[2:120]" \
1355 -S "server hello, adding alpn extension" \
1356 -C "found alpn extension" \
1357 -C "Application Layer Protocol is 1234" \
1358 -S "Application Layer Protocol is 1234"
1359
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001360fi
1361
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001362# Tests for keyUsage in leaf certificates, part 1:
1363# server-side certificate/suite selection
1364
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001365run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001366 "$P_SRV key_file=data_files/server2.key \
1367 crt_file=data_files/server2.ku-ds.crt" \
1368 "$P_CLI" \
1369 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001370 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001371
1372
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001373run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001374 "$P_SRV key_file=data_files/server2.key \
1375 crt_file=data_files/server2.ku-ke.crt" \
1376 "$P_CLI" \
1377 0 \
1378 -c "Ciphersuite is TLS-RSA-WITH-"
1379
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001380run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001381 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001382 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001383 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001384 1 \
1385 -C "Ciphersuite is "
1386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001387run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001388 "$P_SRV key_file=data_files/server5.key \
1389 crt_file=data_files/server5.ku-ds.crt" \
1390 "$P_CLI" \
1391 0 \
1392 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1393
1394
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001395run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001396 "$P_SRV key_file=data_files/server5.key \
1397 crt_file=data_files/server5.ku-ka.crt" \
1398 "$P_CLI" \
1399 0 \
1400 -c "Ciphersuite is TLS-ECDH-"
1401
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001402run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001403 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001404 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001405 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001406 1 \
1407 -C "Ciphersuite is "
1408
1409# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001410# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001411
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001412run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001413 "$O_SRV -key data_files/server2.key \
1414 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001415 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001416 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1417 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001418 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001419 -C "Processing of the Certificate handshake message failed" \
1420 -c "Ciphersuite is TLS-"
1421
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001422run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001423 "$O_SRV -key data_files/server2.key \
1424 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001425 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001426 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1427 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001428 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001429 -C "Processing of the Certificate handshake message failed" \
1430 -c "Ciphersuite is TLS-"
1431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001432run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001433 "$O_SRV -key data_files/server2.key \
1434 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001435 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001436 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1437 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001438 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001439 -C "Processing of the Certificate handshake message failed" \
1440 -c "Ciphersuite is TLS-"
1441
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001442run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001443 "$O_SRV -key data_files/server2.key \
1444 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001445 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001446 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1447 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001448 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001449 -c "Processing of the Certificate handshake message failed" \
1450 -C "Ciphersuite is TLS-"
1451
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001452run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001453 "$O_SRV -key data_files/server2.key \
1454 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001455 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001456 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1457 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001458 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001459 -C "Processing of the Certificate handshake message failed" \
1460 -c "Ciphersuite is TLS-"
1461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001462run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001463 "$O_SRV -key data_files/server2.key \
1464 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001465 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001466 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1467 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001468 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001469 -c "Processing of the Certificate handshake message failed" \
1470 -C "Ciphersuite is TLS-"
1471
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001472# Tests for keyUsage in leaf certificates, part 3:
1473# server-side checking of client cert
1474
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001475run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001476 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001477 "$O_CLI -key data_files/server2.key \
1478 -cert data_files/server2.ku-ds.crt" \
1479 0 \
1480 -S "bad certificate (usage extensions)" \
1481 -S "Processing of the Certificate handshake message failed"
1482
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001483run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001484 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001485 "$O_CLI -key data_files/server2.key \
1486 -cert data_files/server2.ku-ke.crt" \
1487 0 \
1488 -s "bad certificate (usage extensions)" \
1489 -S "Processing of the Certificate handshake message failed"
1490
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001491run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001492 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001493 "$O_CLI -key data_files/server2.key \
1494 -cert data_files/server2.ku-ke.crt" \
1495 1 \
1496 -s "bad certificate (usage extensions)" \
1497 -s "Processing of the Certificate handshake message failed"
1498
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001499run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001500 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001501 "$O_CLI -key data_files/server5.key \
1502 -cert data_files/server5.ku-ds.crt" \
1503 0 \
1504 -S "bad certificate (usage extensions)" \
1505 -S "Processing of the Certificate handshake message failed"
1506
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001507run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001508 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001509 "$O_CLI -key data_files/server5.key \
1510 -cert data_files/server5.ku-ka.crt" \
1511 0 \
1512 -s "bad certificate (usage extensions)" \
1513 -S "Processing of the Certificate handshake message failed"
1514
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001515# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1516
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001517run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001518 "$P_SRV key_file=data_files/server5.key \
1519 crt_file=data_files/server5.eku-srv.crt" \
1520 "$P_CLI" \
1521 0
1522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001523run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001524 "$P_SRV key_file=data_files/server5.key \
1525 crt_file=data_files/server5.eku-srv.crt" \
1526 "$P_CLI" \
1527 0
1528
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001529run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001530 "$P_SRV key_file=data_files/server5.key \
1531 crt_file=data_files/server5.eku-cs_any.crt" \
1532 "$P_CLI" \
1533 0
1534
1535# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001536run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001537 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1538 crt_file=data_files/server5.eku-cli.crt" \
1539 "$P_CLI psk=badbad" \
1540 1
1541
1542# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1543
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001544run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001545 "$O_SRV -key data_files/server5.key \
1546 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001547 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001548 0 \
1549 -C "bad certificate (usage extensions)" \
1550 -C "Processing of the Certificate handshake message failed" \
1551 -c "Ciphersuite is TLS-"
1552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001553run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001554 "$O_SRV -key data_files/server5.key \
1555 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001556 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001557 0 \
1558 -C "bad certificate (usage extensions)" \
1559 -C "Processing of the Certificate handshake message failed" \
1560 -c "Ciphersuite is TLS-"
1561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001562run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001563 "$O_SRV -key data_files/server5.key \
1564 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001565 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001566 0 \
1567 -C "bad certificate (usage extensions)" \
1568 -C "Processing of the Certificate handshake message failed" \
1569 -c "Ciphersuite is TLS-"
1570
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001571run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001572 "$O_SRV -key data_files/server5.key \
1573 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001574 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001575 1 \
1576 -c "bad certificate (usage extensions)" \
1577 -c "Processing of the Certificate handshake message failed" \
1578 -C "Ciphersuite is TLS-"
1579
1580# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1581
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001582run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001583 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001584 "$O_CLI -key data_files/server5.key \
1585 -cert data_files/server5.eku-cli.crt" \
1586 0 \
1587 -S "bad certificate (usage extensions)" \
1588 -S "Processing of the Certificate handshake message failed"
1589
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001590run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001591 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001592 "$O_CLI -key data_files/server5.key \
1593 -cert data_files/server5.eku-srv_cli.crt" \
1594 0 \
1595 -S "bad certificate (usage extensions)" \
1596 -S "Processing of the Certificate handshake message failed"
1597
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001598run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001599 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001600 "$O_CLI -key data_files/server5.key \
1601 -cert data_files/server5.eku-cs_any.crt" \
1602 0 \
1603 -S "bad certificate (usage extensions)" \
1604 -S "Processing of the Certificate handshake message failed"
1605
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001606run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001607 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001608 "$O_CLI -key data_files/server5.key \
1609 -cert data_files/server5.eku-cs.crt" \
1610 0 \
1611 -s "bad certificate (usage extensions)" \
1612 -S "Processing of the Certificate handshake message failed"
1613
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001614run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001615 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001616 "$O_CLI -key data_files/server5.key \
1617 -cert data_files/server5.eku-cs.crt" \
1618 1 \
1619 -s "bad certificate (usage extensions)" \
1620 -s "Processing of the Certificate handshake message failed"
1621
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001622# Tests for DHM parameters loading
1623
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001624run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001625 "$P_SRV" \
1626 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1627 debug_level=3" \
1628 0 \
1629 -c "value of 'DHM: P ' (2048 bits)" \
1630 -c "value of 'DHM: G ' (2048 bits)"
1631
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001632run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001633 "$P_SRV dhm_file=data_files/dhparams.pem" \
1634 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1635 debug_level=3" \
1636 0 \
1637 -c "value of 'DHM: P ' (1024 bits)" \
1638 -c "value of 'DHM: G ' (2 bits)"
1639
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001640# Tests for PSK callback
1641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001642run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001643 "$P_SRV psk=abc123 psk_identity=foo" \
1644 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1645 psk_identity=foo psk=abc123" \
1646 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001647 -S "SSL - The server has no ciphersuites in common" \
1648 -S "SSL - Unknown identity received" \
1649 -S "SSL - Verification of the message MAC failed"
1650
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001651run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001652 "$P_SRV" \
1653 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1654 psk_identity=foo psk=abc123" \
1655 1 \
1656 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001657 -S "SSL - Unknown identity received" \
1658 -S "SSL - Verification of the message MAC failed"
1659
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001660run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001661 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1662 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1663 psk_identity=foo psk=abc123" \
1664 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001665 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001666 -s "SSL - Unknown identity received" \
1667 -S "SSL - Verification of the message MAC failed"
1668
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001669run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001670 "$P_SRV psk_list=abc,dead,def,beef" \
1671 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1672 psk_identity=abc psk=dead" \
1673 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001674 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001675 -S "SSL - Unknown identity received" \
1676 -S "SSL - Verification of the message MAC failed"
1677
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001678run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001679 "$P_SRV psk_list=abc,dead,def,beef" \
1680 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1681 psk_identity=def psk=beef" \
1682 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001683 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001684 -S "SSL - Unknown identity received" \
1685 -S "SSL - Verification of the message MAC failed"
1686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001687run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001688 "$P_SRV psk_list=abc,dead,def,beef" \
1689 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1690 psk_identity=ghi psk=beef" \
1691 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001692 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001693 -s "SSL - Unknown identity received" \
1694 -S "SSL - Verification of the message MAC failed"
1695
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001696run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001697 "$P_SRV psk_list=abc,dead,def,beef" \
1698 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1699 psk_identity=abc psk=beef" \
1700 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001701 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001702 -S "SSL - Unknown identity received" \
1703 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001704
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001705# Tests for ciphersuites per version
1706
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001707run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001708 "$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" \
1709 "$P_CLI force_version=ssl3" \
1710 0 \
1711 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001713run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001714 "$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" \
1715 "$P_CLI force_version=tls1" \
1716 0 \
1717 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1718
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001719run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001720 "$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" \
1721 "$P_CLI force_version=tls1_1" \
1722 0 \
1723 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1724
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001725run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001726 "$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" \
1727 "$P_CLI force_version=tls1_2" \
1728 0 \
1729 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1730
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001731# Tests for ssl_get_bytes_avail()
1732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001733run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001734 "$P_SRV" \
1735 "$P_CLI request_size=100" \
1736 0 \
1737 -s "Read from client: 100 bytes read$"
1738
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001739run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001740 "$P_SRV" \
1741 "$P_CLI request_size=500" \
1742 0 \
1743 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001744
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001745# Tests for small packets
1746
1747run_test "Small packet SSLv3 BlockCipher" \
1748 "$P_SRV" \
1749 "$P_CLI request_size=1 force_version=ssl3 \
1750 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1751 0 \
1752 -s "Read from client: 1 bytes read"
1753
1754run_test "Small packet SSLv3 StreamCipher" \
1755 "$P_SRV" \
1756 "$P_CLI request_size=1 force_version=ssl3 \
1757 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1758 0 \
1759 -s "Read from client: 1 bytes read"
1760
1761run_test "Small packet TLS 1.0 BlockCipher" \
1762 "$P_SRV" \
1763 "$P_CLI request_size=1 force_version=tls1 \
1764 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1765 0 \
1766 -s "Read from client: 1 bytes read"
1767
1768run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1769 "$P_SRV" \
1770 "$P_CLI request_size=1 force_version=tls1 \
1771 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1772 trunc_hmac=1" \
1773 0 \
1774 -s "Read from client: 1 bytes read"
1775
1776run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1777 "$P_SRV" \
1778 "$P_CLI request_size=1 force_version=tls1 \
1779 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1780 trunc_hmac=1" \
1781 0 \
1782 -s "Read from client: 1 bytes read"
1783
1784run_test "Small packet TLS 1.1 BlockCipher" \
1785 "$P_SRV" \
1786 "$P_CLI request_size=1 force_version=tls1_1 \
1787 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1788 0 \
1789 -s "Read from client: 1 bytes read"
1790
1791run_test "Small packet TLS 1.1 StreamCipher" \
1792 "$P_SRV" \
1793 "$P_CLI request_size=1 force_version=tls1_1 \
1794 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1795 0 \
1796 -s "Read from client: 1 bytes read"
1797
1798run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1799 "$P_SRV" \
1800 "$P_CLI request_size=1 force_version=tls1_1 \
1801 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1802 trunc_hmac=1" \
1803 0 \
1804 -s "Read from client: 1 bytes read"
1805
1806run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1807 "$P_SRV" \
1808 "$P_CLI request_size=1 force_version=tls1_1 \
1809 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1810 trunc_hmac=1" \
1811 0 \
1812 -s "Read from client: 1 bytes read"
1813
1814run_test "Small packet TLS 1.2 BlockCipher" \
1815 "$P_SRV" \
1816 "$P_CLI request_size=1 force_version=tls1_2 \
1817 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1818 0 \
1819 -s "Read from client: 1 bytes read"
1820
1821run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1822 "$P_SRV" \
1823 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1824 0 \
1825 -s "Read from client: 1 bytes read"
1826
1827run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1828 "$P_SRV" \
1829 "$P_CLI request_size=1 force_version=tls1_2 \
1830 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1831 trunc_hmac=1" \
1832 0 \
1833 -s "Read from client: 1 bytes read"
1834
1835run_test "Small packet TLS 1.2 StreamCipher" \
1836 "$P_SRV" \
1837 "$P_CLI request_size=1 force_version=tls1_2 \
1838 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1839 0 \
1840 -s "Read from client: 1 bytes read"
1841
1842run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1843 "$P_SRV" \
1844 "$P_CLI request_size=1 force_version=tls1_2 \
1845 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1846 trunc_hmac=1" \
1847 0 \
1848 -s "Read from client: 1 bytes read"
1849
1850run_test "Small packet TLS 1.2 AEAD" \
1851 "$P_SRV" \
1852 "$P_CLI request_size=1 force_version=tls1_2 \
1853 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1854 0 \
1855 -s "Read from client: 1 bytes read"
1856
1857run_test "Small packet TLS 1.2 AEAD shorter tag" \
1858 "$P_SRV" \
1859 "$P_CLI request_size=1 force_version=tls1_2 \
1860 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1861 0 \
1862 -s "Read from client: 1 bytes read"
1863
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001864# Test for large packets
1865
1866run_test "Large packet SSLv3 BlockCipher" \
1867 "$P_SRV" \
1868 "$P_CLI request_size=16384 force_version=ssl3 \
1869 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1870 0 \
1871 -s "Read from client: 16384 bytes read"
1872
1873run_test "Large packet SSLv3 StreamCipher" \
1874 "$P_SRV" \
1875 "$P_CLI request_size=16384 force_version=ssl3 \
1876 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1877 0 \
1878 -s "Read from client: 16384 bytes read"
1879
1880run_test "Large packet TLS 1.0 BlockCipher" \
1881 "$P_SRV" \
1882 "$P_CLI request_size=16384 force_version=tls1 \
1883 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1884 0 \
1885 -s "Read from client: 16384 bytes read"
1886
1887run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1888 "$P_SRV" \
1889 "$P_CLI request_size=16384 force_version=tls1 \
1890 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1891 trunc_hmac=1" \
1892 0 \
1893 -s "Read from client: 16384 bytes read"
1894
1895run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1896 "$P_SRV" \
1897 "$P_CLI request_size=16384 force_version=tls1 \
1898 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1899 trunc_hmac=1" \
1900 0 \
1901 -s "Read from client: 16384 bytes read"
1902
1903run_test "Large packet TLS 1.1 BlockCipher" \
1904 "$P_SRV" \
1905 "$P_CLI request_size=16384 force_version=tls1_1 \
1906 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1907 0 \
1908 -s "Read from client: 16384 bytes read"
1909
1910run_test "Large packet TLS 1.1 StreamCipher" \
1911 "$P_SRV" \
1912 "$P_CLI request_size=16384 force_version=tls1_1 \
1913 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1914 0 \
1915 -s "Read from client: 16384 bytes read"
1916
1917run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1918 "$P_SRV" \
1919 "$P_CLI request_size=16384 force_version=tls1_1 \
1920 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1921 trunc_hmac=1" \
1922 0 \
1923 -s "Read from client: 16384 bytes read"
1924
1925run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1926 "$P_SRV" \
1927 "$P_CLI request_size=16384 force_version=tls1_1 \
1928 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1929 trunc_hmac=1" \
1930 0 \
1931 -s "Read from client: 16384 bytes read"
1932
1933run_test "Large packet TLS 1.2 BlockCipher" \
1934 "$P_SRV" \
1935 "$P_CLI request_size=16384 force_version=tls1_2 \
1936 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1937 0 \
1938 -s "Read from client: 16384 bytes read"
1939
1940run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1941 "$P_SRV" \
1942 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1943 0 \
1944 -s "Read from client: 16384 bytes read"
1945
1946run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1947 "$P_SRV" \
1948 "$P_CLI request_size=16384 force_version=tls1_2 \
1949 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1950 trunc_hmac=1" \
1951 0 \
1952 -s "Read from client: 16384 bytes read"
1953
1954run_test "Large packet TLS 1.2 StreamCipher" \
1955 "$P_SRV" \
1956 "$P_CLI request_size=16384 force_version=tls1_2 \
1957 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1958 0 \
1959 -s "Read from client: 16384 bytes read"
1960
1961run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1962 "$P_SRV" \
1963 "$P_CLI request_size=16384 force_version=tls1_2 \
1964 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1965 trunc_hmac=1" \
1966 0 \
1967 -s "Read from client: 16384 bytes read"
1968
1969run_test "Large packet TLS 1.2 AEAD" \
1970 "$P_SRV" \
1971 "$P_CLI request_size=16384 force_version=tls1_2 \
1972 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1973 0 \
1974 -s "Read from client: 16384 bytes read"
1975
1976run_test "Large packet TLS 1.2 AEAD shorter tag" \
1977 "$P_SRV" \
1978 "$P_CLI request_size=16384 force_version=tls1_2 \
1979 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1980 0 \
1981 -s "Read from client: 16384 bytes read"
1982
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001983# Tests for DTLS HelloVerifyRequest
1984
1985run_test "DTLS cookie: enabled" \
1986 "$P_SRV dtls=1 debug_level=2" \
1987 "$P_CLI dtls=1 debug_level=2" \
1988 0 \
1989 -s "cookie verification failed" \
1990 -s "cookie verification passed" \
1991 -S "cookie verification skipped" \
1992 -c "received hello verify request" \
1993 -S "SSL - The requested feature is not available"
1994
1995run_test "DTLS cookie: disabled" \
1996 "$P_SRV dtls=1 debug_level=2 cookies=0" \
1997 "$P_CLI dtls=1 debug_level=2" \
1998 0 \
1999 -S "cookie verification failed" \
2000 -S "cookie verification passed" \
2001 -s "cookie verification skipped" \
2002 -C "received hello verify request" \
2003 -S "SSL - The requested feature is not available"
2004
2005# wait for client having a timeout, or server sending an alert
2006#run_test "DTLS cookie: default (failing)" \
2007# "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2008# "$P_CLI dtls=1 debug_level=2" \
2009# 0 \
2010# -S "cookie verification failed" \
2011# -S "cookie verification passed" \
2012# -S "cookie verification skipped" \
2013# -C "received hello verify request" \
2014# -s "SSL - The requested feature is not available"
2015
2016requires_ipv6
2017run_test "DTLS cookie: enabled, IPv6" \
2018 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2019 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2020 0 \
2021 -s "cookie verification failed" \
2022 -s "cookie verification passed" \
2023 -S "cookie verification skipped" \
2024 -c "received hello verify request" \
2025 -S "SSL - The requested feature is not available"
2026
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02002027# Tests for receiving fragmented handshake messages with DTLS
2028
2029requires_gnutls
2030run_test "DTLS reassembly: no fragmentation (gnutls server)" \
2031 "$G_SRV -u --mtu 2048 -a" \
2032 "$P_CLI dtls=1 debug_level=2" \
2033 0 \
2034 -C "found fragmented DTLS handshake message" \
2035 -C "error"
2036
2037requires_gnutls
2038run_test "DTLS reassembly: some fragmentation (gnutls server)" \
2039 "$G_SRV -u --mtu 512" \
2040 "$P_CLI dtls=1 debug_level=2" \
2041 0 \
2042 -c "found fragmented DTLS handshake message" \
2043 -C "error"
2044
2045requires_gnutls
2046run_test "DTLS reassembly: more fragmentation (gnutls server)" \
2047 "$G_SRV -u --mtu 128" \
2048 "$P_CLI dtls=1 debug_level=2" \
2049 0 \
2050 -c "found fragmented DTLS handshake message" \
2051 -C "error"
2052
2053requires_gnutls
2054run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
2055 "$G_SRV -u --mtu 128" \
2056 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2057 0 \
2058 -c "found fragmented DTLS handshake message" \
2059 -C "error"
2060
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002061requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002062run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
2063 "$G_SRV -u --mtu 256" \
2064 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
2065 0 \
2066 -c "found fragmented DTLS handshake message" \
2067 -c "client hello, adding renegotiation extension" \
2068 -c "found renegotiation extension" \
2069 -c "=> renegotiate" \
2070 -C "ssl_handshake returned" \
2071 -C "error" \
2072 -s "Extra-header:"
2073
2074requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002075run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
2076 "$G_SRV -u --mtu 256" \
2077 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
2078 0 \
2079 -c "found fragmented DTLS handshake message" \
2080 -c "client hello, adding renegotiation extension" \
2081 -c "found renegotiation extension" \
2082 -c "=> renegotiate" \
2083 -C "ssl_handshake returned" \
2084 -C "error" \
2085 -s "Extra-header:"
2086
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002087run_test "DTLS reassembly: no fragmentation (openssl server)" \
2088 "$O_SRV -dtls1 -mtu 2048" \
2089 "$P_CLI dtls=1 debug_level=2" \
2090 0 \
2091 -C "found fragmented DTLS handshake message" \
2092 -C "error"
2093
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002094run_test "DTLS reassembly: some fragmentation (openssl server)" \
2095 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002096 "$P_CLI dtls=1 debug_level=2" \
2097 0 \
2098 -c "found fragmented DTLS handshake message" \
2099 -C "error"
2100
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002101run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002102 "$O_SRV -dtls1 -mtu 256" \
2103 "$P_CLI dtls=1 debug_level=2" \
2104 0 \
2105 -c "found fragmented DTLS handshake message" \
2106 -C "error"
2107
2108run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2109 "$O_SRV -dtls1 -mtu 256" \
2110 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2111 0 \
2112 -c "found fragmented DTLS handshake message" \
2113 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002114
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002115# Tests with UDP proxy emulating unreliable transport
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002116
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002117not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002118run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002119 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002120 "$P_SRV dtls=1 debug_level=2" \
2121 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002122 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002123 -C "replayed record" \
2124 -S "replayed record" \
2125 -C "record from another epoch" \
2126 -S "record from another epoch" \
2127 -C "discarding invalid record" \
2128 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002129 -C "resend" \
2130 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002131 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002132 -c "HTTP/1.0 200 OK"
2133
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002134not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002135run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002136 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002137 "$P_SRV dtls=1 debug_level=2" \
2138 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002139 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002140 -c "replayed record" \
2141 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002142 -c "discarding invalid record" \
2143 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002144 -C "resend" \
2145 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002146 -s "Extra-header:" \
2147 -c "HTTP/1.0 200 OK"
2148
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002149run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
2150 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002151 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
2152 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002153 0 \
2154 -c "replayed record" \
2155 -S "replayed record" \
2156 -c "discarding invalid record" \
2157 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002158 -c "resend" \
2159 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002160 -s "Extra-header:" \
2161 -c "HTTP/1.0 200 OK"
2162
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002163run_test "DTLS proxy: inject invalid AD record" \
2164 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002165 "$P_SRV dtls=1 debug_level=1" \
2166 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002167 0 \
2168 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002169 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002170 -s "Extra-header:" \
2171 -c "HTTP/1.0 200 OK"
2172
2173run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002174 -p "$P_PXY delay_ccs=1" \
2175 "$P_SRV dtls=1 debug_level=1" \
2176 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002177 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002178 -c "record from another epoch" \
2179 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002180 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002181 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002182 -s "Extra-header:" \
2183 -c "HTTP/1.0 200 OK"
2184
2185run_test "DTLS proxy: delay a few packets" \
2186 -p "$P_PXY delay=10" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002187 "$P_SRV dtls=1 debug_level=1" \
2188 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002189 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002190 -C "replayed record" \
2191 -S "replayed record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002192 -s "Extra-header:" \
2193 -c "HTTP/1.0 200 OK"
2194
2195run_test "DTLS proxy: delay a bit more packets" \
2196 -p "$P_PXY delay=6" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002197 "$P_SRV dtls=1 debug_level=1" \
2198 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002199 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002200 -C "replayed record" \
2201 -S "replayed record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002202 -s "Extra-header:" \
2203 -c "HTTP/1.0 200 OK"
2204
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002205needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002206run_test "DTLS proxy: delay more packets" \
2207 -p "$P_PXY delay=3" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002208 "$P_SRV dtls=1 debug_level=1" \
2209 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002210 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002211 -C "replayed record" \
2212 -S "replayed record" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002213 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002214 -c "HTTP/1.0 200 OK"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002215
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02002216run_test "DTLS proxy: drop a few packets" \
2217 -p "$P_PXY drop=10" \
2218 "$P_SRV dtls=1" \
2219 "$P_CLI dtls=1" \
2220 0 \
2221 -s "Extra-header:" \
2222 -c "HTTP/1.0 200 OK"
2223
2224needs_more_time 2
2225run_test "DTLS proxy: drop a bit more packets" \
2226 -p "$P_PXY drop=6" \
2227 "$P_SRV dtls=1" \
2228 "$P_CLI dtls=1" \
2229 0 \
2230 -s "Extra-header:" \
2231 -c "HTTP/1.0 200 OK"
2232
2233needs_more_time 3
2234run_test "DTLS proxy: drop more packets" \
2235 -p "$P_PXY drop=3" \
2236 "$P_SRV dtls=1" \
2237 "$P_CLI dtls=1" \
2238 0 \
2239 -s "Extra-header:" \
2240 -c "HTTP/1.0 200 OK"
2241
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002242needs_more_time 2
2243run_test "DTLS proxy: 3d (drop + delay + duplicate)" \
2244 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2245 "$P_SRV dtls=1" \
2246 "$P_CLI dtls=1" \
2247 0 \
2248 -s "Extra-header:" \
2249 -c "HTTP/1.0 200 OK"
2250
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002251# Final report
2252
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002253echo "------------------------------------------------------------------------"
2254
2255if [ $FAILS = 0 ]; then
2256 echo -n "PASSED"
2257else
2258 echo -n "FAILED"
2259fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002260PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002261echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002262
2263exit $FAILS