blob: 51d31fdfdc1cae3fd3c6ba3993b3aa1cd92a9d59 [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
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200174# wait for server to start: two versions depending on lsof availability
175wait_server_start() {
Manuel Pégourié-Gonnard84690c32015-08-04 20:34:39 +0200176 if which lsof >/dev/null 2>&1; then
177 START_TIME=$( date +%s )
178 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200179
180 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard84690c32015-08-04 20:34:39 +0200181 while [ $DONE -eq 0 ]; do
182 if lsof -nbi TCP:"$PORT" 2>/dev/null | grep LISTEN >/dev/null
183 then
184 DONE=1
185 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
186 echo "SERVERSTART TIMEOUT"
187 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
188 DONE=1
189 fi
190 done
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200191 else
192 sleep "$START_DELAY"
193 fi
194}
195
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200196# wait for client to terminate and set CLI_EXIT
197# must be called right after starting the client
198wait_client_done() {
199 CLI_PID=$!
200
201 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
202 WATCHDOG_PID=$!
203
204 wait $CLI_PID
205 CLI_EXIT=$?
206
207 kill $WATCHDOG_PID
208 wait $WATCHDOG_PID
209
210 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
211}
212
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100213# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100214# Options: -s pattern pattern that must be present in server output
215# -c pattern pattern that must be present in client output
Simon Butcher696f92e2016-10-13 14:13:17 +0100216# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100217# -S pattern pattern that must be absent in server output
218# -C pattern pattern that must be absent in client output
Simon Butcher696f92e2016-10-13 14:13:17 +0100219# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100220run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100221 NAME="$1"
222 SRV_CMD="$2"
223 CLI_CMD="$3"
224 CLI_EXPECT="$4"
225 shift 4
226
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100227 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
228 else
Manuel Pégourié-Gonnard33e8d342017-07-10 11:55:31 +0200229 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100230 return
231 fi
232
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100233 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100234
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200235 # should we skip?
236 if [ "X$SKIP_NEXT" = "XYES" ]; then
237 SKIP_NEXT="NO"
238 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200239 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200240 return
241 fi
242
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100243 # prepend valgrind to our commands if active
244 if [ "$MEMCHECK" -gt 0 ]; then
245 if is_polar "$SRV_CMD"; then
246 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
247 fi
248 if is_polar "$CLI_CMD"; then
249 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
250 fi
251 fi
252
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100253 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200254 echo "$SRV_CMD" > $SRV_OUT
255 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100256 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200257 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200258
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200259 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200260 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
261 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100262
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200263 # kill the server
264 kill $SRV_PID
265 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100266
267 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200268 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100269 # expected client exit to incorrectly succeed in case of catastrophic
270 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100271 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200272 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100273 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100274 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100275 return
276 fi
277 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100278 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200279 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100280 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100281 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100282 return
283 fi
284 fi
285
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100286 # check server exit code
287 if [ $? != 0 ]; then
288 fail "server fail"
289 return
290 fi
291
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100292 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100293 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
294 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100295 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100296 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100297 return
298 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100299
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100300 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200301 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100302 while [ $# -gt 0 ]
303 do
304 case $1 in
305 "-s")
Simon Butcher696f92e2016-10-13 14:13:17 +0100306 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
307 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100308 return
309 fi
310 ;;
311
312 "-c")
Simon Butcher696f92e2016-10-13 14:13:17 +0100313 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
314 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100315 return
316 fi
317 ;;
318
319 "-S")
Simon Butcher696f92e2016-10-13 14:13:17 +0100320 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
321 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100322 return
323 fi
324 ;;
325
326 "-C")
Simon Butcher696f92e2016-10-13 14:13:17 +0100327 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
328 fail "pattern '$2' MUST NOT be present in the Client output"
329 return
330 fi
331 ;;
332
333 # The filtering in the following two options (-u and -U) do the following
334 # - ignore valgrind output
335 # - filter out everything but lines right after the pattern occurances
336 # - keep one of each non-unique line
337 # - count how many lines remain
338 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
339 # if there were no duplicates.
340 "-U")
341 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
342 fail "lines following pattern '$2' must be unique in Server output"
343 return
344 fi
345 ;;
346
347 "-u")
348 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
349 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100350 return
351 fi
352 ;;
353
354 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200355 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100356 exit 1
357 esac
358 shift 2
359 done
360
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100361 # check valgrind's results
362 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200363 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100364 fail "Server has memory errors"
365 return
366 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200367 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100368 fail "Client has memory errors"
369 return
370 fi
371 fi
372
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100373 # if we're here, everything is ok
374 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200375 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100376}
377
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100378cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200379 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200380 kill $SRV_PID >/dev/null 2>&1
381 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100382 exit 1
383}
384
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100385#
386# MAIN
387#
388
Manuel Pégourié-Gonnard751286b2015-03-10 13:41:04 +0000389if cd $( dirname $0 ); then :; else
390 echo "cd $( dirname $0 ) failed" >&2
391 exit 1
392fi
393
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100394get_options "$@"
395
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100396# sanity checks, avoid an avalanche of errors
397if [ ! -x "$P_SRV" ]; then
398 echo "Command '$P_SRV' is not an executable file"
399 exit 1
400fi
401if [ ! -x "$P_CLI" ]; then
402 echo "Command '$P_CLI' is not an executable file"
403 exit 1
404fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100405if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
406 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100407 exit 1
408fi
409
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200410# used by watchdog
411MAIN_PID="$$"
412
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200413# be more patient with valgrind
414if [ "$MEMCHECK" -gt 0 ]; then
415 START_DELAY=3
416 DOG_DELAY=30
417else
418 START_DELAY=1
419 DOG_DELAY=10
420fi
421
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200422# Pick a "unique" port in the range 10000-19999.
423PORT="0000$$"
Manuel Pégourié-Gonnarddc370e42015-01-22 10:24:59 +0000424PORT="1$( printf $PORT | tail -c 4 )"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200425
426# fix commands to use this port
427P_SRV="$P_SRV server_port=$PORT"
428P_CLI="$P_CLI server_port=$PORT"
429O_SRV="$O_SRV -accept $PORT"
430O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200431G_SRV="$G_SRV -p $PORT"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100432G_CLI="$G_CLI -p $PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200433
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200434# Also pick a unique name for intermediate files
435SRV_OUT="srv_out.$$"
436CLI_OUT="cli_out.$$"
437SESSION="session.$$"
438
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200439SKIP_NEXT="NO"
440
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100441trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100442
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200443# Basic test
444
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200445# Checks that:
446# - things work with all ciphersuites active (used with config-full in all.sh)
447# - the expected (highest security) parameters are selected
448# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200449run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200450 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200451 "$P_CLI" \
452 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200453 -s "Protocol is TLSv1.2" \
454 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
455 -s "client hello v3, signature_algorithm ext: 6" \
456 -s "ECDHE curve: secp521r1" \
457 -S "error" \
458 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200459
Simon Butcher696f92e2016-10-13 14:13:17 +0100460# Test for uniqueness of IVs in AEAD ciphersuites
461run_test "Unique IV in GCM" \
462 "$P_SRV exchanges=20 debug_level=4" \
463 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
464 0 \
465 -u "IV used" \
466 -U "IV used"
467
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100468# Tests for rc4 option
469
470run_test "RC4: server disabled, client enabled" \
471 "$P_SRV" \
472 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
473 1 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100474 -s "SSL - None of the common ciphersuites is usable"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100475
476run_test "RC4: server enabled, client disabled" \
477 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
478 "$P_CLI" \
479 1 \
480 -s "SSL - The server has no ciphersuites in common"
481
482run_test "RC4: both enabled" \
483 "$P_SRV arc4=1" \
484 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
485 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100486 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100487 -S "SSL - The server has no ciphersuites in common"
488
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100489# Test for SSLv2 ClientHello
490
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200491requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200492run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100493 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100494 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100495 0 \
496 -S "parse client hello v2" \
497 -S "ssl_handshake returned"
498
499# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200500requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200501run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200502 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100503 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100504 0 \
505 -s "parse client hello v2" \
506 -S "ssl_handshake returned"
507
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100508# Tests for Truncated HMAC extension
509
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100510run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200511 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100512 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100513 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100514 -s "dumping 'computed mac' (20 bytes)" \
515 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100516
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100517run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200518 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100519 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
520 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100521 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100522 -s "dumping 'computed mac' (20 bytes)" \
523 -S "dumping 'computed mac' (10 bytes)"
524
525run_test "Truncated HMAC: client enabled, server default" \
526 "$P_SRV debug_level=4" \
527 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
528 trunc_hmac=1" \
529 0 \
530 -S "dumping 'computed mac' (20 bytes)" \
531 -s "dumping 'computed mac' (10 bytes)"
532
533run_test "Truncated HMAC: client enabled, server disabled" \
534 "$P_SRV debug_level=4 trunc_hmac=0" \
535 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
536 trunc_hmac=1" \
537 0 \
538 -s "dumping 'computed mac' (20 bytes)" \
539 -S "dumping 'computed mac' (10 bytes)"
540
541run_test "Truncated HMAC: client enabled, server enabled" \
542 "$P_SRV debug_level=4 trunc_hmac=1" \
543 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
544 trunc_hmac=1" \
545 0 \
546 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100547 -s "dumping 'computed mac' (10 bytes)"
548
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100549# Tests for Encrypt-then-MAC extension
550
551run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100552 "$P_SRV debug_level=3 \
553 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100554 "$P_CLI debug_level=3" \
555 0 \
556 -c "client hello, adding encrypt_then_mac extension" \
557 -s "found encrypt then mac extension" \
558 -s "server hello, adding encrypt then mac extension" \
559 -c "found encrypt_then_mac extension" \
560 -c "using encrypt then mac" \
561 -s "using encrypt then mac"
562
563run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100564 "$P_SRV debug_level=3 etm=0 \
565 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100566 "$P_CLI debug_level=3 etm=1" \
567 0 \
568 -c "client hello, adding encrypt_then_mac extension" \
569 -s "found encrypt then mac extension" \
570 -S "server hello, adding encrypt then mac extension" \
571 -C "found encrypt_then_mac extension" \
572 -C "using encrypt then mac" \
573 -S "using encrypt then mac"
574
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100575run_test "Encrypt then MAC: client enabled, aead cipher" \
576 "$P_SRV debug_level=3 etm=1 \
577 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
578 "$P_CLI debug_level=3 etm=1" \
579 0 \
580 -c "client hello, adding encrypt_then_mac extension" \
581 -s "found encrypt then mac extension" \
582 -S "server hello, adding encrypt then mac extension" \
583 -C "found encrypt_then_mac extension" \
584 -C "using encrypt then mac" \
585 -S "using encrypt then mac"
586
587run_test "Encrypt then MAC: client enabled, stream cipher" \
588 "$P_SRV debug_level=3 etm=1 \
589 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100590 "$P_CLI debug_level=3 etm=1 arc4=1" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100591 0 \
592 -c "client hello, adding encrypt_then_mac extension" \
593 -s "found encrypt then mac extension" \
594 -S "server hello, adding encrypt then mac extension" \
595 -C "found encrypt_then_mac extension" \
596 -C "using encrypt then mac" \
597 -S "using encrypt then mac"
598
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100599run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100600 "$P_SRV debug_level=3 etm=1 \
601 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100602 "$P_CLI debug_level=3 etm=0" \
603 0 \
604 -C "client hello, adding encrypt_then_mac extension" \
605 -S "found encrypt then mac extension" \
606 -S "server hello, adding encrypt then mac extension" \
607 -C "found encrypt_then_mac extension" \
608 -C "using encrypt then mac" \
609 -S "using encrypt then mac"
610
Janos Follath4dfecab2016-03-14 13:40:43 +0000611requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100612run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100613 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100614 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100615 "$P_CLI debug_level=3 force_version=ssl3" \
616 0 \
617 -C "client hello, adding encrypt_then_mac extension" \
618 -S "found encrypt then mac extension" \
619 -S "server hello, adding encrypt then mac extension" \
620 -C "found encrypt_then_mac extension" \
621 -C "using encrypt then mac" \
622 -S "using encrypt then mac"
623
Janos Follath4dfecab2016-03-14 13:40:43 +0000624requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100625run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100626 "$P_SRV debug_level=3 force_version=ssl3 \
627 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100628 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100629 0 \
630 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath8abaa8b2016-05-06 13:48:23 +0100631 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100632 -S "server hello, adding encrypt then mac extension" \
633 -C "found encrypt_then_mac extension" \
634 -C "using encrypt then mac" \
635 -S "using encrypt then mac"
636
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200637# Tests for Extended Master Secret extension
638
639run_test "Extended Master Secret: default" \
640 "$P_SRV debug_level=3" \
641 "$P_CLI debug_level=3" \
642 0 \
643 -c "client hello, adding extended_master_secret extension" \
644 -s "found extended master secret extension" \
645 -s "server hello, adding extended master secret extension" \
646 -c "found extended_master_secret extension" \
647 -c "using extended master secret" \
648 -s "using extended master secret"
649
650run_test "Extended Master Secret: client enabled, server disabled" \
651 "$P_SRV debug_level=3 extended_ms=0" \
652 "$P_CLI debug_level=3 extended_ms=1" \
653 0 \
654 -c "client hello, adding extended_master_secret extension" \
655 -s "found extended master secret extension" \
656 -S "server hello, adding extended master secret extension" \
657 -C "found extended_master_secret extension" \
658 -C "using extended master secret" \
659 -S "using extended master secret"
660
661run_test "Extended Master Secret: client disabled, server enabled" \
662 "$P_SRV debug_level=3 extended_ms=1" \
663 "$P_CLI debug_level=3 extended_ms=0" \
664 0 \
665 -C "client hello, adding extended_master_secret extension" \
666 -S "found extended master secret extension" \
667 -S "server hello, adding extended master secret extension" \
668 -C "found extended_master_secret extension" \
669 -C "using extended master secret" \
670 -S "using extended master secret"
671
Janos Follath4dfecab2016-03-14 13:40:43 +0000672requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200673run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100674 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200675 "$P_CLI debug_level=3 force_version=ssl3" \
676 0 \
677 -C "client hello, adding extended_master_secret extension" \
678 -S "found extended master secret extension" \
679 -S "server hello, adding extended master secret extension" \
680 -C "found extended_master_secret extension" \
681 -C "using extended master secret" \
682 -S "using extended master secret"
683
Janos Follath4dfecab2016-03-14 13:40:43 +0000684requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200685run_test "Extended Master Secret: client enabled, server SSLv3" \
686 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100687 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200688 0 \
689 -c "client hello, adding extended_master_secret extension" \
Janos Follath8abaa8b2016-05-06 13:48:23 +0100690 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200691 -S "server hello, adding extended master secret extension" \
692 -C "found extended_master_secret extension" \
693 -C "using extended master secret" \
694 -S "using extended master secret"
695
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200696# Tests for FALLBACK_SCSV
697
698run_test "Fallback SCSV: default" \
699 "$P_SRV" \
700 "$P_CLI debug_level=3 force_version=tls1_1" \
701 0 \
702 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200703 -S "received FALLBACK_SCSV" \
704 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200705 -C "is a fatal alert message (msg 86)"
706
707run_test "Fallback SCSV: explicitly disabled" \
708 "$P_SRV" \
709 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
710 0 \
711 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200712 -S "received FALLBACK_SCSV" \
713 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200714 -C "is a fatal alert message (msg 86)"
715
716run_test "Fallback SCSV: enabled" \
717 "$P_SRV" \
718 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200719 1 \
720 -c "adding FALLBACK_SCSV" \
721 -s "received FALLBACK_SCSV" \
722 -s "inapropriate fallback" \
723 -c "is a fatal alert message (msg 86)"
724
725run_test "Fallback SCSV: enabled, max version" \
726 "$P_SRV" \
727 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200728 0 \
729 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200730 -s "received FALLBACK_SCSV" \
731 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200732 -C "is a fatal alert message (msg 86)"
733
734requires_openssl_with_fallback_scsv
735run_test "Fallback SCSV: default, openssl server" \
736 "$O_SRV" \
737 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
738 0 \
739 -C "adding FALLBACK_SCSV" \
740 -C "is a fatal alert message (msg 86)"
741
742requires_openssl_with_fallback_scsv
743run_test "Fallback SCSV: enabled, openssl server" \
744 "$O_SRV" \
745 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
746 1 \
747 -c "adding FALLBACK_SCSV" \
748 -c "is a fatal alert message (msg 86)"
749
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200750requires_openssl_with_fallback_scsv
751run_test "Fallback SCSV: disabled, openssl client" \
752 "$P_SRV" \
753 "$O_CLI -tls1_1" \
754 0 \
755 -S "received FALLBACK_SCSV" \
756 -S "inapropriate fallback"
757
758requires_openssl_with_fallback_scsv
759run_test "Fallback SCSV: enabled, openssl client" \
760 "$P_SRV" \
761 "$O_CLI -tls1_1 -fallback_scsv" \
762 1 \
763 -s "received FALLBACK_SCSV" \
764 -s "inapropriate fallback"
765
766requires_openssl_with_fallback_scsv
767run_test "Fallback SCSV: enabled, max version, openssl client" \
768 "$P_SRV" \
769 "$O_CLI -fallback_scsv" \
770 0 \
771 -s "received FALLBACK_SCSV" \
772 -S "inapropriate fallback"
773
Gilles Peskinea1cf6c82017-05-17 14:50:38 +0200774## ClientHello generated with
775## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
776## then manually twiddling the ciphersuite list.
777## The ClientHello content is spelled out below as a hex string as
778## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
779## The expected response is an inappropriate_fallback alert.
780requires_openssl_with_fallback_scsv
781run_test "Fallback SCSV: beginning of list" \
782 "$P_SRV debug_level=2" \
783 "$TCP_CLIENT localhost $PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
784 0 \
785 -s "received FALLBACK_SCSV" \
786 -s "inapropriate fallback"
787
788requires_openssl_with_fallback_scsv
789run_test "Fallback SCSV: end of list" \
790 "$P_SRV debug_level=2" \
791 "$TCP_CLIENT localhost $PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
792 0 \
793 -s "received FALLBACK_SCSV" \
794 -s "inapropriate fallback"
795
796## Here the expected response is a valid ServerHello prefix, up to the random.
797requires_openssl_with_fallback_scsv
798run_test "Fallback SCSV: not in list" \
799 "$P_SRV debug_level=2" \
800 "$TCP_CLIENT localhost $PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
801 0 \
802 -S "received FALLBACK_SCSV" \
803 -S "inapropriate fallback"
804
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100805# Tests for CBC 1/n-1 record splitting
806
807run_test "CBC Record splitting: TLS 1.2, no splitting" \
808 "$P_SRV" \
809 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
810 request_size=123 force_version=tls1_2" \
811 0 \
812 -s "Read from client: 123 bytes read" \
813 -S "Read from client: 1 bytes read" \
814 -S "122 bytes read"
815
816run_test "CBC Record splitting: TLS 1.1, no splitting" \
817 "$P_SRV" \
818 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
819 request_size=123 force_version=tls1_1" \
820 0 \
821 -s "Read from client: 123 bytes read" \
822 -S "Read from client: 1 bytes read" \
823 -S "122 bytes read"
824
825run_test "CBC Record splitting: TLS 1.0, splitting" \
826 "$P_SRV" \
827 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
828 request_size=123 force_version=tls1" \
829 0 \
830 -S "Read from client: 123 bytes read" \
831 -s "Read from client: 1 bytes read" \
832 -s "122 bytes read"
833
Janos Follath4dfecab2016-03-14 13:40:43 +0000834requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100835run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100836 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100837 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
838 request_size=123 force_version=ssl3" \
839 0 \
840 -S "Read from client: 123 bytes read" \
841 -s "Read from client: 1 bytes read" \
842 -s "122 bytes read"
843
844run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100845 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100846 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
847 request_size=123 force_version=tls1" \
848 0 \
849 -s "Read from client: 123 bytes read" \
850 -S "Read from client: 1 bytes read" \
851 -S "122 bytes read"
852
853run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
854 "$P_SRV" \
855 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
856 request_size=123 force_version=tls1 recsplit=0" \
857 0 \
858 -s "Read from client: 123 bytes read" \
859 -S "Read from client: 1 bytes read" \
860 -S "122 bytes read"
861
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100862run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
863 "$P_SRV nbio=2" \
864 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
865 request_size=123 force_version=tls1" \
866 0 \
867 -S "Read from client: 123 bytes read" \
868 -s "Read from client: 1 bytes read" \
869 -s "122 bytes read"
870
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100871# Tests for Session Tickets
872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200873run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200874 "$P_SRV debug_level=3 tickets=1" \
875 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100876 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100877 -c "client hello, adding session ticket extension" \
878 -s "found session ticket extension" \
879 -s "server hello, adding session ticket extension" \
880 -c "found session_ticket extension" \
881 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100882 -S "session successfully restored from cache" \
883 -s "session successfully restored from ticket" \
884 -s "a session has been resumed" \
885 -c "a session has been resumed"
886
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200887run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200888 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
889 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100890 0 \
891 -c "client hello, adding session ticket extension" \
892 -s "found session ticket extension" \
893 -s "server hello, adding session ticket extension" \
894 -c "found session_ticket extension" \
895 -c "parse new session ticket" \
896 -S "session successfully restored from cache" \
897 -s "session successfully restored from ticket" \
898 -s "a session has been resumed" \
899 -c "a session has been resumed"
900
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200901run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200902 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
903 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100904 0 \
905 -c "client hello, adding session ticket extension" \
906 -s "found session ticket extension" \
907 -s "server hello, adding session ticket extension" \
908 -c "found session_ticket extension" \
909 -c "parse new session ticket" \
910 -S "session successfully restored from cache" \
911 -S "session successfully restored from ticket" \
912 -S "a session has been resumed" \
913 -C "a session has been resumed"
914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200915run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100916 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200917 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100918 0 \
919 -c "client hello, adding session ticket extension" \
920 -c "found session_ticket extension" \
921 -c "parse new session ticket" \
922 -c "a session has been resumed"
923
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200924run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200925 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200926 "( $O_CLI -sess_out $SESSION; \
927 $O_CLI -sess_in $SESSION; \
928 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100929 0 \
930 -s "found session ticket extension" \
931 -s "server hello, adding session ticket extension" \
932 -S "session successfully restored from cache" \
933 -s "session successfully restored from ticket" \
934 -s "a session has been resumed"
935
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100936# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100937
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200938run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200939 "$P_SRV debug_level=3 tickets=0" \
940 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100941 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100942 -c "client hello, adding session ticket extension" \
943 -s "found session ticket extension" \
944 -S "server hello, adding session ticket extension" \
945 -C "found session_ticket extension" \
946 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100947 -s "session successfully restored from cache" \
948 -S "session successfully restored from ticket" \
949 -s "a session has been resumed" \
950 -c "a session has been resumed"
951
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200952run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200953 "$P_SRV debug_level=3 tickets=1" \
954 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100955 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100956 -C "client hello, adding session ticket extension" \
957 -S "found session ticket extension" \
958 -S "server hello, adding session ticket extension" \
959 -C "found session_ticket extension" \
960 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100961 -s "session successfully restored from cache" \
962 -S "session successfully restored from ticket" \
963 -s "a session has been resumed" \
964 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100965
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200966run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200967 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
968 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100969 0 \
970 -S "session successfully restored from cache" \
971 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100972 -S "a session has been resumed" \
973 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200975run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200976 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
977 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100978 0 \
979 -s "session successfully restored from cache" \
980 -S "session successfully restored from ticket" \
981 -s "a session has been resumed" \
982 -c "a session has been resumed"
983
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200984run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200985 "$P_SRV debug_level=3 tickets=0" \
986 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100987 0 \
988 -s "session successfully restored from cache" \
989 -S "session successfully restored from ticket" \
990 -s "a session has been resumed" \
991 -c "a session has been resumed"
992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200993run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200994 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
995 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100996 0 \
997 -S "session successfully restored from cache" \
998 -S "session successfully restored from ticket" \
999 -S "a session has been resumed" \
1000 -C "a session has been resumed"
1001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001002run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001003 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1004 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001005 0 \
1006 -s "session successfully restored from cache" \
1007 -S "session successfully restored from ticket" \
1008 -s "a session has been resumed" \
1009 -c "a session has been resumed"
1010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001011run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001012 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001013 "( $O_CLI -sess_out $SESSION; \
1014 $O_CLI -sess_in $SESSION; \
1015 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001016 0 \
1017 -s "found session ticket extension" \
1018 -S "server hello, adding session ticket extension" \
1019 -s "session successfully restored from cache" \
1020 -S "session successfully restored from ticket" \
1021 -s "a session has been resumed"
1022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001023run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001024 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001025 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001026 0 \
1027 -C "found session_ticket extension" \
1028 -C "parse new session ticket" \
1029 -c "a session has been resumed"
1030
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001031# Tests for Max Fragment Length extension
1032
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001033run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001034 "$P_SRV debug_level=3" \
1035 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001036 0 \
1037 -C "client hello, adding max_fragment_length extension" \
1038 -S "found max fragment length extension" \
1039 -S "server hello, max_fragment_length extension" \
1040 -C "found max_fragment_length extension"
1041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001042run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001043 "$P_SRV debug_level=3" \
1044 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001045 0 \
1046 -c "client hello, adding max_fragment_length extension" \
1047 -s "found max fragment length extension" \
1048 -s "server hello, max_fragment_length extension" \
1049 -c "found max_fragment_length extension"
1050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001051run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001052 "$P_SRV debug_level=3 max_frag_len=4096" \
1053 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001054 0 \
1055 -C "client hello, adding max_fragment_length extension" \
1056 -S "found max fragment length extension" \
1057 -S "server hello, max_fragment_length extension" \
1058 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001060requires_gnutls
1061run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001062 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001063 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001064 0 \
1065 -c "client hello, adding max_fragment_length extension" \
1066 -c "found max_fragment_length extension"
1067
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001068# Tests for renegotiation
1069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001070run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001071 "$P_SRV debug_level=3 exchanges=2" \
1072 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001073 0 \
1074 -C "client hello, adding renegotiation extension" \
1075 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1076 -S "found renegotiation extension" \
1077 -s "server hello, secure renegotiation extension" \
1078 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001079 -C "=> renegotiate" \
1080 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001081 -S "write hello request"
1082
Hanno Beckere8f3d932017-10-25 09:38:00 +01001083requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001084run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001085 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
1086 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001087 0 \
1088 -c "client hello, adding renegotiation extension" \
1089 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1090 -s "found renegotiation extension" \
1091 -s "server hello, secure renegotiation extension" \
1092 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001093 -c "=> renegotiate" \
1094 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001095 -S "write hello request"
1096
Hanno Beckere8f3d932017-10-25 09:38:00 +01001097requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001098run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001099 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1100 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001101 0 \
1102 -c "client hello, adding renegotiation extension" \
1103 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1104 -s "found renegotiation extension" \
1105 -s "server hello, secure renegotiation extension" \
1106 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001107 -c "=> renegotiate" \
1108 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001109 -s "write hello request"
1110
Janos Follathea111c52017-10-05 12:29:42 +01001111# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1112# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1113# algorithm stronger than SHA-1 is enabled in config.h
Hanno Beckere8f3d932017-10-25 09:38:00 +01001114requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Janos Follathea111c52017-10-05 12:29:42 +01001115run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1116 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1117 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1118 0 \
1119 -c "client hello, adding renegotiation extension" \
1120 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1121 -s "found renegotiation extension" \
1122 -s "server hello, secure renegotiation extension" \
1123 -c "found renegotiation extension" \
1124 -c "=> renegotiate" \
1125 -s "=> renegotiate" \
1126 -S "write hello request" \
1127 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1128
1129# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1130# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1131# algorithm stronger than SHA-1 is enabled in config.h
Hanno Beckere8f3d932017-10-25 09:38:00 +01001132requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Janos Follathea111c52017-10-05 12:29:42 +01001133run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1134 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1135 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1136 0 \
1137 -c "client hello, adding renegotiation extension" \
1138 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1139 -s "found renegotiation extension" \
1140 -s "server hello, secure renegotiation extension" \
1141 -c "found renegotiation extension" \
1142 -c "=> renegotiate" \
1143 -s "=> renegotiate" \
1144 -s "write hello request" \
1145 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1146
Hanno Beckere8f3d932017-10-25 09:38:00 +01001147requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001148run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001149 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1150 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001151 0 \
1152 -c "client hello, adding renegotiation extension" \
1153 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1154 -s "found renegotiation extension" \
1155 -s "server hello, secure renegotiation extension" \
1156 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001157 -c "=> renegotiate" \
1158 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001159 -s "write hello request"
1160
Hanno Beckere8f3d932017-10-25 09:38:00 +01001161requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001162run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001163 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1164 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001165 1 \
1166 -c "client hello, adding renegotiation extension" \
1167 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1168 -S "found renegotiation extension" \
1169 -s "server hello, secure renegotiation extension" \
1170 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001171 -c "=> renegotiate" \
1172 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001173 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001174 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001175 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001176
Hanno Beckere8f3d932017-10-25 09:38:00 +01001177requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001178run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001179 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1180 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001181 0 \
1182 -C "client hello, adding renegotiation extension" \
1183 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1184 -S "found renegotiation extension" \
1185 -s "server hello, secure renegotiation extension" \
1186 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001187 -C "=> renegotiate" \
1188 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001189 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001190 -S "SSL - An unexpected message was received from our peer" \
1191 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001192
Hanno Beckere8f3d932017-10-25 09:38:00 +01001193requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001194run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001195 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001196 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001197 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001198 0 \
1199 -C "client hello, adding renegotiation extension" \
1200 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1201 -S "found renegotiation extension" \
1202 -s "server hello, secure renegotiation extension" \
1203 -c "found renegotiation extension" \
1204 -C "=> renegotiate" \
1205 -S "=> renegotiate" \
1206 -s "write hello request" \
1207 -S "SSL - An unexpected message was received from our peer" \
1208 -S "failed"
1209
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001210# delay 2 for 1 alert record + 1 application data record
Hanno Beckere8f3d932017-10-25 09:38:00 +01001211requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001212run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001213 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001214 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001215 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001216 0 \
1217 -C "client hello, adding renegotiation extension" \
1218 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1219 -S "found renegotiation extension" \
1220 -s "server hello, secure renegotiation extension" \
1221 -c "found renegotiation extension" \
1222 -C "=> renegotiate" \
1223 -S "=> renegotiate" \
1224 -s "write hello request" \
1225 -S "SSL - An unexpected message was received from our peer" \
1226 -S "failed"
1227
Hanno Beckere8f3d932017-10-25 09:38:00 +01001228requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001229run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001230 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001231 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001232 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001233 0 \
1234 -C "client hello, adding renegotiation extension" \
1235 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1236 -S "found renegotiation extension" \
1237 -s "server hello, secure renegotiation extension" \
1238 -c "found renegotiation extension" \
1239 -C "=> renegotiate" \
1240 -S "=> renegotiate" \
1241 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001242 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001243
Hanno Beckere8f3d932017-10-25 09:38:00 +01001244requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001245run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001246 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001247 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001248 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001249 0 \
1250 -c "client hello, adding renegotiation extension" \
1251 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1252 -s "found renegotiation extension" \
1253 -s "server hello, secure renegotiation extension" \
1254 -c "found renegotiation extension" \
1255 -c "=> renegotiate" \
1256 -s "=> renegotiate" \
1257 -s "write hello request" \
1258 -S "SSL - An unexpected message was received from our peer" \
1259 -S "failed"
1260
Hanno Beckere8f3d932017-10-25 09:38:00 +01001261requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001262run_test "Renegotiation: periodic, just below period" \
1263 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1264 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1265 0 \
1266 -C "client hello, adding renegotiation extension" \
1267 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1268 -S "found renegotiation extension" \
1269 -s "server hello, secure renegotiation extension" \
1270 -c "found renegotiation extension" \
1271 -S "record counter limit reached: renegotiate" \
1272 -C "=> renegotiate" \
1273 -S "=> renegotiate" \
1274 -S "write hello request" \
1275 -S "SSL - An unexpected message was received from our peer" \
1276 -S "failed"
1277
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001278# one extra exchange to be able to complete renego
Hanno Beckere8f3d932017-10-25 09:38:00 +01001279requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001280run_test "Renegotiation: periodic, just above period" \
1281 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001282 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001283 0 \
1284 -c "client hello, adding renegotiation extension" \
1285 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1286 -s "found renegotiation extension" \
1287 -s "server hello, secure renegotiation extension" \
1288 -c "found renegotiation extension" \
1289 -s "record counter limit reached: renegotiate" \
1290 -c "=> renegotiate" \
1291 -s "=> renegotiate" \
1292 -s "write hello request" \
1293 -S "SSL - An unexpected message was received from our peer" \
1294 -S "failed"
1295
Hanno Beckere8f3d932017-10-25 09:38:00 +01001296requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001297run_test "Renegotiation: periodic, two times period" \
1298 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001299 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001300 0 \
1301 -c "client hello, adding renegotiation extension" \
1302 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1303 -s "found renegotiation extension" \
1304 -s "server hello, secure renegotiation extension" \
1305 -c "found renegotiation extension" \
1306 -s "record counter limit reached: renegotiate" \
1307 -c "=> renegotiate" \
1308 -s "=> renegotiate" \
1309 -s "write hello request" \
1310 -S "SSL - An unexpected message was received from our peer" \
1311 -S "failed"
1312
Hanno Beckere8f3d932017-10-25 09:38:00 +01001313requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001314run_test "Renegotiation: periodic, above period, disabled" \
1315 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1316 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1317 0 \
1318 -C "client hello, adding renegotiation extension" \
1319 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1320 -S "found renegotiation extension" \
1321 -s "server hello, secure renegotiation extension" \
1322 -c "found renegotiation extension" \
1323 -S "record counter limit reached: renegotiate" \
1324 -C "=> renegotiate" \
1325 -S "=> renegotiate" \
1326 -S "write hello request" \
1327 -S "SSL - An unexpected message was received from our peer" \
1328 -S "failed"
1329
Hanno Beckere8f3d932017-10-25 09:38:00 +01001330requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001331run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001332 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1333 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001334 0 \
1335 -c "client hello, adding renegotiation extension" \
1336 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1337 -s "found renegotiation extension" \
1338 -s "server hello, secure renegotiation extension" \
1339 -c "found renegotiation extension" \
1340 -c "=> renegotiate" \
1341 -s "=> renegotiate" \
1342 -S "write hello request"
1343
Hanno Beckere8f3d932017-10-25 09:38:00 +01001344requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001345run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001346 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1347 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001348 0 \
1349 -c "client hello, adding renegotiation extension" \
1350 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1351 -s "found renegotiation extension" \
1352 -s "server hello, secure renegotiation extension" \
1353 -c "found renegotiation extension" \
1354 -c "=> renegotiate" \
1355 -s "=> renegotiate" \
1356 -s "write hello request"
1357
Hanno Beckere8f3d932017-10-25 09:38:00 +01001358requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001359run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001360 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001361 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001362 0 \
1363 -c "client hello, adding renegotiation extension" \
1364 -c "found renegotiation extension" \
1365 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001366 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001367 -C "error" \
1368 -c "HTTP/1.0 200 [Oo][Kk]"
1369
Paul Bakker539d9722015-02-08 16:18:35 +01001370requires_gnutls
Hanno Beckere8f3d932017-10-25 09:38:00 +01001371requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001372run_test "Renegotiation: gnutls server strict, client-initiated" \
1373 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001374 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001375 0 \
1376 -c "client hello, adding renegotiation extension" \
1377 -c "found renegotiation extension" \
1378 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001379 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001380 -C "error" \
1381 -c "HTTP/1.0 200 [Oo][Kk]"
1382
Paul Bakker539d9722015-02-08 16:18:35 +01001383requires_gnutls
Hanno Beckere8f3d932017-10-25 09:38:00 +01001384requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001385run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1386 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1387 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1388 1 \
1389 -c "client hello, adding renegotiation extension" \
1390 -C "found renegotiation extension" \
1391 -c "=> renegotiate" \
1392 -c "ssl_handshake() returned" \
1393 -c "error" \
1394 -C "HTTP/1.0 200 [Oo][Kk]"
1395
Paul Bakker539d9722015-02-08 16:18:35 +01001396requires_gnutls
Hanno Beckere8f3d932017-10-25 09:38:00 +01001397requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001398run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1399 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1400 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1401 allow_legacy=0" \
1402 1 \
1403 -c "client hello, adding renegotiation extension" \
1404 -C "found renegotiation extension" \
1405 -c "=> renegotiate" \
1406 -c "ssl_handshake() returned" \
1407 -c "error" \
1408 -C "HTTP/1.0 200 [Oo][Kk]"
1409
Paul Bakker539d9722015-02-08 16:18:35 +01001410requires_gnutls
Hanno Beckere8f3d932017-10-25 09:38:00 +01001411requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001412run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1413 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1414 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1415 allow_legacy=1" \
1416 0 \
1417 -c "client hello, adding renegotiation extension" \
1418 -C "found renegotiation extension" \
1419 -c "=> renegotiate" \
1420 -C "ssl_hanshake() returned" \
1421 -C "error" \
1422 -c "HTTP/1.0 200 [Oo][Kk]"
1423
1424# Test for the "secure renegotation" extension only (no actual renegotiation)
1425
Paul Bakker539d9722015-02-08 16:18:35 +01001426requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001427run_test "Renego ext: gnutls server strict, client default" \
1428 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1429 "$P_CLI debug_level=3" \
1430 0 \
1431 -c "found renegotiation extension" \
1432 -C "error" \
1433 -c "HTTP/1.0 200 [Oo][Kk]"
1434
Paul Bakker539d9722015-02-08 16:18:35 +01001435requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001436run_test "Renego ext: gnutls server unsafe, client default" \
1437 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1438 "$P_CLI debug_level=3" \
1439 0 \
1440 -C "found renegotiation extension" \
1441 -C "error" \
1442 -c "HTTP/1.0 200 [Oo][Kk]"
1443
Paul Bakker539d9722015-02-08 16:18:35 +01001444requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001445run_test "Renego ext: gnutls server unsafe, client break legacy" \
1446 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1447 "$P_CLI debug_level=3 allow_legacy=-1" \
1448 1 \
1449 -C "found renegotiation extension" \
1450 -c "error" \
1451 -C "HTTP/1.0 200 [Oo][Kk]"
1452
Paul Bakker539d9722015-02-08 16:18:35 +01001453requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001454run_test "Renego ext: gnutls client strict, server default" \
1455 "$P_SRV debug_level=3" \
1456 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1457 0 \
1458 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1459 -s "server hello, secure renegotiation extension"
1460
Paul Bakker539d9722015-02-08 16:18:35 +01001461requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001462run_test "Renego ext: gnutls client unsafe, server default" \
1463 "$P_SRV debug_level=3" \
1464 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1465 0 \
1466 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1467 -S "server hello, secure renegotiation extension"
1468
Paul Bakker539d9722015-02-08 16:18:35 +01001469requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001470run_test "Renego ext: gnutls client unsafe, server break legacy" \
1471 "$P_SRV debug_level=3 allow_legacy=-1" \
1472 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1473 1 \
1474 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1475 -S "server hello, secure renegotiation extension"
1476
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001477# Tests for auth_mode
1478
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001479run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001480 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001481 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001482 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001483 1 \
1484 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001485 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001486 -c "! ssl_handshake returned" \
1487 -c "X509 - Certificate verification failed"
1488
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001489run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001490 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001491 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001492 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001493 0 \
1494 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001495 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001496 -C "! ssl_handshake returned" \
1497 -C "X509 - Certificate verification failed"
1498
Hanno Becker6fd6d242017-05-25 17:51:31 +01001499run_test "Authentication: server goodcert, client optional, no trusted CA" \
1500 "$P_SRV" \
1501 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1502 0 \
1503 -c "x509_verify_cert() returned" \
1504 -c "! The certificate is not correctly signed by the trusted CA" \
1505 -c "! Certificate verification flags"\
1506 -C "! ssl_handshake returned" \
1507 -C "X509 - Certificate verification failed" \
1508 -C "SSL - No CA Chain is set, but required to operate"
1509
1510run_test "Authentication: server goodcert, client required, no trusted CA" \
1511 "$P_SRV" \
1512 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1513 1 \
1514 -c "x509_verify_cert() returned" \
1515 -c "! The certificate is not correctly signed by the trusted CA" \
1516 -c "! Certificate verification flags"\
1517 -c "! ssl_handshake returned" \
1518 -c "SSL - No CA Chain is set, but required to operate"
1519
1520# The purpose of the next two tests is to test the client's behaviour when receiving a server
1521# certificate with an unsupported elliptic curve. This should usually not happen because
1522# the client informs the server about the supported curves - it does, though, in the
1523# corner case of a static ECDH suite, because the server doesn't check the curve on that
1524# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1525# different means to have the server ignoring the client's supported curve list.
1526
1527requires_config_enabled POLARSSL_SSL_SET_CURVES
1528run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1529 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1530 crt_file=data_files/server5.ku-ka.crt" \
1531 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1532 1 \
1533 -c "bad certificate (EC key curve)"\
1534 -c "! Certificate verification flags"\
1535 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1536
1537requires_config_enabled POLARSSL_SSL_SET_CURVES
1538run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1539 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1540 crt_file=data_files/server5.ku-ka.crt" \
1541 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1542 1 \
1543 -c "bad certificate (EC key curve)"\
1544 -c "! Certificate verification flags"\
1545 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001547run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001548 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001549 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001550 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001551 0 \
1552 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001553 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001554 -C "! ssl_handshake returned" \
1555 -C "X509 - Certificate verification failed"
1556
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001557run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001558 "$P_SRV debug_level=3 auth_mode=required" \
1559 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001560 key_file=data_files/server5.key" \
1561 1 \
1562 -S "skip write certificate request" \
1563 -C "skip parse certificate request" \
1564 -c "got a certificate request" \
1565 -C "skip write certificate" \
1566 -C "skip write certificate verify" \
1567 -S "skip parse certificate verify" \
1568 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001569 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001570 -s "! ssl_handshake returned" \
1571 -c "! ssl_handshake returned" \
1572 -s "X509 - Certificate verification failed"
1573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001574run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001575 "$P_SRV debug_level=3 auth_mode=optional" \
1576 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001577 key_file=data_files/server5.key" \
1578 0 \
1579 -S "skip write certificate request" \
1580 -C "skip parse certificate request" \
1581 -c "got a certificate request" \
1582 -C "skip write certificate" \
1583 -C "skip write certificate verify" \
1584 -S "skip parse certificate verify" \
1585 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001586 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001587 -S "! ssl_handshake returned" \
1588 -C "! ssl_handshake returned" \
1589 -S "X509 - Certificate verification failed"
1590
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001591run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001592 "$P_SRV debug_level=3 auth_mode=none" \
1593 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001594 key_file=data_files/server5.key" \
1595 0 \
1596 -s "skip write certificate request" \
1597 -C "skip parse certificate request" \
1598 -c "got no certificate request" \
1599 -c "skip write certificate" \
1600 -c "skip write certificate verify" \
1601 -s "skip parse certificate verify" \
1602 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001603 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001604 -S "! ssl_handshake returned" \
1605 -C "! ssl_handshake returned" \
1606 -S "X509 - Certificate verification failed"
1607
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001608run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001609 "$P_SRV debug_level=3 auth_mode=optional" \
1610 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001611 0 \
1612 -S "skip write certificate request" \
1613 -C "skip parse certificate request" \
1614 -c "got a certificate request" \
1615 -C "skip write certificate$" \
1616 -C "got no certificate to send" \
1617 -S "SSLv3 client has no certificate" \
1618 -c "skip write certificate verify" \
1619 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001620 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001621 -S "! ssl_handshake returned" \
1622 -C "! ssl_handshake returned" \
1623 -S "X509 - Certificate verification failed"
1624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001625run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001626 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001627 "$O_CLI" \
1628 0 \
1629 -S "skip write certificate request" \
1630 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001631 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001632 -S "! ssl_handshake returned" \
1633 -S "X509 - Certificate verification failed"
1634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001635run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001636 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001637 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001638 0 \
1639 -C "skip parse certificate request" \
1640 -c "got a certificate request" \
1641 -C "skip write certificate$" \
1642 -c "skip write certificate verify" \
1643 -C "! ssl_handshake returned"
1644
Janos Follath4dfecab2016-03-14 13:40:43 +00001645requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001646run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001647 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001648 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001649 0 \
1650 -S "skip write certificate request" \
1651 -C "skip parse certificate request" \
1652 -c "got a certificate request" \
1653 -C "skip write certificate$" \
1654 -c "skip write certificate verify" \
1655 -c "got no certificate to send" \
1656 -s "SSLv3 client has no certificate" \
1657 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001658 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001659 -S "! ssl_handshake returned" \
1660 -C "! ssl_handshake returned" \
1661 -S "X509 - Certificate verification failed"
1662
Manuel Pégourié-Gonnarda68d5912017-07-10 11:31:43 +02001663run_test "Authentication: server max_int chain, client default" \
1664 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
1665 key_file=data_files/dir-maxpath/09.key" \
1666 "$P_CLI server_name=CA09 server_addr=127.0.0.1 \
1667 ca_file=data_files/dir-maxpath/00.crt" \
1668 0 \
1669 -C "X509 - A fatal error occured"
1670
1671run_test "Authentication: server max_int+1 chain, client default" \
1672 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
1673 key_file=data_files/dir-maxpath/10.key" \
1674 "$P_CLI server_name=CA10 server_addr=127.0.0.1 \
1675 ca_file=data_files/dir-maxpath/00.crt" \
1676 1 \
1677 -c "X509 - A fatal error occured"
1678
1679run_test "Authentication: server max_int+1 chain, client optional" \
1680 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
1681 key_file=data_files/dir-maxpath/10.key" \
1682 "$P_CLI server_name=CA10 server_addr=127.0.0.1 \
1683 ca_file=data_files/dir-maxpath/00.crt \
1684 auth_mode=optional" \
1685 1 \
1686 -c "X509 - A fatal error occured"
1687
1688run_test "Authentication: server max_int+1 chain, client none" \
1689 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
1690 key_file=data_files/dir-maxpath/10.key" \
1691 "$P_CLI server_name=CA10 server_addr=127.0.0.1 ca_file=data_files/dir-maxpath/00.crt \
1692 auth_mode=none" \
1693 0 \
1694 -C "X509 - A fatal error occured"
1695
1696run_test "Authentication: client max_int+1 chain, server none" \
1697 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=none" \
1698 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
1699 key_file=data_files/dir-maxpath/10.key" \
1700 0 \
1701 -S "X509 - A fatal error occured"
1702
1703run_test "Authentication: client max_int+1 chain, server optional" \
1704 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
1705 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
1706 key_file=data_files/dir-maxpath/10.key" \
1707 1 \
1708 -s "X509 - A fatal error occured"
1709
1710run_test "Authentication: client max_int+1 chain, server required" \
1711 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
1712 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
1713 key_file=data_files/dir-maxpath/10.key" \
1714 1 \
1715 -s "X509 - A fatal error occured"
1716
1717run_test "Authentication: client max_int chain, server required" \
1718 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
1719 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
1720 key_file=data_files/dir-maxpath/09.key" \
1721 0 \
1722 -S "X509 - A fatal error occured"
1723
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001724# Tests for certificate selection based on SHA verson
1725
1726run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1727 "$P_SRV crt_file=data_files/server5.crt \
1728 key_file=data_files/server5.key \
1729 crt_file2=data_files/server5-sha1.crt \
1730 key_file2=data_files/server5.key" \
1731 "$P_CLI force_version=tls1_2" \
1732 0 \
1733 -c "signed using.*ECDSA with SHA256" \
1734 -C "signed using.*ECDSA with SHA1"
1735
1736run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1737 "$P_SRV crt_file=data_files/server5.crt \
1738 key_file=data_files/server5.key \
1739 crt_file2=data_files/server5-sha1.crt \
1740 key_file2=data_files/server5.key" \
1741 "$P_CLI force_version=tls1_1" \
1742 0 \
1743 -C "signed using.*ECDSA with SHA256" \
1744 -c "signed using.*ECDSA with SHA1"
1745
1746run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1747 "$P_SRV crt_file=data_files/server5.crt \
1748 key_file=data_files/server5.key \
1749 crt_file2=data_files/server5-sha1.crt \
1750 key_file2=data_files/server5.key" \
1751 "$P_CLI force_version=tls1" \
1752 0 \
1753 -C "signed using.*ECDSA with SHA256" \
1754 -c "signed using.*ECDSA with SHA1"
1755
1756run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1757 "$P_SRV crt_file=data_files/server5.crt \
1758 key_file=data_files/server5.key \
1759 crt_file2=data_files/server6.crt \
1760 key_file2=data_files/server6.key" \
1761 "$P_CLI force_version=tls1_1" \
1762 0 \
1763 -c "serial number.*09" \
1764 -c "signed using.*ECDSA with SHA256" \
1765 -C "signed using.*ECDSA with SHA1"
1766
1767run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1768 "$P_SRV crt_file=data_files/server6.crt \
1769 key_file=data_files/server6.key \
1770 crt_file2=data_files/server5.crt \
1771 key_file2=data_files/server5.key" \
1772 "$P_CLI force_version=tls1_1" \
1773 0 \
1774 -c "serial number.*0A" \
1775 -c "signed using.*ECDSA with SHA256" \
1776 -C "signed using.*ECDSA with SHA1"
1777
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001778# tests for SNI
1779
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001780run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001781 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001782 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001783 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001784 server_name=localhost" \
1785 0 \
1786 -S "parse ServerName extension" \
1787 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1788 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001790run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001791 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001792 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001793 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 +01001794 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001795 server_name=localhost" \
1796 0 \
1797 -s "parse ServerName extension" \
1798 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1799 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001801run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001802 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001803 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001804 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 +01001805 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001806 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001807 0 \
1808 -s "parse ServerName extension" \
1809 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001810 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001812run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001813 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001814 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001815 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 +01001816 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001817 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001818 1 \
1819 -s "parse ServerName extension" \
1820 -s "ssl_sni_wrapper() returned" \
1821 -s "ssl_handshake returned" \
1822 -c "ssl_handshake returned" \
1823 -c "SSL - A fatal alert message was received from our peer"
1824
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001825# Tests for non-blocking I/O: exercise a variety of handshake flows
1826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001827run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001828 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1829 "$P_CLI nbio=2 tickets=0" \
1830 0 \
1831 -S "ssl_handshake returned" \
1832 -C "ssl_handshake returned" \
1833 -c "Read from server: .* bytes read"
1834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001835run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001836 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1837 "$P_CLI nbio=2 tickets=0" \
1838 0 \
1839 -S "ssl_handshake returned" \
1840 -C "ssl_handshake returned" \
1841 -c "Read from server: .* bytes read"
1842
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001843run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001844 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1845 "$P_CLI nbio=2 tickets=1" \
1846 0 \
1847 -S "ssl_handshake returned" \
1848 -C "ssl_handshake returned" \
1849 -c "Read from server: .* bytes read"
1850
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001851run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001852 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1853 "$P_CLI nbio=2 tickets=1" \
1854 0 \
1855 -S "ssl_handshake returned" \
1856 -C "ssl_handshake returned" \
1857 -c "Read from server: .* bytes read"
1858
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001859run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001860 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1861 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1862 0 \
1863 -S "ssl_handshake returned" \
1864 -C "ssl_handshake returned" \
1865 -c "Read from server: .* bytes read"
1866
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001867run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001868 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1869 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1870 0 \
1871 -S "ssl_handshake returned" \
1872 -C "ssl_handshake returned" \
1873 -c "Read from server: .* bytes read"
1874
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001875run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001876 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1877 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1878 0 \
1879 -S "ssl_handshake returned" \
1880 -C "ssl_handshake returned" \
1881 -c "Read from server: .* bytes read"
1882
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001883# Tests for version negotiation
1884
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001885run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001886 "$P_SRV" \
1887 "$P_CLI" \
1888 0 \
1889 -S "ssl_handshake returned" \
1890 -C "ssl_handshake returned" \
1891 -s "Protocol is TLSv1.2" \
1892 -c "Protocol is TLSv1.2"
1893
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001894run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001895 "$P_SRV" \
1896 "$P_CLI max_version=tls1_1" \
1897 0 \
1898 -S "ssl_handshake returned" \
1899 -C "ssl_handshake returned" \
1900 -s "Protocol is TLSv1.1" \
1901 -c "Protocol is TLSv1.1"
1902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001903run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001904 "$P_SRV max_version=tls1_1" \
1905 "$P_CLI" \
1906 0 \
1907 -S "ssl_handshake returned" \
1908 -C "ssl_handshake returned" \
1909 -s "Protocol is TLSv1.1" \
1910 -c "Protocol is TLSv1.1"
1911
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001912run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001913 "$P_SRV max_version=tls1_1" \
1914 "$P_CLI max_version=tls1_1" \
1915 0 \
1916 -S "ssl_handshake returned" \
1917 -C "ssl_handshake returned" \
1918 -s "Protocol is TLSv1.1" \
1919 -c "Protocol is TLSv1.1"
1920
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001921run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001922 "$P_SRV min_version=tls1_1" \
1923 "$P_CLI max_version=tls1_1" \
1924 0 \
1925 -S "ssl_handshake returned" \
1926 -C "ssl_handshake returned" \
1927 -s "Protocol is TLSv1.1" \
1928 -c "Protocol is TLSv1.1"
1929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001930run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001931 "$P_SRV max_version=tls1_1" \
1932 "$P_CLI min_version=tls1_1" \
1933 0 \
1934 -S "ssl_handshake returned" \
1935 -C "ssl_handshake returned" \
1936 -s "Protocol is TLSv1.1" \
1937 -c "Protocol is TLSv1.1"
1938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001939run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001940 "$P_SRV max_version=tls1_1" \
1941 "$P_CLI min_version=tls1_2" \
1942 1 \
1943 -s "ssl_handshake returned" \
1944 -c "ssl_handshake returned" \
1945 -c "SSL - Handshake protocol not within min/max boundaries"
1946
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001947run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001948 "$P_SRV min_version=tls1_2" \
1949 "$P_CLI max_version=tls1_1" \
1950 1 \
1951 -s "ssl_handshake returned" \
1952 -c "ssl_handshake returned" \
1953 -s "SSL - Handshake protocol not within min/max boundaries"
1954
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001955# Tests for ALPN extension
1956
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001957if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1958
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001959run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001960 "$P_SRV debug_level=3" \
1961 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001962 0 \
1963 -C "client hello, adding alpn extension" \
1964 -S "found alpn extension" \
1965 -C "got an alert message, type: \\[2:120]" \
1966 -S "server hello, adding alpn extension" \
1967 -C "found alpn extension " \
1968 -C "Application Layer Protocol is" \
1969 -S "Application Layer Protocol is"
1970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001971run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001972 "$P_SRV debug_level=3" \
1973 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001974 0 \
1975 -c "client hello, adding alpn extension" \
1976 -s "found alpn extension" \
1977 -C "got an alert message, type: \\[2:120]" \
1978 -S "server hello, adding alpn extension" \
1979 -C "found alpn extension " \
1980 -c "Application Layer Protocol is (none)" \
1981 -S "Application Layer Protocol is"
1982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001983run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001984 "$P_SRV debug_level=3 alpn=abc,1234" \
1985 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001986 0 \
1987 -C "client hello, adding alpn extension" \
1988 -S "found alpn extension" \
1989 -C "got an alert message, type: \\[2:120]" \
1990 -S "server hello, adding alpn extension" \
1991 -C "found alpn extension " \
1992 -C "Application Layer Protocol is" \
1993 -s "Application Layer Protocol is (none)"
1994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001995run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001996 "$P_SRV debug_level=3 alpn=abc,1234" \
1997 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001998 0 \
1999 -c "client hello, adding alpn extension" \
2000 -s "found alpn extension" \
2001 -C "got an alert message, type: \\[2:120]" \
2002 -s "server hello, adding alpn extension" \
2003 -c "found alpn extension" \
2004 -c "Application Layer Protocol is abc" \
2005 -s "Application Layer Protocol is abc"
2006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002007run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002008 "$P_SRV debug_level=3 alpn=abc,1234" \
2009 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002010 0 \
2011 -c "client hello, adding alpn extension" \
2012 -s "found alpn extension" \
2013 -C "got an alert message, type: \\[2:120]" \
2014 -s "server hello, adding alpn extension" \
2015 -c "found alpn extension" \
2016 -c "Application Layer Protocol is abc" \
2017 -s "Application Layer Protocol is abc"
2018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002019run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002020 "$P_SRV debug_level=3 alpn=abc,1234" \
2021 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002022 0 \
2023 -c "client hello, adding alpn extension" \
2024 -s "found alpn extension" \
2025 -C "got an alert message, type: \\[2:120]" \
2026 -s "server hello, adding alpn extension" \
2027 -c "found alpn extension" \
2028 -c "Application Layer Protocol is 1234" \
2029 -s "Application Layer Protocol is 1234"
2030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002031run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002032 "$P_SRV debug_level=3 alpn=abc,123" \
2033 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002034 1 \
2035 -c "client hello, adding alpn extension" \
2036 -s "found alpn extension" \
2037 -c "got an alert message, type: \\[2:120]" \
2038 -S "server hello, adding alpn extension" \
2039 -C "found alpn extension" \
2040 -C "Application Layer Protocol is 1234" \
2041 -S "Application Layer Protocol is 1234"
2042
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002043fi
2044
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002045# Tests for keyUsage in leaf certificates, part 1:
2046# server-side certificate/suite selection
2047
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002048run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002049 "$P_SRV key_file=data_files/server2.key \
2050 crt_file=data_files/server2.ku-ds.crt" \
2051 "$P_CLI" \
2052 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002053 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002054
2055
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002056run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002057 "$P_SRV key_file=data_files/server2.key \
2058 crt_file=data_files/server2.ku-ke.crt" \
2059 "$P_CLI" \
2060 0 \
2061 -c "Ciphersuite is TLS-RSA-WITH-"
2062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002063run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002064 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002065 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002066 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002067 1 \
2068 -C "Ciphersuite is "
2069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002070run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002071 "$P_SRV key_file=data_files/server5.key \
2072 crt_file=data_files/server5.ku-ds.crt" \
2073 "$P_CLI" \
2074 0 \
2075 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2076
2077
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002078run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002079 "$P_SRV key_file=data_files/server5.key \
2080 crt_file=data_files/server5.ku-ka.crt" \
2081 "$P_CLI" \
2082 0 \
2083 -c "Ciphersuite is TLS-ECDH-"
2084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002085run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002086 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002087 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002088 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002089 1 \
2090 -C "Ciphersuite is "
2091
2092# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002093# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002094
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002095run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002096 "$O_SRV -key data_files/server2.key \
2097 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002098 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002099 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2100 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002101 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002102 -C "Processing of the Certificate handshake message failed" \
2103 -c "Ciphersuite is TLS-"
2104
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002105run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002106 "$O_SRV -key data_files/server2.key \
2107 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002108 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002109 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2110 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002111 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002112 -C "Processing of the Certificate handshake message failed" \
2113 -c "Ciphersuite is TLS-"
2114
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002115run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002116 "$O_SRV -key data_files/server2.key \
2117 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002118 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002119 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2120 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002121 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002122 -C "Processing of the Certificate handshake message failed" \
2123 -c "Ciphersuite is TLS-"
2124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002125run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002126 "$O_SRV -key data_files/server2.key \
2127 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002128 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002129 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2130 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002131 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002132 -c "Processing of the Certificate handshake message failed" \
2133 -C "Ciphersuite is TLS-"
2134
Manuel Pégourié-Gonnarde16b62c2015-04-17 16:55:53 +02002135run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2136 "$O_SRV -key data_files/server2.key \
2137 -cert data_files/server2.ku-ke.crt" \
2138 "$P_CLI debug_level=1 auth_mode=optional \
2139 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2140 0 \
2141 -c "bad certificate (usage extensions)" \
2142 -C "Processing of the Certificate handshake message failed" \
2143 -c "Ciphersuite is TLS-" \
2144 -c "! Usage does not match the keyUsage extension"
2145
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002146run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002147 "$O_SRV -key data_files/server2.key \
2148 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002149 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002150 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2151 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002152 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002153 -C "Processing of the Certificate handshake message failed" \
2154 -c "Ciphersuite is TLS-"
2155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002156run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002157 "$O_SRV -key data_files/server2.key \
2158 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002159 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002160 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2161 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002162 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002163 -c "Processing of the Certificate handshake message failed" \
2164 -C "Ciphersuite is TLS-"
2165
Manuel Pégourié-Gonnarde16b62c2015-04-17 16:55:53 +02002166run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2167 "$O_SRV -key data_files/server2.key \
2168 -cert data_files/server2.ku-ds.crt" \
2169 "$P_CLI debug_level=1 auth_mode=optional \
2170 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2171 0 \
2172 -c "bad certificate (usage extensions)" \
2173 -C "Processing of the Certificate handshake message failed" \
2174 -c "Ciphersuite is TLS-" \
2175 -c "! Usage does not match the keyUsage extension"
2176
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002177# Tests for keyUsage in leaf certificates, part 3:
2178# server-side checking of client cert
2179
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002180run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002181 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002182 "$O_CLI -key data_files/server2.key \
2183 -cert data_files/server2.ku-ds.crt" \
2184 0 \
2185 -S "bad certificate (usage extensions)" \
2186 -S "Processing of the Certificate handshake message failed"
2187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002188run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002189 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002190 "$O_CLI -key data_files/server2.key \
2191 -cert data_files/server2.ku-ke.crt" \
2192 0 \
2193 -s "bad certificate (usage extensions)" \
2194 -S "Processing of the Certificate handshake message failed"
2195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002196run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002197 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002198 "$O_CLI -key data_files/server2.key \
2199 -cert data_files/server2.ku-ke.crt" \
2200 1 \
2201 -s "bad certificate (usage extensions)" \
2202 -s "Processing of the Certificate handshake message failed"
2203
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002204run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002205 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002206 "$O_CLI -key data_files/server5.key \
2207 -cert data_files/server5.ku-ds.crt" \
2208 0 \
2209 -S "bad certificate (usage extensions)" \
2210 -S "Processing of the Certificate handshake message failed"
2211
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002212run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002213 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002214 "$O_CLI -key data_files/server5.key \
2215 -cert data_files/server5.ku-ka.crt" \
2216 0 \
2217 -s "bad certificate (usage extensions)" \
2218 -S "Processing of the Certificate handshake message failed"
2219
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002220# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2221
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002222run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002223 "$P_SRV key_file=data_files/server5.key \
2224 crt_file=data_files/server5.eku-srv.crt" \
2225 "$P_CLI" \
2226 0
2227
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002228run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002229 "$P_SRV key_file=data_files/server5.key \
2230 crt_file=data_files/server5.eku-srv.crt" \
2231 "$P_CLI" \
2232 0
2233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002234run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002235 "$P_SRV key_file=data_files/server5.key \
2236 crt_file=data_files/server5.eku-cs_any.crt" \
2237 "$P_CLI" \
2238 0
2239
2240# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002241run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002242 "$P_SRV psk=abc123 key_file=data_files/server5.key \
2243 crt_file=data_files/server5.eku-cli.crt" \
2244 "$P_CLI psk=badbad" \
2245 1
2246
2247# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2248
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002249run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002250 "$O_SRV -key data_files/server5.key \
2251 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002252 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002253 0 \
2254 -C "bad certificate (usage extensions)" \
2255 -C "Processing of the Certificate handshake message failed" \
2256 -c "Ciphersuite is TLS-"
2257
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002258run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002259 "$O_SRV -key data_files/server5.key \
2260 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002261 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002262 0 \
2263 -C "bad certificate (usage extensions)" \
2264 -C "Processing of the Certificate handshake message failed" \
2265 -c "Ciphersuite is TLS-"
2266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002267run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002268 "$O_SRV -key data_files/server5.key \
2269 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002270 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002271 0 \
2272 -C "bad certificate (usage extensions)" \
2273 -C "Processing of the Certificate handshake message failed" \
2274 -c "Ciphersuite is TLS-"
2275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002276run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002277 "$O_SRV -key data_files/server5.key \
2278 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002279 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002280 1 \
2281 -c "bad certificate (usage extensions)" \
2282 -c "Processing of the Certificate handshake message failed" \
2283 -C "Ciphersuite is TLS-"
2284
2285# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002287run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002288 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002289 "$O_CLI -key data_files/server5.key \
2290 -cert data_files/server5.eku-cli.crt" \
2291 0 \
2292 -S "bad certificate (usage extensions)" \
2293 -S "Processing of the Certificate handshake message failed"
2294
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002295run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002296 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002297 "$O_CLI -key data_files/server5.key \
2298 -cert data_files/server5.eku-srv_cli.crt" \
2299 0 \
2300 -S "bad certificate (usage extensions)" \
2301 -S "Processing of the Certificate handshake message failed"
2302
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002303run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002304 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002305 "$O_CLI -key data_files/server5.key \
2306 -cert data_files/server5.eku-cs_any.crt" \
2307 0 \
2308 -S "bad certificate (usage extensions)" \
2309 -S "Processing of the Certificate handshake message failed"
2310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002311run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002312 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002313 "$O_CLI -key data_files/server5.key \
2314 -cert data_files/server5.eku-cs.crt" \
2315 0 \
2316 -s "bad certificate (usage extensions)" \
2317 -S "Processing of the Certificate handshake message failed"
2318
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002319run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002320 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002321 "$O_CLI -key data_files/server5.key \
2322 -cert data_files/server5.eku-cs.crt" \
2323 1 \
2324 -s "bad certificate (usage extensions)" \
2325 -s "Processing of the Certificate handshake message failed"
2326
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002327# Tests for DHM parameters loading
2328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002329run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002330 "$P_SRV" \
2331 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2332 debug_level=3" \
2333 0 \
2334 -c "value of 'DHM: P ' (2048 bits)" \
2335 -c "value of 'DHM: G ' (2048 bits)"
2336
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002337run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002338 "$P_SRV dhm_file=data_files/dhparams.pem" \
2339 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2340 debug_level=3" \
2341 0 \
2342 -c "value of 'DHM: P ' (1024 bits)" \
2343 -c "value of 'DHM: G ' (2 bits)"
2344
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002345# Tests for PSK callback
2346
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002347run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002348 "$P_SRV psk=abc123 psk_identity=foo" \
2349 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2350 psk_identity=foo psk=abc123" \
2351 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002352 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002353 -S "SSL - Unknown identity received" \
2354 -S "SSL - Verification of the message MAC failed"
2355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002356run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002357 "$P_SRV" \
2358 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2359 psk_identity=foo psk=abc123" \
2360 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002361 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002362 -S "SSL - Unknown identity received" \
2363 -S "SSL - Verification of the message MAC failed"
2364
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002365run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002366 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2367 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2368 psk_identity=foo psk=abc123" \
2369 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002370 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002371 -s "SSL - Unknown identity received" \
2372 -S "SSL - Verification of the message MAC failed"
2373
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002374run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002375 "$P_SRV psk_list=abc,dead,def,beef" \
2376 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2377 psk_identity=abc psk=dead" \
2378 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002379 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002380 -S "SSL - Unknown identity received" \
2381 -S "SSL - Verification of the message MAC failed"
2382
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002383run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002384 "$P_SRV psk_list=abc,dead,def,beef" \
2385 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2386 psk_identity=def psk=beef" \
2387 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002388 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002389 -S "SSL - Unknown identity received" \
2390 -S "SSL - Verification of the message MAC failed"
2391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002392run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002393 "$P_SRV psk_list=abc,dead,def,beef" \
2394 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2395 psk_identity=ghi psk=beef" \
2396 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002397 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002398 -s "SSL - Unknown identity received" \
2399 -S "SSL - Verification of the message MAC failed"
2400
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002401run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002402 "$P_SRV psk_list=abc,dead,def,beef" \
2403 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2404 psk_identity=abc psk=beef" \
2405 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002406 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002407 -S "SSL - Unknown identity received" \
2408 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002409
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002410# Tests for ciphersuites per version
2411
Janos Follath4dfecab2016-03-14 13:40:43 +00002412requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002413run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002414 "$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 +02002415 "$P_CLI force_version=ssl3" \
2416 0 \
2417 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2418
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002419run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002420 "$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" \
2421 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002422 0 \
2423 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2424
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002425run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002426 "$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" \
2427 "$P_CLI force_version=tls1_1" \
2428 0 \
2429 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002431run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002432 "$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" \
2433 "$P_CLI force_version=tls1_2" \
2434 0 \
2435 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2436
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002437# Tests for ssl_get_bytes_avail()
2438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002439run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002440 "$P_SRV" \
2441 "$P_CLI request_size=100" \
2442 0 \
2443 -s "Read from client: 100 bytes read$"
2444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002445run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002446 "$P_SRV" \
2447 "$P_CLI request_size=500" \
2448 0 \
2449 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002450
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002451# Tests for small packets
2452
Janos Follath4dfecab2016-03-14 13:40:43 +00002453requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002454run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002455 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002456 "$P_CLI request_size=1 force_version=ssl3 \
2457 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2458 0 \
2459 -s "Read from client: 1 bytes read"
2460
Janos Follath4dfecab2016-03-14 13:40:43 +00002461requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002462run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002463 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002464 "$P_CLI request_size=1 force_version=ssl3 \
2465 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2466 0 \
2467 -s "Read from client: 1 bytes read"
2468
2469run_test "Small packet TLS 1.0 BlockCipher" \
2470 "$P_SRV" \
2471 "$P_CLI request_size=1 force_version=tls1 \
2472 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2473 0 \
2474 -s "Read from client: 1 bytes read"
2475
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002476run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2477 "$P_SRV" \
2478 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2479 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2480 0 \
2481 -s "Read from client: 1 bytes read"
2482
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002483run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2484 "$P_SRV" \
2485 "$P_CLI request_size=1 force_version=tls1 \
2486 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2487 trunc_hmac=1" \
2488 0 \
2489 -s "Read from client: 1 bytes read"
2490
2491run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002492 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002493 "$P_CLI request_size=1 force_version=tls1 \
2494 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2495 trunc_hmac=1" \
2496 0 \
2497 -s "Read from client: 1 bytes read"
2498
2499run_test "Small packet TLS 1.1 BlockCipher" \
2500 "$P_SRV" \
2501 "$P_CLI request_size=1 force_version=tls1_1 \
2502 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2503 0 \
2504 -s "Read from client: 1 bytes read"
2505
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002506run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2507 "$P_SRV" \
2508 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2509 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2510 0 \
2511 -s "Read from client: 1 bytes read"
2512
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002513run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002514 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002515 "$P_CLI request_size=1 force_version=tls1_1 \
2516 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2517 0 \
2518 -s "Read from client: 1 bytes read"
2519
2520run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2521 "$P_SRV" \
2522 "$P_CLI request_size=1 force_version=tls1_1 \
2523 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2524 trunc_hmac=1" \
2525 0 \
2526 -s "Read from client: 1 bytes read"
2527
2528run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002529 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002530 "$P_CLI request_size=1 force_version=tls1_1 \
2531 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2532 trunc_hmac=1" \
2533 0 \
2534 -s "Read from client: 1 bytes read"
2535
2536run_test "Small packet TLS 1.2 BlockCipher" \
2537 "$P_SRV" \
2538 "$P_CLI request_size=1 force_version=tls1_2 \
2539 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2540 0 \
2541 -s "Read from client: 1 bytes read"
2542
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002543run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2544 "$P_SRV" \
2545 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2546 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2547 0 \
2548 -s "Read from client: 1 bytes read"
2549
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002550run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2551 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002552 "$P_CLI request_size=1 force_version=tls1_2 \
2553 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002554 0 \
2555 -s "Read from client: 1 bytes read"
2556
2557run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2558 "$P_SRV" \
2559 "$P_CLI request_size=1 force_version=tls1_2 \
2560 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2561 trunc_hmac=1" \
2562 0 \
2563 -s "Read from client: 1 bytes read"
2564
2565run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002566 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002567 "$P_CLI request_size=1 force_version=tls1_2 \
2568 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2569 0 \
2570 -s "Read from client: 1 bytes read"
2571
2572run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002573 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002574 "$P_CLI request_size=1 force_version=tls1_2 \
2575 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2576 trunc_hmac=1" \
2577 0 \
2578 -s "Read from client: 1 bytes read"
2579
2580run_test "Small packet TLS 1.2 AEAD" \
2581 "$P_SRV" \
2582 "$P_CLI request_size=1 force_version=tls1_2 \
2583 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2584 0 \
2585 -s "Read from client: 1 bytes read"
2586
2587run_test "Small packet TLS 1.2 AEAD shorter tag" \
2588 "$P_SRV" \
2589 "$P_CLI request_size=1 force_version=tls1_2 \
2590 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2591 0 \
2592 -s "Read from client: 1 bytes read"
2593
Janos Follath8abaa8b2016-05-06 13:48:23 +01002594# A test for extensions in SSLv3
2595
Hanno Becker6fd6d242017-05-25 17:51:31 +01002596requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Janos Follath8abaa8b2016-05-06 13:48:23 +01002597run_test "SSLv3 with extensions, server side" \
2598 "$P_SRV min_version=ssl3 debug_level=3" \
2599 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2600 0 \
2601 -S "dumping 'client hello extensions'" \
2602 -S "server hello, total extension length:"
2603
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002604# Test for large packets
2605
Janos Follath4dfecab2016-03-14 13:40:43 +00002606requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002607run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002608 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002609 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002610 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2611 0 \
2612 -s "Read from client: 16384 bytes read"
2613
Janos Follath4dfecab2016-03-14 13:40:43 +00002614requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002615run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002616 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002617 "$P_CLI request_size=16384 force_version=ssl3 \
2618 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2619 0 \
2620 -s "Read from client: 16384 bytes read"
2621
2622run_test "Large packet TLS 1.0 BlockCipher" \
2623 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002624 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002625 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2626 0 \
2627 -s "Read from client: 16384 bytes read"
2628
2629run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2630 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002631 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002632 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2633 trunc_hmac=1" \
2634 0 \
2635 -s "Read from client: 16384 bytes read"
2636
2637run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002638 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002639 "$P_CLI request_size=16384 force_version=tls1 \
2640 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2641 trunc_hmac=1" \
2642 0 \
2643 -s "Read from client: 16384 bytes read"
2644
2645run_test "Large packet TLS 1.1 BlockCipher" \
2646 "$P_SRV" \
2647 "$P_CLI request_size=16384 force_version=tls1_1 \
2648 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2649 0 \
2650 -s "Read from client: 16384 bytes read"
2651
2652run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002653 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002654 "$P_CLI request_size=16384 force_version=tls1_1 \
2655 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2656 0 \
2657 -s "Read from client: 16384 bytes read"
2658
2659run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2660 "$P_SRV" \
2661 "$P_CLI request_size=16384 force_version=tls1_1 \
2662 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2663 trunc_hmac=1" \
2664 0 \
2665 -s "Read from client: 16384 bytes read"
2666
2667run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002668 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002669 "$P_CLI request_size=16384 force_version=tls1_1 \
2670 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2671 trunc_hmac=1" \
2672 0 \
2673 -s "Read from client: 16384 bytes read"
2674
2675run_test "Large packet TLS 1.2 BlockCipher" \
2676 "$P_SRV" \
2677 "$P_CLI request_size=16384 force_version=tls1_2 \
2678 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2679 0 \
2680 -s "Read from client: 16384 bytes read"
2681
2682run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2683 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002684 "$P_CLI request_size=16384 force_version=tls1_2 \
2685 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002686 0 \
2687 -s "Read from client: 16384 bytes read"
2688
2689run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2690 "$P_SRV" \
2691 "$P_CLI request_size=16384 force_version=tls1_2 \
2692 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2693 trunc_hmac=1" \
2694 0 \
2695 -s "Read from client: 16384 bytes read"
2696
2697run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002698 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002699 "$P_CLI request_size=16384 force_version=tls1_2 \
2700 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2701 0 \
2702 -s "Read from client: 16384 bytes read"
2703
2704run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002705 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002706 "$P_CLI request_size=16384 force_version=tls1_2 \
2707 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2708 trunc_hmac=1" \
2709 0 \
2710 -s "Read from client: 16384 bytes read"
2711
2712run_test "Large packet TLS 1.2 AEAD" \
2713 "$P_SRV" \
2714 "$P_CLI request_size=16384 force_version=tls1_2 \
2715 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2716 0 \
2717 -s "Read from client: 16384 bytes read"
2718
2719run_test "Large packet TLS 1.2 AEAD shorter tag" \
2720 "$P_SRV" \
2721 "$P_CLI request_size=16384 force_version=tls1_2 \
2722 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2723 0 \
2724 -s "Read from client: 16384 bytes read"
2725
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002726# Final report
2727
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002728echo "------------------------------------------------------------------------"
2729
2730if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002731 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002732else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002733 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002734fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002735PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002736echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002737
2738exit $FAILS