blob: 4945cf1f0ec7fae49a529f0998d498f7e61b4dfb [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é-Gonnard74faf3c2014-03-13 18:47:44 +010016: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020017: ${GNUTLS_CLI:=gnutls-cli}
18: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010019
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +020020O_SRV="$OPENSSL_CMD s_server -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010021O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020022G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
23G_CLI="$GNUTLS_CLI"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010024
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010025TESTS=0
26FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020027SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020029CONFIG_H='../include/polarssl/config.h'
30
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010031MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010032FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020033EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034
35print_usage() {
36 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010037 echo -e " -h|--help\tPrint this help."
38 echo -e " -m|--memcheck\tCheck memory leaks and errors."
39 echo -e " -f|--filter\tOnly matching tests are executed (default: '$FILTER')"
40 echo -e " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041}
42
43get_options() {
44 while [ $# -gt 0 ]; do
45 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046 -f|--filter)
47 shift; FILTER=$1
48 ;;
49 -e|--exclude)
50 shift; EXCLUDE=$1
51 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052 -m|--memcheck)
53 MEMCHECK=1
54 ;;
55 -h|--help)
56 print_usage
57 exit 0
58 ;;
59 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020060 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061 print_usage
62 exit 1
63 ;;
64 esac
65 shift
66 done
67}
68
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020069# skip next test if OpenSSL can't send SSLv2 ClientHello
70requires_openssl_with_sslv2() {
71 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020072 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020073 OPENSSL_HAS_SSL2="YES"
74 else
75 OPENSSL_HAS_SSL2="NO"
76 fi
77 fi
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +020078
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020079 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
80 SKIP_NEXT="YES"
81 fi
82}
83
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020084# skip next test if GnuTLS isn't available
85requires_gnutls() {
86 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
87 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
88 GNUTLS_AVAILABLE="YES"
89 else
90 GNUTLS_AVAILABLE="NO"
91 fi
92 fi
93 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
94 SKIP_NEXT="YES"
95 fi
96}
97
Manuel Pégourié-Gonnard77b0b8d2014-08-31 20:19:40 +020098# skip next test if valgrind is in use (temporary)
99not_with_valgrind() {
100 if [ $MEMCHECK -gt 0 ]; then
101 SKIP_NEXT="YES"
102 else
103 SKIP_NEXT="NO"
104 fi
105}
106
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200107# skip next test if IPv6 isn't available on this host
108requires_ipv6() {
109 if [ -z "${HAS_IPV6:-}" ]; then
110 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
111 SRV_PID=$!
112 sleep 1
113 kill $SRV_PID >/dev/null 2>&1
114 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
115 HAS_IPV6="NO"
116 else
117 HAS_IPV6="YES"
118 fi
119 rm -r $SRV_OUT
120 fi
121
122 if [ "$HAS_IPV6" = "NO" ]; then
123 SKIP_NEXT="YES"
124 fi
125}
126
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100127# print_name <name>
128print_name() {
129 echo -n "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200130 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100131 for i in `seq 1 $LEN`; do echo -n '.'; done
132 echo -n ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100133
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200134 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100135}
136
137# fail <message>
138fail() {
139 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100140 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100141
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200142 mv $SRV_OUT o-srv-${TESTS}.log
143 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100144 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100145
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200146 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
147 echo " ! server output:"
148 cat o-srv-${TESTS}.log
149 echo " ! ============================================================"
150 echo " ! client output:"
151 cat o-cli-${TESTS}.log
152 fi
153
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200154 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100155}
156
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100157# is_polar <cmd_line>
158is_polar() {
159 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
160}
161
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100162# has_mem_err <log_file_name>
163has_mem_err() {
164 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
165 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
166 then
167 return 1 # false: does not have errors
168 else
169 return 0 # true: has errors
170 fi
171}
172
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200173# wait for server to start: two versions depending on lsof availability
174wait_server_start() {
175 if which lsof >/dev/null; then
176 # make sure we don't loop forever
177 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
178 WATCHDOG_PID=$!
179
180 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200181 if [ "$DTLS" -eq 1 ]; then
182 until lsof -nbi UDP:"$PORT" | grep UDP >/dev/null; do :; done
183 else
184 until lsof -nbi TCP:"$PORT" | grep LISTEN >/dev/null; do :; done
185 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200186
187 kill $WATCHDOG_PID
188 wait $WATCHDOG_PID
189 else
190 sleep "$START_DELAY"
191 fi
192}
193
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200194# wait for client to terminate and set CLI_EXIT
195# must be called right after starting the client
196wait_client_done() {
197 CLI_PID=$!
198
199 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
200 WATCHDOG_PID=$!
201
202 wait $CLI_PID
203 CLI_EXIT=$?
204
205 kill $WATCHDOG_PID
206 wait $WATCHDOG_PID
207
208 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
209}
210
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200211# check if the given command uses dtls and sets global variable DTLS
212detect_dtls() {
213 if echo "$1" | grep ' dtls=1 \| -dtls1\| -u ' >/dev/null; then
214 DTLS=1
215 else
216 DTLS=0
217 fi
218}
219
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100220# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100221# Options: -s pattern pattern that must be present in server output
222# -c pattern pattern that must be present in client output
223# -S pattern pattern that must be absent in server output
224# -C pattern pattern that must be absent in client output
225run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100226 NAME="$1"
227 SRV_CMD="$2"
228 CLI_CMD="$3"
229 CLI_EXPECT="$4"
230 shift 4
231
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100232 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
233 else
234 return
235 fi
236
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100237 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100238
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200239 # should we skip?
240 if [ "X$SKIP_NEXT" = "XYES" ]; then
241 SKIP_NEXT="NO"
242 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200243 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200244 return
245 fi
246
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200247 # update DTLS variable
248 detect_dtls "$SRV_CMD"
249
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100250 # prepend valgrind to our commands if active
251 if [ "$MEMCHECK" -gt 0 ]; then
252 if is_polar "$SRV_CMD"; then
253 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
254 fi
255 if is_polar "$CLI_CMD"; then
256 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
257 fi
258 fi
259
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100260 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200261 echo "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +0200262 # for servers without -www, eg openssl with DTLS
263 yes blabla | $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100264 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200265 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200266
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200267 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200268 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
269 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100270
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200271 # kill the server
272 kill $SRV_PID
273 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100274
275 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200276 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100277 # expected client exit to incorrectly succeed in case of catastrophic
278 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100279 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200280 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100281 else
282 fail "server failed to start"
283 return
284 fi
285 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100286 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200287 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100288 else
289 fail "client failed to start"
290 return
291 fi
292 fi
293
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100294 # check server exit code
295 if [ $? != 0 ]; then
296 fail "server fail"
297 return
298 fi
299
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100300 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100301 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
302 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100303 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100304 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100305 return
306 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100307
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100308 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200309 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100310 while [ $# -gt 0 ]
311 do
312 case $1 in
313 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200314 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100315 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100316 return
317 fi
318 ;;
319
320 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200321 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100322 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100323 return
324 fi
325 ;;
326
327 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200328 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100329 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100330 return
331 fi
332 ;;
333
334 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200335 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100336 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100337 return
338 fi
339 ;;
340
341 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200342 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100343 exit 1
344 esac
345 shift 2
346 done
347
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100348 # check valgrind's results
349 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200350 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100351 fail "Server has memory errors"
352 return
353 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200354 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100355 fail "Client has memory errors"
356 return
357 fi
358 fi
359
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100360 # if we're here, everything is ok
361 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200362 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100363}
364
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100365cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200366 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200367 kill $SRV_PID >/dev/null 2>&1
368 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100369 exit 1
370}
371
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100372#
373# MAIN
374#
375
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100376get_options "$@"
377
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100378# sanity checks, avoid an avalanche of errors
379if [ ! -x "$P_SRV" ]; then
380 echo "Command '$P_SRV' is not an executable file"
381 exit 1
382fi
383if [ ! -x "$P_CLI" ]; then
384 echo "Command '$P_CLI' is not an executable file"
385 exit 1
386fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100387if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
388 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100389 exit 1
390fi
391
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200392# used by watchdog
393MAIN_PID="$$"
394
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200395# be more patient with valgrind
396if [ "$MEMCHECK" -gt 0 ]; then
397 START_DELAY=3
398 DOG_DELAY=30
399else
400 START_DELAY=1
401 DOG_DELAY=10
402fi
403
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200404# Pick a "unique" port in the range 10000-19999.
405PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200406PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200407
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200408# fix commands to use this port, force IPv4 while at it
409P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$PORT"
410P_CLI="$P_CLI server_addr=127.0.0.1 server_port=$PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200411O_SRV="$O_SRV -accept $PORT"
412O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200413G_SRV="$G_SRV -p $PORT"
414G_CLI="$G_CLI -p $PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200415
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200416# Also pick a unique name for intermediate files
417SRV_OUT="srv_out.$$"
418CLI_OUT="cli_out.$$"
419SESSION="session.$$"
420
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200421SKIP_NEXT="NO"
422
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100423trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100424
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200425# Basic test
426
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200427# Checks that:
428# - things work with all ciphersuites active (used with config-full in all.sh)
429# - the expected (highest security) parameters are selected
430# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200431run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200432 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200433 "$P_CLI" \
434 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200435 -s "Protocol is TLSv1.2" \
436 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
437 -s "client hello v3, signature_algorithm ext: 6" \
438 -s "ECDHE curve: secp521r1" \
439 -S "error" \
440 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200441
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100442# Test for SSLv2 ClientHello
443
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200444requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200445run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100446 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100447 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100448 0 \
449 -S "parse client hello v2" \
450 -S "ssl_handshake returned"
451
452# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200453requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200454run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200455 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100456 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100457 0 \
458 -s "parse client hello v2" \
459 -S "ssl_handshake returned"
460
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100461# Tests for Truncated HMAC extension
462
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200463run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200464 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100465 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100466 0 \
467 -s "dumping 'computed mac' (20 bytes)"
468
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200469run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200470 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100471 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100472 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100473 -s "dumping 'computed mac' (10 bytes)"
474
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100475# Tests for Session Tickets
476
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200477run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200478 "$P_SRV debug_level=3 tickets=1" \
479 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100480 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100481 -c "client hello, adding session ticket extension" \
482 -s "found session ticket extension" \
483 -s "server hello, adding session ticket extension" \
484 -c "found session_ticket extension" \
485 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100486 -S "session successfully restored from cache" \
487 -s "session successfully restored from ticket" \
488 -s "a session has been resumed" \
489 -c "a session has been resumed"
490
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200491run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200492 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
493 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100494 0 \
495 -c "client hello, adding session ticket extension" \
496 -s "found session ticket extension" \
497 -s "server hello, adding session ticket extension" \
498 -c "found session_ticket extension" \
499 -c "parse new session ticket" \
500 -S "session successfully restored from cache" \
501 -s "session successfully restored from ticket" \
502 -s "a session has been resumed" \
503 -c "a session has been resumed"
504
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200505run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200506 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
507 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100508 0 \
509 -c "client hello, adding session ticket extension" \
510 -s "found session ticket extension" \
511 -s "server hello, adding session ticket extension" \
512 -c "found session_ticket extension" \
513 -c "parse new session ticket" \
514 -S "session successfully restored from cache" \
515 -S "session successfully restored from ticket" \
516 -S "a session has been resumed" \
517 -C "a session has been resumed"
518
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200519run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100520 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200521 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100522 0 \
523 -c "client hello, adding session ticket extension" \
524 -c "found session_ticket extension" \
525 -c "parse new session ticket" \
526 -c "a session has been resumed"
527
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200528run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200529 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200530 "( $O_CLI -sess_out $SESSION; \
531 $O_CLI -sess_in $SESSION; \
532 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100533 0 \
534 -s "found session ticket extension" \
535 -s "server hello, adding session ticket extension" \
536 -S "session successfully restored from cache" \
537 -s "session successfully restored from ticket" \
538 -s "a session has been resumed"
539
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100540# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200542run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200543 "$P_SRV debug_level=3 tickets=0" \
544 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100545 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100546 -c "client hello, adding session ticket extension" \
547 -s "found session ticket extension" \
548 -S "server hello, adding session ticket extension" \
549 -C "found session_ticket extension" \
550 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100551 -s "session successfully restored from cache" \
552 -S "session successfully restored from ticket" \
553 -s "a session has been resumed" \
554 -c "a session has been resumed"
555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200556run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200557 "$P_SRV debug_level=3 tickets=1" \
558 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100559 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100560 -C "client hello, adding session ticket extension" \
561 -S "found session ticket extension" \
562 -S "server hello, adding session ticket extension" \
563 -C "found session_ticket extension" \
564 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100565 -s "session successfully restored from cache" \
566 -S "session successfully restored from ticket" \
567 -s "a session has been resumed" \
568 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100569
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200570run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200571 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
572 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100573 0 \
574 -S "session successfully restored from cache" \
575 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100576 -S "a session has been resumed" \
577 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100578
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200579run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200580 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
581 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100582 0 \
583 -s "session successfully restored from cache" \
584 -S "session successfully restored from ticket" \
585 -s "a session has been resumed" \
586 -c "a session has been resumed"
587
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200588run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200589 "$P_SRV debug_level=3 tickets=0" \
590 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100591 0 \
592 -s "session successfully restored from cache" \
593 -S "session successfully restored from ticket" \
594 -s "a session has been resumed" \
595 -c "a session has been resumed"
596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200597run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200598 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
599 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100600 0 \
601 -S "session successfully restored from cache" \
602 -S "session successfully restored from ticket" \
603 -S "a session has been resumed" \
604 -C "a session has been resumed"
605
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200606run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200607 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
608 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100609 0 \
610 -s "session successfully restored from cache" \
611 -S "session successfully restored from ticket" \
612 -s "a session has been resumed" \
613 -c "a session has been resumed"
614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200615run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200616 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200617 "( $O_CLI -sess_out $SESSION; \
618 $O_CLI -sess_in $SESSION; \
619 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100620 0 \
621 -s "found session ticket extension" \
622 -S "server hello, adding session ticket extension" \
623 -s "session successfully restored from cache" \
624 -S "session successfully restored from ticket" \
625 -s "a session has been resumed"
626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200627run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100628 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200629 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100630 0 \
631 -C "found session_ticket extension" \
632 -C "parse new session ticket" \
633 -c "a session has been resumed"
634
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100635# Tests for Max Fragment Length extension
636
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200637run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200638 "$P_SRV debug_level=3" \
639 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100640 0 \
641 -C "client hello, adding max_fragment_length extension" \
642 -S "found max fragment length extension" \
643 -S "server hello, max_fragment_length extension" \
644 -C "found max_fragment_length extension"
645
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200646run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200647 "$P_SRV debug_level=3" \
648 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100649 0 \
650 -c "client hello, adding max_fragment_length extension" \
651 -s "found max fragment length extension" \
652 -s "server hello, max_fragment_length extension" \
653 -c "found max_fragment_length extension"
654
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200655run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200656 "$P_SRV debug_level=3 max_frag_len=4096" \
657 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100658 0 \
659 -C "client hello, adding max_fragment_length extension" \
660 -S "found max fragment length extension" \
661 -S "server hello, max_fragment_length extension" \
662 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100663
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200664requires_gnutls
665run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200666 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200667 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200668 0 \
669 -c "client hello, adding max_fragment_length extension" \
670 -c "found max_fragment_length extension"
671
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100672# Tests for renegotiation
673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200674run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200675 "$P_SRV debug_level=3 exchanges=2" \
676 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100677 0 \
678 -C "client hello, adding renegotiation extension" \
679 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
680 -S "found renegotiation extension" \
681 -s "server hello, secure renegotiation extension" \
682 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100683 -C "=> renegotiate" \
684 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100685 -S "write hello request"
686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200687run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200688 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
689 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100690 0 \
691 -c "client hello, adding renegotiation extension" \
692 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
693 -s "found renegotiation extension" \
694 -s "server hello, secure renegotiation extension" \
695 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100696 -c "=> renegotiate" \
697 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100698 -S "write hello request"
699
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200700run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200701 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
702 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100703 0 \
704 -c "client hello, adding renegotiation extension" \
705 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
706 -s "found renegotiation extension" \
707 -s "server hello, secure renegotiation extension" \
708 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100709 -c "=> renegotiate" \
710 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100711 -s "write hello request"
712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200713run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200714 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
715 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100716 0 \
717 -c "client hello, adding renegotiation extension" \
718 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
719 -s "found renegotiation extension" \
720 -s "server hello, secure renegotiation extension" \
721 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100722 -c "=> renegotiate" \
723 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100724 -s "write hello request"
725
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200726run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200727 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
728 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100729 1 \
730 -c "client hello, adding renegotiation extension" \
731 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
732 -S "found renegotiation extension" \
733 -s "server hello, secure renegotiation extension" \
734 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100735 -c "=> renegotiate" \
736 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200737 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200738 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200739 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100740
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200741run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200742 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
743 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100744 0 \
745 -C "client hello, adding renegotiation extension" \
746 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
747 -S "found renegotiation extension" \
748 -s "server hello, secure renegotiation extension" \
749 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100750 -C "=> renegotiate" \
751 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100752 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200753 -S "SSL - An unexpected message was received from our peer" \
754 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100755
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200756run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200757 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200758 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200759 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200760 0 \
761 -C "client hello, adding renegotiation extension" \
762 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
763 -S "found renegotiation extension" \
764 -s "server hello, secure renegotiation extension" \
765 -c "found renegotiation extension" \
766 -C "=> renegotiate" \
767 -S "=> renegotiate" \
768 -s "write hello request" \
769 -S "SSL - An unexpected message was received from our peer" \
770 -S "failed"
771
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200772# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200773run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200774 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200775 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200776 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200777 0 \
778 -C "client hello, adding renegotiation extension" \
779 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
780 -S "found renegotiation extension" \
781 -s "server hello, secure renegotiation extension" \
782 -c "found renegotiation extension" \
783 -C "=> renegotiate" \
784 -S "=> renegotiate" \
785 -s "write hello request" \
786 -S "SSL - An unexpected message was received from our peer" \
787 -S "failed"
788
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200789run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200790 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200791 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200792 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200793 0 \
794 -C "client hello, adding renegotiation extension" \
795 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
796 -S "found renegotiation extension" \
797 -s "server hello, secure renegotiation extension" \
798 -c "found renegotiation extension" \
799 -C "=> renegotiate" \
800 -S "=> renegotiate" \
801 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200802 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200803
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200804run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200805 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200806 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200807 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200808 0 \
809 -c "client hello, adding renegotiation extension" \
810 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
811 -s "found renegotiation extension" \
812 -s "server hello, secure renegotiation extension" \
813 -c "found renegotiation extension" \
814 -c "=> renegotiate" \
815 -s "=> renegotiate" \
816 -s "write hello request" \
817 -S "SSL - An unexpected message was received from our peer" \
818 -S "failed"
819
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200820run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200821 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
822 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200823 0 \
824 -c "client hello, adding renegotiation extension" \
825 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
826 -s "found renegotiation extension" \
827 -s "server hello, secure renegotiation extension" \
828 -c "found renegotiation extension" \
829 -c "=> renegotiate" \
830 -s "=> renegotiate" \
831 -S "write hello request"
832
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200833run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200834 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
835 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +0200836 0 \
837 -c "client hello, adding renegotiation extension" \
838 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
839 -s "found renegotiation extension" \
840 -s "server hello, secure renegotiation extension" \
841 -c "found renegotiation extension" \
842 -c "=> renegotiate" \
843 -s "=> renegotiate" \
844 -s "write hello request"
845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200846run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +0200847 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200848 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200849 0 \
850 -c "client hello, adding renegotiation extension" \
851 -c "found renegotiation extension" \
852 -c "=> renegotiate" \
853 -C "ssl_handshake returned" \
854 -C "error" \
855 -c "HTTP/1.0 200 [Oo][Kk]"
856
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200857run_test "Renegotiation: gnutls server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200858 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200859 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +0200860 0 \
861 -c "client hello, adding renegotiation extension" \
862 -c "found renegotiation extension" \
863 -c "=> renegotiate" \
864 -C "ssl_handshake returned" \
865 -C "error" \
866 -c "HTTP/1.0 200 [Oo][Kk]"
867
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +0200868run_test "Renegotiation: DTLS, client-initiated" \
869 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
870 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
871 0 \
872 -c "client hello, adding renegotiation extension" \
873 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
874 -s "found renegotiation extension" \
875 -s "server hello, secure renegotiation extension" \
876 -c "found renegotiation extension" \
877 -c "=> renegotiate" \
878 -s "=> renegotiate" \
879 -S "write hello request"
880
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +0200881run_test "Renegotiation: DTLS, server-initiated" \
882 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
883 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
884 0 \
885 -c "client hello, adding renegotiation extension" \
886 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
887 -s "found renegotiation extension" \
888 -s "server hello, secure renegotiation extension" \
889 -c "found renegotiation extension" \
890 -c "=> renegotiate" \
891 -s "=> renegotiate" \
892 -s "write hello request"
893
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100894# Tests for auth_mode
895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200896run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100897 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100898 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200899 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100900 1 \
901 -c "x509_verify_cert() returned" \
902 -c "! self-signed or not signed by a trusted CA" \
903 -c "! ssl_handshake returned" \
904 -c "X509 - Certificate verification failed"
905
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200906run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100907 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100908 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200909 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100910 0 \
911 -c "x509_verify_cert() returned" \
912 -c "! self-signed or not signed by a trusted CA" \
913 -C "! ssl_handshake returned" \
914 -C "X509 - Certificate verification failed"
915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200916run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100917 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100918 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200919 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100920 0 \
921 -C "x509_verify_cert() returned" \
922 -C "! self-signed or not signed by a trusted CA" \
923 -C "! ssl_handshake returned" \
924 -C "X509 - Certificate verification failed"
925
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200926run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200927 "$P_SRV debug_level=3 auth_mode=required" \
928 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100929 key_file=data_files/server5.key" \
930 1 \
931 -S "skip write certificate request" \
932 -C "skip parse certificate request" \
933 -c "got a certificate request" \
934 -C "skip write certificate" \
935 -C "skip write certificate verify" \
936 -S "skip parse certificate verify" \
937 -s "x509_verify_cert() returned" \
938 -S "! self-signed or not signed by a trusted CA" \
939 -s "! ssl_handshake returned" \
940 -c "! ssl_handshake returned" \
941 -s "X509 - Certificate verification failed"
942
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200943run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200944 "$P_SRV debug_level=3 auth_mode=optional" \
945 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100946 key_file=data_files/server5.key" \
947 0 \
948 -S "skip write certificate request" \
949 -C "skip parse certificate request" \
950 -c "got a certificate request" \
951 -C "skip write certificate" \
952 -C "skip write certificate verify" \
953 -S "skip parse certificate verify" \
954 -s "x509_verify_cert() returned" \
955 -s "! self-signed or not signed by a trusted CA" \
956 -S "! ssl_handshake returned" \
957 -C "! ssl_handshake returned" \
958 -S "X509 - Certificate verification failed"
959
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200960run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200961 "$P_SRV debug_level=3 auth_mode=none" \
962 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100963 key_file=data_files/server5.key" \
964 0 \
965 -s "skip write certificate request" \
966 -C "skip parse certificate request" \
967 -c "got no certificate request" \
968 -c "skip write certificate" \
969 -c "skip write certificate verify" \
970 -s "skip parse certificate verify" \
971 -S "x509_verify_cert() returned" \
972 -S "! self-signed or not signed by a trusted CA" \
973 -S "! ssl_handshake returned" \
974 -C "! ssl_handshake returned" \
975 -S "X509 - Certificate verification failed"
976
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200977run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200978 "$P_SRV debug_level=3 auth_mode=optional" \
979 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100980 0 \
981 -S "skip write certificate request" \
982 -C "skip parse certificate request" \
983 -c "got a certificate request" \
984 -C "skip write certificate$" \
985 -C "got no certificate to send" \
986 -S "SSLv3 client has no certificate" \
987 -c "skip write certificate verify" \
988 -s "skip parse certificate verify" \
989 -s "! no client certificate sent" \
990 -S "! ssl_handshake returned" \
991 -C "! ssl_handshake returned" \
992 -S "X509 - Certificate verification failed"
993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200994run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200995 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +0100996 "$O_CLI" \
997 0 \
998 -S "skip write certificate request" \
999 -s "skip parse certificate verify" \
1000 -s "! no client certificate sent" \
1001 -S "! ssl_handshake returned" \
1002 -S "X509 - Certificate verification failed"
1003
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001004run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001005 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001006 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001007 0 \
1008 -C "skip parse certificate request" \
1009 -c "got a certificate request" \
1010 -C "skip write certificate$" \
1011 -c "skip write certificate verify" \
1012 -C "! ssl_handshake returned"
1013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001014run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001015 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1016 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001017 0 \
1018 -S "skip write certificate request" \
1019 -C "skip parse certificate request" \
1020 -c "got a certificate request" \
1021 -C "skip write certificate$" \
1022 -c "skip write certificate verify" \
1023 -c "got no certificate to send" \
1024 -s "SSLv3 client has no certificate" \
1025 -s "skip parse certificate verify" \
1026 -s "! no client certificate sent" \
1027 -S "! ssl_handshake returned" \
1028 -C "! ssl_handshake returned" \
1029 -S "X509 - Certificate verification failed"
1030
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001031# tests for SNI
1032
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001033run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001034 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001035 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001036 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001037 0 \
1038 -S "parse ServerName extension" \
1039 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1040 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001042run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001043 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001044 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001045 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 +02001046 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001047 0 \
1048 -s "parse ServerName extension" \
1049 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1050 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001052run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001053 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001054 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001055 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 +02001056 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001057 0 \
1058 -s "parse ServerName extension" \
1059 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001060 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001062run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001063 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001064 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001065 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 +02001066 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001067 1 \
1068 -s "parse ServerName extension" \
1069 -s "ssl_sni_wrapper() returned" \
1070 -s "ssl_handshake returned" \
1071 -c "ssl_handshake returned" \
1072 -c "SSL - A fatal alert message was received from our peer"
1073
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001074# Tests for non-blocking I/O: exercise a variety of handshake flows
1075
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001076run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001077 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1078 "$P_CLI nbio=2 tickets=0" \
1079 0 \
1080 -S "ssl_handshake returned" \
1081 -C "ssl_handshake returned" \
1082 -c "Read from server: .* bytes read"
1083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001084run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001085 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1086 "$P_CLI nbio=2 tickets=0" \
1087 0 \
1088 -S "ssl_handshake returned" \
1089 -C "ssl_handshake returned" \
1090 -c "Read from server: .* bytes read"
1091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001092run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001093 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1094 "$P_CLI nbio=2 tickets=1" \
1095 0 \
1096 -S "ssl_handshake returned" \
1097 -C "ssl_handshake returned" \
1098 -c "Read from server: .* bytes read"
1099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001100run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001101 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1102 "$P_CLI nbio=2 tickets=1" \
1103 0 \
1104 -S "ssl_handshake returned" \
1105 -C "ssl_handshake returned" \
1106 -c "Read from server: .* bytes read"
1107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001108run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001109 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1110 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1111 0 \
1112 -S "ssl_handshake returned" \
1113 -C "ssl_handshake returned" \
1114 -c "Read from server: .* bytes read"
1115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001116run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001117 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1118 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1119 0 \
1120 -S "ssl_handshake returned" \
1121 -C "ssl_handshake returned" \
1122 -c "Read from server: .* bytes read"
1123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001124run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001125 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1126 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1127 0 \
1128 -S "ssl_handshake returned" \
1129 -C "ssl_handshake returned" \
1130 -c "Read from server: .* bytes read"
1131
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001132# Tests for version negotiation
1133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001134run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001135 "$P_SRV" \
1136 "$P_CLI" \
1137 0 \
1138 -S "ssl_handshake returned" \
1139 -C "ssl_handshake returned" \
1140 -s "Protocol is TLSv1.2" \
1141 -c "Protocol is TLSv1.2"
1142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001143run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001144 "$P_SRV" \
1145 "$P_CLI max_version=tls1_1" \
1146 0 \
1147 -S "ssl_handshake returned" \
1148 -C "ssl_handshake returned" \
1149 -s "Protocol is TLSv1.1" \
1150 -c "Protocol is TLSv1.1"
1151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001152run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001153 "$P_SRV max_version=tls1_1" \
1154 "$P_CLI" \
1155 0 \
1156 -S "ssl_handshake returned" \
1157 -C "ssl_handshake returned" \
1158 -s "Protocol is TLSv1.1" \
1159 -c "Protocol is TLSv1.1"
1160
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001161run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001162 "$P_SRV max_version=tls1_1" \
1163 "$P_CLI max_version=tls1_1" \
1164 0 \
1165 -S "ssl_handshake returned" \
1166 -C "ssl_handshake returned" \
1167 -s "Protocol is TLSv1.1" \
1168 -c "Protocol is TLSv1.1"
1169
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001170run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001171 "$P_SRV min_version=tls1_1" \
1172 "$P_CLI max_version=tls1_1" \
1173 0 \
1174 -S "ssl_handshake returned" \
1175 -C "ssl_handshake returned" \
1176 -s "Protocol is TLSv1.1" \
1177 -c "Protocol is TLSv1.1"
1178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001179run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001180 "$P_SRV max_version=tls1_1" \
1181 "$P_CLI min_version=tls1_1" \
1182 0 \
1183 -S "ssl_handshake returned" \
1184 -C "ssl_handshake returned" \
1185 -s "Protocol is TLSv1.1" \
1186 -c "Protocol is TLSv1.1"
1187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001188run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001189 "$P_SRV max_version=tls1_1" \
1190 "$P_CLI min_version=tls1_2" \
1191 1 \
1192 -s "ssl_handshake returned" \
1193 -c "ssl_handshake returned" \
1194 -c "SSL - Handshake protocol not within min/max boundaries"
1195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001196run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001197 "$P_SRV min_version=tls1_2" \
1198 "$P_CLI max_version=tls1_1" \
1199 1 \
1200 -s "ssl_handshake returned" \
1201 -c "ssl_handshake returned" \
1202 -s "SSL - Handshake protocol not within min/max boundaries"
1203
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001204# Tests for ALPN extension
1205
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001206if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001208run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001209 "$P_SRV debug_level=3" \
1210 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001211 0 \
1212 -C "client hello, adding alpn extension" \
1213 -S "found alpn extension" \
1214 -C "got an alert message, type: \\[2:120]" \
1215 -S "server hello, adding alpn extension" \
1216 -C "found alpn extension " \
1217 -C "Application Layer Protocol is" \
1218 -S "Application Layer Protocol is"
1219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001220run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001221 "$P_SRV debug_level=3" \
1222 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001223 0 \
1224 -c "client hello, adding alpn extension" \
1225 -s "found alpn extension" \
1226 -C "got an alert message, type: \\[2:120]" \
1227 -S "server hello, adding alpn extension" \
1228 -C "found alpn extension " \
1229 -c "Application Layer Protocol is (none)" \
1230 -S "Application Layer Protocol is"
1231
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001232run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001233 "$P_SRV debug_level=3 alpn=abc,1234" \
1234 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001235 0 \
1236 -C "client hello, adding alpn extension" \
1237 -S "found alpn extension" \
1238 -C "got an alert message, type: \\[2:120]" \
1239 -S "server hello, adding alpn extension" \
1240 -C "found alpn extension " \
1241 -C "Application Layer Protocol is" \
1242 -s "Application Layer Protocol is (none)"
1243
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001244run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001245 "$P_SRV debug_level=3 alpn=abc,1234" \
1246 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001247 0 \
1248 -c "client hello, adding alpn extension" \
1249 -s "found alpn extension" \
1250 -C "got an alert message, type: \\[2:120]" \
1251 -s "server hello, adding alpn extension" \
1252 -c "found alpn extension" \
1253 -c "Application Layer Protocol is abc" \
1254 -s "Application Layer Protocol is abc"
1255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001256run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_SRV debug_level=3 alpn=abc,1234" \
1258 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001259 0 \
1260 -c "client hello, adding alpn extension" \
1261 -s "found alpn extension" \
1262 -C "got an alert message, type: \\[2:120]" \
1263 -s "server hello, adding alpn extension" \
1264 -c "found alpn extension" \
1265 -c "Application Layer Protocol is abc" \
1266 -s "Application Layer Protocol is abc"
1267
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001268run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001269 "$P_SRV debug_level=3 alpn=abc,1234" \
1270 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001271 0 \
1272 -c "client hello, adding alpn extension" \
1273 -s "found alpn extension" \
1274 -C "got an alert message, type: \\[2:120]" \
1275 -s "server hello, adding alpn extension" \
1276 -c "found alpn extension" \
1277 -c "Application Layer Protocol is 1234" \
1278 -s "Application Layer Protocol is 1234"
1279
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001280run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001281 "$P_SRV debug_level=3 alpn=abc,123" \
1282 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001283 1 \
1284 -c "client hello, adding alpn extension" \
1285 -s "found alpn extension" \
1286 -c "got an alert message, type: \\[2:120]" \
1287 -S "server hello, adding alpn extension" \
1288 -C "found alpn extension" \
1289 -C "Application Layer Protocol is 1234" \
1290 -S "Application Layer Protocol is 1234"
1291
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001292fi
1293
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001294# Tests for keyUsage in leaf certificates, part 1:
1295# server-side certificate/suite selection
1296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001297run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001298 "$P_SRV key_file=data_files/server2.key \
1299 crt_file=data_files/server2.ku-ds.crt" \
1300 "$P_CLI" \
1301 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001302 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001303
1304
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001305run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001306 "$P_SRV key_file=data_files/server2.key \
1307 crt_file=data_files/server2.ku-ke.crt" \
1308 "$P_CLI" \
1309 0 \
1310 -c "Ciphersuite is TLS-RSA-WITH-"
1311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001312run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001313 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001314 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001315 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001316 1 \
1317 -C "Ciphersuite is "
1318
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001319run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001320 "$P_SRV key_file=data_files/server5.key \
1321 crt_file=data_files/server5.ku-ds.crt" \
1322 "$P_CLI" \
1323 0 \
1324 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1325
1326
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001327run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001328 "$P_SRV key_file=data_files/server5.key \
1329 crt_file=data_files/server5.ku-ka.crt" \
1330 "$P_CLI" \
1331 0 \
1332 -c "Ciphersuite is TLS-ECDH-"
1333
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001334run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001335 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001336 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001337 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001338 1 \
1339 -C "Ciphersuite is "
1340
1341# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001342# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001343
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001344run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001345 "$O_SRV -key data_files/server2.key \
1346 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001347 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001348 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1349 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001350 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001351 -C "Processing of the Certificate handshake message failed" \
1352 -c "Ciphersuite is TLS-"
1353
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001354run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001355 "$O_SRV -key data_files/server2.key \
1356 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001357 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001358 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1359 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001360 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001361 -C "Processing of the Certificate handshake message failed" \
1362 -c "Ciphersuite is TLS-"
1363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001364run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001365 "$O_SRV -key data_files/server2.key \
1366 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001367 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001368 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1369 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001370 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001371 -C "Processing of the Certificate handshake message failed" \
1372 -c "Ciphersuite is TLS-"
1373
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001374run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001375 "$O_SRV -key data_files/server2.key \
1376 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001377 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001378 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1379 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001380 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001381 -c "Processing of the Certificate handshake message failed" \
1382 -C "Ciphersuite is TLS-"
1383
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001384run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001385 "$O_SRV -key data_files/server2.key \
1386 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001387 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001388 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1389 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001390 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001391 -C "Processing of the Certificate handshake message failed" \
1392 -c "Ciphersuite is TLS-"
1393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001394run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001395 "$O_SRV -key data_files/server2.key \
1396 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001397 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001398 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1399 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001400 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001401 -c "Processing of the Certificate handshake message failed" \
1402 -C "Ciphersuite is TLS-"
1403
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001404# Tests for keyUsage in leaf certificates, part 3:
1405# server-side checking of client cert
1406
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001407run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001408 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001409 "$O_CLI -key data_files/server2.key \
1410 -cert data_files/server2.ku-ds.crt" \
1411 0 \
1412 -S "bad certificate (usage extensions)" \
1413 -S "Processing of the Certificate handshake message failed"
1414
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001415run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001416 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001417 "$O_CLI -key data_files/server2.key \
1418 -cert data_files/server2.ku-ke.crt" \
1419 0 \
1420 -s "bad certificate (usage extensions)" \
1421 -S "Processing of the Certificate handshake message failed"
1422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001423run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001424 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001425 "$O_CLI -key data_files/server2.key \
1426 -cert data_files/server2.ku-ke.crt" \
1427 1 \
1428 -s "bad certificate (usage extensions)" \
1429 -s "Processing of the Certificate handshake message failed"
1430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001431run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001432 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001433 "$O_CLI -key data_files/server5.key \
1434 -cert data_files/server5.ku-ds.crt" \
1435 0 \
1436 -S "bad certificate (usage extensions)" \
1437 -S "Processing of the Certificate handshake message failed"
1438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001439run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001440 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001441 "$O_CLI -key data_files/server5.key \
1442 -cert data_files/server5.ku-ka.crt" \
1443 0 \
1444 -s "bad certificate (usage extensions)" \
1445 -S "Processing of the Certificate handshake message failed"
1446
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001447# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1448
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001449run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001450 "$P_SRV key_file=data_files/server5.key \
1451 crt_file=data_files/server5.eku-srv.crt" \
1452 "$P_CLI" \
1453 0
1454
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001455run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001456 "$P_SRV key_file=data_files/server5.key \
1457 crt_file=data_files/server5.eku-srv.crt" \
1458 "$P_CLI" \
1459 0
1460
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001461run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001462 "$P_SRV key_file=data_files/server5.key \
1463 crt_file=data_files/server5.eku-cs_any.crt" \
1464 "$P_CLI" \
1465 0
1466
1467# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001468run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001469 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1470 crt_file=data_files/server5.eku-cli.crt" \
1471 "$P_CLI psk=badbad" \
1472 1
1473
1474# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1475
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001476run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001477 "$O_SRV -key data_files/server5.key \
1478 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001479 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001480 0 \
1481 -C "bad certificate (usage extensions)" \
1482 -C "Processing of the Certificate handshake message failed" \
1483 -c "Ciphersuite is TLS-"
1484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001485run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001486 "$O_SRV -key data_files/server5.key \
1487 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001488 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001489 0 \
1490 -C "bad certificate (usage extensions)" \
1491 -C "Processing of the Certificate handshake message failed" \
1492 -c "Ciphersuite is TLS-"
1493
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001494run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001495 "$O_SRV -key data_files/server5.key \
1496 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001497 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001498 0 \
1499 -C "bad certificate (usage extensions)" \
1500 -C "Processing of the Certificate handshake message failed" \
1501 -c "Ciphersuite is TLS-"
1502
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001503run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001504 "$O_SRV -key data_files/server5.key \
1505 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001506 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001507 1 \
1508 -c "bad certificate (usage extensions)" \
1509 -c "Processing of the Certificate handshake message failed" \
1510 -C "Ciphersuite is TLS-"
1511
1512# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1513
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001514run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001515 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001516 "$O_CLI -key data_files/server5.key \
1517 -cert data_files/server5.eku-cli.crt" \
1518 0 \
1519 -S "bad certificate (usage extensions)" \
1520 -S "Processing of the Certificate handshake message failed"
1521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001522run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001523 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001524 "$O_CLI -key data_files/server5.key \
1525 -cert data_files/server5.eku-srv_cli.crt" \
1526 0 \
1527 -S "bad certificate (usage extensions)" \
1528 -S "Processing of the Certificate handshake message failed"
1529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001530run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001531 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001532 "$O_CLI -key data_files/server5.key \
1533 -cert data_files/server5.eku-cs_any.crt" \
1534 0 \
1535 -S "bad certificate (usage extensions)" \
1536 -S "Processing of the Certificate handshake message failed"
1537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001538run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001539 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001540 "$O_CLI -key data_files/server5.key \
1541 -cert data_files/server5.eku-cs.crt" \
1542 0 \
1543 -s "bad certificate (usage extensions)" \
1544 -S "Processing of the Certificate handshake message failed"
1545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001546run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001547 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001548 "$O_CLI -key data_files/server5.key \
1549 -cert data_files/server5.eku-cs.crt" \
1550 1 \
1551 -s "bad certificate (usage extensions)" \
1552 -s "Processing of the Certificate handshake message failed"
1553
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001554# Tests for DHM parameters loading
1555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001556run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001557 "$P_SRV" \
1558 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1559 debug_level=3" \
1560 0 \
1561 -c "value of 'DHM: P ' (2048 bits)" \
1562 -c "value of 'DHM: G ' (2048 bits)"
1563
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001564run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001565 "$P_SRV dhm_file=data_files/dhparams.pem" \
1566 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1567 debug_level=3" \
1568 0 \
1569 -c "value of 'DHM: P ' (1024 bits)" \
1570 -c "value of 'DHM: G ' (2 bits)"
1571
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001572# Tests for PSK callback
1573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001574run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001575 "$P_SRV psk=abc123 psk_identity=foo" \
1576 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1577 psk_identity=foo psk=abc123" \
1578 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001579 -S "SSL - The server has no ciphersuites in common" \
1580 -S "SSL - Unknown identity received" \
1581 -S "SSL - Verification of the message MAC failed"
1582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001583run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001584 "$P_SRV" \
1585 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1586 psk_identity=foo psk=abc123" \
1587 1 \
1588 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001589 -S "SSL - Unknown identity received" \
1590 -S "SSL - Verification of the message MAC failed"
1591
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001592run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001593 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1594 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1595 psk_identity=foo psk=abc123" \
1596 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001597 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001598 -s "SSL - Unknown identity received" \
1599 -S "SSL - Verification of the message MAC failed"
1600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001601run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001602 "$P_SRV psk_list=abc,dead,def,beef" \
1603 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1604 psk_identity=abc psk=dead" \
1605 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001606 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001607 -S "SSL - Unknown identity received" \
1608 -S "SSL - Verification of the message MAC failed"
1609
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001610run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001611 "$P_SRV psk_list=abc,dead,def,beef" \
1612 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1613 psk_identity=def psk=beef" \
1614 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001615 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001616 -S "SSL - Unknown identity received" \
1617 -S "SSL - Verification of the message MAC failed"
1618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001619run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001620 "$P_SRV psk_list=abc,dead,def,beef" \
1621 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1622 psk_identity=ghi psk=beef" \
1623 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001624 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001625 -s "SSL - Unknown identity received" \
1626 -S "SSL - Verification of the message MAC failed"
1627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001628run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001629 "$P_SRV psk_list=abc,dead,def,beef" \
1630 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1631 psk_identity=abc psk=beef" \
1632 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001633 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001634 -S "SSL - Unknown identity received" \
1635 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001636
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001637# Tests for ciphersuites per version
1638
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001639run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001640 "$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" \
1641 "$P_CLI force_version=ssl3" \
1642 0 \
1643 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001645run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001646 "$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" \
1647 "$P_CLI force_version=tls1" \
1648 0 \
1649 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1650
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001651run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001652 "$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" \
1653 "$P_CLI force_version=tls1_1" \
1654 0 \
1655 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1656
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001657run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001658 "$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" \
1659 "$P_CLI force_version=tls1_2" \
1660 0 \
1661 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1662
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001663# Tests for ssl_get_bytes_avail()
1664
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001665run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001666 "$P_SRV" \
1667 "$P_CLI request_size=100" \
1668 0 \
1669 -s "Read from client: 100 bytes read$"
1670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001671run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001672 "$P_SRV" \
1673 "$P_CLI request_size=500" \
1674 0 \
1675 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001676
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001677# Tests for small packets
1678
1679run_test "Small packet SSLv3 BlockCipher" \
1680 "$P_SRV" \
1681 "$P_CLI request_size=1 force_version=ssl3 \
1682 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1683 0 \
1684 -s "Read from client: 1 bytes read"
1685
1686run_test "Small packet SSLv3 StreamCipher" \
1687 "$P_SRV" \
1688 "$P_CLI request_size=1 force_version=ssl3 \
1689 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1690 0 \
1691 -s "Read from client: 1 bytes read"
1692
1693run_test "Small packet TLS 1.0 BlockCipher" \
1694 "$P_SRV" \
1695 "$P_CLI request_size=1 force_version=tls1 \
1696 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1697 0 \
1698 -s "Read from client: 1 bytes read"
1699
1700run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
1701 "$P_SRV" \
1702 "$P_CLI request_size=1 force_version=tls1 \
1703 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1704 trunc_hmac=1" \
1705 0 \
1706 -s "Read from client: 1 bytes read"
1707
1708run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
1709 "$P_SRV" \
1710 "$P_CLI request_size=1 force_version=tls1 \
1711 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1712 trunc_hmac=1" \
1713 0 \
1714 -s "Read from client: 1 bytes read"
1715
1716run_test "Small packet TLS 1.1 BlockCipher" \
1717 "$P_SRV" \
1718 "$P_CLI request_size=1 force_version=tls1_1 \
1719 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1720 0 \
1721 -s "Read from client: 1 bytes read"
1722
1723run_test "Small packet TLS 1.1 StreamCipher" \
1724 "$P_SRV" \
1725 "$P_CLI request_size=1 force_version=tls1_1 \
1726 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1727 0 \
1728 -s "Read from client: 1 bytes read"
1729
1730run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
1731 "$P_SRV" \
1732 "$P_CLI request_size=1 force_version=tls1_1 \
1733 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1734 trunc_hmac=1" \
1735 0 \
1736 -s "Read from client: 1 bytes read"
1737
1738run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
1739 "$P_SRV" \
1740 "$P_CLI request_size=1 force_version=tls1_1 \
1741 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1742 trunc_hmac=1" \
1743 0 \
1744 -s "Read from client: 1 bytes read"
1745
1746run_test "Small packet TLS 1.2 BlockCipher" \
1747 "$P_SRV" \
1748 "$P_CLI request_size=1 force_version=tls1_2 \
1749 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1750 0 \
1751 -s "Read from client: 1 bytes read"
1752
1753run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
1754 "$P_SRV" \
1755 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1756 0 \
1757 -s "Read from client: 1 bytes read"
1758
1759run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
1760 "$P_SRV" \
1761 "$P_CLI request_size=1 force_version=tls1_2 \
1762 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1763 trunc_hmac=1" \
1764 0 \
1765 -s "Read from client: 1 bytes read"
1766
1767run_test "Small packet TLS 1.2 StreamCipher" \
1768 "$P_SRV" \
1769 "$P_CLI request_size=1 force_version=tls1_2 \
1770 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1771 0 \
1772 -s "Read from client: 1 bytes read"
1773
1774run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
1775 "$P_SRV" \
1776 "$P_CLI request_size=1 force_version=tls1_2 \
1777 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1778 trunc_hmac=1" \
1779 0 \
1780 -s "Read from client: 1 bytes read"
1781
1782run_test "Small packet TLS 1.2 AEAD" \
1783 "$P_SRV" \
1784 "$P_CLI request_size=1 force_version=tls1_2 \
1785 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1786 0 \
1787 -s "Read from client: 1 bytes read"
1788
1789run_test "Small packet TLS 1.2 AEAD shorter tag" \
1790 "$P_SRV" \
1791 "$P_CLI request_size=1 force_version=tls1_2 \
1792 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1793 0 \
1794 -s "Read from client: 1 bytes read"
1795
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02001796# Test for large packets
1797
1798run_test "Large packet SSLv3 BlockCipher" \
1799 "$P_SRV" \
1800 "$P_CLI request_size=16384 force_version=ssl3 \
1801 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1802 0 \
1803 -s "Read from client: 16384 bytes read"
1804
1805run_test "Large packet SSLv3 StreamCipher" \
1806 "$P_SRV" \
1807 "$P_CLI request_size=16384 force_version=ssl3 \
1808 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1809 0 \
1810 -s "Read from client: 16384 bytes read"
1811
1812run_test "Large packet TLS 1.0 BlockCipher" \
1813 "$P_SRV" \
1814 "$P_CLI request_size=16384 force_version=tls1 \
1815 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1816 0 \
1817 -s "Read from client: 16384 bytes read"
1818
1819run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
1820 "$P_SRV" \
1821 "$P_CLI request_size=16384 force_version=tls1 \
1822 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1823 trunc_hmac=1" \
1824 0 \
1825 -s "Read from client: 16384 bytes read"
1826
1827run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
1828 "$P_SRV" \
1829 "$P_CLI request_size=16384 force_version=tls1 \
1830 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1831 trunc_hmac=1" \
1832 0 \
1833 -s "Read from client: 16384 bytes read"
1834
1835run_test "Large packet TLS 1.1 BlockCipher" \
1836 "$P_SRV" \
1837 "$P_CLI request_size=16384 force_version=tls1_1 \
1838 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1839 0 \
1840 -s "Read from client: 16384 bytes read"
1841
1842run_test "Large packet TLS 1.1 StreamCipher" \
1843 "$P_SRV" \
1844 "$P_CLI request_size=16384 force_version=tls1_1 \
1845 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1846 0 \
1847 -s "Read from client: 16384 bytes read"
1848
1849run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
1850 "$P_SRV" \
1851 "$P_CLI request_size=16384 force_version=tls1_1 \
1852 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1853 trunc_hmac=1" \
1854 0 \
1855 -s "Read from client: 16384 bytes read"
1856
1857run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
1858 "$P_SRV" \
1859 "$P_CLI request_size=16384 force_version=tls1_1 \
1860 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1861 trunc_hmac=1" \
1862 0 \
1863 -s "Read from client: 16384 bytes read"
1864
1865run_test "Large packet TLS 1.2 BlockCipher" \
1866 "$P_SRV" \
1867 "$P_CLI request_size=16384 force_version=tls1_2 \
1868 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1869 0 \
1870 -s "Read from client: 16384 bytes read"
1871
1872run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
1873 "$P_SRV" \
1874 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
1875 0 \
1876 -s "Read from client: 16384 bytes read"
1877
1878run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
1879 "$P_SRV" \
1880 "$P_CLI request_size=16384 force_version=tls1_2 \
1881 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
1882 trunc_hmac=1" \
1883 0 \
1884 -s "Read from client: 16384 bytes read"
1885
1886run_test "Large packet TLS 1.2 StreamCipher" \
1887 "$P_SRV" \
1888 "$P_CLI request_size=16384 force_version=tls1_2 \
1889 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1890 0 \
1891 -s "Read from client: 16384 bytes read"
1892
1893run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
1894 "$P_SRV" \
1895 "$P_CLI request_size=16384 force_version=tls1_2 \
1896 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1897 trunc_hmac=1" \
1898 0 \
1899 -s "Read from client: 16384 bytes read"
1900
1901run_test "Large packet TLS 1.2 AEAD" \
1902 "$P_SRV" \
1903 "$P_CLI request_size=16384 force_version=tls1_2 \
1904 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
1905 0 \
1906 -s "Read from client: 16384 bytes read"
1907
1908run_test "Large packet TLS 1.2 AEAD shorter tag" \
1909 "$P_SRV" \
1910 "$P_CLI request_size=16384 force_version=tls1_2 \
1911 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
1912 0 \
1913 -s "Read from client: 16384 bytes read"
1914
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001915# Tests for DTLS HelloVerifyRequest
1916
1917run_test "DTLS cookie: enabled" \
1918 "$P_SRV dtls=1 debug_level=2" \
1919 "$P_CLI dtls=1 debug_level=2" \
1920 0 \
1921 -s "cookie verification failed" \
1922 -s "cookie verification passed" \
1923 -S "cookie verification skipped" \
1924 -c "received hello verify request" \
1925 -S "SSL - The requested feature is not available"
1926
1927run_test "DTLS cookie: disabled" \
1928 "$P_SRV dtls=1 debug_level=2 cookies=0" \
1929 "$P_CLI dtls=1 debug_level=2" \
1930 0 \
1931 -S "cookie verification failed" \
1932 -S "cookie verification passed" \
1933 -s "cookie verification skipped" \
1934 -C "received hello verify request" \
1935 -S "SSL - The requested feature is not available"
1936
1937# wait for client having a timeout, or server sending an alert
1938#run_test "DTLS cookie: default (failing)" \
1939# "$P_SRV dtls=1 debug_level=2 cookies=-1" \
1940# "$P_CLI dtls=1 debug_level=2" \
1941# 0 \
1942# -S "cookie verification failed" \
1943# -S "cookie verification passed" \
1944# -S "cookie verification skipped" \
1945# -C "received hello verify request" \
1946# -s "SSL - The requested feature is not available"
1947
1948requires_ipv6
1949run_test "DTLS cookie: enabled, IPv6" \
1950 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
1951 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
1952 0 \
1953 -s "cookie verification failed" \
1954 -s "cookie verification passed" \
1955 -S "cookie verification skipped" \
1956 -c "received hello verify request" \
1957 -S "SSL - The requested feature is not available"
1958
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02001959# Tests for receiving fragmented handshake messages with DTLS
1960
1961requires_gnutls
Manuel Pégourié-Gonnard77b0b8d2014-08-31 20:19:40 +02001962not_with_valgrind
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02001963run_test "DTLS reassembly: no fragmentation (gnutls server)" \
1964 "$G_SRV -u --mtu 2048 -a" \
1965 "$P_CLI dtls=1 debug_level=2" \
1966 0 \
1967 -C "found fragmented DTLS handshake message" \
1968 -C "error"
1969
1970requires_gnutls
Manuel Pégourié-Gonnard77b0b8d2014-08-31 20:19:40 +02001971not_with_valgrind
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02001972run_test "DTLS reassembly: some fragmentation (gnutls server)" \
1973 "$G_SRV -u --mtu 512" \
1974 "$P_CLI dtls=1 debug_level=2" \
1975 0 \
1976 -c "found fragmented DTLS handshake message" \
1977 -C "error"
1978
1979requires_gnutls
Manuel Pégourié-Gonnard77b0b8d2014-08-31 20:19:40 +02001980not_with_valgrind
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02001981run_test "DTLS reassembly: more fragmentation (gnutls server)" \
1982 "$G_SRV -u --mtu 128" \
1983 "$P_CLI dtls=1 debug_level=2" \
1984 0 \
1985 -c "found fragmented DTLS handshake message" \
1986 -C "error"
1987
1988requires_gnutls
Manuel Pégourié-Gonnard77b0b8d2014-08-31 20:19:40 +02001989not_with_valgrind
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02001990run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
1991 "$G_SRV -u --mtu 128" \
1992 "$P_CLI dtls=1 nbio=2 debug_level=2" \
1993 0 \
1994 -c "found fragmented DTLS handshake message" \
1995 -C "error"
1996
Manuel Pégourié-Gonnard77b0b8d2014-08-31 20:19:40 +02001997not_with_valgrind
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001998run_test "DTLS reassembly: no fragmentation (openssl server)" \
1999 "$O_SRV -dtls1 -mtu 2048" \
2000 "$P_CLI dtls=1 debug_level=2" \
2001 0 \
2002 -C "found fragmented DTLS handshake message" \
2003 -C "error"
2004
Manuel Pégourié-Gonnard77b0b8d2014-08-31 20:19:40 +02002005not_with_valgrind
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002006run_test "DTLS reassembly: fragmentation (openssl server)" \
2007 "$O_SRV -dtls1 -mtu 256" \
2008 "$P_CLI dtls=1 debug_level=2" \
2009 0 \
2010 -c "found fragmented DTLS handshake message" \
2011 -C "error"
2012
Manuel Pégourié-Gonnard77b0b8d2014-08-31 20:19:40 +02002013not_with_valgrind
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002014run_test "DTLS reassembly: fragmentation (openssl server)" \
2015 "$O_SRV -dtls1 -mtu 256" \
2016 "$P_CLI dtls=1 debug_level=2" \
2017 0 \
2018 -c "found fragmented DTLS handshake message" \
2019 -C "error"
2020
Manuel Pégourié-Gonnard77b0b8d2014-08-31 20:19:40 +02002021not_with_valgrind
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002022run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2023 "$O_SRV -dtls1 -mtu 256" \
2024 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2025 0 \
2026 -c "found fragmented DTLS handshake message" \
2027 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002028
2029# TODO: fragmentation with renegotiation, openssl + gnutls
2030
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002031# Final report
2032
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002033echo "------------------------------------------------------------------------"
2034
2035if [ $FAILS = 0 ]; then
2036 echo -n "PASSED"
2037else
2038 echo -n "FAILED"
2039fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002040PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002041echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002042
2043exit $FAILS