blob: 86a29d1028fdca69714189f81db6a30c0ca42040 [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"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010024G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
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é-Gonnardf46f1282014-12-11 11:51:28 +010038 printf " -h|--help\tPrint this help.\n"
39 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
40 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
41 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
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é-Gonnard1cbd39d2014-10-20 13:34:59 +020085# skip next test if OpenSSL doesn't support FALLBACK_SCSV
86requires_openssl_with_fallback_scsv() {
87 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
88 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
89 then
90 OPENSSL_HAS_FBSCSV="YES"
91 else
92 OPENSSL_HAS_FBSCSV="NO"
93 fi
94 fi
95 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
96 SKIP_NEXT="YES"
97 fi
98}
99
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200100# skip next test if GnuTLS isn't available
101requires_gnutls() {
102 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
103 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
104 GNUTLS_AVAILABLE="YES"
105 else
106 GNUTLS_AVAILABLE="NO"
107 fi
108 fi
109 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
110 SKIP_NEXT="YES"
111 fi
112}
113
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200114# skip next test if IPv6 isn't available on this host
115requires_ipv6() {
116 if [ -z "${HAS_IPV6:-}" ]; then
117 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
118 SRV_PID=$!
119 sleep 1
120 kill $SRV_PID >/dev/null 2>&1
121 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
122 HAS_IPV6="NO"
123 else
124 HAS_IPV6="YES"
125 fi
126 rm -r $SRV_OUT
127 fi
128
129 if [ "$HAS_IPV6" = "NO" ]; then
130 SKIP_NEXT="YES"
131 fi
132}
133
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200134# skip the next test if valgrind is in use
135not_with_valgrind() {
136 if [ "$MEMCHECK" -gt 0 ]; then
137 SKIP_NEXT="YES"
138 fi
139}
140
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200141# multiply the client timeout delay by the given factor for the next test
142needs_more_time() {
143 CLI_DELAY_FACTOR=$1
144}
145
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100146# print_name <name>
147print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100148 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200149 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100150 for i in `seq 1 $LEN`; do printf '.'; done
151 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100152
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200153 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100154}
155
156# fail <message>
157fail() {
158 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100159 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100160
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200161 mv $SRV_OUT o-srv-${TESTS}.log
162 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200163 if [ -n "$PXY_CMD" ]; then
164 mv $PXY_OUT o-pxy-${TESTS}.log
165 fi
166 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100167
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200168 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
169 echo " ! server output:"
170 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200171 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200172 echo " ! client output:"
173 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200174 if [ -n "$PXY_CMD" ]; then
175 echo " ! ========================================================"
176 echo " ! proxy output:"
177 cat o-pxy-${TESTS}.log
178 fi
179 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200180 fi
181
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200182 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100183}
184
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100185# is_polar <cmd_line>
186is_polar() {
187 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
188}
189
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200190# openssl s_server doesn't have -www with DTLS
191check_osrv_dtls() {
192 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
193 NEEDS_INPUT=1
194 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
195 else
196 NEEDS_INPUT=0
197 fi
198}
199
200# provide input to commands that need it
201provide_input() {
202 if [ $NEEDS_INPUT -eq 0 ]; then
203 return
204 fi
205
206 while true; do
207 echo "HTTP/1.0 200 OK"
208 sleep 1
209 done
210}
211
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100212# has_mem_err <log_file_name>
213has_mem_err() {
214 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
215 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
216 then
217 return 1 # false: does not have errors
218 else
219 return 0 # true: has errors
220 fi
221}
222
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200223# wait for server to start: two versions depending on lsof availability
224wait_server_start() {
225 if which lsof >/dev/null; then
226 # make sure we don't loop forever
227 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200228 DOG_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200229
230 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200231 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnarda65d5082015-01-12 14:54:55 +0100232 until lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null;
233 do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200234 else
Manuel Pégourié-Gonnarda65d5082015-01-12 14:54:55 +0100235 until lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null;
236 do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200237 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200238
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200239 kill $DOG_PID >/dev/null 2>&1
240 wait $DOG_PID
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200241 else
242 sleep "$START_DELAY"
243 fi
244}
245
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200246# wait for client to terminate and set CLI_EXIT
247# must be called right after starting the client
248wait_client_done() {
249 CLI_PID=$!
250
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200251 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
252 CLI_DELAY_FACTOR=1
253
254 ( sleep $CLI_DELAY; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200255 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200256
257 wait $CLI_PID
258 CLI_EXIT=$?
259
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200260 kill $DOG_PID >/dev/null 2>&1
261 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200262
263 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
264}
265
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200266# check if the given command uses dtls and sets global variable DTLS
267detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200268 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200269 DTLS=1
270 else
271 DTLS=0
272 fi
273}
274
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200275# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100276# Options: -s pattern pattern that must be present in server output
277# -c pattern pattern that must be present in client output
278# -S pattern pattern that must be absent in server output
279# -C pattern pattern that must be absent in client output
280run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100281 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200282 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100283
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100284 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
285 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200286 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100287 return
288 fi
289
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100290 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100291
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200292 # should we skip?
293 if [ "X$SKIP_NEXT" = "XYES" ]; then
294 SKIP_NEXT="NO"
295 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200296 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200297 return
298 fi
299
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200300 # does this test use a proxy?
301 if [ "X$1" = "X-p" ]; then
302 PXY_CMD="$2"
303 shift 2
304 else
305 PXY_CMD=""
306 fi
307
308 # get commands and client output
309 SRV_CMD="$1"
310 CLI_CMD="$2"
311 CLI_EXPECT="$3"
312 shift 3
313
314 # fix client port
315 if [ -n "$PXY_CMD" ]; then
316 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
317 else
318 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
319 fi
320
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200321 # update DTLS variable
322 detect_dtls "$SRV_CMD"
323
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100324 # prepend valgrind to our commands if active
325 if [ "$MEMCHECK" -gt 0 ]; then
326 if is_polar "$SRV_CMD"; then
327 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
328 fi
329 if is_polar "$CLI_CMD"; then
330 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
331 fi
332 fi
333
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100334 # run the commands
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200335 if [ -n "$PXY_CMD" ]; then
336 echo "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200337 $PXY_CMD >> $PXY_OUT 2>&1 &
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200338 PXY_PID=$!
339 # assume proxy starts faster than server
340 fi
341
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200342 check_osrv_dtls
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200343 echo "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200344 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100345 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200346 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200347
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200348 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200349 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
350 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100351
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200352 # terminate the server (and the proxy)
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200353 kill $SRV_PID
354 wait $SRV_PID
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200355 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200356 kill $PXY_PID >/dev/null 2>&1
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200357 wait $PXY_PID
358 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100359
360 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200361 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100362 # expected client exit to incorrectly succeed in case of catastrophic
363 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100364 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200365 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100366 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100367 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100368 return
369 fi
370 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100371 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200372 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100373 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100374 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100375 return
376 fi
377 fi
378
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100379 # check server exit code
380 if [ $? != 0 ]; then
381 fail "server fail"
382 return
383 fi
384
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100385 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100386 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
387 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100388 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200389 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100390 return
391 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100392
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100393 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200394 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100395 while [ $# -gt 0 ]
396 do
397 case $1 in
398 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200399 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100400 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100401 return
402 fi
403 ;;
404
405 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200406 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100407 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100408 return
409 fi
410 ;;
411
412 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200413 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100414 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100415 return
416 fi
417 ;;
418
419 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200420 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100421 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100422 return
423 fi
424 ;;
425
426 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200427 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100428 exit 1
429 esac
430 shift 2
431 done
432
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100433 # check valgrind's results
434 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200435 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100436 fail "Server has memory errors"
437 return
438 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200439 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100440 fail "Client has memory errors"
441 return
442 fi
443 fi
444
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100445 # if we're here, everything is ok
446 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200447 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100448}
449
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100450cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200451 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200452 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
453 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
454 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
455 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100456 exit 1
457}
458
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100459#
460# MAIN
461#
462
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100463get_options "$@"
464
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100465# sanity checks, avoid an avalanche of errors
466if [ ! -x "$P_SRV" ]; then
467 echo "Command '$P_SRV' is not an executable file"
468 exit 1
469fi
470if [ ! -x "$P_CLI" ]; then
471 echo "Command '$P_CLI' is not an executable file"
472 exit 1
473fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200474if [ ! -x "$P_PXY" ]; then
475 echo "Command '$P_PXY' is not an executable file"
476 exit 1
477fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100478if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
479 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100480 exit 1
481fi
482
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200483# used by watchdog
484MAIN_PID="$$"
485
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200486# be more patient with valgrind
487if [ "$MEMCHECK" -gt 0 ]; then
488 START_DELAY=3
489 DOG_DELAY=30
490else
491 START_DELAY=1
492 DOG_DELAY=10
493fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200494CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200495
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200496# Pick a "unique" server port in the range 10000-19999, and a proxy port
497PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000498PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200499SRV_PORT="1$PORT_BASE"
500PXY_PORT="2$PORT_BASE"
501unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200502
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200503# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000504# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200505P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
506P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
507P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
508O_SRV="$O_SRV -accept $SRV_PORT"
509O_CLI="$O_CLI -connect localhost:+SRV_PORT"
510G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000511G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200512
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200513# Also pick a unique name for intermediate files
514SRV_OUT="srv_out.$$"
515CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200516PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200517SESSION="session.$$"
518
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200519SKIP_NEXT="NO"
520
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100521trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100522
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200523# Basic test
524
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200525# Checks that:
526# - things work with all ciphersuites active (used with config-full in all.sh)
527# - the expected (highest security) parameters are selected
528# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200529run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200530 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200531 "$P_CLI" \
532 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200533 -s "Protocol is TLSv1.2" \
534 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
535 -s "client hello v3, signature_algorithm ext: 6" \
536 -s "ECDHE curve: secp521r1" \
537 -S "error" \
538 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200539
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100540# Tests for rc4 option
541
542run_test "RC4: server disabled, client enabled" \
543 "$P_SRV" \
544 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
545 1 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100546 -s "SSL - None of the common ciphersuites is usable"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100547
548run_test "RC4: server enabled, client disabled" \
549 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
550 "$P_CLI" \
551 1 \
552 -s "SSL - The server has no ciphersuites in common"
553
554run_test "RC4: both enabled" \
555 "$P_SRV arc4=1" \
556 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
557 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100558 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100559 -S "SSL - The server has no ciphersuites in common"
560
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100561# Test for SSLv2 ClientHello
562
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200563requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200564run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100565 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100566 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100567 0 \
568 -S "parse client hello v2" \
569 -S "ssl_handshake returned"
570
571# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200572requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200573run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200574 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100575 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100576 0 \
577 -s "parse client hello v2" \
578 -S "ssl_handshake returned"
579
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100580# Tests for Truncated HMAC extension
581
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100582run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200583 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100584 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100585 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100586 -s "dumping 'computed mac' (20 bytes)" \
587 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100588
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100589run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200590 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100591 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
592 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100593 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100594 -s "dumping 'computed mac' (20 bytes)" \
595 -S "dumping 'computed mac' (10 bytes)"
596
597run_test "Truncated HMAC: client enabled, server default" \
598 "$P_SRV debug_level=4" \
599 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
600 trunc_hmac=1" \
601 0 \
602 -S "dumping 'computed mac' (20 bytes)" \
603 -s "dumping 'computed mac' (10 bytes)"
604
605run_test "Truncated HMAC: client enabled, server disabled" \
606 "$P_SRV debug_level=4 trunc_hmac=0" \
607 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
608 trunc_hmac=1" \
609 0 \
610 -s "dumping 'computed mac' (20 bytes)" \
611 -S "dumping 'computed mac' (10 bytes)"
612
613run_test "Truncated HMAC: client enabled, server enabled" \
614 "$P_SRV debug_level=4 trunc_hmac=1" \
615 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
616 trunc_hmac=1" \
617 0 \
618 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100619 -s "dumping 'computed mac' (10 bytes)"
620
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100621# Tests for Encrypt-then-MAC extension
622
623run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100624 "$P_SRV debug_level=3 \
625 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100626 "$P_CLI debug_level=3" \
627 0 \
628 -c "client hello, adding encrypt_then_mac extension" \
629 -s "found encrypt then mac extension" \
630 -s "server hello, adding encrypt then mac extension" \
631 -c "found encrypt_then_mac extension" \
632 -c "using encrypt then mac" \
633 -s "using encrypt then mac"
634
635run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100636 "$P_SRV debug_level=3 etm=0 \
637 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100638 "$P_CLI debug_level=3 etm=1" \
639 0 \
640 -c "client hello, adding encrypt_then_mac extension" \
641 -s "found encrypt then mac extension" \
642 -S "server hello, adding encrypt then mac extension" \
643 -C "found encrypt_then_mac extension" \
644 -C "using encrypt then mac" \
645 -S "using encrypt then mac"
646
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100647run_test "Encrypt then MAC: client enabled, aead cipher" \
648 "$P_SRV debug_level=3 etm=1 \
649 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
650 "$P_CLI debug_level=3 etm=1" \
651 0 \
652 -c "client hello, adding encrypt_then_mac extension" \
653 -s "found encrypt then mac extension" \
654 -S "server hello, adding encrypt then mac extension" \
655 -C "found encrypt_then_mac extension" \
656 -C "using encrypt then mac" \
657 -S "using encrypt then mac"
658
659run_test "Encrypt then MAC: client enabled, stream cipher" \
660 "$P_SRV debug_level=3 etm=1 \
661 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100662 "$P_CLI debug_level=3 etm=1 arc4=1" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100663 0 \
664 -c "client hello, adding encrypt_then_mac extension" \
665 -s "found encrypt then mac extension" \
666 -S "server hello, adding encrypt then mac extension" \
667 -C "found encrypt_then_mac extension" \
668 -C "using encrypt then mac" \
669 -S "using encrypt then mac"
670
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100671run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100672 "$P_SRV debug_level=3 etm=1 \
673 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100674 "$P_CLI debug_level=3 etm=0" \
675 0 \
676 -C "client hello, adding encrypt_then_mac extension" \
677 -S "found encrypt then mac extension" \
678 -S "server hello, adding encrypt then mac extension" \
679 -C "found encrypt_then_mac extension" \
680 -C "using encrypt then mac" \
681 -S "using encrypt then mac"
682
683run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100684 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100685 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100686 "$P_CLI debug_level=3 force_version=ssl3" \
687 0 \
688 -C "client hello, adding encrypt_then_mac extension" \
689 -S "found encrypt then mac extension" \
690 -S "server hello, adding encrypt then mac extension" \
691 -C "found encrypt_then_mac extension" \
692 -C "using encrypt then mac" \
693 -S "using encrypt then mac"
694
695run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100696 "$P_SRV debug_level=3 force_version=ssl3 \
697 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100698 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100699 0 \
700 -c "client hello, adding encrypt_then_mac extension" \
701 -s "found encrypt then mac extension" \
702 -S "server hello, adding encrypt then mac extension" \
703 -C "found encrypt_then_mac extension" \
704 -C "using encrypt then mac" \
705 -S "using encrypt then mac"
706
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200707# Tests for Extended Master Secret extension
708
709run_test "Extended Master Secret: default" \
710 "$P_SRV debug_level=3" \
711 "$P_CLI debug_level=3" \
712 0 \
713 -c "client hello, adding extended_master_secret extension" \
714 -s "found extended master secret extension" \
715 -s "server hello, adding extended master secret extension" \
716 -c "found extended_master_secret extension" \
717 -c "using extended master secret" \
718 -s "using extended master secret"
719
720run_test "Extended Master Secret: client enabled, server disabled" \
721 "$P_SRV debug_level=3 extended_ms=0" \
722 "$P_CLI debug_level=3 extended_ms=1" \
723 0 \
724 -c "client hello, adding extended_master_secret extension" \
725 -s "found extended master secret extension" \
726 -S "server hello, adding extended master secret extension" \
727 -C "found extended_master_secret extension" \
728 -C "using extended master secret" \
729 -S "using extended master secret"
730
731run_test "Extended Master Secret: client disabled, server enabled" \
732 "$P_SRV debug_level=3 extended_ms=1" \
733 "$P_CLI debug_level=3 extended_ms=0" \
734 0 \
735 -C "client hello, adding extended_master_secret extension" \
736 -S "found extended master secret extension" \
737 -S "server hello, adding extended master secret extension" \
738 -C "found extended_master_secret extension" \
739 -C "using extended master secret" \
740 -S "using extended master secret"
741
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200742run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100743 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200744 "$P_CLI debug_level=3 force_version=ssl3" \
745 0 \
746 -C "client hello, adding extended_master_secret extension" \
747 -S "found extended master secret extension" \
748 -S "server hello, adding extended master secret extension" \
749 -C "found extended_master_secret extension" \
750 -C "using extended master secret" \
751 -S "using extended master secret"
752
753run_test "Extended Master Secret: client enabled, server SSLv3" \
754 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100755 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200756 0 \
757 -c "client hello, adding extended_master_secret extension" \
758 -s "found extended master secret extension" \
759 -S "server hello, adding extended master secret extension" \
760 -C "found extended_master_secret extension" \
761 -C "using extended master secret" \
762 -S "using extended master secret"
763
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200764# Tests for FALLBACK_SCSV
765
766run_test "Fallback SCSV: default" \
767 "$P_SRV" \
768 "$P_CLI debug_level=3 force_version=tls1_1" \
769 0 \
770 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200771 -S "received FALLBACK_SCSV" \
772 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200773 -C "is a fatal alert message (msg 86)"
774
775run_test "Fallback SCSV: explicitly disabled" \
776 "$P_SRV" \
777 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
778 0 \
779 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200780 -S "received FALLBACK_SCSV" \
781 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200782 -C "is a fatal alert message (msg 86)"
783
784run_test "Fallback SCSV: enabled" \
785 "$P_SRV" \
786 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200787 1 \
788 -c "adding FALLBACK_SCSV" \
789 -s "received FALLBACK_SCSV" \
790 -s "inapropriate fallback" \
791 -c "is a fatal alert message (msg 86)"
792
793run_test "Fallback SCSV: enabled, max version" \
794 "$P_SRV" \
795 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200796 0 \
797 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200798 -s "received FALLBACK_SCSV" \
799 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200800 -C "is a fatal alert message (msg 86)"
801
802requires_openssl_with_fallback_scsv
803run_test "Fallback SCSV: default, openssl server" \
804 "$O_SRV" \
805 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
806 0 \
807 -C "adding FALLBACK_SCSV" \
808 -C "is a fatal alert message (msg 86)"
809
810requires_openssl_with_fallback_scsv
811run_test "Fallback SCSV: enabled, openssl server" \
812 "$O_SRV" \
813 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
814 1 \
815 -c "adding FALLBACK_SCSV" \
816 -c "is a fatal alert message (msg 86)"
817
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200818requires_openssl_with_fallback_scsv
819run_test "Fallback SCSV: disabled, openssl client" \
820 "$P_SRV" \
821 "$O_CLI -tls1_1" \
822 0 \
823 -S "received FALLBACK_SCSV" \
824 -S "inapropriate fallback"
825
826requires_openssl_with_fallback_scsv
827run_test "Fallback SCSV: enabled, openssl client" \
828 "$P_SRV" \
829 "$O_CLI -tls1_1 -fallback_scsv" \
830 1 \
831 -s "received FALLBACK_SCSV" \
832 -s "inapropriate fallback"
833
834requires_openssl_with_fallback_scsv
835run_test "Fallback SCSV: enabled, max version, openssl client" \
836 "$P_SRV" \
837 "$O_CLI -fallback_scsv" \
838 0 \
839 -s "received FALLBACK_SCSV" \
840 -S "inapropriate fallback"
841
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100842# Tests for CBC 1/n-1 record splitting
843
844run_test "CBC Record splitting: TLS 1.2, no splitting" \
845 "$P_SRV" \
846 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
847 request_size=123 force_version=tls1_2" \
848 0 \
849 -s "Read from client: 123 bytes read" \
850 -S "Read from client: 1 bytes read" \
851 -S "122 bytes read"
852
853run_test "CBC Record splitting: TLS 1.1, no splitting" \
854 "$P_SRV" \
855 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
856 request_size=123 force_version=tls1_1" \
857 0 \
858 -s "Read from client: 123 bytes read" \
859 -S "Read from client: 1 bytes read" \
860 -S "122 bytes read"
861
862run_test "CBC Record splitting: TLS 1.0, splitting" \
863 "$P_SRV" \
864 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
865 request_size=123 force_version=tls1" \
866 0 \
867 -S "Read from client: 123 bytes read" \
868 -s "Read from client: 1 bytes read" \
869 -s "122 bytes read"
870
871run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100872 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100873 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
874 request_size=123 force_version=ssl3" \
875 0 \
876 -S "Read from client: 123 bytes read" \
877 -s "Read from client: 1 bytes read" \
878 -s "122 bytes read"
879
880run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100881 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100882 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
883 request_size=123 force_version=tls1" \
884 0 \
885 -s "Read from client: 123 bytes read" \
886 -S "Read from client: 1 bytes read" \
887 -S "122 bytes read"
888
889run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
890 "$P_SRV" \
891 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
892 request_size=123 force_version=tls1 recsplit=0" \
893 0 \
894 -s "Read from client: 123 bytes read" \
895 -S "Read from client: 1 bytes read" \
896 -S "122 bytes read"
897
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100898run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
899 "$P_SRV nbio=2" \
900 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
901 request_size=123 force_version=tls1" \
902 0 \
903 -S "Read from client: 123 bytes read" \
904 -s "Read from client: 1 bytes read" \
905 -s "122 bytes read"
906
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100907# Tests for Session Tickets
908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200909run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200910 "$P_SRV debug_level=3 tickets=1" \
911 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100912 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100913 -c "client hello, adding session ticket extension" \
914 -s "found session ticket extension" \
915 -s "server hello, adding session ticket extension" \
916 -c "found session_ticket extension" \
917 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100918 -S "session successfully restored from cache" \
919 -s "session successfully restored from ticket" \
920 -s "a session has been resumed" \
921 -c "a session has been resumed"
922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200923run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200924 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
925 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100926 0 \
927 -c "client hello, adding session ticket extension" \
928 -s "found session ticket extension" \
929 -s "server hello, adding session ticket extension" \
930 -c "found session_ticket extension" \
931 -c "parse new session ticket" \
932 -S "session successfully restored from cache" \
933 -s "session successfully restored from ticket" \
934 -s "a session has been resumed" \
935 -c "a session has been resumed"
936
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200937run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200938 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
939 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100940 0 \
941 -c "client hello, adding session ticket extension" \
942 -s "found session ticket extension" \
943 -s "server hello, adding session ticket extension" \
944 -c "found session_ticket extension" \
945 -c "parse new session ticket" \
946 -S "session successfully restored from cache" \
947 -S "session successfully restored from ticket" \
948 -S "a session has been resumed" \
949 -C "a session has been resumed"
950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200951run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100952 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200953 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100954 0 \
955 -c "client hello, adding session ticket extension" \
956 -c "found session_ticket extension" \
957 -c "parse new session ticket" \
958 -c "a session has been resumed"
959
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200960run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200961 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200962 "( $O_CLI -sess_out $SESSION; \
963 $O_CLI -sess_in $SESSION; \
964 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100965 0 \
966 -s "found session ticket extension" \
967 -s "server hello, adding session ticket extension" \
968 -S "session successfully restored from cache" \
969 -s "session successfully restored from ticket" \
970 -s "a session has been resumed"
971
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100972# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100973
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200974run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200975 "$P_SRV debug_level=3 tickets=0" \
976 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100977 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100978 -c "client hello, adding session ticket extension" \
979 -s "found session ticket extension" \
980 -S "server hello, adding session ticket extension" \
981 -C "found session_ticket extension" \
982 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100983 -s "session successfully restored from cache" \
984 -S "session successfully restored from ticket" \
985 -s "a session has been resumed" \
986 -c "a session has been resumed"
987
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200988run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200989 "$P_SRV debug_level=3 tickets=1" \
990 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100991 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100992 -C "client hello, adding session ticket extension" \
993 -S "found session ticket extension" \
994 -S "server hello, adding session ticket extension" \
995 -C "found session_ticket extension" \
996 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100997 -s "session successfully restored from cache" \
998 -S "session successfully restored from ticket" \
999 -s "a session has been resumed" \
1000 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001002run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001003 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1004 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001005 0 \
1006 -S "session successfully restored from cache" \
1007 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001008 -S "a session has been resumed" \
1009 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001011run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001012 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1013 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001014 0 \
1015 -s "session successfully restored from cache" \
1016 -S "session successfully restored from ticket" \
1017 -s "a session has been resumed" \
1018 -c "a session has been resumed"
1019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001020run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001021 "$P_SRV debug_level=3 tickets=0" \
1022 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001023 0 \
1024 -s "session successfully restored from cache" \
1025 -S "session successfully restored from ticket" \
1026 -s "a session has been resumed" \
1027 -c "a session has been resumed"
1028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001029run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001030 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1031 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001032 0 \
1033 -S "session successfully restored from cache" \
1034 -S "session successfully restored from ticket" \
1035 -S "a session has been resumed" \
1036 -C "a session has been resumed"
1037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001038run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001039 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1040 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001041 0 \
1042 -s "session successfully restored from cache" \
1043 -S "session successfully restored from ticket" \
1044 -s "a session has been resumed" \
1045 -c "a session has been resumed"
1046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001047run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001048 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001049 "( $O_CLI -sess_out $SESSION; \
1050 $O_CLI -sess_in $SESSION; \
1051 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001052 0 \
1053 -s "found session ticket extension" \
1054 -S "server hello, adding session ticket extension" \
1055 -s "session successfully restored from cache" \
1056 -S "session successfully restored from ticket" \
1057 -s "a session has been resumed"
1058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001059run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001060 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001061 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001062 0 \
1063 -C "found session_ticket extension" \
1064 -C "parse new session ticket" \
1065 -c "a session has been resumed"
1066
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001067# Tests for Max Fragment Length extension
1068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001069run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001070 "$P_SRV debug_level=3" \
1071 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001072 0 \
1073 -C "client hello, adding max_fragment_length extension" \
1074 -S "found max fragment length extension" \
1075 -S "server hello, max_fragment_length extension" \
1076 -C "found max_fragment_length extension"
1077
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001078run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001079 "$P_SRV debug_level=3" \
1080 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001081 0 \
1082 -c "client hello, adding max_fragment_length extension" \
1083 -s "found max fragment length extension" \
1084 -s "server hello, max_fragment_length extension" \
1085 -c "found max_fragment_length extension"
1086
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001087run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001088 "$P_SRV debug_level=3 max_frag_len=4096" \
1089 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001090 0 \
1091 -C "client hello, adding max_fragment_length extension" \
1092 -S "found max fragment length extension" \
1093 -S "server hello, max_fragment_length extension" \
1094 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001095
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001096requires_gnutls
1097run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001098 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001099 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001100 0 \
1101 -c "client hello, adding max_fragment_length extension" \
1102 -c "found max_fragment_length extension"
1103
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001104run_test "Max fragment length: client, message just fits" \
1105 "$P_SRV debug_level=3" \
1106 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1107 0 \
1108 -c "client hello, adding max_fragment_length extension" \
1109 -s "found max fragment length extension" \
1110 -s "server hello, max_fragment_length extension" \
1111 -c "found max_fragment_length extension" \
1112 -c "2048 bytes written in 1 fragments" \
1113 -s "2048 bytes read"
1114
1115run_test "Max fragment length: client, larger message" \
1116 "$P_SRV debug_level=3" \
1117 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1118 0 \
1119 -c "client hello, adding max_fragment_length extension" \
1120 -s "found max fragment length extension" \
1121 -s "server hello, max_fragment_length extension" \
1122 -c "found max_fragment_length extension" \
1123 -c "2345 bytes written in 2 fragments" \
1124 -s "2048 bytes read" \
1125 -s "297 bytes read"
1126
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001127run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001128 "$P_SRV debug_level=3 dtls=1" \
1129 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1130 1 \
1131 -c "client hello, adding max_fragment_length extension" \
1132 -s "found max fragment length extension" \
1133 -s "server hello, max_fragment_length extension" \
1134 -c "found max_fragment_length extension" \
1135 -c "fragment larger than.*maximum"
1136
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001137# Tests for renegotiation
1138
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001139run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001140 "$P_SRV debug_level=3 exchanges=2" \
1141 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001142 0 \
1143 -C "client hello, adding renegotiation extension" \
1144 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1145 -S "found renegotiation extension" \
1146 -s "server hello, secure renegotiation extension" \
1147 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001148 -C "=> renegotiate" \
1149 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001150 -S "write hello request"
1151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001152run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001153 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
1154 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001155 0 \
1156 -c "client hello, adding renegotiation extension" \
1157 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1158 -s "found renegotiation extension" \
1159 -s "server hello, secure renegotiation extension" \
1160 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001161 -c "=> renegotiate" \
1162 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001163 -S "write hello request"
1164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001165run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001166 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1167 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001168 0 \
1169 -c "client hello, adding renegotiation extension" \
1170 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1171 -s "found renegotiation extension" \
1172 -s "server hello, secure renegotiation extension" \
1173 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001174 -c "=> renegotiate" \
1175 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001176 -s "write hello request"
1177
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001178run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001179 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1180 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001181 0 \
1182 -c "client hello, adding renegotiation extension" \
1183 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1184 -s "found renegotiation extension" \
1185 -s "server hello, secure renegotiation extension" \
1186 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001187 -c "=> renegotiate" \
1188 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001189 -s "write hello request"
1190
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001191run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001192 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1193 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001194 1 \
1195 -c "client hello, adding renegotiation extension" \
1196 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1197 -S "found renegotiation extension" \
1198 -s "server hello, secure renegotiation extension" \
1199 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001200 -c "=> renegotiate" \
1201 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001202 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001203 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001204 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001206run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001207 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1208 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001209 0 \
1210 -C "client hello, adding renegotiation extension" \
1211 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1212 -S "found renegotiation extension" \
1213 -s "server hello, secure renegotiation extension" \
1214 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001215 -C "=> renegotiate" \
1216 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001217 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001218 -S "SSL - An unexpected message was received from our peer" \
1219 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001220
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001221run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001222 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001223 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001224 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001225 0 \
1226 -C "client hello, adding renegotiation extension" \
1227 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1228 -S "found renegotiation extension" \
1229 -s "server hello, secure renegotiation extension" \
1230 -c "found renegotiation extension" \
1231 -C "=> renegotiate" \
1232 -S "=> renegotiate" \
1233 -s "write hello request" \
1234 -S "SSL - An unexpected message was received from our peer" \
1235 -S "failed"
1236
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001237# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001238run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001239 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001240 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001241 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001242 0 \
1243 -C "client hello, adding renegotiation extension" \
1244 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1245 -S "found renegotiation extension" \
1246 -s "server hello, secure renegotiation extension" \
1247 -c "found renegotiation extension" \
1248 -C "=> renegotiate" \
1249 -S "=> renegotiate" \
1250 -s "write hello request" \
1251 -S "SSL - An unexpected message was received from our peer" \
1252 -S "failed"
1253
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001254run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001255 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001256 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001258 0 \
1259 -C "client hello, adding renegotiation extension" \
1260 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1261 -S "found renegotiation extension" \
1262 -s "server hello, secure renegotiation extension" \
1263 -c "found renegotiation extension" \
1264 -C "=> renegotiate" \
1265 -S "=> renegotiate" \
1266 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001267 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001268
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001269run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001270 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001271 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001272 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001273 0 \
1274 -c "client hello, adding renegotiation extension" \
1275 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1276 -s "found renegotiation extension" \
1277 -s "server hello, secure renegotiation extension" \
1278 -c "found renegotiation extension" \
1279 -c "=> renegotiate" \
1280 -s "=> renegotiate" \
1281 -s "write hello request" \
1282 -S "SSL - An unexpected message was received from our peer" \
1283 -S "failed"
1284
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001285run_test "Renegotiation: periodic, just below period" \
1286 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1287 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1288 0 \
1289 -C "client hello, adding renegotiation extension" \
1290 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1291 -S "found renegotiation extension" \
1292 -s "server hello, secure renegotiation extension" \
1293 -c "found renegotiation extension" \
1294 -S "record counter limit reached: renegotiate" \
1295 -C "=> renegotiate" \
1296 -S "=> renegotiate" \
1297 -S "write hello request" \
1298 -S "SSL - An unexpected message was received from our peer" \
1299 -S "failed"
1300
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001301# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001302run_test "Renegotiation: periodic, just above period" \
1303 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001304 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001305 0 \
1306 -c "client hello, adding renegotiation extension" \
1307 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1308 -s "found renegotiation extension" \
1309 -s "server hello, secure renegotiation extension" \
1310 -c "found renegotiation extension" \
1311 -s "record counter limit reached: renegotiate" \
1312 -c "=> renegotiate" \
1313 -s "=> renegotiate" \
1314 -s "write hello request" \
1315 -S "SSL - An unexpected message was received from our peer" \
1316 -S "failed"
1317
1318run_test "Renegotiation: periodic, two times period" \
1319 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001320 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001321 0 \
1322 -c "client hello, adding renegotiation extension" \
1323 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1324 -s "found renegotiation extension" \
1325 -s "server hello, secure renegotiation extension" \
1326 -c "found renegotiation extension" \
1327 -s "record counter limit reached: renegotiate" \
1328 -c "=> renegotiate" \
1329 -s "=> renegotiate" \
1330 -s "write hello request" \
1331 -S "SSL - An unexpected message was received from our peer" \
1332 -S "failed"
1333
1334run_test "Renegotiation: periodic, above period, disabled" \
1335 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1336 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1337 0 \
1338 -C "client hello, adding renegotiation extension" \
1339 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1340 -S "found renegotiation extension" \
1341 -s "server hello, secure renegotiation extension" \
1342 -c "found renegotiation extension" \
1343 -S "record counter limit reached: renegotiate" \
1344 -C "=> renegotiate" \
1345 -S "=> renegotiate" \
1346 -S "write hello request" \
1347 -S "SSL - An unexpected message was received from our peer" \
1348 -S "failed"
1349
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001350run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001351 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1352 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001353 0 \
1354 -c "client hello, adding renegotiation extension" \
1355 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1356 -s "found renegotiation extension" \
1357 -s "server hello, secure renegotiation extension" \
1358 -c "found renegotiation extension" \
1359 -c "=> renegotiate" \
1360 -s "=> renegotiate" \
1361 -S "write hello request"
1362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001363run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001364 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1365 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001366 0 \
1367 -c "client hello, adding renegotiation extension" \
1368 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1369 -s "found renegotiation extension" \
1370 -s "server hello, secure renegotiation extension" \
1371 -c "found renegotiation extension" \
1372 -c "=> renegotiate" \
1373 -s "=> renegotiate" \
1374 -s "write hello request"
1375
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001376run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001377 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001378 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001379 0 \
1380 -c "client hello, adding renegotiation extension" \
1381 -c "found renegotiation extension" \
1382 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001383 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001384 -C "error" \
1385 -c "HTTP/1.0 200 [Oo][Kk]"
1386
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001387run_test "Renegotiation: gnutls server strict, client-initiated" \
1388 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001389 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001390 0 \
1391 -c "client hello, adding renegotiation extension" \
1392 -c "found renegotiation extension" \
1393 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001394 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001395 -C "error" \
1396 -c "HTTP/1.0 200 [Oo][Kk]"
1397
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001398run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1399 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1400 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1401 1 \
1402 -c "client hello, adding renegotiation extension" \
1403 -C "found renegotiation extension" \
1404 -c "=> renegotiate" \
1405 -c "ssl_handshake() returned" \
1406 -c "error" \
1407 -C "HTTP/1.0 200 [Oo][Kk]"
1408
1409run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1410 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1411 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1412 allow_legacy=0" \
1413 1 \
1414 -c "client hello, adding renegotiation extension" \
1415 -C "found renegotiation extension" \
1416 -c "=> renegotiate" \
1417 -c "ssl_handshake() returned" \
1418 -c "error" \
1419 -C "HTTP/1.0 200 [Oo][Kk]"
1420
1421run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1422 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1423 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1424 allow_legacy=1" \
1425 0 \
1426 -c "client hello, adding renegotiation extension" \
1427 -C "found renegotiation extension" \
1428 -c "=> renegotiate" \
1429 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001430 -C "error" \
1431 -c "HTTP/1.0 200 [Oo][Kk]"
1432
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001433run_test "Renegotiation: DTLS, client-initiated" \
1434 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1435 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1436 0 \
1437 -c "client hello, adding renegotiation extension" \
1438 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1439 -s "found renegotiation extension" \
1440 -s "server hello, secure renegotiation extension" \
1441 -c "found renegotiation extension" \
1442 -c "=> renegotiate" \
1443 -s "=> renegotiate" \
1444 -S "write hello request"
1445
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001446run_test "Renegotiation: DTLS, server-initiated" \
1447 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001448 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1449 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001450 0 \
1451 -c "client hello, adding renegotiation extension" \
1452 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1453 -s "found renegotiation extension" \
1454 -s "server hello, secure renegotiation extension" \
1455 -c "found renegotiation extension" \
1456 -c "=> renegotiate" \
1457 -s "=> renegotiate" \
1458 -s "write hello request"
1459
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001460run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1461 "$G_SRV -u --mtu 4096" \
1462 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1463 0 \
1464 -c "client hello, adding renegotiation extension" \
1465 -c "found renegotiation extension" \
1466 -c "=> renegotiate" \
1467 -C "ssl_handshake returned" \
1468 -C "error" \
1469 -s "Extra-header:"
1470
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001471# Test for the "secure renegotation" extension only (no actual renegotiation)
1472
1473run_test "Renego ext: gnutls server strict, client default" \
1474 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1475 "$P_CLI debug_level=3" \
1476 0 \
1477 -c "found renegotiation extension" \
1478 -C "error" \
1479 -c "HTTP/1.0 200 [Oo][Kk]"
1480
1481run_test "Renego ext: gnutls server unsafe, client default" \
1482 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1483 "$P_CLI debug_level=3" \
1484 0 \
1485 -C "found renegotiation extension" \
1486 -C "error" \
1487 -c "HTTP/1.0 200 [Oo][Kk]"
1488
1489run_test "Renego ext: gnutls server unsafe, client break legacy" \
1490 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1491 "$P_CLI debug_level=3 allow_legacy=-1" \
1492 1 \
1493 -C "found renegotiation extension" \
1494 -c "error" \
1495 -C "HTTP/1.0 200 [Oo][Kk]"
1496
1497run_test "Renego ext: gnutls client strict, server default" \
1498 "$P_SRV debug_level=3" \
1499 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1500 0 \
1501 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1502 -s "server hello, secure renegotiation extension"
1503
1504run_test "Renego ext: gnutls client unsafe, server default" \
1505 "$P_SRV debug_level=3" \
1506 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1507 0 \
1508 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1509 -S "server hello, secure renegotiation extension"
1510
1511run_test "Renego ext: gnutls client unsafe, server break legacy" \
1512 "$P_SRV debug_level=3 allow_legacy=-1" \
1513 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1514 1 \
1515 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1516 -S "server hello, secure renegotiation extension"
1517
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001518# Tests for auth_mode
1519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001520run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001521 "$P_SRV crt_file=data_files/server5-badsign.crt \
1522 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001523 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001524 1 \
1525 -c "x509_verify_cert() returned" \
1526 -c "! self-signed or not signed by a trusted CA" \
1527 -c "! ssl_handshake returned" \
1528 -c "X509 - Certificate verification failed"
1529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001530run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001531 "$P_SRV crt_file=data_files/server5-badsign.crt \
1532 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001533 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001534 0 \
1535 -c "x509_verify_cert() returned" \
1536 -c "! self-signed or not signed by a trusted CA" \
1537 -C "! ssl_handshake returned" \
1538 -C "X509 - Certificate verification failed"
1539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001540run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001541 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001542 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001543 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001544 0 \
1545 -C "x509_verify_cert() returned" \
1546 -C "! self-signed or not signed by a trusted CA" \
1547 -C "! ssl_handshake returned" \
1548 -C "X509 - Certificate verification failed"
1549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001550run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001551 "$P_SRV debug_level=3 auth_mode=required" \
1552 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001553 key_file=data_files/server5.key" \
1554 1 \
1555 -S "skip write certificate request" \
1556 -C "skip parse certificate request" \
1557 -c "got a certificate request" \
1558 -C "skip write certificate" \
1559 -C "skip write certificate verify" \
1560 -S "skip parse certificate verify" \
1561 -s "x509_verify_cert() returned" \
1562 -S "! self-signed or not signed by a trusted CA" \
1563 -s "! ssl_handshake returned" \
1564 -c "! ssl_handshake returned" \
1565 -s "X509 - Certificate verification failed"
1566
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001567run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001568 "$P_SRV debug_level=3 auth_mode=optional" \
1569 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001570 key_file=data_files/server5.key" \
1571 0 \
1572 -S "skip write certificate request" \
1573 -C "skip parse certificate request" \
1574 -c "got a certificate request" \
1575 -C "skip write certificate" \
1576 -C "skip write certificate verify" \
1577 -S "skip parse certificate verify" \
1578 -s "x509_verify_cert() returned" \
1579 -s "! self-signed or not signed by a trusted CA" \
1580 -S "! ssl_handshake returned" \
1581 -C "! ssl_handshake returned" \
1582 -S "X509 - Certificate verification failed"
1583
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001584run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001585 "$P_SRV debug_level=3 auth_mode=none" \
1586 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001587 key_file=data_files/server5.key" \
1588 0 \
1589 -s "skip write certificate request" \
1590 -C "skip parse certificate request" \
1591 -c "got no certificate request" \
1592 -c "skip write certificate" \
1593 -c "skip write certificate verify" \
1594 -s "skip parse certificate verify" \
1595 -S "x509_verify_cert() returned" \
1596 -S "! self-signed or not signed by a trusted CA" \
1597 -S "! ssl_handshake returned" \
1598 -C "! ssl_handshake returned" \
1599 -S "X509 - Certificate verification failed"
1600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001601run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001602 "$P_SRV debug_level=3 auth_mode=optional" \
1603 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001604 0 \
1605 -S "skip write certificate request" \
1606 -C "skip parse certificate request" \
1607 -c "got a certificate request" \
1608 -C "skip write certificate$" \
1609 -C "got no certificate to send" \
1610 -S "SSLv3 client has no certificate" \
1611 -c "skip write certificate verify" \
1612 -s "skip parse certificate verify" \
1613 -s "! no client certificate sent" \
1614 -S "! ssl_handshake returned" \
1615 -C "! ssl_handshake returned" \
1616 -S "X509 - Certificate verification failed"
1617
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001618run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001619 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001620 "$O_CLI" \
1621 0 \
1622 -S "skip write certificate request" \
1623 -s "skip parse certificate verify" \
1624 -s "! no client certificate sent" \
1625 -S "! ssl_handshake returned" \
1626 -S "X509 - Certificate verification failed"
1627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001628run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001629 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001630 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001631 0 \
1632 -C "skip parse certificate request" \
1633 -c "got a certificate request" \
1634 -C "skip write certificate$" \
1635 -c "skip write certificate verify" \
1636 -C "! ssl_handshake returned"
1637
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001638run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001639 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001640 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001641 0 \
1642 -S "skip write certificate request" \
1643 -C "skip parse certificate request" \
1644 -c "got a certificate request" \
1645 -C "skip write certificate$" \
1646 -c "skip write certificate verify" \
1647 -c "got no certificate to send" \
1648 -s "SSLv3 client has no certificate" \
1649 -s "skip parse certificate verify" \
1650 -s "! no client certificate sent" \
1651 -S "! ssl_handshake returned" \
1652 -C "! ssl_handshake returned" \
1653 -S "X509 - Certificate verification failed"
1654
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001655# Tests for certificate selection based on SHA verson
1656
1657run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1658 "$P_SRV crt_file=data_files/server5.crt \
1659 key_file=data_files/server5.key \
1660 crt_file2=data_files/server5-sha1.crt \
1661 key_file2=data_files/server5.key" \
1662 "$P_CLI force_version=tls1_2" \
1663 0 \
1664 -c "signed using.*ECDSA with SHA256" \
1665 -C "signed using.*ECDSA with SHA1"
1666
1667run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1668 "$P_SRV crt_file=data_files/server5.crt \
1669 key_file=data_files/server5.key \
1670 crt_file2=data_files/server5-sha1.crt \
1671 key_file2=data_files/server5.key" \
1672 "$P_CLI force_version=tls1_1" \
1673 0 \
1674 -C "signed using.*ECDSA with SHA256" \
1675 -c "signed using.*ECDSA with SHA1"
1676
1677run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1678 "$P_SRV crt_file=data_files/server5.crt \
1679 key_file=data_files/server5.key \
1680 crt_file2=data_files/server5-sha1.crt \
1681 key_file2=data_files/server5.key" \
1682 "$P_CLI force_version=tls1" \
1683 0 \
1684 -C "signed using.*ECDSA with SHA256" \
1685 -c "signed using.*ECDSA with SHA1"
1686
1687run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1688 "$P_SRV crt_file=data_files/server5.crt \
1689 key_file=data_files/server5.key \
1690 crt_file2=data_files/server6.crt \
1691 key_file2=data_files/server6.key" \
1692 "$P_CLI force_version=tls1_1" \
1693 0 \
1694 -c "serial number.*09" \
1695 -c "signed using.*ECDSA with SHA256" \
1696 -C "signed using.*ECDSA with SHA1"
1697
1698run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1699 "$P_SRV crt_file=data_files/server6.crt \
1700 key_file=data_files/server6.key \
1701 crt_file2=data_files/server5.crt \
1702 key_file2=data_files/server5.key" \
1703 "$P_CLI force_version=tls1_1" \
1704 0 \
1705 -c "serial number.*0A" \
1706 -c "signed using.*ECDSA with SHA256" \
1707 -C "signed using.*ECDSA with SHA1"
1708
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001709# tests for SNI
1710
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001711run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001712 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001713 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001714 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001715 0 \
1716 -S "parse ServerName extension" \
1717 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1718 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1719
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001720run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001721 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001722 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001723 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 +02001724 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001725 0 \
1726 -s "parse ServerName extension" \
1727 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1728 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001730run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001731 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001732 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001733 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 +02001734 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001735 0 \
1736 -s "parse ServerName extension" \
1737 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001738 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001739
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001740run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001741 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001742 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001743 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 +02001744 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001745 1 \
1746 -s "parse ServerName extension" \
1747 -s "ssl_sni_wrapper() returned" \
1748 -s "ssl_handshake returned" \
1749 -c "ssl_handshake returned" \
1750 -c "SSL - A fatal alert message was received from our peer"
1751
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001752# Tests for non-blocking I/O: exercise a variety of handshake flows
1753
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001754run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001755 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1756 "$P_CLI nbio=2 tickets=0" \
1757 0 \
1758 -S "ssl_handshake returned" \
1759 -C "ssl_handshake returned" \
1760 -c "Read from server: .* bytes read"
1761
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001762run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001763 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1764 "$P_CLI nbio=2 tickets=0" \
1765 0 \
1766 -S "ssl_handshake returned" \
1767 -C "ssl_handshake returned" \
1768 -c "Read from server: .* bytes read"
1769
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001770run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001771 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1772 "$P_CLI nbio=2 tickets=1" \
1773 0 \
1774 -S "ssl_handshake returned" \
1775 -C "ssl_handshake returned" \
1776 -c "Read from server: .* bytes read"
1777
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001778run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001779 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1780 "$P_CLI nbio=2 tickets=1" \
1781 0 \
1782 -S "ssl_handshake returned" \
1783 -C "ssl_handshake returned" \
1784 -c "Read from server: .* bytes read"
1785
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001786run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001787 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1788 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1789 0 \
1790 -S "ssl_handshake returned" \
1791 -C "ssl_handshake returned" \
1792 -c "Read from server: .* bytes read"
1793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001794run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001795 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1796 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1797 0 \
1798 -S "ssl_handshake returned" \
1799 -C "ssl_handshake returned" \
1800 -c "Read from server: .* bytes read"
1801
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001802run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001803 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1804 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1805 0 \
1806 -S "ssl_handshake returned" \
1807 -C "ssl_handshake returned" \
1808 -c "Read from server: .* bytes read"
1809
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001810# Tests for version negotiation
1811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001812run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001813 "$P_SRV" \
1814 "$P_CLI" \
1815 0 \
1816 -S "ssl_handshake returned" \
1817 -C "ssl_handshake returned" \
1818 -s "Protocol is TLSv1.2" \
1819 -c "Protocol is TLSv1.2"
1820
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001821run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001822 "$P_SRV" \
1823 "$P_CLI max_version=tls1_1" \
1824 0 \
1825 -S "ssl_handshake returned" \
1826 -C "ssl_handshake returned" \
1827 -s "Protocol is TLSv1.1" \
1828 -c "Protocol is TLSv1.1"
1829
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001830run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001831 "$P_SRV max_version=tls1_1" \
1832 "$P_CLI" \
1833 0 \
1834 -S "ssl_handshake returned" \
1835 -C "ssl_handshake returned" \
1836 -s "Protocol is TLSv1.1" \
1837 -c "Protocol is TLSv1.1"
1838
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001839run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001840 "$P_SRV max_version=tls1_1" \
1841 "$P_CLI max_version=tls1_1" \
1842 0 \
1843 -S "ssl_handshake returned" \
1844 -C "ssl_handshake returned" \
1845 -s "Protocol is TLSv1.1" \
1846 -c "Protocol is TLSv1.1"
1847
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001848run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001849 "$P_SRV min_version=tls1_1" \
1850 "$P_CLI max_version=tls1_1" \
1851 0 \
1852 -S "ssl_handshake returned" \
1853 -C "ssl_handshake returned" \
1854 -s "Protocol is TLSv1.1" \
1855 -c "Protocol is TLSv1.1"
1856
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001857run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001858 "$P_SRV max_version=tls1_1" \
1859 "$P_CLI min_version=tls1_1" \
1860 0 \
1861 -S "ssl_handshake returned" \
1862 -C "ssl_handshake returned" \
1863 -s "Protocol is TLSv1.1" \
1864 -c "Protocol is TLSv1.1"
1865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001866run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001867 "$P_SRV max_version=tls1_1" \
1868 "$P_CLI min_version=tls1_2" \
1869 1 \
1870 -s "ssl_handshake returned" \
1871 -c "ssl_handshake returned" \
1872 -c "SSL - Handshake protocol not within min/max boundaries"
1873
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001874run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001875 "$P_SRV min_version=tls1_2" \
1876 "$P_CLI max_version=tls1_1" \
1877 1 \
1878 -s "ssl_handshake returned" \
1879 -c "ssl_handshake returned" \
1880 -s "SSL - Handshake protocol not within min/max boundaries"
1881
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001882# Tests for ALPN extension
1883
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001884if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1885
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001886run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001887 "$P_SRV debug_level=3" \
1888 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001889 0 \
1890 -C "client hello, adding alpn extension" \
1891 -S "found alpn extension" \
1892 -C "got an alert message, type: \\[2:120]" \
1893 -S "server hello, adding alpn extension" \
1894 -C "found alpn extension " \
1895 -C "Application Layer Protocol is" \
1896 -S "Application Layer Protocol is"
1897
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001898run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001899 "$P_SRV debug_level=3" \
1900 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001901 0 \
1902 -c "client hello, adding alpn extension" \
1903 -s "found alpn extension" \
1904 -C "got an alert message, type: \\[2:120]" \
1905 -S "server hello, adding alpn extension" \
1906 -C "found alpn extension " \
1907 -c "Application Layer Protocol is (none)" \
1908 -S "Application Layer Protocol is"
1909
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001910run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001911 "$P_SRV debug_level=3 alpn=abc,1234" \
1912 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001913 0 \
1914 -C "client hello, adding alpn extension" \
1915 -S "found alpn extension" \
1916 -C "got an alert message, type: \\[2:120]" \
1917 -S "server hello, adding alpn extension" \
1918 -C "found alpn extension " \
1919 -C "Application Layer Protocol is" \
1920 -s "Application Layer Protocol is (none)"
1921
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001922run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001923 "$P_SRV debug_level=3 alpn=abc,1234" \
1924 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001925 0 \
1926 -c "client hello, adding alpn extension" \
1927 -s "found alpn extension" \
1928 -C "got an alert message, type: \\[2:120]" \
1929 -s "server hello, adding alpn extension" \
1930 -c "found alpn extension" \
1931 -c "Application Layer Protocol is abc" \
1932 -s "Application Layer Protocol is abc"
1933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001934run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001935 "$P_SRV debug_level=3 alpn=abc,1234" \
1936 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001937 0 \
1938 -c "client hello, adding alpn extension" \
1939 -s "found alpn extension" \
1940 -C "got an alert message, type: \\[2:120]" \
1941 -s "server hello, adding alpn extension" \
1942 -c "found alpn extension" \
1943 -c "Application Layer Protocol is abc" \
1944 -s "Application Layer Protocol is abc"
1945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001946run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001947 "$P_SRV debug_level=3 alpn=abc,1234" \
1948 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001949 0 \
1950 -c "client hello, adding alpn extension" \
1951 -s "found alpn extension" \
1952 -C "got an alert message, type: \\[2:120]" \
1953 -s "server hello, adding alpn extension" \
1954 -c "found alpn extension" \
1955 -c "Application Layer Protocol is 1234" \
1956 -s "Application Layer Protocol is 1234"
1957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001958run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001959 "$P_SRV debug_level=3 alpn=abc,123" \
1960 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001961 1 \
1962 -c "client hello, adding alpn extension" \
1963 -s "found alpn extension" \
1964 -c "got an alert message, type: \\[2:120]" \
1965 -S "server hello, adding alpn extension" \
1966 -C "found alpn extension" \
1967 -C "Application Layer Protocol is 1234" \
1968 -S "Application Layer Protocol is 1234"
1969
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001970fi
1971
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001972# Tests for keyUsage in leaf certificates, part 1:
1973# server-side certificate/suite selection
1974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001975run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001976 "$P_SRV key_file=data_files/server2.key \
1977 crt_file=data_files/server2.ku-ds.crt" \
1978 "$P_CLI" \
1979 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001980 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001981
1982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001983run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001984 "$P_SRV key_file=data_files/server2.key \
1985 crt_file=data_files/server2.ku-ke.crt" \
1986 "$P_CLI" \
1987 0 \
1988 -c "Ciphersuite is TLS-RSA-WITH-"
1989
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001990run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001991 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001992 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001993 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001994 1 \
1995 -C "Ciphersuite is "
1996
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001997run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001998 "$P_SRV key_file=data_files/server5.key \
1999 crt_file=data_files/server5.ku-ds.crt" \
2000 "$P_CLI" \
2001 0 \
2002 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2003
2004
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002005run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002006 "$P_SRV key_file=data_files/server5.key \
2007 crt_file=data_files/server5.ku-ka.crt" \
2008 "$P_CLI" \
2009 0 \
2010 -c "Ciphersuite is TLS-ECDH-"
2011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002012run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002013 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002014 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002015 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002016 1 \
2017 -C "Ciphersuite is "
2018
2019# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002020# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002021
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002022run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002023 "$O_SRV -key data_files/server2.key \
2024 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002025 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002026 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2027 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002028 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002029 -C "Processing of the Certificate handshake message failed" \
2030 -c "Ciphersuite is TLS-"
2031
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002032run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002033 "$O_SRV -key data_files/server2.key \
2034 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002035 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002036 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2037 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002038 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002039 -C "Processing of the Certificate handshake message failed" \
2040 -c "Ciphersuite is TLS-"
2041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002042run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002043 "$O_SRV -key data_files/server2.key \
2044 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002045 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002046 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2047 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002048 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002049 -C "Processing of the Certificate handshake message failed" \
2050 -c "Ciphersuite is TLS-"
2051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002052run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002053 "$O_SRV -key data_files/server2.key \
2054 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002055 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002056 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2057 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002058 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002059 -c "Processing of the Certificate handshake message failed" \
2060 -C "Ciphersuite is TLS-"
2061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002062run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002063 "$O_SRV -key data_files/server2.key \
2064 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002065 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002066 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2067 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002068 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002069 -C "Processing of the Certificate handshake message failed" \
2070 -c "Ciphersuite is TLS-"
2071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002072run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002073 "$O_SRV -key data_files/server2.key \
2074 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002075 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002076 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2077 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002078 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002079 -c "Processing of the Certificate handshake message failed" \
2080 -C "Ciphersuite is TLS-"
2081
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002082# Tests for keyUsage in leaf certificates, part 3:
2083# server-side checking of client cert
2084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002085run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002086 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002087 "$O_CLI -key data_files/server2.key \
2088 -cert data_files/server2.ku-ds.crt" \
2089 0 \
2090 -S "bad certificate (usage extensions)" \
2091 -S "Processing of the Certificate handshake message failed"
2092
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002093run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002094 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002095 "$O_CLI -key data_files/server2.key \
2096 -cert data_files/server2.ku-ke.crt" \
2097 0 \
2098 -s "bad certificate (usage extensions)" \
2099 -S "Processing of the Certificate handshake message failed"
2100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002101run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002102 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002103 "$O_CLI -key data_files/server2.key \
2104 -cert data_files/server2.ku-ke.crt" \
2105 1 \
2106 -s "bad certificate (usage extensions)" \
2107 -s "Processing of the Certificate handshake message failed"
2108
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002109run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002110 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002111 "$O_CLI -key data_files/server5.key \
2112 -cert data_files/server5.ku-ds.crt" \
2113 0 \
2114 -S "bad certificate (usage extensions)" \
2115 -S "Processing of the Certificate handshake message failed"
2116
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002117run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002118 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002119 "$O_CLI -key data_files/server5.key \
2120 -cert data_files/server5.ku-ka.crt" \
2121 0 \
2122 -s "bad certificate (usage extensions)" \
2123 -S "Processing of the Certificate handshake message failed"
2124
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002125# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002127run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002128 "$P_SRV key_file=data_files/server5.key \
2129 crt_file=data_files/server5.eku-srv.crt" \
2130 "$P_CLI" \
2131 0
2132
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002133run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002134 "$P_SRV key_file=data_files/server5.key \
2135 crt_file=data_files/server5.eku-srv.crt" \
2136 "$P_CLI" \
2137 0
2138
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002139run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002140 "$P_SRV key_file=data_files/server5.key \
2141 crt_file=data_files/server5.eku-cs_any.crt" \
2142 "$P_CLI" \
2143 0
2144
2145# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002146run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002147 "$P_SRV psk=abc123 key_file=data_files/server5.key \
2148 crt_file=data_files/server5.eku-cli.crt" \
2149 "$P_CLI psk=badbad" \
2150 1
2151
2152# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002154run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002155 "$O_SRV -key data_files/server5.key \
2156 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002157 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002158 0 \
2159 -C "bad certificate (usage extensions)" \
2160 -C "Processing of the Certificate handshake message failed" \
2161 -c "Ciphersuite is TLS-"
2162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002163run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002164 "$O_SRV -key data_files/server5.key \
2165 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002166 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002167 0 \
2168 -C "bad certificate (usage extensions)" \
2169 -C "Processing of the Certificate handshake message failed" \
2170 -c "Ciphersuite is TLS-"
2171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002172run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002173 "$O_SRV -key data_files/server5.key \
2174 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002175 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002176 0 \
2177 -C "bad certificate (usage extensions)" \
2178 -C "Processing of the Certificate handshake message failed" \
2179 -c "Ciphersuite is TLS-"
2180
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002181run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002182 "$O_SRV -key data_files/server5.key \
2183 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002184 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002185 1 \
2186 -c "bad certificate (usage extensions)" \
2187 -c "Processing of the Certificate handshake message failed" \
2188 -C "Ciphersuite is TLS-"
2189
2190# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002192run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002193 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002194 "$O_CLI -key data_files/server5.key \
2195 -cert data_files/server5.eku-cli.crt" \
2196 0 \
2197 -S "bad certificate (usage extensions)" \
2198 -S "Processing of the Certificate handshake message failed"
2199
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002200run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002201 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002202 "$O_CLI -key data_files/server5.key \
2203 -cert data_files/server5.eku-srv_cli.crt" \
2204 0 \
2205 -S "bad certificate (usage extensions)" \
2206 -S "Processing of the Certificate handshake message failed"
2207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002208run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002209 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002210 "$O_CLI -key data_files/server5.key \
2211 -cert data_files/server5.eku-cs_any.crt" \
2212 0 \
2213 -S "bad certificate (usage extensions)" \
2214 -S "Processing of the Certificate handshake message failed"
2215
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002216run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002217 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002218 "$O_CLI -key data_files/server5.key \
2219 -cert data_files/server5.eku-cs.crt" \
2220 0 \
2221 -s "bad certificate (usage extensions)" \
2222 -S "Processing of the Certificate handshake message failed"
2223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002224run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002225 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002226 "$O_CLI -key data_files/server5.key \
2227 -cert data_files/server5.eku-cs.crt" \
2228 1 \
2229 -s "bad certificate (usage extensions)" \
2230 -s "Processing of the Certificate handshake message failed"
2231
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002232# Tests for DHM parameters loading
2233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002234run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002235 "$P_SRV" \
2236 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2237 debug_level=3" \
2238 0 \
2239 -c "value of 'DHM: P ' (2048 bits)" \
2240 -c "value of 'DHM: G ' (2048 bits)"
2241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002242run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002243 "$P_SRV dhm_file=data_files/dhparams.pem" \
2244 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2245 debug_level=3" \
2246 0 \
2247 -c "value of 'DHM: P ' (1024 bits)" \
2248 -c "value of 'DHM: G ' (2 bits)"
2249
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002250# Tests for PSK callback
2251
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002252run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002253 "$P_SRV psk=abc123 psk_identity=foo" \
2254 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2255 psk_identity=foo psk=abc123" \
2256 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002257 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002258 -S "SSL - Unknown identity received" \
2259 -S "SSL - Verification of the message MAC failed"
2260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002261run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002262 "$P_SRV" \
2263 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2264 psk_identity=foo psk=abc123" \
2265 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002266 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002267 -S "SSL - Unknown identity received" \
2268 -S "SSL - Verification of the message MAC failed"
2269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002270run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002271 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2272 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2273 psk_identity=foo psk=abc123" \
2274 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002275 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002276 -s "SSL - Unknown identity received" \
2277 -S "SSL - Verification of the message MAC failed"
2278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002279run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002280 "$P_SRV psk_list=abc,dead,def,beef" \
2281 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2282 psk_identity=abc psk=dead" \
2283 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002284 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002285 -S "SSL - Unknown identity received" \
2286 -S "SSL - Verification of the message MAC failed"
2287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002288run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002289 "$P_SRV psk_list=abc,dead,def,beef" \
2290 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2291 psk_identity=def psk=beef" \
2292 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002293 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002294 -S "SSL - Unknown identity received" \
2295 -S "SSL - Verification of the message MAC failed"
2296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002297run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002298 "$P_SRV psk_list=abc,dead,def,beef" \
2299 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2300 psk_identity=ghi psk=beef" \
2301 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002302 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002303 -s "SSL - Unknown identity received" \
2304 -S "SSL - Verification of the message MAC failed"
2305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002306run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002307 "$P_SRV psk_list=abc,dead,def,beef" \
2308 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2309 psk_identity=abc psk=beef" \
2310 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002311 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002312 -S "SSL - Unknown identity received" \
2313 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002314
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002315# Tests for ciphersuites per version
2316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002317run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002318 "$P_SRV min_version=ssl3 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" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002319 "$P_CLI force_version=ssl3" \
2320 0 \
2321 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2322
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002323run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002324 "$P_SRV arc4=1 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" \
2325 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002326 0 \
2327 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002329run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002330 "$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" \
2331 "$P_CLI force_version=tls1_1" \
2332 0 \
2333 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2334
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002335run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002336 "$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" \
2337 "$P_CLI force_version=tls1_2" \
2338 0 \
2339 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2340
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002341# Tests for ssl_get_bytes_avail()
2342
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002343run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002344 "$P_SRV" \
2345 "$P_CLI request_size=100" \
2346 0 \
2347 -s "Read from client: 100 bytes read$"
2348
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002349run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002350 "$P_SRV" \
2351 "$P_CLI request_size=500" \
2352 0 \
2353 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002354
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002355# Tests for small packets
2356
2357run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002358 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002359 "$P_CLI request_size=1 force_version=ssl3 \
2360 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2361 0 \
2362 -s "Read from client: 1 bytes read"
2363
2364run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002365 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002366 "$P_CLI request_size=1 force_version=ssl3 \
2367 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2368 0 \
2369 -s "Read from client: 1 bytes read"
2370
2371run_test "Small packet TLS 1.0 BlockCipher" \
2372 "$P_SRV" \
2373 "$P_CLI request_size=1 force_version=tls1 \
2374 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2375 0 \
2376 -s "Read from client: 1 bytes read"
2377
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002378run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2379 "$P_SRV" \
2380 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2381 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2382 0 \
2383 -s "Read from client: 1 bytes read"
2384
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002385run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2386 "$P_SRV" \
2387 "$P_CLI request_size=1 force_version=tls1 \
2388 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2389 trunc_hmac=1" \
2390 0 \
2391 -s "Read from client: 1 bytes read"
2392
2393run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002394 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002395 "$P_CLI request_size=1 force_version=tls1 \
2396 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2397 trunc_hmac=1" \
2398 0 \
2399 -s "Read from client: 1 bytes read"
2400
2401run_test "Small packet TLS 1.1 BlockCipher" \
2402 "$P_SRV" \
2403 "$P_CLI request_size=1 force_version=tls1_1 \
2404 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2405 0 \
2406 -s "Read from client: 1 bytes read"
2407
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002408run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2409 "$P_SRV" \
2410 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2411 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2412 0 \
2413 -s "Read from client: 1 bytes read"
2414
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002415run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002416 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002417 "$P_CLI request_size=1 force_version=tls1_1 \
2418 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2419 0 \
2420 -s "Read from client: 1 bytes read"
2421
2422run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2423 "$P_SRV" \
2424 "$P_CLI request_size=1 force_version=tls1_1 \
2425 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2426 trunc_hmac=1" \
2427 0 \
2428 -s "Read from client: 1 bytes read"
2429
2430run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002431 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002432 "$P_CLI request_size=1 force_version=tls1_1 \
2433 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2434 trunc_hmac=1" \
2435 0 \
2436 -s "Read from client: 1 bytes read"
2437
2438run_test "Small packet TLS 1.2 BlockCipher" \
2439 "$P_SRV" \
2440 "$P_CLI request_size=1 force_version=tls1_2 \
2441 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2442 0 \
2443 -s "Read from client: 1 bytes read"
2444
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002445run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2446 "$P_SRV" \
2447 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2448 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2449 0 \
2450 -s "Read from client: 1 bytes read"
2451
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002452run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2453 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002454 "$P_CLI request_size=1 force_version=tls1_2 \
2455 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002456 0 \
2457 -s "Read from client: 1 bytes read"
2458
2459run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2460 "$P_SRV" \
2461 "$P_CLI request_size=1 force_version=tls1_2 \
2462 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2463 trunc_hmac=1" \
2464 0 \
2465 -s "Read from client: 1 bytes read"
2466
2467run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002468 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002469 "$P_CLI request_size=1 force_version=tls1_2 \
2470 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2471 0 \
2472 -s "Read from client: 1 bytes read"
2473
2474run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002475 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002476 "$P_CLI request_size=1 force_version=tls1_2 \
2477 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2478 trunc_hmac=1" \
2479 0 \
2480 -s "Read from client: 1 bytes read"
2481
2482run_test "Small packet TLS 1.2 AEAD" \
2483 "$P_SRV" \
2484 "$P_CLI request_size=1 force_version=tls1_2 \
2485 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2486 0 \
2487 -s "Read from client: 1 bytes read"
2488
2489run_test "Small packet TLS 1.2 AEAD shorter tag" \
2490 "$P_SRV" \
2491 "$P_CLI request_size=1 force_version=tls1_2 \
2492 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2493 0 \
2494 -s "Read from client: 1 bytes read"
2495
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002496# Test for large packets
2497
2498run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002499 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002500 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002501 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2502 0 \
2503 -s "Read from client: 16384 bytes read"
2504
2505run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002506 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002507 "$P_CLI request_size=16384 force_version=ssl3 \
2508 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2509 0 \
2510 -s "Read from client: 16384 bytes read"
2511
2512run_test "Large packet TLS 1.0 BlockCipher" \
2513 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002514 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002515 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2516 0 \
2517 -s "Read from client: 16384 bytes read"
2518
2519run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2520 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002521 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002522 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2523 trunc_hmac=1" \
2524 0 \
2525 -s "Read from client: 16384 bytes read"
2526
2527run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002528 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002529 "$P_CLI request_size=16384 force_version=tls1 \
2530 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2531 trunc_hmac=1" \
2532 0 \
2533 -s "Read from client: 16384 bytes read"
2534
2535run_test "Large packet TLS 1.1 BlockCipher" \
2536 "$P_SRV" \
2537 "$P_CLI request_size=16384 force_version=tls1_1 \
2538 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2539 0 \
2540 -s "Read from client: 16384 bytes read"
2541
2542run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002543 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002544 "$P_CLI request_size=16384 force_version=tls1_1 \
2545 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2546 0 \
2547 -s "Read from client: 16384 bytes read"
2548
2549run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2550 "$P_SRV" \
2551 "$P_CLI request_size=16384 force_version=tls1_1 \
2552 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2553 trunc_hmac=1" \
2554 0 \
2555 -s "Read from client: 16384 bytes read"
2556
2557run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002558 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002559 "$P_CLI request_size=16384 force_version=tls1_1 \
2560 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2561 trunc_hmac=1" \
2562 0 \
2563 -s "Read from client: 16384 bytes read"
2564
2565run_test "Large packet TLS 1.2 BlockCipher" \
2566 "$P_SRV" \
2567 "$P_CLI request_size=16384 force_version=tls1_2 \
2568 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2569 0 \
2570 -s "Read from client: 16384 bytes read"
2571
2572run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2573 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002574 "$P_CLI request_size=16384 force_version=tls1_2 \
2575 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002576 0 \
2577 -s "Read from client: 16384 bytes read"
2578
2579run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2580 "$P_SRV" \
2581 "$P_CLI request_size=16384 force_version=tls1_2 \
2582 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2583 trunc_hmac=1" \
2584 0 \
2585 -s "Read from client: 16384 bytes read"
2586
2587run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002588 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002589 "$P_CLI request_size=16384 force_version=tls1_2 \
2590 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2591 0 \
2592 -s "Read from client: 16384 bytes read"
2593
2594run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002595 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002596 "$P_CLI request_size=16384 force_version=tls1_2 \
2597 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2598 trunc_hmac=1" \
2599 0 \
2600 -s "Read from client: 16384 bytes read"
2601
2602run_test "Large packet TLS 1.2 AEAD" \
2603 "$P_SRV" \
2604 "$P_CLI request_size=16384 force_version=tls1_2 \
2605 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2606 0 \
2607 -s "Read from client: 16384 bytes read"
2608
2609run_test "Large packet TLS 1.2 AEAD shorter tag" \
2610 "$P_SRV" \
2611 "$P_CLI request_size=16384 force_version=tls1_2 \
2612 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2613 0 \
2614 -s "Read from client: 16384 bytes read"
2615
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002616# Tests for DTLS HelloVerifyRequest
2617
2618run_test "DTLS cookie: enabled" \
2619 "$P_SRV dtls=1 debug_level=2" \
2620 "$P_CLI dtls=1 debug_level=2" \
2621 0 \
2622 -s "cookie verification failed" \
2623 -s "cookie verification passed" \
2624 -S "cookie verification skipped" \
2625 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002626 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002627 -S "SSL - The requested feature is not available"
2628
2629run_test "DTLS cookie: disabled" \
2630 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2631 "$P_CLI dtls=1 debug_level=2" \
2632 0 \
2633 -S "cookie verification failed" \
2634 -S "cookie verification passed" \
2635 -s "cookie verification skipped" \
2636 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002637 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002638 -S "SSL - The requested feature is not available"
2639
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002640run_test "DTLS cookie: default (failing)" \
2641 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2642 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2643 1 \
2644 -s "cookie verification failed" \
2645 -S "cookie verification passed" \
2646 -S "cookie verification skipped" \
2647 -C "received hello verify request" \
2648 -S "hello verification requested" \
2649 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002650
2651requires_ipv6
2652run_test "DTLS cookie: enabled, IPv6" \
2653 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2654 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2655 0 \
2656 -s "cookie verification failed" \
2657 -s "cookie verification passed" \
2658 -S "cookie verification skipped" \
2659 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002660 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002661 -S "SSL - The requested feature is not available"
2662
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002663run_test "DTLS cookie: enabled, nbio" \
2664 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2665 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2666 0 \
2667 -s "cookie verification failed" \
2668 -s "cookie verification passed" \
2669 -S "cookie verification skipped" \
2670 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002671 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002672 -S "SSL - The requested feature is not available"
2673
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002674# Tests for various cases of client authentication with DTLS
2675# (focused on handshake flows and message parsing)
2676
2677run_test "DTLS client auth: required" \
2678 "$P_SRV dtls=1 auth_mode=required" \
2679 "$P_CLI dtls=1" \
2680 0 \
2681 -s "Verifying peer X.509 certificate... ok"
2682
2683run_test "DTLS client auth: optional, client has no cert" \
2684 "$P_SRV dtls=1 auth_mode=optional" \
2685 "$P_CLI dtls=1 crt_file=none key_file=none" \
2686 0 \
2687 -s "! no client certificate sent"
2688
2689run_test "DTLS client auth: optional, client has no cert" \
2690 "$P_SRV dtls=1 auth_mode=none" \
2691 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
2692 0 \
2693 -c "skip write certificate$" \
2694 -s "! no client certificate sent"
2695
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02002696# Tests for receiving fragmented handshake messages with DTLS
2697
2698requires_gnutls
2699run_test "DTLS reassembly: no fragmentation (gnutls server)" \
2700 "$G_SRV -u --mtu 2048 -a" \
2701 "$P_CLI dtls=1 debug_level=2" \
2702 0 \
2703 -C "found fragmented DTLS handshake message" \
2704 -C "error"
2705
2706requires_gnutls
2707run_test "DTLS reassembly: some fragmentation (gnutls server)" \
2708 "$G_SRV -u --mtu 512" \
2709 "$P_CLI dtls=1 debug_level=2" \
2710 0 \
2711 -c "found fragmented DTLS handshake message" \
2712 -C "error"
2713
2714requires_gnutls
2715run_test "DTLS reassembly: more fragmentation (gnutls server)" \
2716 "$G_SRV -u --mtu 128" \
2717 "$P_CLI dtls=1 debug_level=2" \
2718 0 \
2719 -c "found fragmented DTLS handshake message" \
2720 -C "error"
2721
2722requires_gnutls
2723run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
2724 "$G_SRV -u --mtu 128" \
2725 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2726 0 \
2727 -c "found fragmented DTLS handshake message" \
2728 -C "error"
2729
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002730requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002731run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
2732 "$G_SRV -u --mtu 256" \
2733 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
2734 0 \
2735 -c "found fragmented DTLS handshake message" \
2736 -c "client hello, adding renegotiation extension" \
2737 -c "found renegotiation extension" \
2738 -c "=> renegotiate" \
2739 -C "ssl_handshake returned" \
2740 -C "error" \
2741 -s "Extra-header:"
2742
2743requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002744run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
2745 "$G_SRV -u --mtu 256" \
2746 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
2747 0 \
2748 -c "found fragmented DTLS handshake message" \
2749 -c "client hello, adding renegotiation extension" \
2750 -c "found renegotiation extension" \
2751 -c "=> renegotiate" \
2752 -C "ssl_handshake returned" \
2753 -C "error" \
2754 -s "Extra-header:"
2755
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002756run_test "DTLS reassembly: no fragmentation (openssl server)" \
2757 "$O_SRV -dtls1 -mtu 2048" \
2758 "$P_CLI dtls=1 debug_level=2" \
2759 0 \
2760 -C "found fragmented DTLS handshake message" \
2761 -C "error"
2762
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002763run_test "DTLS reassembly: some fragmentation (openssl server)" \
2764 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002765 "$P_CLI dtls=1 debug_level=2" \
2766 0 \
2767 -c "found fragmented DTLS handshake message" \
2768 -C "error"
2769
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002770run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002771 "$O_SRV -dtls1 -mtu 256" \
2772 "$P_CLI dtls=1 debug_level=2" \
2773 0 \
2774 -c "found fragmented DTLS handshake message" \
2775 -C "error"
2776
2777run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2778 "$O_SRV -dtls1 -mtu 256" \
2779 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2780 0 \
2781 -c "found fragmented DTLS handshake message" \
2782 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002783
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002784# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002785
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002786not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002787run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002788 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002789 "$P_SRV dtls=1 debug_level=2" \
2790 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002791 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002792 -C "replayed record" \
2793 -S "replayed record" \
2794 -C "record from another epoch" \
2795 -S "record from another epoch" \
2796 -C "discarding invalid record" \
2797 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002798 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002799 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002800 -c "HTTP/1.0 200 OK"
2801
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002802not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002803run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002804 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002805 "$P_SRV dtls=1 debug_level=2" \
2806 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002807 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002808 -c "replayed record" \
2809 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002810 -c "discarding invalid record" \
2811 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002812 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002813 -s "Extra-header:" \
2814 -c "HTTP/1.0 200 OK"
2815
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002816run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
2817 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002818 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
2819 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002820 0 \
2821 -c "replayed record" \
2822 -S "replayed record" \
2823 -c "discarding invalid record" \
2824 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002825 -c "resend" \
2826 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002827 -s "Extra-header:" \
2828 -c "HTTP/1.0 200 OK"
2829
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002830run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002831 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002832 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002833 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002834 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002835 -c "discarding invalid record (mac)" \
2836 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002837 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002838 -c "HTTP/1.0 200 OK" \
2839 -S "too many records with bad MAC" \
2840 -S "Verification of the message MAC failed"
2841
2842run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
2843 -p "$P_PXY bad_ad=1" \
2844 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
2845 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2846 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002847 -C "discarding invalid record (mac)" \
2848 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002849 -S "Extra-header:" \
2850 -C "HTTP/1.0 200 OK" \
2851 -s "too many records with bad MAC" \
2852 -s "Verification of the message MAC failed"
2853
2854run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
2855 -p "$P_PXY bad_ad=1" \
2856 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
2857 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2858 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002859 -c "discarding invalid record (mac)" \
2860 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002861 -s "Extra-header:" \
2862 -c "HTTP/1.0 200 OK" \
2863 -S "too many records with bad MAC" \
2864 -S "Verification of the message MAC failed"
2865
2866run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
2867 -p "$P_PXY bad_ad=1" \
2868 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
2869 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
2870 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002871 -c "discarding invalid record (mac)" \
2872 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002873 -s "Extra-header:" \
2874 -c "HTTP/1.0 200 OK" \
2875 -s "too many records with bad MAC" \
2876 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002877
2878run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002879 -p "$P_PXY delay_ccs=1" \
2880 "$P_SRV dtls=1 debug_level=1" \
2881 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002882 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002883 -c "record from another epoch" \
2884 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002885 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002886 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002887 -s "Extra-header:" \
2888 -c "HTTP/1.0 200 OK"
2889
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002890# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002891
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002892needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002893run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002894 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002895 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2896 psk=abc123" \
2897 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002898 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2899 0 \
2900 -s "Extra-header:" \
2901 -c "HTTP/1.0 200 OK"
2902
2903needs_more_time 2
2904run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
2905 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002906 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2907 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002908 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2909 0 \
2910 -s "Extra-header:" \
2911 -c "HTTP/1.0 200 OK"
2912
2913needs_more_time 2
2914run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
2915 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002916 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
2917 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002918 0 \
2919 -s "Extra-header:" \
2920 -c "HTTP/1.0 200 OK"
2921
2922needs_more_time 2
2923run_test "DTLS proxy: 3d, FS, client auth" \
2924 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002925 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
2926 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002927 0 \
2928 -s "Extra-header:" \
2929 -c "HTTP/1.0 200 OK"
2930
2931needs_more_time 2
2932run_test "DTLS proxy: 3d, FS, ticket" \
2933 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002934 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
2935 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02002936 0 \
2937 -s "Extra-header:" \
2938 -c "HTTP/1.0 200 OK"
2939
2940needs_more_time 2
2941run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
2942 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002943 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
2944 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002945 0 \
2946 -s "Extra-header:" \
2947 -c "HTTP/1.0 200 OK"
2948
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002949needs_more_time 2
2950run_test "DTLS proxy: 3d, max handshake, nbio" \
2951 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002952 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
2953 auth_mode=required" \
2954 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002955 0 \
2956 -s "Extra-header:" \
2957 -c "HTTP/1.0 200 OK"
2958
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002959needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02002960run_test "DTLS proxy: 3d, min handshake, resumption" \
2961 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2962 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2963 psk=abc123 debug_level=3" \
2964 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2965 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
2966 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2967 0 \
2968 -s "a session has been resumed" \
2969 -c "a session has been resumed" \
2970 -s "Extra-header:" \
2971 -c "HTTP/1.0 200 OK"
2972
2973needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02002974run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
2975 -p "$P_PXY drop=5 delay=5 duplicate=5" \
2976 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2977 psk=abc123 debug_level=3 nbio=2" \
2978 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2979 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
2980 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
2981 0 \
2982 -s "a session has been resumed" \
2983 -c "a session has been resumed" \
2984 -s "Extra-header:" \
2985 -c "HTTP/1.0 200 OK"
2986
2987needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02002988run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002989 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02002990 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
2991 psk=abc123 renegotiation=1 debug_level=2" \
2992 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
2993 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02002994 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
2995 0 \
2996 -c "=> renegotiate" \
2997 -s "=> renegotiate" \
2998 -s "Extra-header:" \
2999 -c "HTTP/1.0 200 OK"
3000
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003001needs_more_time 4
3002run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3003 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003004 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3005 psk=abc123 renegotiation=1 debug_level=2" \
3006 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3007 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003008 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3009 0 \
3010 -c "=> renegotiate" \
3011 -s "=> renegotiate" \
3012 -s "Extra-header:" \
3013 -c "HTTP/1.0 200 OK"
3014
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003015needs_more_time 4
3016run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003017 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003018 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003019 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003020 debug_level=2" \
3021 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003022 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003023 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3024 0 \
3025 -c "=> renegotiate" \
3026 -s "=> renegotiate" \
3027 -s "Extra-header:" \
3028 -c "HTTP/1.0 200 OK"
3029
3030needs_more_time 4
3031run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003032 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003033 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003034 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003035 debug_level=2 nbio=2" \
3036 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003037 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003038 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3039 0 \
3040 -c "=> renegotiate" \
3041 -s "=> renegotiate" \
3042 -s "Extra-header:" \
3043 -c "HTTP/1.0 200 OK"
3044
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003045needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003046run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003047 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3048 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003049 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003050 0 \
3051 -s "Extra-header:" \
3052 -c "HTTP/1.0 200 OK"
3053
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003054needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003055run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3056 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3057 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003058 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003059 0 \
3060 -s "Extra-header:" \
3061 -c "HTTP/1.0 200 OK"
3062
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003063needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003064run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3065 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3066 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003067 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003068 0 \
3069 -s "Extra-header:" \
3070 -c "HTTP/1.0 200 OK"
3071
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003072needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003073run_test "DTLS proxy: 3d, gnutls server" \
3074 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3075 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003076 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003077 0 \
3078 -s "Extra-header:" \
3079 -c "Extra-header:"
3080
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003081needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003082run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3083 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3084 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003085 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003086 0 \
3087 -s "Extra-header:" \
3088 -c "Extra-header:"
3089
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003090needs_more_time 6
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003091run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3092 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3093 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003094 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003095 0 \
3096 -s "Extra-header:" \
3097 -c "Extra-header:"
3098
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003099# Final report
3100
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003101echo "------------------------------------------------------------------------"
3102
3103if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003104 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003105else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003106 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003107fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003108PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003109echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003110
3111exit $FAILS