blob: f5949bf5237488cf223135021241a72256490971 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02009# Assumes a build with default options.
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010010
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020016: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010017: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020018: ${GNUTLS_CLI:=gnutls-cli}
19: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010020
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020021O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010022O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020023G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
24G_CLI="$GNUTLS_CLI"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010025
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010026TESTS=0
27FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020028SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010029
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020030CONFIG_H='../include/polarssl/config.h'
31
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010032MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010033FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020034EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010035
36print_usage() {
37 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010038 echo -e " -h|--help\tPrint this help."
39 echo -e " -m|--memcheck\tCheck memory leaks and errors."
40 echo -e " -f|--filter\tOnly matching tests are executed (default: '$FILTER')"
41 echo -e " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010042}
43
44get_options() {
45 while [ $# -gt 0 ]; do
46 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010047 -f|--filter)
48 shift; FILTER=$1
49 ;;
50 -e|--exclude)
51 shift; EXCLUDE=$1
52 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010053 -m|--memcheck)
54 MEMCHECK=1
55 ;;
56 -h|--help)
57 print_usage
58 exit 0
59 ;;
60 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020061 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062 print_usage
63 exit 1
64 ;;
65 esac
66 shift
67 done
68}
69
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020070# skip next test if OpenSSL can't send SSLv2 ClientHello
71requires_openssl_with_sslv2() {
72 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020073 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020074 OPENSSL_HAS_SSL2="YES"
75 else
76 OPENSSL_HAS_SSL2="NO"
77 fi
78 fi
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +020079
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020080 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
81 SKIP_NEXT="YES"
82 fi
83}
84
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020085# skip next test if GnuTLS isn't available
86requires_gnutls() {
87 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
88 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
89 GNUTLS_AVAILABLE="YES"
90 else
91 GNUTLS_AVAILABLE="NO"
92 fi
93 fi
94 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
95 SKIP_NEXT="YES"
96 fi
97}
98
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +020099# skip next test if IPv6 isn't available on this host
100requires_ipv6() {
101 if [ -z "${HAS_IPV6:-}" ]; then
102 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
103 SRV_PID=$!
104 sleep 1
105 kill $SRV_PID >/dev/null 2>&1
106 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
107 HAS_IPV6="NO"
108 else
109 HAS_IPV6="YES"
110 fi
111 rm -r $SRV_OUT
112 fi
113
114 if [ "$HAS_IPV6" = "NO" ]; then
115 SKIP_NEXT="YES"
116 fi
117}
118
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200119# skip the next test if valgrind is in use
120not_with_valgrind() {
121 if [ "$MEMCHECK" -gt 0 ]; then
122 SKIP_NEXT="YES"
123 fi
124}
125
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200126# multiply the client timeout delay by the given factor for the next test
127needs_more_time() {
128 CLI_DELAY_FACTOR=$1
129}
130
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100131# print_name <name>
132print_name() {
133 echo -n "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200134 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100135 for i in `seq 1 $LEN`; do echo -n '.'; done
136 echo -n ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100137
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200138 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100139}
140
141# fail <message>
142fail() {
143 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100144 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100145
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200146 mv $SRV_OUT o-srv-${TESTS}.log
147 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200148 if [ -n "$PXY_CMD" ]; then
149 mv $PXY_OUT o-pxy-${TESTS}.log
150 fi
151 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100152
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200153 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
154 echo " ! server output:"
155 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200156 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200157 echo " ! client output:"
158 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200159 if [ -n "$PXY_CMD" ]; then
160 echo " ! ========================================================"
161 echo " ! proxy output:"
162 cat o-pxy-${TESTS}.log
163 fi
164 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200165 fi
166
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200167 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100168}
169
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100170# is_polar <cmd_line>
171is_polar() {
172 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
173}
174
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200175# openssl s_server doesn't have -www with DTLS
176check_osrv_dtls() {
177 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
178 NEEDS_INPUT=1
179 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
180 else
181 NEEDS_INPUT=0
182 fi
183}
184
185# provide input to commands that need it
186provide_input() {
187 if [ $NEEDS_INPUT -eq 0 ]; then
188 return
189 fi
190
191 while true; do
192 echo "HTTP/1.0 200 OK"
193 sleep 1
194 done
195}
196
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100197# has_mem_err <log_file_name>
198has_mem_err() {
199 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
200 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
201 then
202 return 1 # false: does not have errors
203 else
204 return 0 # true: has errors
205 fi
206}
207
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200208# wait for server to start: two versions depending on lsof availability
209wait_server_start() {
210 if which lsof >/dev/null; then
211 # make sure we don't loop forever
212 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200213 DOG_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200214
215 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200216 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200217 until lsof -nbi UDP:"$SRV_PORT" | grep UDP >/dev/null; do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200218 else
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200219 until lsof -nbi TCP:"$SRV_PORT" | grep LISTEN >/dev/null; do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200220 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200221
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200222 kill $DOG_PID >/dev/null 2>&1
223 wait $DOG_PID
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200224 else
225 sleep "$START_DELAY"
226 fi
227}
228
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200229# wait for client to terminate and set CLI_EXIT
230# must be called right after starting the client
231wait_client_done() {
232 CLI_PID=$!
233
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200234 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
235 CLI_DELAY_FACTOR=1
236
237 ( sleep $CLI_DELAY; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200238 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200239
240 wait $CLI_PID
241 CLI_EXIT=$?
242
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200243 kill $DOG_PID >/dev/null 2>&1
244 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200245
246 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
247}
248
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200249# check if the given command uses dtls and sets global variable DTLS
250detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200251 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200252 DTLS=1
253 else
254 DTLS=0
255 fi
256}
257
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200258# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100259# Options: -s pattern pattern that must be present in server output
260# -c pattern pattern that must be present in client output
261# -S pattern pattern that must be absent in server output
262# -C pattern pattern that must be absent in client output
263run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100264 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200265 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100266
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100267 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
268 else
269 return
270 fi
271
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100272 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100273
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200274 # should we skip?
275 if [ "X$SKIP_NEXT" = "XYES" ]; then
276 SKIP_NEXT="NO"
277 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200278 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200279 return
280 fi
281
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200282 # does this test use a proxy?
283 if [ "X$1" = "X-p" ]; then
284 PXY_CMD="$2"
285 shift 2
286 else
287 PXY_CMD=""
288 fi
289
290 # get commands and client output
291 SRV_CMD="$1"
292 CLI_CMD="$2"
293 CLI_EXPECT="$3"
294 shift 3
295
296 # fix client port
297 if [ -n "$PXY_CMD" ]; then
298 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
299 else
300 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
301 fi
302
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200303 # update DTLS variable
304 detect_dtls "$SRV_CMD"
305
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100306 # prepend valgrind to our commands if active
307 if [ "$MEMCHECK" -gt 0 ]; then
308 if is_polar "$SRV_CMD"; then
309 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
310 fi
311 if is_polar "$CLI_CMD"; then
312 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
313 fi
314 fi
315
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100316 # run the commands
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200317 if [ -n "$PXY_CMD" ]; then
318 echo "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200319 $PXY_CMD >> $PXY_OUT 2>&1 &
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200320 PXY_PID=$!
321 # assume proxy starts faster than server
322 fi
323
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200324 check_osrv_dtls
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200325 echo "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200326 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100327 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200328 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200329
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200330 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200331 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
332 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100333
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200334 # terminate the server (and the proxy)
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200335 kill $SRV_PID
336 wait $SRV_PID
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200337 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200338 kill $PXY_PID >/dev/null 2>&1
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200339 wait $PXY_PID
340 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100341
342 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200343 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100344 # expected client exit to incorrectly succeed in case of catastrophic
345 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100346 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200347 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100348 else
349 fail "server failed to start"
350 return
351 fi
352 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100353 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200354 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100355 else
356 fail "client failed to start"
357 return
358 fi
359 fi
360
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100361 # check server exit code
362 if [ $? != 0 ]; then
363 fail "server fail"
364 return
365 fi
366
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100367 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100368 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
369 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100370 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200371 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100372 return
373 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100374
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100375 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200376 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100377 while [ $# -gt 0 ]
378 do
379 case $1 in
380 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200381 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100382 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100383 return
384 fi
385 ;;
386
387 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200388 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100389 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100390 return
391 fi
392 ;;
393
394 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200395 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100396 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100397 return
398 fi
399 ;;
400
401 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200402 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100403 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100404 return
405 fi
406 ;;
407
408 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200409 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100410 exit 1
411 esac
412 shift 2
413 done
414
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100415 # check valgrind's results
416 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200417 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100418 fail "Server has memory errors"
419 return
420 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200421 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100422 fail "Client has memory errors"
423 return
424 fi
425 fi
426
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100427 # if we're here, everything is ok
428 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200429 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100430}
431
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100432cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200433 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200434 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
435 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
436 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
437 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100438 exit 1
439}
440
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100441#
442# MAIN
443#
444
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100445get_options "$@"
446
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100447# sanity checks, avoid an avalanche of errors
448if [ ! -x "$P_SRV" ]; then
449 echo "Command '$P_SRV' is not an executable file"
450 exit 1
451fi
452if [ ! -x "$P_CLI" ]; then
453 echo "Command '$P_CLI' is not an executable file"
454 exit 1
455fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200456if [ ! -x "$P_PXY" ]; then
457 echo "Command '$P_PXY' is not an executable file"
458 exit 1
459fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100460if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
461 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100462 exit 1
463fi
464
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200465# used by watchdog
466MAIN_PID="$$"
467
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200468# be more patient with valgrind
469if [ "$MEMCHECK" -gt 0 ]; then
470 START_DELAY=3
471 DOG_DELAY=30
472else
473 START_DELAY=1
474 DOG_DELAY=10
475fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200476CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200477
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200478# Pick a "unique" server port in the range 10000-19999, and a proxy port
479PORT_BASE="0000$$"
480PORT_BASE="$( echo -n $PORT_BASE | tail -c 4 )"
481SRV_PORT="1$PORT_BASE"
482PXY_PORT="2$PORT_BASE"
483unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200484
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200485# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200486P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
487P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
488P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
489O_SRV="$O_SRV -accept $SRV_PORT"
490O_CLI="$O_CLI -connect localhost:+SRV_PORT"
491G_SRV="$G_SRV -p $SRV_PORT"
492G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200493
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200494# Also pick a unique name for intermediate files
495SRV_OUT="srv_out.$$"
496CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200497PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200498SESSION="session.$$"
499
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200500SKIP_NEXT="NO"
501
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100502trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100503
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200504# Basic test
505
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200506# Checks that:
507# - things work with all ciphersuites active (used with config-full in all.sh)
508# - the expected (highest security) parameters are selected
509# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200510run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200511 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200512 "$P_CLI" \
513 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200514 -s "Protocol is TLSv1.2" \
515 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
516 -s "client hello v3, signature_algorithm ext: 6" \
517 -s "ECDHE curve: secp521r1" \
518 -S "error" \
519 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200520
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100521# Test for SSLv2 ClientHello
522
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200523requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200524run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100525 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100526 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100527 0 \
528 -S "parse client hello v2" \
529 -S "ssl_handshake returned"
530
531# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200532requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200533run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200534 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100535 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100536 0 \
537 -s "parse client hello v2" \
538 -S "ssl_handshake returned"
539
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100540# Tests for Truncated HMAC extension
541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200542run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200543 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100544 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100545 0 \
546 -s "dumping 'computed mac' (20 bytes)"
547
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200548run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200549 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100550 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100551 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100552 -s "dumping 'computed mac' (10 bytes)"
553
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100554# Tests for Session Tickets
555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200556run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200557 "$P_SRV debug_level=3 tickets=1" \
558 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100559 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100560 -c "client hello, adding session ticket extension" \
561 -s "found session ticket extension" \
562 -s "server hello, adding session ticket extension" \
563 -c "found session_ticket extension" \
564 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100565 -S "session successfully restored from cache" \
566 -s "session successfully restored from ticket" \
567 -s "a session has been resumed" \
568 -c "a session has been resumed"
569
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200570run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200571 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
572 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100573 0 \
574 -c "client hello, adding session ticket extension" \
575 -s "found session ticket extension" \
576 -s "server hello, adding session ticket extension" \
577 -c "found session_ticket extension" \
578 -c "parse new session ticket" \
579 -S "session successfully restored from cache" \
580 -s "session successfully restored from ticket" \
581 -s "a session has been resumed" \
582 -c "a session has been resumed"
583
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200584run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200585 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
586 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100587 0 \
588 -c "client hello, adding session ticket extension" \
589 -s "found session ticket extension" \
590 -s "server hello, adding session ticket extension" \
591 -c "found session_ticket extension" \
592 -c "parse new session ticket" \
593 -S "session successfully restored from cache" \
594 -S "session successfully restored from ticket" \
595 -S "a session has been resumed" \
596 -C "a session has been resumed"
597
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200598run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100599 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200600 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100601 0 \
602 -c "client hello, adding session ticket extension" \
603 -c "found session_ticket extension" \
604 -c "parse new session ticket" \
605 -c "a session has been resumed"
606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200607run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200608 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200609 "( $O_CLI -sess_out $SESSION; \
610 $O_CLI -sess_in $SESSION; \
611 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100612 0 \
613 -s "found session ticket extension" \
614 -s "server hello, adding session ticket extension" \
615 -S "session successfully restored from cache" \
616 -s "session successfully restored from ticket" \
617 -s "a session has been resumed"
618
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100619# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200621run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200622 "$P_SRV debug_level=3 tickets=0" \
623 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100624 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100625 -c "client hello, adding session ticket extension" \
626 -s "found session ticket extension" \
627 -S "server hello, adding session ticket extension" \
628 -C "found session_ticket extension" \
629 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100630 -s "session successfully restored from cache" \
631 -S "session successfully restored from ticket" \
632 -s "a session has been resumed" \
633 -c "a session has been resumed"
634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200635run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200636 "$P_SRV debug_level=3 tickets=1" \
637 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100638 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100639 -C "client hello, adding session ticket extension" \
640 -S "found session ticket extension" \
641 -S "server hello, adding session ticket extension" \
642 -C "found session_ticket extension" \
643 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100644 -s "session successfully restored from cache" \
645 -S "session successfully restored from ticket" \
646 -s "a session has been resumed" \
647 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100648
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200649run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200650 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
651 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100652 0 \
653 -S "session successfully restored from cache" \
654 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100655 -S "a session has been resumed" \
656 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100657
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200658run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200659 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
660 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100661 0 \
662 -s "session successfully restored from cache" \
663 -S "session successfully restored from ticket" \
664 -s "a session has been resumed" \
665 -c "a session has been resumed"
666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200667run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200668 "$P_SRV debug_level=3 tickets=0" \
669 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100670 0 \
671 -s "session successfully restored from cache" \
672 -S "session successfully restored from ticket" \
673 -s "a session has been resumed" \
674 -c "a session has been resumed"
675
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200676run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200677 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
678 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100679 0 \
680 -S "session successfully restored from cache" \
681 -S "session successfully restored from ticket" \
682 -S "a session has been resumed" \
683 -C "a session has been resumed"
684
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200685run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200686 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
687 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100688 0 \
689 -s "session successfully restored from cache" \
690 -S "session successfully restored from ticket" \
691 -s "a session has been resumed" \
692 -c "a session has been resumed"
693
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200694run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200695 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200696 "( $O_CLI -sess_out $SESSION; \
697 $O_CLI -sess_in $SESSION; \
698 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100699 0 \
700 -s "found session ticket extension" \
701 -S "server hello, adding session ticket extension" \
702 -s "session successfully restored from cache" \
703 -S "session successfully restored from ticket" \
704 -s "a session has been resumed"
705
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200706run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100707 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200708 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100709 0 \
710 -C "found session_ticket extension" \
711 -C "parse new session ticket" \
712 -c "a session has been resumed"
713
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100714# Tests for Max Fragment Length extension
715
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200716run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200717 "$P_SRV debug_level=3" \
718 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100719 0 \
720 -C "client hello, adding max_fragment_length extension" \
721 -S "found max fragment length extension" \
722 -S "server hello, max_fragment_length extension" \
723 -C "found max_fragment_length extension"
724
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200725run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200726 "$P_SRV debug_level=3" \
727 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100728 0 \
729 -c "client hello, adding max_fragment_length extension" \
730 -s "found max fragment length extension" \
731 -s "server hello, max_fragment_length extension" \
732 -c "found max_fragment_length extension"
733
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200734run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200735 "$P_SRV debug_level=3 max_frag_len=4096" \
736 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100737 0 \
738 -C "client hello, adding max_fragment_length extension" \
739 -S "found max fragment length extension" \
740 -S "server hello, max_fragment_length extension" \
741 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200743requires_gnutls
744run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200745 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200746 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200747 0 \
748 -c "client hello, adding max_fragment_length extension" \
749 -c "found max_fragment_length extension"
750
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100751# Tests for renegotiation
752
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200753run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200754 "$P_SRV debug_level=3 exchanges=2" \
755 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100756 0 \
757 -C "client hello, adding renegotiation extension" \
758 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
759 -S "found renegotiation extension" \
760 -s "server hello, secure renegotiation extension" \
761 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100762 -C "=> renegotiate" \
763 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100764 -S "write hello request"
765
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200766run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200767 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
768 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100769 0 \
770 -c "client hello, adding renegotiation extension" \
771 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
772 -s "found renegotiation extension" \
773 -s "server hello, secure renegotiation extension" \
774 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100775 -c "=> renegotiate" \
776 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100777 -S "write hello request"
778
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200779run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200780 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
781 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100782 0 \
783 -c "client hello, adding renegotiation extension" \
784 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
785 -s "found renegotiation extension" \
786 -s "server hello, secure renegotiation extension" \
787 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100788 -c "=> renegotiate" \
789 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100790 -s "write hello request"
791
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200792run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200793 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
794 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100795 0 \
796 -c "client hello, adding renegotiation extension" \
797 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
798 -s "found renegotiation extension" \
799 -s "server hello, secure renegotiation extension" \
800 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100801 -c "=> renegotiate" \
802 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100803 -s "write hello request"
804
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200805run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200806 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
807 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100808 1 \
809 -c "client hello, adding renegotiation extension" \
810 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
811 -S "found renegotiation extension" \
812 -s "server hello, secure renegotiation extension" \
813 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100814 -c "=> renegotiate" \
815 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200816 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200817 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200818 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100819
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200820run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200821 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
822 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100823 0 \
824 -C "client hello, adding renegotiation extension" \
825 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
826 -S "found renegotiation extension" \
827 -s "server hello, secure renegotiation extension" \
828 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100829 -C "=> renegotiate" \
830 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100831 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200832 -S "SSL - An unexpected message was received from our peer" \
833 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200835run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200836 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200837 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200838 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200839 0 \
840 -C "client hello, adding renegotiation extension" \
841 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
842 -S "found renegotiation extension" \
843 -s "server hello, secure renegotiation extension" \
844 -c "found renegotiation extension" \
845 -C "=> renegotiate" \
846 -S "=> renegotiate" \
847 -s "write hello request" \
848 -S "SSL - An unexpected message was received from our peer" \
849 -S "failed"
850
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200851# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200852run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200853 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200854 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200855 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200856 0 \
857 -C "client hello, adding renegotiation extension" \
858 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
859 -S "found renegotiation extension" \
860 -s "server hello, secure renegotiation extension" \
861 -c "found renegotiation extension" \
862 -C "=> renegotiate" \
863 -S "=> renegotiate" \
864 -s "write hello request" \
865 -S "SSL - An unexpected message was received from our peer" \
866 -S "failed"
867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200868run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200869 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200870 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200871 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200872 0 \
873 -C "client hello, adding renegotiation extension" \
874 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
875 -S "found renegotiation extension" \
876 -s "server hello, secure renegotiation extension" \
877 -c "found renegotiation extension" \
878 -C "=> renegotiate" \
879 -S "=> renegotiate" \
880 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200881 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200882
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200883run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200884 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200885 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200886 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200887 0 \
888 -c "client hello, adding renegotiation extension" \
889 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
890 -s "found renegotiation extension" \
891 -s "server hello, secure renegotiation extension" \
892 -c "found renegotiation extension" \
893 -c "=> renegotiate" \
894 -s "=> renegotiate" \
895 -s "write hello request" \
896 -S "SSL - An unexpected message was received from our peer" \
897 -S "failed"
898
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200899run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200900 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
901 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200902 0 \
903 -c "client hello, adding renegotiation extension" \
904 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
905 -s "found renegotiation extension" \
906 -s "server hello, secure renegotiation extension" \
907 -c "found renegotiation extension" \
908 -c "=> renegotiate" \
909 -s "=> renegotiate" \
910 -S "write hello request"
911
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200912run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200913 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
914 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200915 0 \
916 -c "client hello, adding renegotiation extension" \
917 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
918 -s "found renegotiation extension" \
919 -s "server hello, secure renegotiation extension" \
920 -c "found renegotiation extension" \
921 -c "=> renegotiate" \
922 -s "=> renegotiate" \
923 -s "write hello request"
924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200925run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +0200926 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200927 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200928 0 \
929 -c "client hello, adding renegotiation extension" \
930 -c "found renegotiation extension" \
931 -c "=> renegotiate" \
932 -C "ssl_handshake returned" \
933 -C "error" \
934 -c "HTTP/1.0 200 [Oo][Kk]"
935
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200936run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200937 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200938 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200939 0 \
940 -c "client hello, adding renegotiation extension" \
941 -c "found renegotiation extension" \
942 -c "=> renegotiate" \
943 -C "ssl_handshake returned" \
944 -C "error" \
945 -c "HTTP/1.0 200 [Oo][Kk]"
946
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +0200947run_test "Renegotiation: DTLS, client-initiated" \
948 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
949 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
950 0 \
951 -c "client hello, adding renegotiation extension" \
952 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
953 -s "found renegotiation extension" \
954 -s "server hello, secure renegotiation extension" \
955 -c "found renegotiation extension" \
956 -c "=> renegotiate" \
957 -s "=> renegotiate" \
958 -S "write hello request"
959
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +0200960run_test "Renegotiation: DTLS, server-initiated" \
961 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
962 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
963 0 \
964 -c "client hello, adding renegotiation extension" \
965 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
966 -s "found renegotiation extension" \
967 -s "server hello, secure renegotiation extension" \
968 -c "found renegotiation extension" \
969 -c "=> renegotiate" \
970 -s "=> renegotiate" \
971 -s "write hello request"
972
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +0200973run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
974 "$G_SRV -u --mtu 4096" \
975 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
976 0 \
977 -c "client hello, adding renegotiation extension" \
978 -c "found renegotiation extension" \
979 -c "=> renegotiate" \
980 -C "ssl_handshake returned" \
981 -C "error" \
982 -s "Extra-header:"
983
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100984# Tests for auth_mode
985
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200986run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100987 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100988 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200989 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100990 1 \
991 -c "x509_verify_cert() returned" \
992 -c "! self-signed or not signed by a trusted CA" \
993 -c "! ssl_handshake returned" \
994 -c "X509 - Certificate verification failed"
995
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200996run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100997 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100998 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200999 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001000 0 \
1001 -c "x509_verify_cert() returned" \
1002 -c "! self-signed or not signed by a trusted CA" \
1003 -C "! ssl_handshake returned" \
1004 -C "X509 - Certificate verification failed"
1005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001006run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001007 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001008 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001009 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001010 0 \
1011 -C "x509_verify_cert() returned" \
1012 -C "! self-signed or not signed by a trusted CA" \
1013 -C "! ssl_handshake returned" \
1014 -C "X509 - Certificate verification failed"
1015
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001016run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001017 "$P_SRV debug_level=3 auth_mode=required" \
1018 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001019 key_file=data_files/server5.key" \
1020 1 \
1021 -S "skip write certificate request" \
1022 -C "skip parse certificate request" \
1023 -c "got a certificate request" \
1024 -C "skip write certificate" \
1025 -C "skip write certificate verify" \
1026 -S "skip parse certificate verify" \
1027 -s "x509_verify_cert() returned" \
1028 -S "! self-signed or not signed by a trusted CA" \
1029 -s "! ssl_handshake returned" \
1030 -c "! ssl_handshake returned" \
1031 -s "X509 - Certificate verification failed"
1032
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001033run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001034 "$P_SRV debug_level=3 auth_mode=optional" \
1035 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001036 key_file=data_files/server5.key" \
1037 0 \
1038 -S "skip write certificate request" \
1039 -C "skip parse certificate request" \
1040 -c "got a certificate request" \
1041 -C "skip write certificate" \
1042 -C "skip write certificate verify" \
1043 -S "skip parse certificate verify" \
1044 -s "x509_verify_cert() returned" \
1045 -s "! self-signed or not signed by a trusted CA" \
1046 -S "! ssl_handshake returned" \
1047 -C "! ssl_handshake returned" \
1048 -S "X509 - Certificate verification failed"
1049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001050run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001051 "$P_SRV debug_level=3 auth_mode=none" \
1052 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001053 key_file=data_files/server5.key" \
1054 0 \
1055 -s "skip write certificate request" \
1056 -C "skip parse certificate request" \
1057 -c "got no certificate request" \
1058 -c "skip write certificate" \
1059 -c "skip write certificate verify" \
1060 -s "skip parse certificate verify" \
1061 -S "x509_verify_cert() returned" \
1062 -S "! self-signed or not signed by a trusted CA" \
1063 -S "! ssl_handshake returned" \
1064 -C "! ssl_handshake returned" \
1065 -S "X509 - Certificate verification failed"
1066
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001067run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001068 "$P_SRV debug_level=3 auth_mode=optional" \
1069 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001070 0 \
1071 -S "skip write certificate request" \
1072 -C "skip parse certificate request" \
1073 -c "got a certificate request" \
1074 -C "skip write certificate$" \
1075 -C "got no certificate to send" \
1076 -S "SSLv3 client has no certificate" \
1077 -c "skip write certificate verify" \
1078 -s "skip parse certificate verify" \
1079 -s "! no client certificate sent" \
1080 -S "! ssl_handshake returned" \
1081 -C "! ssl_handshake returned" \
1082 -S "X509 - Certificate verification failed"
1083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001084run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001085 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001086 "$O_CLI" \
1087 0 \
1088 -S "skip write certificate request" \
1089 -s "skip parse certificate verify" \
1090 -s "! no client certificate sent" \
1091 -S "! ssl_handshake returned" \
1092 -S "X509 - Certificate verification failed"
1093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001094run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001095 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001096 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001097 0 \
1098 -C "skip parse certificate request" \
1099 -c "got a certificate request" \
1100 -C "skip write certificate$" \
1101 -c "skip write certificate verify" \
1102 -C "! ssl_handshake returned"
1103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001104run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001105 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1106 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001107 0 \
1108 -S "skip write certificate request" \
1109 -C "skip parse certificate request" \
1110 -c "got a certificate request" \
1111 -C "skip write certificate$" \
1112 -c "skip write certificate verify" \
1113 -c "got no certificate to send" \
1114 -s "SSLv3 client has no certificate" \
1115 -s "skip parse certificate verify" \
1116 -s "! no client certificate sent" \
1117 -S "! ssl_handshake returned" \
1118 -C "! ssl_handshake returned" \
1119 -S "X509 - Certificate verification failed"
1120
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001121# tests for SNI
1122
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001123run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001124 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001125 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001126 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001127 0 \
1128 -S "parse ServerName extension" \
1129 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1130 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001132run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001133 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001134 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001135 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 +02001136 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001137 0 \
1138 -s "parse ServerName extension" \
1139 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1140 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001142run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001143 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001144 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001145 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 +02001146 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001147 0 \
1148 -s "parse ServerName extension" \
1149 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001150 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001152run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001153 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001154 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001155 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 +02001156 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001157 1 \
1158 -s "parse ServerName extension" \
1159 -s "ssl_sni_wrapper() returned" \
1160 -s "ssl_handshake returned" \
1161 -c "ssl_handshake returned" \
1162 -c "SSL - A fatal alert message was received from our peer"
1163
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001164# Tests for non-blocking I/O: exercise a variety of handshake flows
1165
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001166run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001167 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1168 "$P_CLI nbio=2 tickets=0" \
1169 0 \
1170 -S "ssl_handshake returned" \
1171 -C "ssl_handshake returned" \
1172 -c "Read from server: .* bytes read"
1173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001174run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001175 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1176 "$P_CLI nbio=2 tickets=0" \
1177 0 \
1178 -S "ssl_handshake returned" \
1179 -C "ssl_handshake returned" \
1180 -c "Read from server: .* bytes read"
1181
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001182run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001183 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1184 "$P_CLI nbio=2 tickets=1" \
1185 0 \
1186 -S "ssl_handshake returned" \
1187 -C "ssl_handshake returned" \
1188 -c "Read from server: .* bytes read"
1189
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001190run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001191 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1192 "$P_CLI nbio=2 tickets=1" \
1193 0 \
1194 -S "ssl_handshake returned" \
1195 -C "ssl_handshake returned" \
1196 -c "Read from server: .* bytes read"
1197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001198run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001199 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1200 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1201 0 \
1202 -S "ssl_handshake returned" \
1203 -C "ssl_handshake returned" \
1204 -c "Read from server: .* bytes read"
1205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001206run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001207 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1208 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1209 0 \
1210 -S "ssl_handshake returned" \
1211 -C "ssl_handshake returned" \
1212 -c "Read from server: .* bytes read"
1213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001214run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001215 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1216 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1217 0 \
1218 -S "ssl_handshake returned" \
1219 -C "ssl_handshake returned" \
1220 -c "Read from server: .* bytes read"
1221
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001222# Tests for version negotiation
1223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001224run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001225 "$P_SRV" \
1226 "$P_CLI" \
1227 0 \
1228 -S "ssl_handshake returned" \
1229 -C "ssl_handshake returned" \
1230 -s "Protocol is TLSv1.2" \
1231 -c "Protocol is TLSv1.2"
1232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001233run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001234 "$P_SRV" \
1235 "$P_CLI max_version=tls1_1" \
1236 0 \
1237 -S "ssl_handshake returned" \
1238 -C "ssl_handshake returned" \
1239 -s "Protocol is TLSv1.1" \
1240 -c "Protocol is TLSv1.1"
1241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001242run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001243 "$P_SRV max_version=tls1_1" \
1244 "$P_CLI" \
1245 0 \
1246 -S "ssl_handshake returned" \
1247 -C "ssl_handshake returned" \
1248 -s "Protocol is TLSv1.1" \
1249 -c "Protocol is TLSv1.1"
1250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001251run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001252 "$P_SRV max_version=tls1_1" \
1253 "$P_CLI max_version=tls1_1" \
1254 0 \
1255 -S "ssl_handshake returned" \
1256 -C "ssl_handshake returned" \
1257 -s "Protocol is TLSv1.1" \
1258 -c "Protocol is TLSv1.1"
1259
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001260run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001261 "$P_SRV min_version=tls1_1" \
1262 "$P_CLI max_version=tls1_1" \
1263 0 \
1264 -S "ssl_handshake returned" \
1265 -C "ssl_handshake returned" \
1266 -s "Protocol is TLSv1.1" \
1267 -c "Protocol is TLSv1.1"
1268
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001269run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001270 "$P_SRV max_version=tls1_1" \
1271 "$P_CLI min_version=tls1_1" \
1272 0 \
1273 -S "ssl_handshake returned" \
1274 -C "ssl_handshake returned" \
1275 -s "Protocol is TLSv1.1" \
1276 -c "Protocol is TLSv1.1"
1277
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001278run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001279 "$P_SRV max_version=tls1_1" \
1280 "$P_CLI min_version=tls1_2" \
1281 1 \
1282 -s "ssl_handshake returned" \
1283 -c "ssl_handshake returned" \
1284 -c "SSL - Handshake protocol not within min/max boundaries"
1285
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001286run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001287 "$P_SRV min_version=tls1_2" \
1288 "$P_CLI max_version=tls1_1" \
1289 1 \
1290 -s "ssl_handshake returned" \
1291 -c "ssl_handshake returned" \
1292 -s "SSL - Handshake protocol not within min/max boundaries"
1293
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001294# Tests for ALPN extension
1295
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001296if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1297
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001298run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001299 "$P_SRV debug_level=3" \
1300 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001301 0 \
1302 -C "client hello, adding alpn extension" \
1303 -S "found alpn extension" \
1304 -C "got an alert message, type: \\[2:120]" \
1305 -S "server hello, adding alpn extension" \
1306 -C "found alpn extension " \
1307 -C "Application Layer Protocol is" \
1308 -S "Application Layer Protocol is"
1309
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001310run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001311 "$P_SRV debug_level=3" \
1312 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001313 0 \
1314 -c "client hello, adding alpn extension" \
1315 -s "found alpn extension" \
1316 -C "got an alert message, type: \\[2:120]" \
1317 -S "server hello, adding alpn extension" \
1318 -C "found alpn extension " \
1319 -c "Application Layer Protocol is (none)" \
1320 -S "Application Layer Protocol is"
1321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001322run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001323 "$P_SRV debug_level=3 alpn=abc,1234" \
1324 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001325 0 \
1326 -C "client hello, adding alpn extension" \
1327 -S "found alpn extension" \
1328 -C "got an alert message, type: \\[2:120]" \
1329 -S "server hello, adding alpn extension" \
1330 -C "found alpn extension " \
1331 -C "Application Layer Protocol is" \
1332 -s "Application Layer Protocol is (none)"
1333
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001334run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001335 "$P_SRV debug_level=3 alpn=abc,1234" \
1336 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001337 0 \
1338 -c "client hello, adding alpn extension" \
1339 -s "found alpn extension" \
1340 -C "got an alert message, type: \\[2:120]" \
1341 -s "server hello, adding alpn extension" \
1342 -c "found alpn extension" \
1343 -c "Application Layer Protocol is abc" \
1344 -s "Application Layer Protocol is abc"
1345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001346run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001347 "$P_SRV debug_level=3 alpn=abc,1234" \
1348 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001349 0 \
1350 -c "client hello, adding alpn extension" \
1351 -s "found alpn extension" \
1352 -C "got an alert message, type: \\[2:120]" \
1353 -s "server hello, adding alpn extension" \
1354 -c "found alpn extension" \
1355 -c "Application Layer Protocol is abc" \
1356 -s "Application Layer Protocol is abc"
1357
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001358run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001359 "$P_SRV debug_level=3 alpn=abc,1234" \
1360 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001361 0 \
1362 -c "client hello, adding alpn extension" \
1363 -s "found alpn extension" \
1364 -C "got an alert message, type: \\[2:120]" \
1365 -s "server hello, adding alpn extension" \
1366 -c "found alpn extension" \
1367 -c "Application Layer Protocol is 1234" \
1368 -s "Application Layer Protocol is 1234"
1369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001370run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001371 "$P_SRV debug_level=3 alpn=abc,123" \
1372 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001373 1 \
1374 -c "client hello, adding alpn extension" \
1375 -s "found alpn extension" \
1376 -c "got an alert message, type: \\[2:120]" \
1377 -S "server hello, adding alpn extension" \
1378 -C "found alpn extension" \
1379 -C "Application Layer Protocol is 1234" \
1380 -S "Application Layer Protocol is 1234"
1381
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001382fi
1383
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001384# Tests for keyUsage in leaf certificates, part 1:
1385# server-side certificate/suite selection
1386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001387run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001388 "$P_SRV key_file=data_files/server2.key \
1389 crt_file=data_files/server2.ku-ds.crt" \
1390 "$P_CLI" \
1391 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001392 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001393
1394
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001395run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001396 "$P_SRV key_file=data_files/server2.key \
1397 crt_file=data_files/server2.ku-ke.crt" \
1398 "$P_CLI" \
1399 0 \
1400 -c "Ciphersuite is TLS-RSA-WITH-"
1401
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001402run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001403 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001404 crt_file=data_files/server2.ku-ka.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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001409run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001410 "$P_SRV key_file=data_files/server5.key \
1411 crt_file=data_files/server5.ku-ds.crt" \
1412 "$P_CLI" \
1413 0 \
1414 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1415
1416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001417run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001418 "$P_SRV key_file=data_files/server5.key \
1419 crt_file=data_files/server5.ku-ka.crt" \
1420 "$P_CLI" \
1421 0 \
1422 -c "Ciphersuite is TLS-ECDH-"
1423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001424run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001425 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001426 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001427 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001428 1 \
1429 -C "Ciphersuite is "
1430
1431# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001432# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001434run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001435 "$O_SRV -key data_files/server2.key \
1436 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001437 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001438 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1439 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001440 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001441 -C "Processing of the Certificate handshake message failed" \
1442 -c "Ciphersuite is TLS-"
1443
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001444run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001445 "$O_SRV -key data_files/server2.key \
1446 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001447 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001448 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1449 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001450 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001451 -C "Processing of the Certificate handshake message failed" \
1452 -c "Ciphersuite is TLS-"
1453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001454run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001455 "$O_SRV -key data_files/server2.key \
1456 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001457 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001458 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1459 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001460 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001461 -C "Processing of the Certificate handshake message failed" \
1462 -c "Ciphersuite is TLS-"
1463
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001464run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001465 "$O_SRV -key data_files/server2.key \
1466 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001467 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001468 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1469 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001470 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001471 -c "Processing of the Certificate handshake message failed" \
1472 -C "Ciphersuite is TLS-"
1473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001474run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001475 "$O_SRV -key data_files/server2.key \
1476 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001477 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001478 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1479 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001480 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001481 -C "Processing of the Certificate handshake message failed" \
1482 -c "Ciphersuite is TLS-"
1483
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001484run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001485 "$O_SRV -key data_files/server2.key \
1486 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001487 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001488 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1489 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001490 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001491 -c "Processing of the Certificate handshake message failed" \
1492 -C "Ciphersuite is TLS-"
1493
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001494# Tests for keyUsage in leaf certificates, part 3:
1495# server-side checking of client cert
1496
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001497run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001498 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001499 "$O_CLI -key data_files/server2.key \
1500 -cert data_files/server2.ku-ds.crt" \
1501 0 \
1502 -S "bad certificate (usage extensions)" \
1503 -S "Processing of the Certificate handshake message failed"
1504
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001505run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001506 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001507 "$O_CLI -key data_files/server2.key \
1508 -cert data_files/server2.ku-ke.crt" \
1509 0 \
1510 -s "bad certificate (usage extensions)" \
1511 -S "Processing of the Certificate handshake message failed"
1512
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001513run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001514 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001515 "$O_CLI -key data_files/server2.key \
1516 -cert data_files/server2.ku-ke.crt" \
1517 1 \
1518 -s "bad certificate (usage extensions)" \
1519 -s "Processing of the Certificate handshake message failed"
1520
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001521run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001522 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001523 "$O_CLI -key data_files/server5.key \
1524 -cert data_files/server5.ku-ds.crt" \
1525 0 \
1526 -S "bad certificate (usage extensions)" \
1527 -S "Processing of the Certificate handshake message failed"
1528
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001529run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001530 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001531 "$O_CLI -key data_files/server5.key \
1532 -cert data_files/server5.ku-ka.crt" \
1533 0 \
1534 -s "bad certificate (usage extensions)" \
1535 -S "Processing of the Certificate handshake message failed"
1536
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001537# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1538
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001539run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001540 "$P_SRV key_file=data_files/server5.key \
1541 crt_file=data_files/server5.eku-srv.crt" \
1542 "$P_CLI" \
1543 0
1544
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001545run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001546 "$P_SRV key_file=data_files/server5.key \
1547 crt_file=data_files/server5.eku-srv.crt" \
1548 "$P_CLI" \
1549 0
1550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001551run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001552 "$P_SRV key_file=data_files/server5.key \
1553 crt_file=data_files/server5.eku-cs_any.crt" \
1554 "$P_CLI" \
1555 0
1556
1557# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001558run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001559 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1560 crt_file=data_files/server5.eku-cli.crt" \
1561 "$P_CLI psk=badbad" \
1562 1
1563
1564# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001566run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001567 "$O_SRV -key data_files/server5.key \
1568 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001569 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001570 0 \
1571 -C "bad certificate (usage extensions)" \
1572 -C "Processing of the Certificate handshake message failed" \
1573 -c "Ciphersuite is TLS-"
1574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001575run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001576 "$O_SRV -key data_files/server5.key \
1577 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001578 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001579 0 \
1580 -C "bad certificate (usage extensions)" \
1581 -C "Processing of the Certificate handshake message failed" \
1582 -c "Ciphersuite is TLS-"
1583
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001584run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001585 "$O_SRV -key data_files/server5.key \
1586 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001587 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001588 0 \
1589 -C "bad certificate (usage extensions)" \
1590 -C "Processing of the Certificate handshake message failed" \
1591 -c "Ciphersuite is TLS-"
1592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001593run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001594 "$O_SRV -key data_files/server5.key \
1595 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001596 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001597 1 \
1598 -c "bad certificate (usage extensions)" \
1599 -c "Processing of the Certificate handshake message failed" \
1600 -C "Ciphersuite is TLS-"
1601
1602# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001604run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001605 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001606 "$O_CLI -key data_files/server5.key \
1607 -cert data_files/server5.eku-cli.crt" \
1608 0 \
1609 -S "bad certificate (usage extensions)" \
1610 -S "Processing of the Certificate handshake message failed"
1611
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001612run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001613 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001614 "$O_CLI -key data_files/server5.key \
1615 -cert data_files/server5.eku-srv_cli.crt" \
1616 0 \
1617 -S "bad certificate (usage extensions)" \
1618 -S "Processing of the Certificate handshake message failed"
1619
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001620run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001621 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001622 "$O_CLI -key data_files/server5.key \
1623 -cert data_files/server5.eku-cs_any.crt" \
1624 0 \
1625 -S "bad certificate (usage extensions)" \
1626 -S "Processing of the Certificate handshake message failed"
1627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001628run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001629 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001630 "$O_CLI -key data_files/server5.key \
1631 -cert data_files/server5.eku-cs.crt" \
1632 0 \
1633 -s "bad certificate (usage extensions)" \
1634 -S "Processing of the Certificate handshake message failed"
1635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001636run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001637 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001638 "$O_CLI -key data_files/server5.key \
1639 -cert data_files/server5.eku-cs.crt" \
1640 1 \
1641 -s "bad certificate (usage extensions)" \
1642 -s "Processing of the Certificate handshake message failed"
1643
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001644# Tests for DHM parameters loading
1645
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001646run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001647 "$P_SRV" \
1648 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1649 debug_level=3" \
1650 0 \
1651 -c "value of 'DHM: P ' (2048 bits)" \
1652 -c "value of 'DHM: G ' (2048 bits)"
1653
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001654run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001655 "$P_SRV dhm_file=data_files/dhparams.pem" \
1656 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1657 debug_level=3" \
1658 0 \
1659 -c "value of 'DHM: P ' (1024 bits)" \
1660 -c "value of 'DHM: G ' (2 bits)"
1661
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001662# Tests for PSK callback
1663
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001664run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001665 "$P_SRV psk=abc123 psk_identity=foo" \
1666 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1667 psk_identity=foo psk=abc123" \
1668 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001669 -S "SSL - The server has no ciphersuites in common" \
1670 -S "SSL - Unknown identity received" \
1671 -S "SSL - Verification of the message MAC failed"
1672
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001673run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001674 "$P_SRV" \
1675 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1676 psk_identity=foo psk=abc123" \
1677 1 \
1678 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001679 -S "SSL - Unknown identity received" \
1680 -S "SSL - Verification of the message MAC failed"
1681
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001682run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001683 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1684 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1685 psk_identity=foo psk=abc123" \
1686 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001687 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001688 -s "SSL - Unknown identity received" \
1689 -S "SSL - Verification of the message MAC failed"
1690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001691run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001692 "$P_SRV psk_list=abc,dead,def,beef" \
1693 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1694 psk_identity=abc psk=dead" \
1695 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001696 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001697 -S "SSL - Unknown identity received" \
1698 -S "SSL - Verification of the message MAC failed"
1699
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001700run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001701 "$P_SRV psk_list=abc,dead,def,beef" \
1702 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1703 psk_identity=def psk=beef" \
1704 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001705 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001706 -S "SSL - Unknown identity received" \
1707 -S "SSL - Verification of the message MAC failed"
1708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001709run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001710 "$P_SRV psk_list=abc,dead,def,beef" \
1711 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1712 psk_identity=ghi psk=beef" \
1713 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001714 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001715 -s "SSL - Unknown identity received" \
1716 -S "SSL - Verification of the message MAC failed"
1717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001718run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001719 "$P_SRV psk_list=abc,dead,def,beef" \
1720 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1721 psk_identity=abc psk=beef" \
1722 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001723 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001724 -S "SSL - Unknown identity received" \
1725 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001726
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001727# Tests for ciphersuites per version
1728
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001729run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001730 "$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" \
1731 "$P_CLI force_version=ssl3" \
1732 0 \
1733 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001735run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001736 "$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" \
1737 "$P_CLI force_version=tls1" \
1738 0 \
1739 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1740
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001741run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001742 "$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" \
1743 "$P_CLI force_version=tls1_1" \
1744 0 \
1745 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001747run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001748 "$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" \
1749 "$P_CLI force_version=tls1_2" \
1750 0 \
1751 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1752
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001753# Tests for ssl_get_bytes_avail()
1754
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001755run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001756 "$P_SRV" \
1757 "$P_CLI request_size=100" \
1758 0 \
1759 -s "Read from client: 100 bytes read$"
1760
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001761run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001762 "$P_SRV" \
1763 "$P_CLI request_size=500" \
1764 0 \
1765 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001766
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001767# Tests for small packets
1768
1769run_test "Small packet SSLv3 BlockCipher" \
1770 "$P_SRV" \
1771 "$P_CLI request_size=1 force_version=ssl3 \
1772 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1773 0 \
1774 -s "Read from client: 1 bytes read"
1775
1776run_test "Small packet SSLv3 StreamCipher" \
1777 "$P_SRV" \
1778 "$P_CLI request_size=1 force_version=ssl3 \
1779 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1780 0 \
1781 -s "Read from client: 1 bytes read"
1782
1783run_test "Small packet TLS 1.0 BlockCipher" \
1784 "$P_SRV" \
1785 "$P_CLI request_size=1 force_version=tls1 \
1786 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1787 0 \
1788 -s "Read from client: 1 bytes read"
1789
1790run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1791 "$P_SRV" \
1792 "$P_CLI request_size=1 force_version=tls1 \
1793 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1794 trunc_hmac=1" \
1795 0 \
1796 -s "Read from client: 1 bytes read"
1797
1798run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1799 "$P_SRV" \
1800 "$P_CLI request_size=1 force_version=tls1 \
1801 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1802 trunc_hmac=1" \
1803 0 \
1804 -s "Read from client: 1 bytes read"
1805
1806run_test "Small packet TLS 1.1 BlockCipher" \
1807 "$P_SRV" \
1808 "$P_CLI request_size=1 force_version=tls1_1 \
1809 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1810 0 \
1811 -s "Read from client: 1 bytes read"
1812
1813run_test "Small packet TLS 1.1 StreamCipher" \
1814 "$P_SRV" \
1815 "$P_CLI request_size=1 force_version=tls1_1 \
1816 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1817 0 \
1818 -s "Read from client: 1 bytes read"
1819
1820run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1821 "$P_SRV" \
1822 "$P_CLI request_size=1 force_version=tls1_1 \
1823 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1824 trunc_hmac=1" \
1825 0 \
1826 -s "Read from client: 1 bytes read"
1827
1828run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1829 "$P_SRV" \
1830 "$P_CLI request_size=1 force_version=tls1_1 \
1831 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1832 trunc_hmac=1" \
1833 0 \
1834 -s "Read from client: 1 bytes read"
1835
1836run_test "Small packet TLS 1.2 BlockCipher" \
1837 "$P_SRV" \
1838 "$P_CLI request_size=1 force_version=tls1_2 \
1839 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1840 0 \
1841 -s "Read from client: 1 bytes read"
1842
1843run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1844 "$P_SRV" \
1845 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1846 0 \
1847 -s "Read from client: 1 bytes read"
1848
1849run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1850 "$P_SRV" \
1851 "$P_CLI request_size=1 force_version=tls1_2 \
1852 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1853 trunc_hmac=1" \
1854 0 \
1855 -s "Read from client: 1 bytes read"
1856
1857run_test "Small packet TLS 1.2 StreamCipher" \
1858 "$P_SRV" \
1859 "$P_CLI request_size=1 force_version=tls1_2 \
1860 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1861 0 \
1862 -s "Read from client: 1 bytes read"
1863
1864run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1865 "$P_SRV" \
1866 "$P_CLI request_size=1 force_version=tls1_2 \
1867 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1868 trunc_hmac=1" \
1869 0 \
1870 -s "Read from client: 1 bytes read"
1871
1872run_test "Small packet TLS 1.2 AEAD" \
1873 "$P_SRV" \
1874 "$P_CLI request_size=1 force_version=tls1_2 \
1875 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1876 0 \
1877 -s "Read from client: 1 bytes read"
1878
1879run_test "Small packet TLS 1.2 AEAD shorter tag" \
1880 "$P_SRV" \
1881 "$P_CLI request_size=1 force_version=tls1_2 \
1882 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1883 0 \
1884 -s "Read from client: 1 bytes read"
1885
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001886# Test for large packets
1887
1888run_test "Large packet SSLv3 BlockCipher" \
1889 "$P_SRV" \
1890 "$P_CLI request_size=16384 force_version=ssl3 \
1891 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1892 0 \
1893 -s "Read from client: 16384 bytes read"
1894
1895run_test "Large packet SSLv3 StreamCipher" \
1896 "$P_SRV" \
1897 "$P_CLI request_size=16384 force_version=ssl3 \
1898 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1899 0 \
1900 -s "Read from client: 16384 bytes read"
1901
1902run_test "Large packet TLS 1.0 BlockCipher" \
1903 "$P_SRV" \
1904 "$P_CLI request_size=16384 force_version=tls1 \
1905 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1906 0 \
1907 -s "Read from client: 16384 bytes read"
1908
1909run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1910 "$P_SRV" \
1911 "$P_CLI request_size=16384 force_version=tls1 \
1912 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1913 trunc_hmac=1" \
1914 0 \
1915 -s "Read from client: 16384 bytes read"
1916
1917run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1918 "$P_SRV" \
1919 "$P_CLI request_size=16384 force_version=tls1 \
1920 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1921 trunc_hmac=1" \
1922 0 \
1923 -s "Read from client: 16384 bytes read"
1924
1925run_test "Large packet TLS 1.1 BlockCipher" \
1926 "$P_SRV" \
1927 "$P_CLI request_size=16384 force_version=tls1_1 \
1928 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1929 0 \
1930 -s "Read from client: 16384 bytes read"
1931
1932run_test "Large packet TLS 1.1 StreamCipher" \
1933 "$P_SRV" \
1934 "$P_CLI request_size=16384 force_version=tls1_1 \
1935 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1936 0 \
1937 -s "Read from client: 16384 bytes read"
1938
1939run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1940 "$P_SRV" \
1941 "$P_CLI request_size=16384 force_version=tls1_1 \
1942 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1943 trunc_hmac=1" \
1944 0 \
1945 -s "Read from client: 16384 bytes read"
1946
1947run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1948 "$P_SRV" \
1949 "$P_CLI request_size=16384 force_version=tls1_1 \
1950 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1951 trunc_hmac=1" \
1952 0 \
1953 -s "Read from client: 16384 bytes read"
1954
1955run_test "Large packet TLS 1.2 BlockCipher" \
1956 "$P_SRV" \
1957 "$P_CLI request_size=16384 force_version=tls1_2 \
1958 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1959 0 \
1960 -s "Read from client: 16384 bytes read"
1961
1962run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1963 "$P_SRV" \
1964 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1965 0 \
1966 -s "Read from client: 16384 bytes read"
1967
1968run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1969 "$P_SRV" \
1970 "$P_CLI request_size=16384 force_version=tls1_2 \
1971 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1972 trunc_hmac=1" \
1973 0 \
1974 -s "Read from client: 16384 bytes read"
1975
1976run_test "Large packet TLS 1.2 StreamCipher" \
1977 "$P_SRV" \
1978 "$P_CLI request_size=16384 force_version=tls1_2 \
1979 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1980 0 \
1981 -s "Read from client: 16384 bytes read"
1982
1983run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1984 "$P_SRV" \
1985 "$P_CLI request_size=16384 force_version=tls1_2 \
1986 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1987 trunc_hmac=1" \
1988 0 \
1989 -s "Read from client: 16384 bytes read"
1990
1991run_test "Large packet TLS 1.2 AEAD" \
1992 "$P_SRV" \
1993 "$P_CLI request_size=16384 force_version=tls1_2 \
1994 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1995 0 \
1996 -s "Read from client: 16384 bytes read"
1997
1998run_test "Large packet TLS 1.2 AEAD shorter tag" \
1999 "$P_SRV" \
2000 "$P_CLI request_size=16384 force_version=tls1_2 \
2001 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2002 0 \
2003 -s "Read from client: 16384 bytes read"
2004
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002005# Tests for DTLS HelloVerifyRequest
2006
2007run_test "DTLS cookie: enabled" \
2008 "$P_SRV dtls=1 debug_level=2" \
2009 "$P_CLI dtls=1 debug_level=2" \
2010 0 \
2011 -s "cookie verification failed" \
2012 -s "cookie verification passed" \
2013 -S "cookie verification skipped" \
2014 -c "received hello verify request" \
2015 -S "SSL - The requested feature is not available"
2016
2017run_test "DTLS cookie: disabled" \
2018 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2019 "$P_CLI dtls=1 debug_level=2" \
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
2027# wait for client having a timeout, or server sending an alert
2028#run_test "DTLS cookie: default (failing)" \
2029# "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2030# "$P_CLI dtls=1 debug_level=2" \
2031# 0 \
2032# -S "cookie verification failed" \
2033# -S "cookie verification passed" \
2034# -S "cookie verification skipped" \
2035# -C "received hello verify request" \
2036# -s "SSL - The requested feature is not available"
2037
2038requires_ipv6
2039run_test "DTLS cookie: enabled, IPv6" \
2040 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2041 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2042 0 \
2043 -s "cookie verification failed" \
2044 -s "cookie verification passed" \
2045 -S "cookie verification skipped" \
2046 -c "received hello verify request" \
2047 -S "SSL - The requested feature is not available"
2048
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002049# Tests for various cases of client authentication with DTLS
2050# (focused on handshake flows and message parsing)
2051
2052run_test "DTLS client auth: required" \
2053 "$P_SRV dtls=1 auth_mode=required" \
2054 "$P_CLI dtls=1" \
2055 0 \
2056 -s "Verifying peer X.509 certificate... ok"
2057
2058run_test "DTLS client auth: optional, client has no cert" \
2059 "$P_SRV dtls=1 auth_mode=optional" \
2060 "$P_CLI dtls=1 crt_file=none key_file=none" \
2061 0 \
2062 -s "! no client certificate sent"
2063
2064run_test "DTLS client auth: optional, client has no cert" \
2065 "$P_SRV dtls=1 auth_mode=none" \
2066 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
2067 0 \
2068 -c "skip write certificate$" \
2069 -s "! no client certificate sent"
2070
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02002071# Tests for receiving fragmented handshake messages with DTLS
2072
2073requires_gnutls
2074run_test "DTLS reassembly: no fragmentation (gnutls server)" \
2075 "$G_SRV -u --mtu 2048 -a" \
2076 "$P_CLI dtls=1 debug_level=2" \
2077 0 \
2078 -C "found fragmented DTLS handshake message" \
2079 -C "error"
2080
2081requires_gnutls
2082run_test "DTLS reassembly: some fragmentation (gnutls server)" \
2083 "$G_SRV -u --mtu 512" \
2084 "$P_CLI dtls=1 debug_level=2" \
2085 0 \
2086 -c "found fragmented DTLS handshake message" \
2087 -C "error"
2088
2089requires_gnutls
2090run_test "DTLS reassembly: more fragmentation (gnutls server)" \
2091 "$G_SRV -u --mtu 128" \
2092 "$P_CLI dtls=1 debug_level=2" \
2093 0 \
2094 -c "found fragmented DTLS handshake message" \
2095 -C "error"
2096
2097requires_gnutls
2098run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
2099 "$G_SRV -u --mtu 128" \
2100 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2101 0 \
2102 -c "found fragmented DTLS handshake message" \
2103 -C "error"
2104
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002105requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002106run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
2107 "$G_SRV -u --mtu 256" \
2108 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
2109 0 \
2110 -c "found fragmented DTLS handshake message" \
2111 -c "client hello, adding renegotiation extension" \
2112 -c "found renegotiation extension" \
2113 -c "=> renegotiate" \
2114 -C "ssl_handshake returned" \
2115 -C "error" \
2116 -s "Extra-header:"
2117
2118requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002119run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
2120 "$G_SRV -u --mtu 256" \
2121 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
2122 0 \
2123 -c "found fragmented DTLS handshake message" \
2124 -c "client hello, adding renegotiation extension" \
2125 -c "found renegotiation extension" \
2126 -c "=> renegotiate" \
2127 -C "ssl_handshake returned" \
2128 -C "error" \
2129 -s "Extra-header:"
2130
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002131run_test "DTLS reassembly: no fragmentation (openssl server)" \
2132 "$O_SRV -dtls1 -mtu 2048" \
2133 "$P_CLI dtls=1 debug_level=2" \
2134 0 \
2135 -C "found fragmented DTLS handshake message" \
2136 -C "error"
2137
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002138run_test "DTLS reassembly: some fragmentation (openssl server)" \
2139 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002140 "$P_CLI dtls=1 debug_level=2" \
2141 0 \
2142 -c "found fragmented DTLS handshake message" \
2143 -C "error"
2144
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002145run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002146 "$O_SRV -dtls1 -mtu 256" \
2147 "$P_CLI dtls=1 debug_level=2" \
2148 0 \
2149 -c "found fragmented DTLS handshake message" \
2150 -C "error"
2151
2152run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2153 "$O_SRV -dtls1 -mtu 256" \
2154 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2155 0 \
2156 -c "found fragmented DTLS handshake message" \
2157 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002158
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002159# Tests with UDP proxy emulating unreliable transport
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002160
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002161not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002162run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002163 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002164 "$P_SRV dtls=1 debug_level=2" \
2165 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002166 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002167 -C "replayed record" \
2168 -S "replayed record" \
2169 -C "record from another epoch" \
2170 -S "record from another epoch" \
2171 -C "discarding invalid record" \
2172 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002173 -C "resend" \
2174 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002175 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002176 -c "HTTP/1.0 200 OK"
2177
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002178not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002179run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002180 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002181 "$P_SRV dtls=1 debug_level=2" \
2182 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002183 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002184 -c "replayed record" \
2185 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002186 -c "discarding invalid record" \
2187 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002188 -C "resend" \
2189 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002190 -s "Extra-header:" \
2191 -c "HTTP/1.0 200 OK"
2192
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002193run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
2194 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002195 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
2196 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002197 0 \
2198 -c "replayed record" \
2199 -S "replayed record" \
2200 -c "discarding invalid record" \
2201 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002202 -c "resend" \
2203 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002204 -s "Extra-header:" \
2205 -c "HTTP/1.0 200 OK"
2206
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002207run_test "DTLS proxy: inject invalid AD record" \
2208 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002209 "$P_SRV dtls=1 debug_level=1" \
2210 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002211 0 \
2212 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002213 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002214 -s "Extra-header:" \
2215 -c "HTTP/1.0 200 OK"
2216
2217run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002218 -p "$P_PXY delay_ccs=1" \
2219 "$P_SRV dtls=1 debug_level=1" \
2220 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002221 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002222 -c "record from another epoch" \
2223 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002224 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002225 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002226 -s "Extra-header:" \
2227 -c "HTTP/1.0 200 OK"
2228
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002229needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002230run_test "DTLS proxy: delay packets heavily" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002231 -p "$P_PXY delay=3" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002232 "$P_SRV dtls=1 debug_level=1" \
2233 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002234 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002235 -C "replayed record" \
2236 -S "replayed record" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002237 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002238 -c "HTTP/1.0 200 OK"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002239
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02002240needs_more_time 3
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002241run_test "DTLS proxy: drop packets heavily" \
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02002242 -p "$P_PXY drop=3" \
2243 "$P_SRV dtls=1" \
2244 "$P_CLI dtls=1" \
2245 0 \
2246 -s "Extra-header:" \
2247 -c "HTTP/1.0 200 OK"
2248
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002249# now try a variety of handshake flows with "unreliable connection"
2250
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002251needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002252run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002253 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002254 "$P_SRV dtls=1 tickets=0 auth_mode=none psk=abc123" \
2255 "$P_CLI dtls=1 tickets=0 psk=abc123 \
2256 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2257 0 \
2258 -s "Extra-header:" \
2259 -c "HTTP/1.0 200 OK"
2260
2261needs_more_time 2
2262run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
2263 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2264 "$P_SRV dtls=1 tickets=0 auth_mode=none" \
2265 "$P_CLI dtls=1 tickets=0 \
2266 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2267 0 \
2268 -s "Extra-header:" \
2269 -c "HTTP/1.0 200 OK"
2270
2271needs_more_time 2
2272run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
2273 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2274 "$P_SRV dtls=1 tickets=0 auth_mode=none" \
2275 "$P_CLI dtls=1 tickets=0" \
2276 0 \
2277 -s "Extra-header:" \
2278 -c "HTTP/1.0 200 OK"
2279
2280needs_more_time 2
2281run_test "DTLS proxy: 3d, FS, client auth" \
2282 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2283 "$P_SRV dtls=1 tickets=0 auth_mode=required" \
2284 "$P_CLI dtls=1 tickets=0" \
2285 0 \
2286 -s "Extra-header:" \
2287 -c "HTTP/1.0 200 OK"
2288
2289needs_more_time 2
2290run_test "DTLS proxy: 3d, FS, ticket" \
2291 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2292 "$P_SRV dtls=1 tickets=1 auth_mode=none" \
2293 "$P_CLI dtls=1 tickets=1" \
2294 0 \
2295 -s "Extra-header:" \
2296 -c "HTTP/1.0 200 OK"
2297
2298needs_more_time 2
2299run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
2300 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2301 "$P_SRV dtls=1 tickets=1 auth_mode=required" \
2302 "$P_CLI dtls=1 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002303 0 \
2304 -s "Extra-header:" \
2305 -c "HTTP/1.0 200 OK"
2306
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002307needs_more_time 4
2308run_test "DTLS proxy: 3d, min handshake, client-initiated renegotiation" \
2309 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2310 "$P_SRV dtls=1 tickets=0 auth_mode=none psk=abc123
2311 renegotiation=1 debug_level=2" \
2312 "$P_CLI dtls=1 tickets=0 psk=abc123 renegotiate=1 debug_level=2
2313 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2314 0 \
2315 -c "=> renegotiate" \
2316 -s "=> renegotiate" \
2317 -s "Extra-header:" \
2318 -c "HTTP/1.0 200 OK"
2319
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02002320needs_more_time 2
2321run_test "DTLS proxy: 3d, max handshake, openssl server" \
2322 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
2323 "$O_SRV -dtls1 -mtu 2048" \
2324 "$P_CLI dtls=1" \
2325 0 \
2326 -s "Extra-header:" \
2327 -c "HTTP/1.0 200 OK"
2328
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002329# Final report
2330
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002331echo "------------------------------------------------------------------------"
2332
2333if [ $FAILS = 0 ]; then
2334 echo -n "PASSED"
2335else
2336 echo -n "FAILED"
2337fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002338PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002339echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002340
2341exit $FAILS