blob: b82f18ef59b1894f9dc7afb4ca64d603516cd5f8 [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#
9# Assumes all options are compiled in.
10
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}
Gilles Peskinea1cf6c82017-05-17 14:50:38 +020019: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010020
Manuel Pégourié-Gonnard6461f362015-06-29 16:20:13 +020021O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010022O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020023G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010024G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskinea1cf6c82017-05-17 14:50:38 +020025TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010026
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010027TESTS=0
28FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020029SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010030
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020031CONFIG_H='../include/polarssl/config.h'
32
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010033MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010034FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020035EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010036
37print_usage() {
38 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010039 printf " -h|--help\tPrint this help.\n"
40 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
41 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
42 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010043}
44
45get_options() {
46 while [ $# -gt 0 ]; do
47 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010048 -f|--filter)
49 shift; FILTER=$1
50 ;;
51 -e|--exclude)
52 shift; EXCLUDE=$1
53 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010054 -m|--memcheck)
55 MEMCHECK=1
56 ;;
57 -h|--help)
58 print_usage
59 exit 0
60 ;;
61 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020062 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010063 print_usage
64 exit 1
65 ;;
66 esac
67 shift
68 done
69}
70
Janos Follath4dfecab2016-03-14 13:40:43 +000071# skip next test if the flag is not enabled in config.h
72requires_config_enabled() {
73 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
74 SKIP_NEXT="YES"
75 fi
76}
77
Hanno Beckere8f3d932017-10-25 09:38:00 +010078# skip next test if the flag is enabled in config.h
79requires_config_disabled() {
80 if grep "^#define $1" $CONFIG_H > /dev/null; then
81 SKIP_NEXT="YES"
82 fi
83}
84
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020085# skip next test if OpenSSL can't send SSLv2 ClientHello
86requires_openssl_with_sslv2() {
87 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020088 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020089 OPENSSL_HAS_SSL2="YES"
90 else
91 OPENSSL_HAS_SSL2="NO"
92 fi
93 fi
94 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
95 SKIP_NEXT="YES"
96 fi
97}
98
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020099# skip next test if OpenSSL doesn't support FALLBACK_SCSV
100requires_openssl_with_fallback_scsv() {
101 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
102 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
103 then
104 OPENSSL_HAS_FBSCSV="YES"
105 else
106 OPENSSL_HAS_FBSCSV="NO"
107 fi
108 fi
109 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
110 SKIP_NEXT="YES"
111 fi
112}
113
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200114# skip next test if GnuTLS isn't available
115requires_gnutls() {
116 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
117 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
118 GNUTLS_AVAILABLE="YES"
119 else
120 GNUTLS_AVAILABLE="NO"
121 fi
122 fi
123 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
124 SKIP_NEXT="YES"
125 fi
126}
127
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100128# print_name <name>
129print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100130 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200131 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100132 for i in `seq 1 $LEN`; do printf '.'; done
133 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100134
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200135 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100136}
137
138# fail <message>
139fail() {
140 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100141 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100142
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200143 mv $SRV_OUT o-srv-${TESTS}.log
144 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100145 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100146
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200147 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
148 echo " ! server output:"
149 cat o-srv-${TESTS}.log
150 echo " ! ============================================================"
151 echo " ! client output:"
152 cat o-cli-${TESTS}.log
153 fi
154
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200155 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100156}
157
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100158# is_polar <cmd_line>
159is_polar() {
160 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
161}
162
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100163# has_mem_err <log_file_name>
164has_mem_err() {
165 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
166 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
167 then
168 return 1 # false: does not have errors
169 else
170 return 0 # true: has errors
171 fi
172}
173
Gilles Peskine80f6be72017-12-19 13:35:10 +0100174# Wait for process $2 to be listening on port $1
175if type lsof >/dev/null 2>/dev/null; then
176 wait_server_start() {
177 START_TIME=$(date +%s)
178 while ! lsof -a -n -b -i "TCP:$1" -p "$2" >/dev/null 2>/dev/null; do
179 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
180 echo "SERVERSTART TIMEOUT"
181 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
182 break
183 fi
184 # Linux and *BSD support decimal arguments to sleep. On other
185 # OSes this may be a tight loop.
186 sleep 0.1 2>/dev/null || true
Manuel Pégourié-Gonnard84690c32015-08-04 20:34:39 +0200187 done
Gilles Peskine80f6be72017-12-19 13:35:10 +0100188 }
189else
190 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200191 sleep "$START_DELAY"
Gilles Peskine80f6be72017-12-19 13:35:10 +0100192 }
193fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200194
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200195# wait for client to terminate and set CLI_EXIT
196# must be called right after starting the client
197wait_client_done() {
198 CLI_PID=$!
199
200 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
201 WATCHDOG_PID=$!
202
203 wait $CLI_PID
204 CLI_EXIT=$?
205
206 kill $WATCHDOG_PID
207 wait $WATCHDOG_PID
208
209 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
210}
211
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100212# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100213# Options: -s pattern pattern that must be present in server output
214# -c pattern pattern that must be present in client output
Simon Butcher696f92e2016-10-13 14:13:17 +0100215# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100216# -S pattern pattern that must be absent in server output
217# -C pattern pattern that must be absent in client output
Simon Butcher696f92e2016-10-13 14:13:17 +0100218# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100219run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100220 NAME="$1"
221 SRV_CMD="$2"
222 CLI_CMD="$3"
223 CLI_EXPECT="$4"
224 shift 4
225
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100226 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
227 else
Manuel Pégourié-Gonnard33e8d342017-07-10 11:55:31 +0200228 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100229 return
230 fi
231
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100232 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100233
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200234 # should we skip?
235 if [ "X$SKIP_NEXT" = "XYES" ]; then
236 SKIP_NEXT="NO"
237 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200238 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200239 return
240 fi
241
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100242 # prepend valgrind to our commands if active
243 if [ "$MEMCHECK" -gt 0 ]; then
244 if is_polar "$SRV_CMD"; then
245 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
246 fi
247 if is_polar "$CLI_CMD"; then
248 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
249 fi
250 fi
251
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100252 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200253 echo "$SRV_CMD" > $SRV_OUT
254 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100255 SRV_PID=$!
Gilles Peskine80f6be72017-12-19 13:35:10 +0100256 wait_server_start "$PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200257
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200258 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200259 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
260 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100261
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200262 # kill the server
263 kill $SRV_PID
264 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100265
266 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200267 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100268 # expected client exit to incorrectly succeed in case of catastrophic
269 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100270 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200271 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100272 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100273 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100274 return
275 fi
276 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100277 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200278 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100279 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100280 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100281 return
282 fi
283 fi
284
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100285 # check server exit code
286 if [ $? != 0 ]; then
287 fail "server fail"
288 return
289 fi
290
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100291 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100292 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
293 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100294 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100295 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100296 return
297 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100298
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100299 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200300 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100301 while [ $# -gt 0 ]
302 do
303 case $1 in
304 "-s")
Simon Butcher696f92e2016-10-13 14:13:17 +0100305 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
306 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100307 return
308 fi
309 ;;
310
311 "-c")
Simon Butcher696f92e2016-10-13 14:13:17 +0100312 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
313 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100314 return
315 fi
316 ;;
317
318 "-S")
Simon Butcher696f92e2016-10-13 14:13:17 +0100319 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
320 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100321 return
322 fi
323 ;;
324
325 "-C")
Simon Butcher696f92e2016-10-13 14:13:17 +0100326 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
327 fail "pattern '$2' MUST NOT be present in the Client output"
328 return
329 fi
330 ;;
331
332 # The filtering in the following two options (-u and -U) do the following
333 # - ignore valgrind output
334 # - filter out everything but lines right after the pattern occurances
335 # - keep one of each non-unique line
336 # - count how many lines remain
337 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
338 # if there were no duplicates.
339 "-U")
340 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
341 fail "lines following pattern '$2' must be unique in Server output"
342 return
343 fi
344 ;;
345
346 "-u")
347 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
348 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100349 return
350 fi
351 ;;
352
353 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200354 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100355 exit 1
356 esac
357 shift 2
358 done
359
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100360 # check valgrind's results
361 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200362 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100363 fail "Server has memory errors"
364 return
365 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200366 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100367 fail "Client has memory errors"
368 return
369 fi
370 fi
371
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100372 # if we're here, everything is ok
373 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200374 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100375}
376
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100377cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200378 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200379 kill $SRV_PID >/dev/null 2>&1
380 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100381 exit 1
382}
383
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100384#
385# MAIN
386#
387
Manuel Pégourié-Gonnard751286b2015-03-10 13:41:04 +0000388if cd $( dirname $0 ); then :; else
389 echo "cd $( dirname $0 ) failed" >&2
390 exit 1
391fi
392
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100393get_options "$@"
394
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100395# sanity checks, avoid an avalanche of errors
396if [ ! -x "$P_SRV" ]; then
397 echo "Command '$P_SRV' is not an executable file"
398 exit 1
399fi
400if [ ! -x "$P_CLI" ]; then
401 echo "Command '$P_CLI' is not an executable file"
402 exit 1
403fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100404if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
405 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100406 exit 1
407fi
408
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200409# used by watchdog
410MAIN_PID="$$"
411
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200412# be more patient with valgrind
413if [ "$MEMCHECK" -gt 0 ]; then
414 START_DELAY=3
415 DOG_DELAY=30
416else
417 START_DELAY=1
418 DOG_DELAY=10
419fi
420
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200421# Pick a "unique" port in the range 10000-19999.
422PORT="0000$$"
Manuel Pégourié-Gonnarddc370e42015-01-22 10:24:59 +0000423PORT="1$( printf $PORT | tail -c 4 )"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200424
425# fix commands to use this port
426P_SRV="$P_SRV server_port=$PORT"
427P_CLI="$P_CLI server_port=$PORT"
428O_SRV="$O_SRV -accept $PORT"
429O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200430G_SRV="$G_SRV -p $PORT"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100431G_CLI="$G_CLI -p $PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200432
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200433# Also pick a unique name for intermediate files
434SRV_OUT="srv_out.$$"
435CLI_OUT="cli_out.$$"
436SESSION="session.$$"
437
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200438SKIP_NEXT="NO"
439
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100440trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100441
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200442# Basic test
443
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200444# Checks that:
445# - things work with all ciphersuites active (used with config-full in all.sh)
446# - the expected (highest security) parameters are selected
447# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200448run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200449 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200450 "$P_CLI" \
451 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200452 -s "Protocol is TLSv1.2" \
453 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
454 -s "client hello v3, signature_algorithm ext: 6" \
455 -s "ECDHE curve: secp521r1" \
456 -S "error" \
457 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200458
Simon Butcher696f92e2016-10-13 14:13:17 +0100459# Test for uniqueness of IVs in AEAD ciphersuites
460run_test "Unique IV in GCM" \
461 "$P_SRV exchanges=20 debug_level=4" \
462 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
463 0 \
464 -u "IV used" \
465 -U "IV used"
466
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100467# Tests for rc4 option
468
469run_test "RC4: server disabled, client enabled" \
470 "$P_SRV" \
471 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
472 1 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100473 -s "SSL - None of the common ciphersuites is usable"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100474
475run_test "RC4: server enabled, client disabled" \
476 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
477 "$P_CLI" \
478 1 \
479 -s "SSL - The server has no ciphersuites in common"
480
481run_test "RC4: both enabled" \
482 "$P_SRV arc4=1" \
483 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
484 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100485 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100486 -S "SSL - The server has no ciphersuites in common"
487
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100488# Test for SSLv2 ClientHello
489
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200490requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200491run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100492 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100493 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100494 0 \
495 -S "parse client hello v2" \
496 -S "ssl_handshake returned"
497
498# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200499requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200500run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200501 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100502 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100503 0 \
504 -s "parse client hello v2" \
505 -S "ssl_handshake returned"
506
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100507# Tests for Truncated HMAC extension
508
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100509run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200510 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100511 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100512 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100513 -s "dumping 'computed mac' (20 bytes)" \
514 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100515
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100516run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200517 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100518 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
519 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100520 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100521 -s "dumping 'computed mac' (20 bytes)" \
522 -S "dumping 'computed mac' (10 bytes)"
523
524run_test "Truncated HMAC: client enabled, server default" \
525 "$P_SRV debug_level=4" \
526 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
527 trunc_hmac=1" \
528 0 \
529 -S "dumping 'computed mac' (20 bytes)" \
530 -s "dumping 'computed mac' (10 bytes)"
531
532run_test "Truncated HMAC: client enabled, server disabled" \
533 "$P_SRV debug_level=4 trunc_hmac=0" \
534 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
535 trunc_hmac=1" \
536 0 \
537 -s "dumping 'computed mac' (20 bytes)" \
538 -S "dumping 'computed mac' (10 bytes)"
539
540run_test "Truncated HMAC: client enabled, server enabled" \
541 "$P_SRV debug_level=4 trunc_hmac=1" \
542 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
543 trunc_hmac=1" \
544 0 \
545 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100546 -s "dumping 'computed mac' (10 bytes)"
547
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100548# Tests for Encrypt-then-MAC extension
549
550run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100551 "$P_SRV debug_level=3 \
552 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100553 "$P_CLI debug_level=3" \
554 0 \
555 -c "client hello, adding encrypt_then_mac extension" \
556 -s "found encrypt then mac extension" \
557 -s "server hello, adding encrypt then mac extension" \
558 -c "found encrypt_then_mac extension" \
559 -c "using encrypt then mac" \
560 -s "using encrypt then mac"
561
562run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100563 "$P_SRV debug_level=3 etm=0 \
564 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100565 "$P_CLI debug_level=3 etm=1" \
566 0 \
567 -c "client hello, adding encrypt_then_mac extension" \
568 -s "found encrypt then mac extension" \
569 -S "server hello, adding encrypt then mac extension" \
570 -C "found encrypt_then_mac extension" \
571 -C "using encrypt then mac" \
572 -S "using encrypt then mac"
573
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100574run_test "Encrypt then MAC: client enabled, aead cipher" \
575 "$P_SRV debug_level=3 etm=1 \
576 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
577 "$P_CLI debug_level=3 etm=1" \
578 0 \
579 -c "client hello, adding encrypt_then_mac extension" \
580 -s "found encrypt then mac extension" \
581 -S "server hello, adding encrypt then mac extension" \
582 -C "found encrypt_then_mac extension" \
583 -C "using encrypt then mac" \
584 -S "using encrypt then mac"
585
586run_test "Encrypt then MAC: client enabled, stream cipher" \
587 "$P_SRV debug_level=3 etm=1 \
588 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100589 "$P_CLI debug_level=3 etm=1 arc4=1" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100590 0 \
591 -c "client hello, adding encrypt_then_mac extension" \
592 -s "found encrypt then mac extension" \
593 -S "server hello, adding encrypt then mac extension" \
594 -C "found encrypt_then_mac extension" \
595 -C "using encrypt then mac" \
596 -S "using encrypt then mac"
597
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100598run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100599 "$P_SRV debug_level=3 etm=1 \
600 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100601 "$P_CLI debug_level=3 etm=0" \
602 0 \
603 -C "client hello, adding encrypt_then_mac extension" \
604 -S "found encrypt then mac extension" \
605 -S "server hello, adding encrypt then mac extension" \
606 -C "found encrypt_then_mac extension" \
607 -C "using encrypt then mac" \
608 -S "using encrypt then mac"
609
Janos Follath4dfecab2016-03-14 13:40:43 +0000610requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100611run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100612 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100613 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100614 "$P_CLI debug_level=3 force_version=ssl3" \
615 0 \
616 -C "client hello, adding encrypt_then_mac extension" \
617 -S "found encrypt then mac extension" \
618 -S "server hello, adding encrypt then mac extension" \
619 -C "found encrypt_then_mac extension" \
620 -C "using encrypt then mac" \
621 -S "using encrypt then mac"
622
Janos Follath4dfecab2016-03-14 13:40:43 +0000623requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100624run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100625 "$P_SRV debug_level=3 force_version=ssl3 \
626 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100627 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100628 0 \
629 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath8abaa8b2016-05-06 13:48:23 +0100630 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100631 -S "server hello, adding encrypt then mac extension" \
632 -C "found encrypt_then_mac extension" \
633 -C "using encrypt then mac" \
634 -S "using encrypt then mac"
635
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200636# Tests for Extended Master Secret extension
637
638run_test "Extended Master Secret: default" \
639 "$P_SRV debug_level=3" \
640 "$P_CLI debug_level=3" \
641 0 \
642 -c "client hello, adding extended_master_secret extension" \
643 -s "found extended master secret extension" \
644 -s "server hello, adding extended master secret extension" \
645 -c "found extended_master_secret extension" \
646 -c "using extended master secret" \
647 -s "using extended master secret"
648
649run_test "Extended Master Secret: client enabled, server disabled" \
650 "$P_SRV debug_level=3 extended_ms=0" \
651 "$P_CLI debug_level=3 extended_ms=1" \
652 0 \
653 -c "client hello, adding extended_master_secret extension" \
654 -s "found extended master secret extension" \
655 -S "server hello, adding extended master secret extension" \
656 -C "found extended_master_secret extension" \
657 -C "using extended master secret" \
658 -S "using extended master secret"
659
660run_test "Extended Master Secret: client disabled, server enabled" \
661 "$P_SRV debug_level=3 extended_ms=1" \
662 "$P_CLI debug_level=3 extended_ms=0" \
663 0 \
664 -C "client hello, adding extended_master_secret extension" \
665 -S "found extended master secret extension" \
666 -S "server hello, adding extended master secret extension" \
667 -C "found extended_master_secret extension" \
668 -C "using extended master secret" \
669 -S "using extended master secret"
670
Janos Follath4dfecab2016-03-14 13:40:43 +0000671requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200672run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100673 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200674 "$P_CLI debug_level=3 force_version=ssl3" \
675 0 \
676 -C "client hello, adding extended_master_secret extension" \
677 -S "found extended master secret extension" \
678 -S "server hello, adding extended master secret extension" \
679 -C "found extended_master_secret extension" \
680 -C "using extended master secret" \
681 -S "using extended master secret"
682
Janos Follath4dfecab2016-03-14 13:40:43 +0000683requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200684run_test "Extended Master Secret: client enabled, server SSLv3" \
685 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100686 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200687 0 \
688 -c "client hello, adding extended_master_secret extension" \
Janos Follath8abaa8b2016-05-06 13:48:23 +0100689 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200690 -S "server hello, adding extended master secret extension" \
691 -C "found extended_master_secret extension" \
692 -C "using extended master secret" \
693 -S "using extended master secret"
694
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200695# Tests for FALLBACK_SCSV
696
697run_test "Fallback SCSV: default" \
698 "$P_SRV" \
699 "$P_CLI debug_level=3 force_version=tls1_1" \
700 0 \
701 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200702 -S "received FALLBACK_SCSV" \
703 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200704 -C "is a fatal alert message (msg 86)"
705
706run_test "Fallback SCSV: explicitly disabled" \
707 "$P_SRV" \
708 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
709 0 \
710 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200711 -S "received FALLBACK_SCSV" \
712 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200713 -C "is a fatal alert message (msg 86)"
714
715run_test "Fallback SCSV: enabled" \
716 "$P_SRV" \
717 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200718 1 \
719 -c "adding FALLBACK_SCSV" \
720 -s "received FALLBACK_SCSV" \
721 -s "inapropriate fallback" \
722 -c "is a fatal alert message (msg 86)"
723
724run_test "Fallback SCSV: enabled, max version" \
725 "$P_SRV" \
726 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200727 0 \
728 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200729 -s "received FALLBACK_SCSV" \
730 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200731 -C "is a fatal alert message (msg 86)"
732
733requires_openssl_with_fallback_scsv
734run_test "Fallback SCSV: default, openssl server" \
735 "$O_SRV" \
736 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
737 0 \
738 -C "adding FALLBACK_SCSV" \
739 -C "is a fatal alert message (msg 86)"
740
741requires_openssl_with_fallback_scsv
742run_test "Fallback SCSV: enabled, openssl server" \
743 "$O_SRV" \
744 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
745 1 \
746 -c "adding FALLBACK_SCSV" \
747 -c "is a fatal alert message (msg 86)"
748
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200749requires_openssl_with_fallback_scsv
750run_test "Fallback SCSV: disabled, openssl client" \
751 "$P_SRV" \
752 "$O_CLI -tls1_1" \
753 0 \
754 -S "received FALLBACK_SCSV" \
755 -S "inapropriate fallback"
756
757requires_openssl_with_fallback_scsv
758run_test "Fallback SCSV: enabled, openssl client" \
759 "$P_SRV" \
760 "$O_CLI -tls1_1 -fallback_scsv" \
761 1 \
762 -s "received FALLBACK_SCSV" \
763 -s "inapropriate fallback"
764
765requires_openssl_with_fallback_scsv
766run_test "Fallback SCSV: enabled, max version, openssl client" \
767 "$P_SRV" \
768 "$O_CLI -fallback_scsv" \
769 0 \
770 -s "received FALLBACK_SCSV" \
771 -S "inapropriate fallback"
772
Gilles Peskinea1cf6c82017-05-17 14:50:38 +0200773## ClientHello generated with
774## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
775## then manually twiddling the ciphersuite list.
776## The ClientHello content is spelled out below as a hex string as
777## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
778## The expected response is an inappropriate_fallback alert.
779requires_openssl_with_fallback_scsv
780run_test "Fallback SCSV: beginning of list" \
781 "$P_SRV debug_level=2" \
782 "$TCP_CLIENT localhost $PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
783 0 \
784 -s "received FALLBACK_SCSV" \
785 -s "inapropriate fallback"
786
787requires_openssl_with_fallback_scsv
788run_test "Fallback SCSV: end of list" \
789 "$P_SRV debug_level=2" \
790 "$TCP_CLIENT localhost $PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
791 0 \
792 -s "received FALLBACK_SCSV" \
793 -s "inapropriate fallback"
794
795## Here the expected response is a valid ServerHello prefix, up to the random.
796requires_openssl_with_fallback_scsv
797run_test "Fallback SCSV: not in list" \
798 "$P_SRV debug_level=2" \
799 "$TCP_CLIENT localhost $PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
800 0 \
801 -S "received FALLBACK_SCSV" \
802 -S "inapropriate fallback"
803
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100804# Tests for CBC 1/n-1 record splitting
805
806run_test "CBC Record splitting: TLS 1.2, no splitting" \
807 "$P_SRV" \
808 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
809 request_size=123 force_version=tls1_2" \
810 0 \
811 -s "Read from client: 123 bytes read" \
812 -S "Read from client: 1 bytes read" \
813 -S "122 bytes read"
814
815run_test "CBC Record splitting: TLS 1.1, no splitting" \
816 "$P_SRV" \
817 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
818 request_size=123 force_version=tls1_1" \
819 0 \
820 -s "Read from client: 123 bytes read" \
821 -S "Read from client: 1 bytes read" \
822 -S "122 bytes read"
823
824run_test "CBC Record splitting: TLS 1.0, splitting" \
825 "$P_SRV" \
826 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
827 request_size=123 force_version=tls1" \
828 0 \
829 -S "Read from client: 123 bytes read" \
830 -s "Read from client: 1 bytes read" \
831 -s "122 bytes read"
832
Janos Follath4dfecab2016-03-14 13:40:43 +0000833requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100834run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100835 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100836 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
837 request_size=123 force_version=ssl3" \
838 0 \
839 -S "Read from client: 123 bytes read" \
840 -s "Read from client: 1 bytes read" \
841 -s "122 bytes read"
842
843run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100844 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100845 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
846 request_size=123 force_version=tls1" \
847 0 \
848 -s "Read from client: 123 bytes read" \
849 -S "Read from client: 1 bytes read" \
850 -S "122 bytes read"
851
852run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
853 "$P_SRV" \
854 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
855 request_size=123 force_version=tls1 recsplit=0" \
856 0 \
857 -s "Read from client: 123 bytes read" \
858 -S "Read from client: 1 bytes read" \
859 -S "122 bytes read"
860
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100861run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
862 "$P_SRV nbio=2" \
863 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
864 request_size=123 force_version=tls1" \
865 0 \
866 -S "Read from client: 123 bytes read" \
867 -s "Read from client: 1 bytes read" \
868 -s "122 bytes read"
869
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100870# Tests for Session Tickets
871
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200872run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200873 "$P_SRV debug_level=3 tickets=1" \
874 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100875 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100876 -c "client hello, adding session ticket extension" \
877 -s "found session ticket extension" \
878 -s "server hello, adding session ticket extension" \
879 -c "found session_ticket extension" \
880 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100881 -S "session successfully restored from cache" \
882 -s "session successfully restored from ticket" \
883 -s "a session has been resumed" \
884 -c "a session has been resumed"
885
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200886run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200887 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
888 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100889 0 \
890 -c "client hello, adding session ticket extension" \
891 -s "found session ticket extension" \
892 -s "server hello, adding session ticket extension" \
893 -c "found session_ticket extension" \
894 -c "parse new session ticket" \
895 -S "session successfully restored from cache" \
896 -s "session successfully restored from ticket" \
897 -s "a session has been resumed" \
898 -c "a session has been resumed"
899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200900run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200901 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
902 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100903 0 \
904 -c "client hello, adding session ticket extension" \
905 -s "found session ticket extension" \
906 -s "server hello, adding session ticket extension" \
907 -c "found session_ticket extension" \
908 -c "parse new session ticket" \
909 -S "session successfully restored from cache" \
910 -S "session successfully restored from ticket" \
911 -S "a session has been resumed" \
912 -C "a session has been resumed"
913
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200914run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100915 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200916 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100917 0 \
918 -c "client hello, adding session ticket extension" \
919 -c "found session_ticket extension" \
920 -c "parse new session ticket" \
921 -c "a session has been resumed"
922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200923run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200924 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200925 "( $O_CLI -sess_out $SESSION; \
926 $O_CLI -sess_in $SESSION; \
927 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100928 0 \
929 -s "found session ticket extension" \
930 -s "server hello, adding session ticket extension" \
931 -S "session successfully restored from cache" \
932 -s "session successfully restored from ticket" \
933 -s "a session has been resumed"
934
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100935# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100936
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200937run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200938 "$P_SRV debug_level=3 tickets=0" \
939 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100940 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100941 -c "client hello, adding session ticket extension" \
942 -s "found session ticket extension" \
943 -S "server hello, adding session ticket extension" \
944 -C "found session_ticket extension" \
945 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100946 -s "session successfully restored from cache" \
947 -S "session successfully restored from ticket" \
948 -s "a session has been resumed" \
949 -c "a session has been resumed"
950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200951run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200952 "$P_SRV debug_level=3 tickets=1" \
953 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100954 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100955 -C "client hello, adding session ticket extension" \
956 -S "found session ticket extension" \
957 -S "server hello, adding session ticket extension" \
958 -C "found session_ticket extension" \
959 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100960 -s "session successfully restored from cache" \
961 -S "session successfully restored from ticket" \
962 -s "a session has been resumed" \
963 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100964
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200965run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200966 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
967 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100968 0 \
969 -S "session successfully restored from cache" \
970 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100971 -S "a session has been resumed" \
972 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100973
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200974run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200975 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
976 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100977 0 \
978 -s "session successfully restored from cache" \
979 -S "session successfully restored from ticket" \
980 -s "a session has been resumed" \
981 -c "a session has been resumed"
982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200983run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200984 "$P_SRV debug_level=3 tickets=0" \
985 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100986 0 \
987 -s "session successfully restored from cache" \
988 -S "session successfully restored from ticket" \
989 -s "a session has been resumed" \
990 -c "a session has been resumed"
991
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200992run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200993 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
994 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100995 0 \
996 -S "session successfully restored from cache" \
997 -S "session successfully restored from ticket" \
998 -S "a session has been resumed" \
999 -C "a session has been resumed"
1000
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001001run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001002 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1003 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001004 0 \
1005 -s "session successfully restored from cache" \
1006 -S "session successfully restored from ticket" \
1007 -s "a session has been resumed" \
1008 -c "a session has been resumed"
1009
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001010run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001011 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001012 "( $O_CLI -sess_out $SESSION; \
1013 $O_CLI -sess_in $SESSION; \
1014 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001015 0 \
1016 -s "found session ticket extension" \
1017 -S "server hello, adding session ticket extension" \
1018 -s "session successfully restored from cache" \
1019 -S "session successfully restored from ticket" \
1020 -s "a session has been resumed"
1021
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001022run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001023 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001024 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001025 0 \
1026 -C "found session_ticket extension" \
1027 -C "parse new session ticket" \
1028 -c "a session has been resumed"
1029
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001030# Tests for Max Fragment Length extension
1031
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001032run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001033 "$P_SRV debug_level=3" \
1034 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001035 0 \
1036 -C "client hello, adding max_fragment_length extension" \
1037 -S "found max fragment length extension" \
1038 -S "server hello, max_fragment_length extension" \
1039 -C "found max_fragment_length extension"
1040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001041run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001042 "$P_SRV debug_level=3" \
1043 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001044 0 \
1045 -c "client hello, adding max_fragment_length extension" \
1046 -s "found max fragment length extension" \
1047 -s "server hello, max_fragment_length extension" \
1048 -c "found max_fragment_length extension"
1049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001050run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001051 "$P_SRV debug_level=3 max_frag_len=4096" \
1052 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001053 0 \
1054 -C "client hello, adding max_fragment_length extension" \
1055 -S "found max fragment length extension" \
1056 -S "server hello, max_fragment_length extension" \
1057 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001059requires_gnutls
1060run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001061 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001062 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001063 0 \
1064 -c "client hello, adding max_fragment_length extension" \
1065 -c "found max_fragment_length extension"
1066
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001067# Tests for renegotiation
1068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001069run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001070 "$P_SRV debug_level=3 exchanges=2" \
1071 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001072 0 \
1073 -C "client hello, adding renegotiation extension" \
1074 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1075 -S "found renegotiation extension" \
1076 -s "server hello, secure renegotiation extension" \
1077 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001078 -C "=> renegotiate" \
1079 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001080 -S "write hello request"
1081
Hanno Beckere8f3d932017-10-25 09:38:00 +01001082requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001083run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001084 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
1085 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001086 0 \
1087 -c "client hello, adding renegotiation extension" \
1088 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1089 -s "found renegotiation extension" \
1090 -s "server hello, secure renegotiation extension" \
1091 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001092 -c "=> renegotiate" \
1093 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001094 -S "write hello request"
1095
Hanno Beckere8f3d932017-10-25 09:38:00 +01001096requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001097run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001098 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1099 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001100 0 \
1101 -c "client hello, adding renegotiation extension" \
1102 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1103 -s "found renegotiation extension" \
1104 -s "server hello, secure renegotiation extension" \
1105 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001106 -c "=> renegotiate" \
1107 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001108 -s "write hello request"
1109
Janos Follathea111c52017-10-05 12:29:42 +01001110# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1111# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1112# algorithm stronger than SHA-1 is enabled in config.h
Hanno Beckere8f3d932017-10-25 09:38:00 +01001113requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Janos Follathea111c52017-10-05 12:29:42 +01001114run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1115 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1116 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1117 0 \
1118 -c "client hello, adding renegotiation extension" \
1119 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1120 -s "found renegotiation extension" \
1121 -s "server hello, secure renegotiation extension" \
1122 -c "found renegotiation extension" \
1123 -c "=> renegotiate" \
1124 -s "=> renegotiate" \
1125 -S "write hello request" \
1126 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1127
1128# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1129# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1130# algorithm stronger than SHA-1 is enabled in config.h
Hanno Beckere8f3d932017-10-25 09:38:00 +01001131requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Janos Follathea111c52017-10-05 12:29:42 +01001132run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1133 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1134 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1135 0 \
1136 -c "client hello, adding renegotiation extension" \
1137 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1138 -s "found renegotiation extension" \
1139 -s "server hello, secure renegotiation extension" \
1140 -c "found renegotiation extension" \
1141 -c "=> renegotiate" \
1142 -s "=> renegotiate" \
1143 -s "write hello request" \
1144 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1145
Hanno Beckere8f3d932017-10-25 09:38:00 +01001146requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001147run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001148 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1149 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001150 0 \
1151 -c "client hello, adding renegotiation extension" \
1152 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1153 -s "found renegotiation extension" \
1154 -s "server hello, secure renegotiation extension" \
1155 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001156 -c "=> renegotiate" \
1157 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001158 -s "write hello request"
1159
Hanno Beckere8f3d932017-10-25 09:38:00 +01001160requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001161run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001162 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1163 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001164 1 \
1165 -c "client hello, adding renegotiation extension" \
1166 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1167 -S "found renegotiation extension" \
1168 -s "server hello, secure renegotiation extension" \
1169 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001170 -c "=> renegotiate" \
1171 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001172 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001173 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001174 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001175
Hanno Beckere8f3d932017-10-25 09:38:00 +01001176requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001177run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001178 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1179 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001180 0 \
1181 -C "client hello, adding renegotiation extension" \
1182 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1183 -S "found renegotiation extension" \
1184 -s "server hello, secure renegotiation extension" \
1185 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001186 -C "=> renegotiate" \
1187 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001188 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001189 -S "SSL - An unexpected message was received from our peer" \
1190 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001191
Hanno Beckere8f3d932017-10-25 09:38:00 +01001192requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001193run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001194 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001195 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001196 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001197 0 \
1198 -C "client hello, adding renegotiation extension" \
1199 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1200 -S "found renegotiation extension" \
1201 -s "server hello, secure renegotiation extension" \
1202 -c "found renegotiation extension" \
1203 -C "=> renegotiate" \
1204 -S "=> renegotiate" \
1205 -s "write hello request" \
1206 -S "SSL - An unexpected message was received from our peer" \
1207 -S "failed"
1208
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001209# delay 2 for 1 alert record + 1 application data record
Hanno Beckere8f3d932017-10-25 09:38:00 +01001210requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001211run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001212 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001213 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001214 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001215 0 \
1216 -C "client hello, adding renegotiation extension" \
1217 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1218 -S "found renegotiation extension" \
1219 -s "server hello, secure renegotiation extension" \
1220 -c "found renegotiation extension" \
1221 -C "=> renegotiate" \
1222 -S "=> renegotiate" \
1223 -s "write hello request" \
1224 -S "SSL - An unexpected message was received from our peer" \
1225 -S "failed"
1226
Hanno Beckere8f3d932017-10-25 09:38:00 +01001227requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001228run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001229 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001230 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001231 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001232 0 \
1233 -C "client hello, adding renegotiation extension" \
1234 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1235 -S "found renegotiation extension" \
1236 -s "server hello, secure renegotiation extension" \
1237 -c "found renegotiation extension" \
1238 -C "=> renegotiate" \
1239 -S "=> renegotiate" \
1240 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001241 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001242
Hanno Beckere8f3d932017-10-25 09:38:00 +01001243requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001244run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001245 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001246 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001247 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001248 0 \
1249 -c "client hello, adding renegotiation extension" \
1250 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1251 -s "found renegotiation extension" \
1252 -s "server hello, secure renegotiation extension" \
1253 -c "found renegotiation extension" \
1254 -c "=> renegotiate" \
1255 -s "=> renegotiate" \
1256 -s "write hello request" \
1257 -S "SSL - An unexpected message was received from our peer" \
1258 -S "failed"
1259
Hanno Beckere8f3d932017-10-25 09:38:00 +01001260requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001261run_test "Renegotiation: periodic, just below period" \
1262 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1263 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1264 0 \
1265 -C "client hello, adding renegotiation extension" \
1266 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1267 -S "found renegotiation extension" \
1268 -s "server hello, secure renegotiation extension" \
1269 -c "found renegotiation extension" \
1270 -S "record counter limit reached: renegotiate" \
1271 -C "=> renegotiate" \
1272 -S "=> renegotiate" \
1273 -S "write hello request" \
1274 -S "SSL - An unexpected message was received from our peer" \
1275 -S "failed"
1276
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001277# one extra exchange to be able to complete renego
Hanno Beckere8f3d932017-10-25 09:38:00 +01001278requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001279run_test "Renegotiation: periodic, just above period" \
1280 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001281 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001282 0 \
1283 -c "client hello, adding renegotiation extension" \
1284 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1285 -s "found renegotiation extension" \
1286 -s "server hello, secure renegotiation extension" \
1287 -c "found renegotiation extension" \
1288 -s "record counter limit reached: renegotiate" \
1289 -c "=> renegotiate" \
1290 -s "=> renegotiate" \
1291 -s "write hello request" \
1292 -S "SSL - An unexpected message was received from our peer" \
1293 -S "failed"
1294
Hanno Beckere8f3d932017-10-25 09:38:00 +01001295requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001296run_test "Renegotiation: periodic, two times period" \
1297 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001298 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001299 0 \
1300 -c "client hello, adding renegotiation extension" \
1301 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1302 -s "found renegotiation extension" \
1303 -s "server hello, secure renegotiation extension" \
1304 -c "found renegotiation extension" \
1305 -s "record counter limit reached: renegotiate" \
1306 -c "=> renegotiate" \
1307 -s "=> renegotiate" \
1308 -s "write hello request" \
1309 -S "SSL - An unexpected message was received from our peer" \
1310 -S "failed"
1311
Hanno Beckere8f3d932017-10-25 09:38:00 +01001312requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001313run_test "Renegotiation: periodic, above period, disabled" \
1314 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1315 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1316 0 \
1317 -C "client hello, adding renegotiation extension" \
1318 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1319 -S "found renegotiation extension" \
1320 -s "server hello, secure renegotiation extension" \
1321 -c "found renegotiation extension" \
1322 -S "record counter limit reached: renegotiate" \
1323 -C "=> renegotiate" \
1324 -S "=> renegotiate" \
1325 -S "write hello request" \
1326 -S "SSL - An unexpected message was received from our peer" \
1327 -S "failed"
1328
Hanno Beckere8f3d932017-10-25 09:38:00 +01001329requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001330run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001331 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1332 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001333 0 \
1334 -c "client hello, adding renegotiation extension" \
1335 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1336 -s "found renegotiation extension" \
1337 -s "server hello, secure renegotiation extension" \
1338 -c "found renegotiation extension" \
1339 -c "=> renegotiate" \
1340 -s "=> renegotiate" \
1341 -S "write hello request"
1342
Hanno Beckere8f3d932017-10-25 09:38:00 +01001343requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001344run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001345 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1346 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001347 0 \
1348 -c "client hello, adding renegotiation extension" \
1349 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1350 -s "found renegotiation extension" \
1351 -s "server hello, secure renegotiation extension" \
1352 -c "found renegotiation extension" \
1353 -c "=> renegotiate" \
1354 -s "=> renegotiate" \
1355 -s "write hello request"
1356
Hanno Beckere8f3d932017-10-25 09:38:00 +01001357requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001358run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001359 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001360 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001361 0 \
1362 -c "client hello, adding renegotiation extension" \
1363 -c "found renegotiation extension" \
1364 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001365 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001366 -C "error" \
1367 -c "HTTP/1.0 200 [Oo][Kk]"
1368
Paul Bakker539d9722015-02-08 16:18:35 +01001369requires_gnutls
Hanno Beckere8f3d932017-10-25 09:38:00 +01001370requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001371run_test "Renegotiation: gnutls server strict, client-initiated" \
1372 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001373 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001374 0 \
1375 -c "client hello, adding renegotiation extension" \
1376 -c "found renegotiation extension" \
1377 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001378 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001379 -C "error" \
1380 -c "HTTP/1.0 200 [Oo][Kk]"
1381
Paul Bakker539d9722015-02-08 16:18:35 +01001382requires_gnutls
Hanno Beckere8f3d932017-10-25 09:38:00 +01001383requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001384run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1385 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1386 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1387 1 \
1388 -c "client hello, adding renegotiation extension" \
1389 -C "found renegotiation extension" \
1390 -c "=> renegotiate" \
1391 -c "ssl_handshake() returned" \
1392 -c "error" \
1393 -C "HTTP/1.0 200 [Oo][Kk]"
1394
Paul Bakker539d9722015-02-08 16:18:35 +01001395requires_gnutls
Hanno Beckere8f3d932017-10-25 09:38:00 +01001396requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001397run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1398 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1399 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1400 allow_legacy=0" \
1401 1 \
1402 -c "client hello, adding renegotiation extension" \
1403 -C "found renegotiation extension" \
1404 -c "=> renegotiate" \
1405 -c "ssl_handshake() returned" \
1406 -c "error" \
1407 -C "HTTP/1.0 200 [Oo][Kk]"
1408
Paul Bakker539d9722015-02-08 16:18:35 +01001409requires_gnutls
Hanno Beckere8f3d932017-10-25 09:38:00 +01001410requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001411run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1412 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1413 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1414 allow_legacy=1" \
1415 0 \
1416 -c "client hello, adding renegotiation extension" \
1417 -C "found renegotiation extension" \
1418 -c "=> renegotiate" \
1419 -C "ssl_hanshake() returned" \
1420 -C "error" \
1421 -c "HTTP/1.0 200 [Oo][Kk]"
1422
1423# Test for the "secure renegotation" extension only (no actual renegotiation)
1424
Paul Bakker539d9722015-02-08 16:18:35 +01001425requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001426run_test "Renego ext: gnutls server strict, client default" \
1427 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1428 "$P_CLI debug_level=3" \
1429 0 \
1430 -c "found renegotiation extension" \
1431 -C "error" \
1432 -c "HTTP/1.0 200 [Oo][Kk]"
1433
Paul Bakker539d9722015-02-08 16:18:35 +01001434requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001435run_test "Renego ext: gnutls server unsafe, client default" \
1436 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1437 "$P_CLI debug_level=3" \
1438 0 \
1439 -C "found renegotiation extension" \
1440 -C "error" \
1441 -c "HTTP/1.0 200 [Oo][Kk]"
1442
Paul Bakker539d9722015-02-08 16:18:35 +01001443requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001444run_test "Renego ext: gnutls server unsafe, client break legacy" \
1445 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1446 "$P_CLI debug_level=3 allow_legacy=-1" \
1447 1 \
1448 -C "found renegotiation extension" \
1449 -c "error" \
1450 -C "HTTP/1.0 200 [Oo][Kk]"
1451
Paul Bakker539d9722015-02-08 16:18:35 +01001452requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001453run_test "Renego ext: gnutls client strict, server default" \
1454 "$P_SRV debug_level=3" \
1455 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1456 0 \
1457 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1458 -s "server hello, secure renegotiation extension"
1459
Paul Bakker539d9722015-02-08 16:18:35 +01001460requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001461run_test "Renego ext: gnutls client unsafe, server default" \
1462 "$P_SRV debug_level=3" \
1463 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1464 0 \
1465 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1466 -S "server hello, secure renegotiation extension"
1467
Paul Bakker539d9722015-02-08 16:18:35 +01001468requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001469run_test "Renego ext: gnutls client unsafe, server break legacy" \
1470 "$P_SRV debug_level=3 allow_legacy=-1" \
1471 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1472 1 \
1473 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1474 -S "server hello, secure renegotiation extension"
1475
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001476# Tests for auth_mode
1477
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001478run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001479 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001480 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001481 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001482 1 \
1483 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001484 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001485 -c "! ssl_handshake returned" \
1486 -c "X509 - Certificate verification failed"
1487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001488run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001489 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001490 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001491 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001492 0 \
1493 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001494 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001495 -C "! ssl_handshake returned" \
1496 -C "X509 - Certificate verification failed"
1497
Hanno Becker6fd6d242017-05-25 17:51:31 +01001498run_test "Authentication: server goodcert, client optional, no trusted CA" \
1499 "$P_SRV" \
1500 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1501 0 \
1502 -c "x509_verify_cert() returned" \
1503 -c "! The certificate is not correctly signed by the trusted CA" \
1504 -c "! Certificate verification flags"\
1505 -C "! ssl_handshake returned" \
1506 -C "X509 - Certificate verification failed" \
1507 -C "SSL - No CA Chain is set, but required to operate"
1508
1509run_test "Authentication: server goodcert, client required, no trusted CA" \
1510 "$P_SRV" \
1511 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1512 1 \
1513 -c "x509_verify_cert() returned" \
1514 -c "! The certificate is not correctly signed by the trusted CA" \
1515 -c "! Certificate verification flags"\
1516 -c "! ssl_handshake returned" \
1517 -c "SSL - No CA Chain is set, but required to operate"
1518
1519# The purpose of the next two tests is to test the client's behaviour when receiving a server
1520# certificate with an unsupported elliptic curve. This should usually not happen because
1521# the client informs the server about the supported curves - it does, though, in the
1522# corner case of a static ECDH suite, because the server doesn't check the curve on that
1523# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1524# different means to have the server ignoring the client's supported curve list.
1525
1526requires_config_enabled POLARSSL_SSL_SET_CURVES
1527run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1528 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1529 crt_file=data_files/server5.ku-ka.crt" \
1530 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1531 1 \
1532 -c "bad certificate (EC key curve)"\
1533 -c "! Certificate verification flags"\
1534 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1535
1536requires_config_enabled POLARSSL_SSL_SET_CURVES
1537run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1538 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1539 crt_file=data_files/server5.ku-ka.crt" \
1540 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1541 1 \
1542 -c "bad certificate (EC key curve)"\
1543 -c "! Certificate verification flags"\
1544 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001546run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001547 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001548 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001549 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001550 0 \
1551 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001552 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001553 -C "! ssl_handshake returned" \
1554 -C "X509 - Certificate verification failed"
1555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001556run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001557 "$P_SRV debug_level=3 auth_mode=required" \
1558 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001559 key_file=data_files/server5.key" \
1560 1 \
1561 -S "skip write certificate request" \
1562 -C "skip parse certificate request" \
1563 -c "got a certificate request" \
1564 -C "skip write certificate" \
1565 -C "skip write certificate verify" \
1566 -S "skip parse certificate verify" \
1567 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001568 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001569 -s "! ssl_handshake returned" \
1570 -c "! ssl_handshake returned" \
1571 -s "X509 - Certificate verification failed"
1572
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001573run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001574 "$P_SRV debug_level=3 auth_mode=optional" \
1575 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001576 key_file=data_files/server5.key" \
1577 0 \
1578 -S "skip write certificate request" \
1579 -C "skip parse certificate request" \
1580 -c "got a certificate request" \
1581 -C "skip write certificate" \
1582 -C "skip write certificate verify" \
1583 -S "skip parse certificate verify" \
1584 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001585 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001586 -S "! ssl_handshake returned" \
1587 -C "! ssl_handshake returned" \
1588 -S "X509 - Certificate verification failed"
1589
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001590run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001591 "$P_SRV debug_level=3 auth_mode=none" \
1592 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001593 key_file=data_files/server5.key" \
1594 0 \
1595 -s "skip write certificate request" \
1596 -C "skip parse certificate request" \
1597 -c "got no certificate request" \
1598 -c "skip write certificate" \
1599 -c "skip write certificate verify" \
1600 -s "skip parse certificate verify" \
1601 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001602 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001603 -S "! ssl_handshake returned" \
1604 -C "! ssl_handshake returned" \
1605 -S "X509 - Certificate verification failed"
1606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001607run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001608 "$P_SRV debug_level=3 auth_mode=optional" \
1609 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001610 0 \
1611 -S "skip write certificate request" \
1612 -C "skip parse certificate request" \
1613 -c "got a certificate request" \
1614 -C "skip write certificate$" \
1615 -C "got no certificate to send" \
1616 -S "SSLv3 client has no certificate" \
1617 -c "skip write certificate verify" \
1618 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001619 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001620 -S "! ssl_handshake returned" \
1621 -C "! ssl_handshake returned" \
1622 -S "X509 - Certificate verification failed"
1623
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001624run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001625 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001626 "$O_CLI" \
1627 0 \
1628 -S "skip write certificate request" \
1629 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001630 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001631 -S "! ssl_handshake returned" \
1632 -S "X509 - Certificate verification failed"
1633
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001634run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001635 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001636 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001637 0 \
1638 -C "skip parse certificate request" \
1639 -c "got a certificate request" \
1640 -C "skip write certificate$" \
1641 -c "skip write certificate verify" \
1642 -C "! ssl_handshake returned"
1643
Janos Follath4dfecab2016-03-14 13:40:43 +00001644requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001645run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001646 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001647 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001648 0 \
1649 -S "skip write certificate request" \
1650 -C "skip parse certificate request" \
1651 -c "got a certificate request" \
1652 -C "skip write certificate$" \
1653 -c "skip write certificate verify" \
1654 -c "got no certificate to send" \
1655 -s "SSLv3 client has no certificate" \
1656 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001657 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001658 -S "! ssl_handshake returned" \
1659 -C "! ssl_handshake returned" \
1660 -S "X509 - Certificate verification failed"
1661
Manuel Pégourié-Gonnarda68d5912017-07-10 11:31:43 +02001662run_test "Authentication: server max_int chain, client default" \
1663 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
1664 key_file=data_files/dir-maxpath/09.key" \
1665 "$P_CLI server_name=CA09 server_addr=127.0.0.1 \
1666 ca_file=data_files/dir-maxpath/00.crt" \
1667 0 \
1668 -C "X509 - A fatal error occured"
1669
1670run_test "Authentication: server max_int+1 chain, client default" \
1671 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
1672 key_file=data_files/dir-maxpath/10.key" \
1673 "$P_CLI server_name=CA10 server_addr=127.0.0.1 \
1674 ca_file=data_files/dir-maxpath/00.crt" \
1675 1 \
1676 -c "X509 - A fatal error occured"
1677
1678run_test "Authentication: server max_int+1 chain, client optional" \
1679 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
1680 key_file=data_files/dir-maxpath/10.key" \
1681 "$P_CLI server_name=CA10 server_addr=127.0.0.1 \
1682 ca_file=data_files/dir-maxpath/00.crt \
1683 auth_mode=optional" \
1684 1 \
1685 -c "X509 - A fatal error occured"
1686
1687run_test "Authentication: server max_int+1 chain, client none" \
1688 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
1689 key_file=data_files/dir-maxpath/10.key" \
1690 "$P_CLI server_name=CA10 server_addr=127.0.0.1 ca_file=data_files/dir-maxpath/00.crt \
1691 auth_mode=none" \
1692 0 \
1693 -C "X509 - A fatal error occured"
1694
1695run_test "Authentication: client max_int+1 chain, server none" \
1696 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=none" \
1697 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
1698 key_file=data_files/dir-maxpath/10.key" \
1699 0 \
1700 -S "X509 - A fatal error occured"
1701
1702run_test "Authentication: client max_int+1 chain, server optional" \
1703 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
1704 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
1705 key_file=data_files/dir-maxpath/10.key" \
1706 1 \
1707 -s "X509 - A fatal error occured"
1708
1709run_test "Authentication: client max_int+1 chain, server required" \
1710 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
1711 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
1712 key_file=data_files/dir-maxpath/10.key" \
1713 1 \
1714 -s "X509 - A fatal error occured"
1715
1716run_test "Authentication: client max_int chain, server required" \
1717 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
1718 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
1719 key_file=data_files/dir-maxpath/09.key" \
1720 0 \
1721 -S "X509 - A fatal error occured"
1722
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001723# Tests for certificate selection based on SHA verson
1724
1725run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1726 "$P_SRV crt_file=data_files/server5.crt \
1727 key_file=data_files/server5.key \
1728 crt_file2=data_files/server5-sha1.crt \
1729 key_file2=data_files/server5.key" \
1730 "$P_CLI force_version=tls1_2" \
1731 0 \
1732 -c "signed using.*ECDSA with SHA256" \
1733 -C "signed using.*ECDSA with SHA1"
1734
1735run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1736 "$P_SRV crt_file=data_files/server5.crt \
1737 key_file=data_files/server5.key \
1738 crt_file2=data_files/server5-sha1.crt \
1739 key_file2=data_files/server5.key" \
1740 "$P_CLI force_version=tls1_1" \
1741 0 \
1742 -C "signed using.*ECDSA with SHA256" \
1743 -c "signed using.*ECDSA with SHA1"
1744
1745run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1746 "$P_SRV crt_file=data_files/server5.crt \
1747 key_file=data_files/server5.key \
1748 crt_file2=data_files/server5-sha1.crt \
1749 key_file2=data_files/server5.key" \
1750 "$P_CLI force_version=tls1" \
1751 0 \
1752 -C "signed using.*ECDSA with SHA256" \
1753 -c "signed using.*ECDSA with SHA1"
1754
1755run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1756 "$P_SRV crt_file=data_files/server5.crt \
1757 key_file=data_files/server5.key \
1758 crt_file2=data_files/server6.crt \
1759 key_file2=data_files/server6.key" \
1760 "$P_CLI force_version=tls1_1" \
1761 0 \
1762 -c "serial number.*09" \
1763 -c "signed using.*ECDSA with SHA256" \
1764 -C "signed using.*ECDSA with SHA1"
1765
1766run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1767 "$P_SRV crt_file=data_files/server6.crt \
1768 key_file=data_files/server6.key \
1769 crt_file2=data_files/server5.crt \
1770 key_file2=data_files/server5.key" \
1771 "$P_CLI force_version=tls1_1" \
1772 0 \
1773 -c "serial number.*0A" \
1774 -c "signed using.*ECDSA with SHA256" \
1775 -C "signed using.*ECDSA with SHA1"
1776
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001777# tests for SNI
1778
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001779run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001780 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001781 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001782 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001783 server_name=localhost" \
1784 0 \
1785 -S "parse ServerName extension" \
1786 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1787 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1788
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001789run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001790 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001791 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001792 sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001793 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001794 server_name=localhost" \
1795 0 \
1796 -s "parse ServerName extension" \
1797 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1798 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001800run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001801 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001802 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001803 sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001804 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001805 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001806 0 \
1807 -s "parse ServerName extension" \
1808 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001809 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001811run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001812 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001813 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001814 sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001815 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001816 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001817 1 \
1818 -s "parse ServerName extension" \
1819 -s "ssl_sni_wrapper() returned" \
1820 -s "ssl_handshake returned" \
1821 -c "ssl_handshake returned" \
1822 -c "SSL - A fatal alert message was received from our peer"
1823
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001824# Tests for non-blocking I/O: exercise a variety of handshake flows
1825
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001826run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001827 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1828 "$P_CLI nbio=2 tickets=0" \
1829 0 \
1830 -S "ssl_handshake returned" \
1831 -C "ssl_handshake returned" \
1832 -c "Read from server: .* bytes read"
1833
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001834run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001835 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1836 "$P_CLI nbio=2 tickets=0" \
1837 0 \
1838 -S "ssl_handshake returned" \
1839 -C "ssl_handshake returned" \
1840 -c "Read from server: .* bytes read"
1841
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001842run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001843 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1844 "$P_CLI nbio=2 tickets=1" \
1845 0 \
1846 -S "ssl_handshake returned" \
1847 -C "ssl_handshake returned" \
1848 -c "Read from server: .* bytes read"
1849
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001850run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001851 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1852 "$P_CLI nbio=2 tickets=1" \
1853 0 \
1854 -S "ssl_handshake returned" \
1855 -C "ssl_handshake returned" \
1856 -c "Read from server: .* bytes read"
1857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001858run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001859 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1860 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1861 0 \
1862 -S "ssl_handshake returned" \
1863 -C "ssl_handshake returned" \
1864 -c "Read from server: .* bytes read"
1865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001866run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001867 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1868 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1869 0 \
1870 -S "ssl_handshake returned" \
1871 -C "ssl_handshake returned" \
1872 -c "Read from server: .* bytes read"
1873
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001874run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001875 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1876 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1877 0 \
1878 -S "ssl_handshake returned" \
1879 -C "ssl_handshake returned" \
1880 -c "Read from server: .* bytes read"
1881
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001882# Tests for version negotiation
1883
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001884run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001885 "$P_SRV" \
1886 "$P_CLI" \
1887 0 \
1888 -S "ssl_handshake returned" \
1889 -C "ssl_handshake returned" \
1890 -s "Protocol is TLSv1.2" \
1891 -c "Protocol is TLSv1.2"
1892
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001893run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001894 "$P_SRV" \
1895 "$P_CLI max_version=tls1_1" \
1896 0 \
1897 -S "ssl_handshake returned" \
1898 -C "ssl_handshake returned" \
1899 -s "Protocol is TLSv1.1" \
1900 -c "Protocol is TLSv1.1"
1901
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001902run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001903 "$P_SRV max_version=tls1_1" \
1904 "$P_CLI" \
1905 0 \
1906 -S "ssl_handshake returned" \
1907 -C "ssl_handshake returned" \
1908 -s "Protocol is TLSv1.1" \
1909 -c "Protocol is TLSv1.1"
1910
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001911run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001912 "$P_SRV max_version=tls1_1" \
1913 "$P_CLI max_version=tls1_1" \
1914 0 \
1915 -S "ssl_handshake returned" \
1916 -C "ssl_handshake returned" \
1917 -s "Protocol is TLSv1.1" \
1918 -c "Protocol is TLSv1.1"
1919
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001920run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001921 "$P_SRV min_version=tls1_1" \
1922 "$P_CLI max_version=tls1_1" \
1923 0 \
1924 -S "ssl_handshake returned" \
1925 -C "ssl_handshake returned" \
1926 -s "Protocol is TLSv1.1" \
1927 -c "Protocol is TLSv1.1"
1928
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001929run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001930 "$P_SRV max_version=tls1_1" \
1931 "$P_CLI min_version=tls1_1" \
1932 0 \
1933 -S "ssl_handshake returned" \
1934 -C "ssl_handshake returned" \
1935 -s "Protocol is TLSv1.1" \
1936 -c "Protocol is TLSv1.1"
1937
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001938run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001939 "$P_SRV max_version=tls1_1" \
1940 "$P_CLI min_version=tls1_2" \
1941 1 \
1942 -s "ssl_handshake returned" \
1943 -c "ssl_handshake returned" \
1944 -c "SSL - Handshake protocol not within min/max boundaries"
1945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001946run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001947 "$P_SRV min_version=tls1_2" \
1948 "$P_CLI max_version=tls1_1" \
1949 1 \
1950 -s "ssl_handshake returned" \
1951 -c "ssl_handshake returned" \
1952 -s "SSL - Handshake protocol not within min/max boundaries"
1953
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001954# Tests for ALPN extension
1955
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001956if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001958run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001959 "$P_SRV debug_level=3" \
1960 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001961 0 \
1962 -C "client hello, adding alpn extension" \
1963 -S "found alpn extension" \
1964 -C "got an alert message, type: \\[2:120]" \
1965 -S "server hello, adding alpn extension" \
1966 -C "found alpn extension " \
1967 -C "Application Layer Protocol is" \
1968 -S "Application Layer Protocol is"
1969
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001970run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001971 "$P_SRV debug_level=3" \
1972 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001973 0 \
1974 -c "client hello, adding alpn extension" \
1975 -s "found alpn extension" \
1976 -C "got an alert message, type: \\[2:120]" \
1977 -S "server hello, adding alpn extension" \
1978 -C "found alpn extension " \
1979 -c "Application Layer Protocol is (none)" \
1980 -S "Application Layer Protocol is"
1981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001982run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001983 "$P_SRV debug_level=3 alpn=abc,1234" \
1984 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001985 0 \
1986 -C "client hello, adding alpn extension" \
1987 -S "found alpn extension" \
1988 -C "got an alert message, type: \\[2:120]" \
1989 -S "server hello, adding alpn extension" \
1990 -C "found alpn extension " \
1991 -C "Application Layer Protocol is" \
1992 -s "Application Layer Protocol is (none)"
1993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001994run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001995 "$P_SRV debug_level=3 alpn=abc,1234" \
1996 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001997 0 \
1998 -c "client hello, adding alpn extension" \
1999 -s "found alpn extension" \
2000 -C "got an alert message, type: \\[2:120]" \
2001 -s "server hello, adding alpn extension" \
2002 -c "found alpn extension" \
2003 -c "Application Layer Protocol is abc" \
2004 -s "Application Layer Protocol is abc"
2005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002006run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002007 "$P_SRV debug_level=3 alpn=abc,1234" \
2008 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002009 0 \
2010 -c "client hello, adding alpn extension" \
2011 -s "found alpn extension" \
2012 -C "got an alert message, type: \\[2:120]" \
2013 -s "server hello, adding alpn extension" \
2014 -c "found alpn extension" \
2015 -c "Application Layer Protocol is abc" \
2016 -s "Application Layer Protocol is abc"
2017
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002018run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002019 "$P_SRV debug_level=3 alpn=abc,1234" \
2020 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002021 0 \
2022 -c "client hello, adding alpn extension" \
2023 -s "found alpn extension" \
2024 -C "got an alert message, type: \\[2:120]" \
2025 -s "server hello, adding alpn extension" \
2026 -c "found alpn extension" \
2027 -c "Application Layer Protocol is 1234" \
2028 -s "Application Layer Protocol is 1234"
2029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002030run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002031 "$P_SRV debug_level=3 alpn=abc,123" \
2032 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002033 1 \
2034 -c "client hello, adding alpn extension" \
2035 -s "found alpn extension" \
2036 -c "got an alert message, type: \\[2:120]" \
2037 -S "server hello, adding alpn extension" \
2038 -C "found alpn extension" \
2039 -C "Application Layer Protocol is 1234" \
2040 -S "Application Layer Protocol is 1234"
2041
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002042fi
2043
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002044# Tests for keyUsage in leaf certificates, part 1:
2045# server-side certificate/suite selection
2046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002047run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002048 "$P_SRV key_file=data_files/server2.key \
2049 crt_file=data_files/server2.ku-ds.crt" \
2050 "$P_CLI" \
2051 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002052 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002053
2054
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002055run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002056 "$P_SRV key_file=data_files/server2.key \
2057 crt_file=data_files/server2.ku-ke.crt" \
2058 "$P_CLI" \
2059 0 \
2060 -c "Ciphersuite is TLS-RSA-WITH-"
2061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002062run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002063 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002064 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002065 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002066 1 \
2067 -C "Ciphersuite is "
2068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002069run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002070 "$P_SRV key_file=data_files/server5.key \
2071 crt_file=data_files/server5.ku-ds.crt" \
2072 "$P_CLI" \
2073 0 \
2074 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2075
2076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002077run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002078 "$P_SRV key_file=data_files/server5.key \
2079 crt_file=data_files/server5.ku-ka.crt" \
2080 "$P_CLI" \
2081 0 \
2082 -c "Ciphersuite is TLS-ECDH-"
2083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002084run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002085 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002086 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002087 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002088 1 \
2089 -C "Ciphersuite is "
2090
2091# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002092# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002094run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002095 "$O_SRV -key data_files/server2.key \
2096 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002097 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002098 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2099 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002100 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002101 -C "Processing of the Certificate handshake message failed" \
2102 -c "Ciphersuite is TLS-"
2103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002104run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002105 "$O_SRV -key data_files/server2.key \
2106 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002107 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002108 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2109 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002110 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002111 -C "Processing of the Certificate handshake message failed" \
2112 -c "Ciphersuite is TLS-"
2113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002114run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002115 "$O_SRV -key data_files/server2.key \
2116 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002117 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002118 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2119 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002120 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002121 -C "Processing of the Certificate handshake message failed" \
2122 -c "Ciphersuite is TLS-"
2123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002124run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002125 "$O_SRV -key data_files/server2.key \
2126 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002127 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002128 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2129 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002130 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002131 -c "Processing of the Certificate handshake message failed" \
2132 -C "Ciphersuite is TLS-"
2133
Manuel Pégourié-Gonnarde16b62c2015-04-17 16:55:53 +02002134run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2135 "$O_SRV -key data_files/server2.key \
2136 -cert data_files/server2.ku-ke.crt" \
2137 "$P_CLI debug_level=1 auth_mode=optional \
2138 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2139 0 \
2140 -c "bad certificate (usage extensions)" \
2141 -C "Processing of the Certificate handshake message failed" \
2142 -c "Ciphersuite is TLS-" \
2143 -c "! Usage does not match the keyUsage extension"
2144
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002145run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002146 "$O_SRV -key data_files/server2.key \
2147 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002148 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002149 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2150 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002151 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002152 -C "Processing of the Certificate handshake message failed" \
2153 -c "Ciphersuite is TLS-"
2154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002155run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002156 "$O_SRV -key data_files/server2.key \
2157 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002158 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002159 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2160 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002161 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002162 -c "Processing of the Certificate handshake message failed" \
2163 -C "Ciphersuite is TLS-"
2164
Manuel Pégourié-Gonnarde16b62c2015-04-17 16:55:53 +02002165run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2166 "$O_SRV -key data_files/server2.key \
2167 -cert data_files/server2.ku-ds.crt" \
2168 "$P_CLI debug_level=1 auth_mode=optional \
2169 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2170 0 \
2171 -c "bad certificate (usage extensions)" \
2172 -C "Processing of the Certificate handshake message failed" \
2173 -c "Ciphersuite is TLS-" \
2174 -c "! Usage does not match the keyUsage extension"
2175
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002176# Tests for keyUsage in leaf certificates, part 3:
2177# server-side checking of client cert
2178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002179run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002180 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002181 "$O_CLI -key data_files/server2.key \
2182 -cert data_files/server2.ku-ds.crt" \
2183 0 \
2184 -S "bad certificate (usage extensions)" \
2185 -S "Processing of the Certificate handshake message failed"
2186
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002187run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002188 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002189 "$O_CLI -key data_files/server2.key \
2190 -cert data_files/server2.ku-ke.crt" \
2191 0 \
2192 -s "bad certificate (usage extensions)" \
2193 -S "Processing of the Certificate handshake message failed"
2194
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002195run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002196 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002197 "$O_CLI -key data_files/server2.key \
2198 -cert data_files/server2.ku-ke.crt" \
2199 1 \
2200 -s "bad certificate (usage extensions)" \
2201 -s "Processing of the Certificate handshake message failed"
2202
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002203run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002204 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002205 "$O_CLI -key data_files/server5.key \
2206 -cert data_files/server5.ku-ds.crt" \
2207 0 \
2208 -S "bad certificate (usage extensions)" \
2209 -S "Processing of the Certificate handshake message failed"
2210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002211run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002212 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002213 "$O_CLI -key data_files/server5.key \
2214 -cert data_files/server5.ku-ka.crt" \
2215 0 \
2216 -s "bad certificate (usage extensions)" \
2217 -S "Processing of the Certificate handshake message failed"
2218
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002219# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2220
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002221run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002222 "$P_SRV key_file=data_files/server5.key \
2223 crt_file=data_files/server5.eku-srv.crt" \
2224 "$P_CLI" \
2225 0
2226
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002227run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002228 "$P_SRV key_file=data_files/server5.key \
2229 crt_file=data_files/server5.eku-srv.crt" \
2230 "$P_CLI" \
2231 0
2232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002233run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002234 "$P_SRV key_file=data_files/server5.key \
2235 crt_file=data_files/server5.eku-cs_any.crt" \
2236 "$P_CLI" \
2237 0
2238
2239# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002240run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002241 "$P_SRV psk=abc123 key_file=data_files/server5.key \
2242 crt_file=data_files/server5.eku-cli.crt" \
2243 "$P_CLI psk=badbad" \
2244 1
2245
2246# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2247
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002248run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002249 "$O_SRV -key data_files/server5.key \
2250 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002251 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002252 0 \
2253 -C "bad certificate (usage extensions)" \
2254 -C "Processing of the Certificate handshake message failed" \
2255 -c "Ciphersuite is TLS-"
2256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002257run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002258 "$O_SRV -key data_files/server5.key \
2259 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002260 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002261 0 \
2262 -C "bad certificate (usage extensions)" \
2263 -C "Processing of the Certificate handshake message failed" \
2264 -c "Ciphersuite is TLS-"
2265
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002266run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002267 "$O_SRV -key data_files/server5.key \
2268 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002269 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002270 0 \
2271 -C "bad certificate (usage extensions)" \
2272 -C "Processing of the Certificate handshake message failed" \
2273 -c "Ciphersuite is TLS-"
2274
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002275run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002276 "$O_SRV -key data_files/server5.key \
2277 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002278 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002279 1 \
2280 -c "bad certificate (usage extensions)" \
2281 -c "Processing of the Certificate handshake message failed" \
2282 -C "Ciphersuite is TLS-"
2283
2284# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2285
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002286run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002287 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002288 "$O_CLI -key data_files/server5.key \
2289 -cert data_files/server5.eku-cli.crt" \
2290 0 \
2291 -S "bad certificate (usage extensions)" \
2292 -S "Processing of the Certificate handshake message failed"
2293
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002294run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002295 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002296 "$O_CLI -key data_files/server5.key \
2297 -cert data_files/server5.eku-srv_cli.crt" \
2298 0 \
2299 -S "bad certificate (usage extensions)" \
2300 -S "Processing of the Certificate handshake message failed"
2301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002302run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002303 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002304 "$O_CLI -key data_files/server5.key \
2305 -cert data_files/server5.eku-cs_any.crt" \
2306 0 \
2307 -S "bad certificate (usage extensions)" \
2308 -S "Processing of the Certificate handshake message failed"
2309
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002310run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002311 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002312 "$O_CLI -key data_files/server5.key \
2313 -cert data_files/server5.eku-cs.crt" \
2314 0 \
2315 -s "bad certificate (usage extensions)" \
2316 -S "Processing of the Certificate handshake message failed"
2317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002318run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002319 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002320 "$O_CLI -key data_files/server5.key \
2321 -cert data_files/server5.eku-cs.crt" \
2322 1 \
2323 -s "bad certificate (usage extensions)" \
2324 -s "Processing of the Certificate handshake message failed"
2325
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002326# Tests for DHM parameters loading
2327
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002328run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002329 "$P_SRV" \
2330 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2331 debug_level=3" \
2332 0 \
2333 -c "value of 'DHM: P ' (2048 bits)" \
2334 -c "value of 'DHM: G ' (2048 bits)"
2335
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002336run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002337 "$P_SRV dhm_file=data_files/dhparams.pem" \
2338 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2339 debug_level=3" \
2340 0 \
2341 -c "value of 'DHM: P ' (1024 bits)" \
2342 -c "value of 'DHM: G ' (2 bits)"
2343
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002344# Tests for PSK callback
2345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002346run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002347 "$P_SRV psk=abc123 psk_identity=foo" \
2348 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2349 psk_identity=foo psk=abc123" \
2350 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002351 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002352 -S "SSL - Unknown identity received" \
2353 -S "SSL - Verification of the message MAC failed"
2354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002355run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002356 "$P_SRV" \
2357 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2358 psk_identity=foo psk=abc123" \
2359 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002360 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002361 -S "SSL - Unknown identity received" \
2362 -S "SSL - Verification of the message MAC failed"
2363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002364run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002365 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2366 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2367 psk_identity=foo psk=abc123" \
2368 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002369 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002370 -s "SSL - Unknown identity received" \
2371 -S "SSL - Verification of the message MAC failed"
2372
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002373run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002374 "$P_SRV psk_list=abc,dead,def,beef" \
2375 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2376 psk_identity=abc psk=dead" \
2377 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002378 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002379 -S "SSL - Unknown identity received" \
2380 -S "SSL - Verification of the message MAC failed"
2381
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002382run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002383 "$P_SRV psk_list=abc,dead,def,beef" \
2384 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2385 psk_identity=def psk=beef" \
2386 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002387 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002388 -S "SSL - Unknown identity received" \
2389 -S "SSL - Verification of the message MAC failed"
2390
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002391run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002392 "$P_SRV psk_list=abc,dead,def,beef" \
2393 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2394 psk_identity=ghi psk=beef" \
2395 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002396 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002397 -s "SSL - Unknown identity received" \
2398 -S "SSL - Verification of the message MAC failed"
2399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002400run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002401 "$P_SRV psk_list=abc,dead,def,beef" \
2402 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2403 psk_identity=abc psk=beef" \
2404 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002405 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002406 -S "SSL - Unknown identity received" \
2407 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002408
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002409# Tests for ciphersuites per version
2410
Janos Follath4dfecab2016-03-14 13:40:43 +00002411requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002412run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002413 "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002414 "$P_CLI force_version=ssl3" \
2415 0 \
2416 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2417
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002418run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002419 "$P_SRV arc4=1 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
2420 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002421 0 \
2422 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002424run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002425 "$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" \
2426 "$P_CLI force_version=tls1_1" \
2427 0 \
2428 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002430run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002431 "$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" \
2432 "$P_CLI force_version=tls1_2" \
2433 0 \
2434 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2435
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002436# Tests for ssl_get_bytes_avail()
2437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002438run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002439 "$P_SRV" \
2440 "$P_CLI request_size=100" \
2441 0 \
2442 -s "Read from client: 100 bytes read$"
2443
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002444run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002445 "$P_SRV" \
2446 "$P_CLI request_size=500" \
2447 0 \
2448 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002449
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002450# Tests for small packets
2451
Janos Follath4dfecab2016-03-14 13:40:43 +00002452requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002453run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002454 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002455 "$P_CLI request_size=1 force_version=ssl3 \
2456 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2457 0 \
2458 -s "Read from client: 1 bytes read"
2459
Janos Follath4dfecab2016-03-14 13:40:43 +00002460requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002461run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002462 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002463 "$P_CLI request_size=1 force_version=ssl3 \
2464 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2465 0 \
2466 -s "Read from client: 1 bytes read"
2467
2468run_test "Small packet TLS 1.0 BlockCipher" \
2469 "$P_SRV" \
2470 "$P_CLI request_size=1 force_version=tls1 \
2471 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2472 0 \
2473 -s "Read from client: 1 bytes read"
2474
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002475run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2476 "$P_SRV" \
2477 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2478 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2479 0 \
2480 -s "Read from client: 1 bytes read"
2481
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002482run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2483 "$P_SRV" \
2484 "$P_CLI request_size=1 force_version=tls1 \
2485 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2486 trunc_hmac=1" \
2487 0 \
2488 -s "Read from client: 1 bytes read"
2489
2490run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002491 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002492 "$P_CLI request_size=1 force_version=tls1 \
2493 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2494 trunc_hmac=1" \
2495 0 \
2496 -s "Read from client: 1 bytes read"
2497
2498run_test "Small packet TLS 1.1 BlockCipher" \
2499 "$P_SRV" \
2500 "$P_CLI request_size=1 force_version=tls1_1 \
2501 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2502 0 \
2503 -s "Read from client: 1 bytes read"
2504
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002505run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2506 "$P_SRV" \
2507 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2508 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2509 0 \
2510 -s "Read from client: 1 bytes read"
2511
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002512run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002513 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002514 "$P_CLI request_size=1 force_version=tls1_1 \
2515 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2516 0 \
2517 -s "Read from client: 1 bytes read"
2518
2519run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2520 "$P_SRV" \
2521 "$P_CLI request_size=1 force_version=tls1_1 \
2522 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2523 trunc_hmac=1" \
2524 0 \
2525 -s "Read from client: 1 bytes read"
2526
2527run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002528 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002529 "$P_CLI request_size=1 force_version=tls1_1 \
2530 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2531 trunc_hmac=1" \
2532 0 \
2533 -s "Read from client: 1 bytes read"
2534
2535run_test "Small packet TLS 1.2 BlockCipher" \
2536 "$P_SRV" \
2537 "$P_CLI request_size=1 force_version=tls1_2 \
2538 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2539 0 \
2540 -s "Read from client: 1 bytes read"
2541
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002542run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2543 "$P_SRV" \
2544 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2545 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2546 0 \
2547 -s "Read from client: 1 bytes read"
2548
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002549run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2550 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002551 "$P_CLI request_size=1 force_version=tls1_2 \
2552 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002553 0 \
2554 -s "Read from client: 1 bytes read"
2555
2556run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2557 "$P_SRV" \
2558 "$P_CLI request_size=1 force_version=tls1_2 \
2559 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2560 trunc_hmac=1" \
2561 0 \
2562 -s "Read from client: 1 bytes read"
2563
2564run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002565 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002566 "$P_CLI request_size=1 force_version=tls1_2 \
2567 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2568 0 \
2569 -s "Read from client: 1 bytes read"
2570
2571run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002572 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002573 "$P_CLI request_size=1 force_version=tls1_2 \
2574 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2575 trunc_hmac=1" \
2576 0 \
2577 -s "Read from client: 1 bytes read"
2578
2579run_test "Small packet TLS 1.2 AEAD" \
2580 "$P_SRV" \
2581 "$P_CLI request_size=1 force_version=tls1_2 \
2582 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2583 0 \
2584 -s "Read from client: 1 bytes read"
2585
2586run_test "Small packet TLS 1.2 AEAD shorter tag" \
2587 "$P_SRV" \
2588 "$P_CLI request_size=1 force_version=tls1_2 \
2589 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2590 0 \
2591 -s "Read from client: 1 bytes read"
2592
Janos Follath8abaa8b2016-05-06 13:48:23 +01002593# A test for extensions in SSLv3
2594
Hanno Becker6fd6d242017-05-25 17:51:31 +01002595requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Janos Follath8abaa8b2016-05-06 13:48:23 +01002596run_test "SSLv3 with extensions, server side" \
2597 "$P_SRV min_version=ssl3 debug_level=3" \
2598 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2599 0 \
2600 -S "dumping 'client hello extensions'" \
2601 -S "server hello, total extension length:"
2602
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002603# Test for large packets
2604
Janos Follath4dfecab2016-03-14 13:40:43 +00002605requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002606run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002607 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002608 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002609 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2610 0 \
2611 -s "Read from client: 16384 bytes read"
2612
Janos Follath4dfecab2016-03-14 13:40:43 +00002613requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002614run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002615 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002616 "$P_CLI request_size=16384 force_version=ssl3 \
2617 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2618 0 \
2619 -s "Read from client: 16384 bytes read"
2620
2621run_test "Large packet TLS 1.0 BlockCipher" \
2622 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002623 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002624 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2625 0 \
2626 -s "Read from client: 16384 bytes read"
2627
2628run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2629 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002630 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002631 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2632 trunc_hmac=1" \
2633 0 \
2634 -s "Read from client: 16384 bytes read"
2635
2636run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002637 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002638 "$P_CLI request_size=16384 force_version=tls1 \
2639 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2640 trunc_hmac=1" \
2641 0 \
2642 -s "Read from client: 16384 bytes read"
2643
2644run_test "Large packet TLS 1.1 BlockCipher" \
2645 "$P_SRV" \
2646 "$P_CLI request_size=16384 force_version=tls1_1 \
2647 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2648 0 \
2649 -s "Read from client: 16384 bytes read"
2650
2651run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002652 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002653 "$P_CLI request_size=16384 force_version=tls1_1 \
2654 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2655 0 \
2656 -s "Read from client: 16384 bytes read"
2657
2658run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2659 "$P_SRV" \
2660 "$P_CLI request_size=16384 force_version=tls1_1 \
2661 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2662 trunc_hmac=1" \
2663 0 \
2664 -s "Read from client: 16384 bytes read"
2665
2666run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002667 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002668 "$P_CLI request_size=16384 force_version=tls1_1 \
2669 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2670 trunc_hmac=1" \
2671 0 \
2672 -s "Read from client: 16384 bytes read"
2673
2674run_test "Large packet TLS 1.2 BlockCipher" \
2675 "$P_SRV" \
2676 "$P_CLI request_size=16384 force_version=tls1_2 \
2677 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2678 0 \
2679 -s "Read from client: 16384 bytes read"
2680
2681run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2682 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002683 "$P_CLI request_size=16384 force_version=tls1_2 \
2684 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002685 0 \
2686 -s "Read from client: 16384 bytes read"
2687
2688run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2689 "$P_SRV" \
2690 "$P_CLI request_size=16384 force_version=tls1_2 \
2691 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2692 trunc_hmac=1" \
2693 0 \
2694 -s "Read from client: 16384 bytes read"
2695
2696run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002697 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002698 "$P_CLI request_size=16384 force_version=tls1_2 \
2699 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2700 0 \
2701 -s "Read from client: 16384 bytes read"
2702
2703run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002704 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002705 "$P_CLI request_size=16384 force_version=tls1_2 \
2706 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2707 trunc_hmac=1" \
2708 0 \
2709 -s "Read from client: 16384 bytes read"
2710
2711run_test "Large packet TLS 1.2 AEAD" \
2712 "$P_SRV" \
2713 "$P_CLI request_size=16384 force_version=tls1_2 \
2714 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2715 0 \
2716 -s "Read from client: 16384 bytes read"
2717
2718run_test "Large packet TLS 1.2 AEAD shorter tag" \
2719 "$P_SRV" \
2720 "$P_CLI request_size=16384 force_version=tls1_2 \
2721 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2722 0 \
2723 -s "Read from client: 16384 bytes read"
2724
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002725# Final report
2726
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002727echo "------------------------------------------------------------------------"
2728
2729if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002730 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002731else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002732 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002733fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002734PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002735echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002736
2737exit $FAILS