blob: 40d47b862f732d0447f5688c5b3c3f5595bd9a89 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
9# Assumes all options are compiled in.
10
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010016: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020017: ${GNUTLS_CLI:=gnutls-cli}
18: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskinea1cf6c82017-05-17 14:50:38 +020019: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010020
Manuel Pégourié-Gonnard6461f362015-06-29 16:20:13 +020021O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010022O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020023G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010024G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskinea1cf6c82017-05-17 14:50:38 +020025TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010026
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010027TESTS=0
28FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020029SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010030
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020031CONFIG_H='../include/polarssl/config.h'
32
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010033MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010034FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020035EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010036
37print_usage() {
38 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010039 printf " -h|--help\tPrint this help.\n"
40 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
41 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
42 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010043}
44
45get_options() {
46 while [ $# -gt 0 ]; do
47 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010048 -f|--filter)
49 shift; FILTER=$1
50 ;;
51 -e|--exclude)
52 shift; EXCLUDE=$1
53 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010054 -m|--memcheck)
55 MEMCHECK=1
56 ;;
57 -h|--help)
58 print_usage
59 exit 0
60 ;;
61 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020062 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010063 print_usage
64 exit 1
65 ;;
66 esac
67 shift
68 done
69}
70
Janos Follath4dfecab2016-03-14 13:40:43 +000071# skip next test if the flag is not enabled in config.h
72requires_config_enabled() {
73 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
74 SKIP_NEXT="YES"
75 fi
76}
77
Hanno Beckere8f3d932017-10-25 09:38:00 +010078# skip next test if the flag is enabled in config.h
79requires_config_disabled() {
80 if grep "^#define $1" $CONFIG_H > /dev/null; then
81 SKIP_NEXT="YES"
82 fi
83}
84
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020085# skip next test if OpenSSL can't send SSLv2 ClientHello
86requires_openssl_with_sslv2() {
87 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020088 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020089 OPENSSL_HAS_SSL2="YES"
90 else
91 OPENSSL_HAS_SSL2="NO"
92 fi
93 fi
94 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
95 SKIP_NEXT="YES"
96 fi
97}
98
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020099# skip next test if OpenSSL doesn't support FALLBACK_SCSV
100requires_openssl_with_fallback_scsv() {
101 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
102 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
103 then
104 OPENSSL_HAS_FBSCSV="YES"
105 else
106 OPENSSL_HAS_FBSCSV="NO"
107 fi
108 fi
109 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
110 SKIP_NEXT="YES"
111 fi
112}
113
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200114# skip next test if GnuTLS isn't available
115requires_gnutls() {
116 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
117 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
118 GNUTLS_AVAILABLE="YES"
119 else
120 GNUTLS_AVAILABLE="NO"
121 fi
122 fi
123 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
124 SKIP_NEXT="YES"
125 fi
126}
127
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100128# print_name <name>
129print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100130 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200131 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100132 for i in `seq 1 $LEN`; do printf '.'; done
133 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100134
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200135 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100136}
137
138# fail <message>
139fail() {
140 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100141 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100142
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200143 mv $SRV_OUT o-srv-${TESTS}.log
144 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100145 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100146
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200147 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
148 echo " ! server output:"
149 cat o-srv-${TESTS}.log
150 echo " ! ============================================================"
151 echo " ! client output:"
152 cat o-cli-${TESTS}.log
153 fi
154
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200155 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100156}
157
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100158# is_polar <cmd_line>
159is_polar() {
160 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
161}
162
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100163# has_mem_err <log_file_name>
164has_mem_err() {
165 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
166 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
167 then
168 return 1 # false: does not have errors
169 else
170 return 0 # true: has errors
171 fi
172}
173
Gilles Peskine80f6be72017-12-19 13:35:10 +0100174# Wait for process $2 to be listening on port $1
175if type lsof >/dev/null 2>/dev/null; then
176 wait_server_start() {
177 START_TIME=$(date +%s)
178 while ! lsof -a -n -b -i "TCP:$1" -p "$2" >/dev/null 2>/dev/null; do
179 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
180 echo "SERVERSTART TIMEOUT"
181 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
182 break
183 fi
184 # Linux and *BSD support decimal arguments to sleep. On other
185 # OSes this may be a tight loop.
186 sleep 0.1 2>/dev/null || true
Manuel Pégourié-Gonnard84690c32015-08-04 20:34:39 +0200187 done
Gilles Peskine80f6be72017-12-19 13:35:10 +0100188 }
189else
Gilles Peskine0870c212018-01-08 12:38:15 +0100190 echo "Warning: lsof not available, wait_server_start = sleep $START_DELAY"
Gilles Peskine80f6be72017-12-19 13:35:10 +0100191 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200192 sleep "$START_DELAY"
Gilles Peskine80f6be72017-12-19 13:35:10 +0100193 }
194fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200195
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=$!
Gilles Peskine80f6be72017-12-19 13:35:10 +0100257 wait_server_start "$PORT" "$SRV_PID"
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é-Gonnard1bca5ef2018-01-22 10:22:09 +0100413# We use somewhat arbitrary delays for tests:
414# - how long do we wait for the server to start (when lsof not available)?
415# - how long do we allow for the client to finish?
416# (not to check performance, just to avoid waiting indefinitely)
417# Things are slower with valgrind, so give extra time here.
418#
419# Note: without lsof, there is a trade-off between the running time of this
420# script and the risk of spurious errors because we didn't wait long enough.
421# The watchdog delay on the other hand doesn't affect normal running time of
422# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200423if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard1bca5ef2018-01-22 10:22:09 +0100424 START_DELAY=6
425 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200426else
Manuel Pégourié-Gonnard1bca5ef2018-01-22 10:22:09 +0100427 START_DELAY=2
428 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200429fi
430
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200431# Pick a "unique" port in the range 10000-19999.
432PORT="0000$$"
Manuel Pégourié-Gonnarddc370e42015-01-22 10:24:59 +0000433PORT="1$( printf $PORT | tail -c 4 )"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200434
435# fix commands to use this port
436P_SRV="$P_SRV server_port=$PORT"
437P_CLI="$P_CLI server_port=$PORT"
438O_SRV="$O_SRV -accept $PORT"
439O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200440G_SRV="$G_SRV -p $PORT"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100441G_CLI="$G_CLI -p $PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200442
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200443# Also pick a unique name for intermediate files
444SRV_OUT="srv_out.$$"
445CLI_OUT="cli_out.$$"
446SESSION="session.$$"
447
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200448SKIP_NEXT="NO"
449
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100450trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100451
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200452# Basic test
453
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200454# Checks that:
455# - things work with all ciphersuites active (used with config-full in all.sh)
456# - the expected (highest security) parameters are selected
457# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200458run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200459 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200460 "$P_CLI" \
461 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200462 -s "Protocol is TLSv1.2" \
463 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
464 -s "client hello v3, signature_algorithm ext: 6" \
465 -s "ECDHE curve: secp521r1" \
466 -S "error" \
467 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200468
Simon Butcher696f92e2016-10-13 14:13:17 +0100469# Test for uniqueness of IVs in AEAD ciphersuites
470run_test "Unique IV in GCM" \
471 "$P_SRV exchanges=20 debug_level=4" \
472 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
473 0 \
474 -u "IV used" \
475 -U "IV used"
476
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100477# Tests for rc4 option
478
479run_test "RC4: server disabled, client enabled" \
480 "$P_SRV" \
481 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
482 1 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100483 -s "SSL - None of the common ciphersuites is usable"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100484
485run_test "RC4: server enabled, client disabled" \
486 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
487 "$P_CLI" \
488 1 \
489 -s "SSL - The server has no ciphersuites in common"
490
491run_test "RC4: both enabled" \
492 "$P_SRV arc4=1" \
493 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
494 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100495 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100496 -S "SSL - The server has no ciphersuites in common"
497
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100498# Test for SSLv2 ClientHello
499
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: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100502 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100503 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100504 0 \
505 -S "parse client hello v2" \
506 -S "ssl_handshake returned"
507
508# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200509requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200510run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200511 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100512 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100513 0 \
514 -s "parse client hello v2" \
515 -S "ssl_handshake returned"
516
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100517# Tests for Truncated HMAC extension
518
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100519run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200520 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100521 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100522 0 \
Hanno Becker251bab52017-11-20 10:30:08 +0000523 -s "dumping 'expected mac' (20 bytes)" \
524 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100525
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100526run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200527 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100528 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
529 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100530 0 \
Hanno Becker251bab52017-11-20 10:30:08 +0000531 -s "dumping 'expected mac' (20 bytes)" \
532 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100533
534run_test "Truncated HMAC: client enabled, server default" \
535 "$P_SRV debug_level=4" \
536 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
537 trunc_hmac=1" \
538 0 \
Hanno Becker251bab52017-11-20 10:30:08 +0000539 -S "dumping 'expected mac' (20 bytes)" \
540 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100541
542run_test "Truncated HMAC: client enabled, server disabled" \
543 "$P_SRV debug_level=4 trunc_hmac=0" \
544 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
545 trunc_hmac=1" \
546 0 \
Hanno Becker251bab52017-11-20 10:30:08 +0000547 -s "dumping 'expected mac' (20 bytes)" \
548 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100549
550run_test "Truncated HMAC: client enabled, server enabled" \
551 "$P_SRV debug_level=4 trunc_hmac=1" \
552 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
553 trunc_hmac=1" \
554 0 \
Hanno Becker251bab52017-11-20 10:30:08 +0000555 -S "dumping 'expected mac' (20 bytes)" \
556 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100557
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100558# Tests for Encrypt-then-MAC extension
559
560run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100561 "$P_SRV debug_level=3 \
562 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100563 "$P_CLI debug_level=3" \
564 0 \
565 -c "client hello, adding encrypt_then_mac extension" \
566 -s "found encrypt then mac extension" \
567 -s "server hello, adding encrypt then mac extension" \
568 -c "found encrypt_then_mac extension" \
569 -c "using encrypt then mac" \
570 -s "using encrypt then mac"
571
572run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100573 "$P_SRV debug_level=3 etm=0 \
574 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100575 "$P_CLI debug_level=3 etm=1" \
576 0 \
577 -c "client hello, adding encrypt_then_mac extension" \
578 -s "found encrypt then mac extension" \
579 -S "server hello, adding encrypt then mac extension" \
580 -C "found encrypt_then_mac extension" \
581 -C "using encrypt then mac" \
582 -S "using encrypt then mac"
583
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100584run_test "Encrypt then MAC: client enabled, aead cipher" \
585 "$P_SRV debug_level=3 etm=1 \
586 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
587 "$P_CLI debug_level=3 etm=1" \
588 0 \
589 -c "client hello, adding encrypt_then_mac extension" \
590 -s "found encrypt then mac extension" \
591 -S "server hello, adding encrypt then mac extension" \
592 -C "found encrypt_then_mac extension" \
593 -C "using encrypt then mac" \
594 -S "using encrypt then mac"
595
596run_test "Encrypt then MAC: client enabled, stream cipher" \
597 "$P_SRV debug_level=3 etm=1 \
598 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100599 "$P_CLI debug_level=3 etm=1 arc4=1" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100600 0 \
601 -c "client hello, adding encrypt_then_mac extension" \
602 -s "found encrypt then mac extension" \
603 -S "server hello, adding encrypt then mac extension" \
604 -C "found encrypt_then_mac extension" \
605 -C "using encrypt then mac" \
606 -S "using encrypt then mac"
607
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100608run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100609 "$P_SRV debug_level=3 etm=1 \
610 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100611 "$P_CLI debug_level=3 etm=0" \
612 0 \
613 -C "client hello, adding encrypt_then_mac extension" \
614 -S "found encrypt then mac extension" \
615 -S "server hello, adding encrypt then mac extension" \
616 -C "found encrypt_then_mac extension" \
617 -C "using encrypt then mac" \
618 -S "using encrypt then mac"
619
Janos Follath4dfecab2016-03-14 13:40:43 +0000620requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100621run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100622 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100623 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100624 "$P_CLI debug_level=3 force_version=ssl3" \
625 0 \
626 -C "client hello, adding encrypt_then_mac extension" \
627 -S "found encrypt then mac extension" \
628 -S "server hello, adding encrypt then mac extension" \
629 -C "found encrypt_then_mac extension" \
630 -C "using encrypt then mac" \
631 -S "using encrypt then mac"
632
Janos Follath4dfecab2016-03-14 13:40:43 +0000633requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100634run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100635 "$P_SRV debug_level=3 force_version=ssl3 \
636 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100637 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100638 0 \
639 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath8abaa8b2016-05-06 13:48:23 +0100640 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100641 -S "server hello, adding encrypt then mac extension" \
642 -C "found encrypt_then_mac extension" \
643 -C "using encrypt then mac" \
644 -S "using encrypt then mac"
645
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200646# Tests for Extended Master Secret extension
647
648run_test "Extended Master Secret: default" \
649 "$P_SRV debug_level=3" \
650 "$P_CLI debug_level=3" \
651 0 \
652 -c "client hello, adding extended_master_secret extension" \
653 -s "found extended master secret extension" \
654 -s "server hello, adding extended master secret extension" \
655 -c "found extended_master_secret extension" \
656 -c "using extended master secret" \
657 -s "using extended master secret"
658
659run_test "Extended Master Secret: client enabled, server disabled" \
660 "$P_SRV debug_level=3 extended_ms=0" \
661 "$P_CLI debug_level=3 extended_ms=1" \
662 0 \
663 -c "client hello, adding extended_master_secret extension" \
664 -s "found extended master secret extension" \
665 -S "server hello, adding extended master secret extension" \
666 -C "found extended_master_secret extension" \
667 -C "using extended master secret" \
668 -S "using extended master secret"
669
670run_test "Extended Master Secret: client disabled, server enabled" \
671 "$P_SRV debug_level=3 extended_ms=1" \
672 "$P_CLI debug_level=3 extended_ms=0" \
673 0 \
674 -C "client hello, adding extended_master_secret extension" \
675 -S "found extended master secret extension" \
676 -S "server hello, adding extended master secret extension" \
677 -C "found extended_master_secret extension" \
678 -C "using extended master secret" \
679 -S "using extended master secret"
680
Janos Follath4dfecab2016-03-14 13:40:43 +0000681requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200682run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100683 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200684 "$P_CLI debug_level=3 force_version=ssl3" \
685 0 \
686 -C "client hello, adding extended_master_secret extension" \
687 -S "found extended master secret extension" \
688 -S "server hello, adding extended master secret extension" \
689 -C "found extended_master_secret extension" \
690 -C "using extended master secret" \
691 -S "using extended master secret"
692
Janos Follath4dfecab2016-03-14 13:40:43 +0000693requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200694run_test "Extended Master Secret: client enabled, server SSLv3" \
695 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100696 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200697 0 \
698 -c "client hello, adding extended_master_secret extension" \
Janos Follath8abaa8b2016-05-06 13:48:23 +0100699 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200700 -S "server hello, adding extended master secret extension" \
701 -C "found extended_master_secret extension" \
702 -C "using extended master secret" \
703 -S "using extended master secret"
704
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200705# Tests for FALLBACK_SCSV
706
707run_test "Fallback SCSV: default" \
708 "$P_SRV" \
709 "$P_CLI debug_level=3 force_version=tls1_1" \
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: explicitly disabled" \
717 "$P_SRV" \
718 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
719 0 \
720 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200721 -S "received FALLBACK_SCSV" \
722 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200723 -C "is a fatal alert message (msg 86)"
724
725run_test "Fallback SCSV: enabled" \
726 "$P_SRV" \
727 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200728 1 \
729 -c "adding FALLBACK_SCSV" \
730 -s "received FALLBACK_SCSV" \
731 -s "inapropriate fallback" \
732 -c "is a fatal alert message (msg 86)"
733
734run_test "Fallback SCSV: enabled, max version" \
735 "$P_SRV" \
736 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200737 0 \
738 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200739 -s "received FALLBACK_SCSV" \
740 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200741 -C "is a fatal alert message (msg 86)"
742
743requires_openssl_with_fallback_scsv
744run_test "Fallback SCSV: default, openssl server" \
745 "$O_SRV" \
746 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
747 0 \
748 -C "adding FALLBACK_SCSV" \
749 -C "is a fatal alert message (msg 86)"
750
751requires_openssl_with_fallback_scsv
752run_test "Fallback SCSV: enabled, openssl server" \
753 "$O_SRV" \
754 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
755 1 \
756 -c "adding FALLBACK_SCSV" \
757 -c "is a fatal alert message (msg 86)"
758
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200759requires_openssl_with_fallback_scsv
760run_test "Fallback SCSV: disabled, openssl client" \
761 "$P_SRV" \
762 "$O_CLI -tls1_1" \
763 0 \
764 -S "received FALLBACK_SCSV" \
765 -S "inapropriate fallback"
766
767requires_openssl_with_fallback_scsv
768run_test "Fallback SCSV: enabled, openssl client" \
769 "$P_SRV" \
770 "$O_CLI -tls1_1 -fallback_scsv" \
771 1 \
772 -s "received FALLBACK_SCSV" \
773 -s "inapropriate fallback"
774
775requires_openssl_with_fallback_scsv
776run_test "Fallback SCSV: enabled, max version, openssl client" \
777 "$P_SRV" \
778 "$O_CLI -fallback_scsv" \
779 0 \
780 -s "received FALLBACK_SCSV" \
781 -S "inapropriate fallback"
782
Gilles Peskinea1cf6c82017-05-17 14:50:38 +0200783## ClientHello generated with
784## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
785## then manually twiddling the ciphersuite list.
786## The ClientHello content is spelled out below as a hex string as
787## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
788## The expected response is an inappropriate_fallback alert.
789requires_openssl_with_fallback_scsv
790run_test "Fallback SCSV: beginning of list" \
791 "$P_SRV debug_level=2" \
792 "$TCP_CLIENT localhost $PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
793 0 \
794 -s "received FALLBACK_SCSV" \
795 -s "inapropriate fallback"
796
797requires_openssl_with_fallback_scsv
798run_test "Fallback SCSV: end of list" \
799 "$P_SRV debug_level=2" \
800 "$TCP_CLIENT localhost $PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
801 0 \
802 -s "received FALLBACK_SCSV" \
803 -s "inapropriate fallback"
804
805## Here the expected response is a valid ServerHello prefix, up to the random.
806requires_openssl_with_fallback_scsv
807run_test "Fallback SCSV: not in list" \
808 "$P_SRV debug_level=2" \
809 "$TCP_CLIENT localhost $PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
810 0 \
811 -S "received FALLBACK_SCSV" \
812 -S "inapropriate fallback"
813
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100814# Tests for CBC 1/n-1 record splitting
815
816run_test "CBC Record splitting: TLS 1.2, no splitting" \
817 "$P_SRV" \
818 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
819 request_size=123 force_version=tls1_2" \
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.1, no splitting" \
826 "$P_SRV" \
827 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
828 request_size=123 force_version=tls1_1" \
829 0 \
830 -s "Read from client: 123 bytes read" \
831 -S "Read from client: 1 bytes read" \
832 -S "122 bytes read"
833
834run_test "CBC Record splitting: TLS 1.0, splitting" \
835 "$P_SRV" \
836 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
837 request_size=123 force_version=tls1" \
838 0 \
839 -S "Read from client: 123 bytes read" \
840 -s "Read from client: 1 bytes read" \
841 -s "122 bytes read"
842
Janos Follath4dfecab2016-03-14 13:40:43 +0000843requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100844run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100845 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100846 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
847 request_size=123 force_version=ssl3" \
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 RC4, no splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100854 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100855 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
856 request_size=123 force_version=tls1" \
857 0 \
858 -s "Read from client: 123 bytes read" \
859 -S "Read from client: 1 bytes read" \
860 -S "122 bytes read"
861
862run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
863 "$P_SRV" \
864 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
865 request_size=123 force_version=tls1 recsplit=0" \
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é-Gonnarda852cf42015-01-13 20:56:15 +0100871run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
872 "$P_SRV nbio=2" \
873 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
874 request_size=123 force_version=tls1" \
875 0 \
876 -S "Read from client: 123 bytes read" \
877 -s "Read from client: 1 bytes read" \
878 -s "122 bytes read"
879
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100880# Tests for Session Tickets
881
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200882run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200883 "$P_SRV debug_level=3 tickets=1" \
884 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100885 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100886 -c "client hello, adding session ticket extension" \
887 -s "found session ticket extension" \
888 -s "server hello, adding session ticket extension" \
889 -c "found session_ticket extension" \
890 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100891 -S "session successfully restored from cache" \
892 -s "session successfully restored from ticket" \
893 -s "a session has been resumed" \
894 -c "a session has been resumed"
895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200896run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200897 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
898 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100899 0 \
900 -c "client hello, adding session ticket extension" \
901 -s "found session ticket extension" \
902 -s "server hello, adding session ticket extension" \
903 -c "found session_ticket extension" \
904 -c "parse new session ticket" \
905 -S "session successfully restored from cache" \
906 -s "session successfully restored from ticket" \
907 -s "a session has been resumed" \
908 -c "a session has been resumed"
909
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200910run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200911 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
912 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100913 0 \
914 -c "client hello, adding session ticket extension" \
915 -s "found session ticket extension" \
916 -s "server hello, adding session ticket extension" \
917 -c "found session_ticket extension" \
918 -c "parse new session ticket" \
919 -S "session successfully restored from cache" \
920 -S "session successfully restored from ticket" \
921 -S "a session has been resumed" \
922 -C "a session has been resumed"
923
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200924run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100925 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200926 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100927 0 \
928 -c "client hello, adding session ticket extension" \
929 -c "found session_ticket extension" \
930 -c "parse new session ticket" \
931 -c "a session has been resumed"
932
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200933run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200934 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200935 "( $O_CLI -sess_out $SESSION; \
936 $O_CLI -sess_in $SESSION; \
937 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100938 0 \
939 -s "found session ticket extension" \
940 -s "server hello, adding session ticket extension" \
941 -S "session successfully restored from cache" \
942 -s "session successfully restored from ticket" \
943 -s "a session has been resumed"
944
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100945# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100946
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200947run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200948 "$P_SRV debug_level=3 tickets=0" \
949 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100950 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100951 -c "client hello, adding session ticket extension" \
952 -s "found session ticket extension" \
953 -S "server hello, adding session ticket extension" \
954 -C "found session_ticket extension" \
955 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100956 -s "session successfully restored from cache" \
957 -S "session successfully restored from ticket" \
958 -s "a session has been resumed" \
959 -c "a session has been resumed"
960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200961run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200962 "$P_SRV debug_level=3 tickets=1" \
963 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100964 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100965 -C "client hello, adding session ticket extension" \
966 -S "found session ticket extension" \
967 -S "server hello, adding session ticket extension" \
968 -C "found session_ticket extension" \
969 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100970 -s "session successfully restored from cache" \
971 -S "session successfully restored from ticket" \
972 -s "a session has been resumed" \
973 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200975run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200976 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
977 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100978 0 \
979 -S "session successfully restored from cache" \
980 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100981 -S "a session has been resumed" \
982 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100983
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200984run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200985 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
986 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
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: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200994 "$P_SRV debug_level=3 tickets=0" \
995 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
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: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001003 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1004 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +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: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001012 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1013 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001014 0 \
1015 -s "session successfully restored from cache" \
1016 -S "session successfully restored from ticket" \
1017 -s "a session has been resumed" \
1018 -c "a session has been resumed"
1019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001020run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001021 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001022 "( $O_CLI -sess_out $SESSION; \
1023 $O_CLI -sess_in $SESSION; \
1024 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001025 0 \
1026 -s "found session ticket extension" \
1027 -S "server hello, adding session ticket extension" \
1028 -s "session successfully restored from cache" \
1029 -S "session successfully restored from ticket" \
1030 -s "a session has been resumed"
1031
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001032run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001033 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001034 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001035 0 \
1036 -C "found session_ticket extension" \
1037 -C "parse new session ticket" \
1038 -c "a session has been resumed"
1039
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001040# Tests for Max Fragment Length extension
1041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001042run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001043 "$P_SRV debug_level=3" \
1044 "$P_CLI debug_level=3" \
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 client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001052 "$P_SRV debug_level=3" \
1053 "$P_CLI debug_level=3 max_frag_len=4096" \
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"
1059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001060run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001061 "$P_SRV debug_level=3 max_frag_len=4096" \
1062 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001063 0 \
1064 -C "client hello, adding max_fragment_length extension" \
1065 -S "found max fragment length extension" \
1066 -S "server hello, max_fragment_length extension" \
1067 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001069requires_gnutls
1070run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001071 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001072 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001073 0 \
1074 -c "client hello, adding max_fragment_length extension" \
1075 -c "found max_fragment_length extension"
1076
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001077# Tests for renegotiation
1078
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001079run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001080 "$P_SRV debug_level=3 exchanges=2" \
1081 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001082 0 \
1083 -C "client hello, adding renegotiation extension" \
1084 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1085 -S "found renegotiation extension" \
1086 -s "server hello, secure renegotiation extension" \
1087 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001088 -C "=> renegotiate" \
1089 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001090 -S "write hello request"
1091
Hanno Beckere8f3d932017-10-25 09:38:00 +01001092requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001093run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001094 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
1095 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001096 0 \
1097 -c "client hello, adding renegotiation extension" \
1098 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1099 -s "found renegotiation extension" \
1100 -s "server hello, secure renegotiation extension" \
1101 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001102 -c "=> renegotiate" \
1103 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001104 -S "write hello request"
1105
Hanno Beckere8f3d932017-10-25 09:38:00 +01001106requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001107run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001108 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1109 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001110 0 \
1111 -c "client hello, adding renegotiation extension" \
1112 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1113 -s "found renegotiation extension" \
1114 -s "server hello, secure renegotiation extension" \
1115 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001116 -c "=> renegotiate" \
1117 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001118 -s "write hello request"
1119
Janos Follathea111c52017-10-05 12:29:42 +01001120# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1121# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1122# algorithm stronger than SHA-1 is enabled in config.h
Hanno Beckere8f3d932017-10-25 09:38:00 +01001123requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Janos Follathea111c52017-10-05 12:29:42 +01001124run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1125 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1126 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1127 0 \
1128 -c "client hello, adding renegotiation extension" \
1129 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1130 -s "found renegotiation extension" \
1131 -s "server hello, secure renegotiation extension" \
1132 -c "found renegotiation extension" \
1133 -c "=> renegotiate" \
1134 -s "=> renegotiate" \
1135 -S "write hello request" \
1136 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1137
1138# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1139# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1140# algorithm stronger than SHA-1 is enabled in config.h
Hanno Beckere8f3d932017-10-25 09:38:00 +01001141requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Janos Follathea111c52017-10-05 12:29:42 +01001142run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1143 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1144 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1145 0 \
1146 -c "client hello, adding renegotiation extension" \
1147 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1148 -s "found renegotiation extension" \
1149 -s "server hello, secure renegotiation extension" \
1150 -c "found renegotiation extension" \
1151 -c "=> renegotiate" \
1152 -s "=> renegotiate" \
1153 -s "write hello request" \
1154 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1155
Hanno Beckere8f3d932017-10-25 09:38:00 +01001156requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001157run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001158 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1159 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001160 0 \
1161 -c "client hello, adding renegotiation extension" \
1162 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1163 -s "found renegotiation extension" \
1164 -s "server hello, secure renegotiation extension" \
1165 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001166 -c "=> renegotiate" \
1167 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001168 -s "write hello request"
1169
Hanno Beckere8f3d932017-10-25 09:38:00 +01001170requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001171run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001172 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1173 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001174 1 \
1175 -c "client hello, adding renegotiation extension" \
1176 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1177 -S "found renegotiation extension" \
1178 -s "server hello, secure renegotiation extension" \
1179 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001180 -c "=> renegotiate" \
1181 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001182 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001183 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001184 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001185
Hanno Beckere8f3d932017-10-25 09:38:00 +01001186requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001187run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001188 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1189 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001190 0 \
1191 -C "client hello, adding renegotiation extension" \
1192 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1193 -S "found renegotiation extension" \
1194 -s "server hello, secure renegotiation extension" \
1195 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001196 -C "=> renegotiate" \
1197 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001198 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001199 -S "SSL - An unexpected message was received from our peer" \
1200 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001201
Hanno Beckere8f3d932017-10-25 09:38:00 +01001202requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001203run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001204 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001205 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001206 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001207 0 \
1208 -C "client hello, adding renegotiation extension" \
1209 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1210 -S "found renegotiation extension" \
1211 -s "server hello, secure renegotiation extension" \
1212 -c "found renegotiation extension" \
1213 -C "=> renegotiate" \
1214 -S "=> renegotiate" \
1215 -s "write hello request" \
1216 -S "SSL - An unexpected message was received from our peer" \
1217 -S "failed"
1218
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001219# delay 2 for 1 alert record + 1 application data record
Hanno Beckere8f3d932017-10-25 09:38:00 +01001220requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001221run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001222 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001223 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001224 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001225 0 \
1226 -C "client hello, adding renegotiation extension" \
1227 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1228 -S "found renegotiation extension" \
1229 -s "server hello, secure renegotiation extension" \
1230 -c "found renegotiation extension" \
1231 -C "=> renegotiate" \
1232 -S "=> renegotiate" \
1233 -s "write hello request" \
1234 -S "SSL - An unexpected message was received from our peer" \
1235 -S "failed"
1236
Hanno Beckere8f3d932017-10-25 09:38:00 +01001237requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001238run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001239 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001240 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001241 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001242 0 \
1243 -C "client hello, adding renegotiation extension" \
1244 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1245 -S "found renegotiation extension" \
1246 -s "server hello, secure renegotiation extension" \
1247 -c "found renegotiation extension" \
1248 -C "=> renegotiate" \
1249 -S "=> renegotiate" \
1250 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001251 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001252
Hanno Beckere8f3d932017-10-25 09:38:00 +01001253requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001254run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001255 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001256 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001258 0 \
1259 -c "client hello, adding renegotiation extension" \
1260 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1261 -s "found renegotiation extension" \
1262 -s "server hello, secure renegotiation extension" \
1263 -c "found renegotiation extension" \
1264 -c "=> renegotiate" \
1265 -s "=> renegotiate" \
1266 -s "write hello request" \
1267 -S "SSL - An unexpected message was received from our peer" \
1268 -S "failed"
1269
Hanno Beckere8f3d932017-10-25 09:38:00 +01001270requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001271run_test "Renegotiation: periodic, just below period" \
1272 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1273 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1274 0 \
1275 -C "client hello, adding renegotiation extension" \
1276 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1277 -S "found renegotiation extension" \
1278 -s "server hello, secure renegotiation extension" \
1279 -c "found renegotiation extension" \
1280 -S "record counter limit reached: renegotiate" \
1281 -C "=> renegotiate" \
1282 -S "=> renegotiate" \
1283 -S "write hello request" \
1284 -S "SSL - An unexpected message was received from our peer" \
1285 -S "failed"
1286
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001287# one extra exchange to be able to complete renego
Hanno Beckere8f3d932017-10-25 09:38:00 +01001288requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001289run_test "Renegotiation: periodic, just above period" \
1290 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001291 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001292 0 \
1293 -c "client hello, adding renegotiation extension" \
1294 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1295 -s "found renegotiation extension" \
1296 -s "server hello, secure renegotiation extension" \
1297 -c "found renegotiation extension" \
1298 -s "record counter limit reached: renegotiate" \
1299 -c "=> renegotiate" \
1300 -s "=> renegotiate" \
1301 -s "write hello request" \
1302 -S "SSL - An unexpected message was received from our peer" \
1303 -S "failed"
1304
Hanno Beckere8f3d932017-10-25 09:38:00 +01001305requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001306run_test "Renegotiation: periodic, two times period" \
1307 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001308 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001309 0 \
1310 -c "client hello, adding renegotiation extension" \
1311 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1312 -s "found renegotiation extension" \
1313 -s "server hello, secure renegotiation extension" \
1314 -c "found renegotiation extension" \
1315 -s "record counter limit reached: renegotiate" \
1316 -c "=> renegotiate" \
1317 -s "=> renegotiate" \
1318 -s "write hello request" \
1319 -S "SSL - An unexpected message was received from our peer" \
1320 -S "failed"
1321
Hanno Beckere8f3d932017-10-25 09:38:00 +01001322requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001323run_test "Renegotiation: periodic, above period, disabled" \
1324 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1325 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1326 0 \
1327 -C "client hello, adding renegotiation extension" \
1328 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1329 -S "found renegotiation extension" \
1330 -s "server hello, secure renegotiation extension" \
1331 -c "found renegotiation extension" \
1332 -S "record counter limit reached: renegotiate" \
1333 -C "=> renegotiate" \
1334 -S "=> renegotiate" \
1335 -S "write hello request" \
1336 -S "SSL - An unexpected message was received from our peer" \
1337 -S "failed"
1338
Hanno Beckere8f3d932017-10-25 09:38:00 +01001339requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001340run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001341 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1342 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001343 0 \
1344 -c "client hello, adding renegotiation extension" \
1345 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1346 -s "found renegotiation extension" \
1347 -s "server hello, secure renegotiation extension" \
1348 -c "found renegotiation extension" \
1349 -c "=> renegotiate" \
1350 -s "=> renegotiate" \
1351 -S "write hello request"
1352
Hanno Beckere8f3d932017-10-25 09:38:00 +01001353requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001354run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001355 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1356 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001357 0 \
1358 -c "client hello, adding renegotiation extension" \
1359 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1360 -s "found renegotiation extension" \
1361 -s "server hello, secure renegotiation extension" \
1362 -c "found renegotiation extension" \
1363 -c "=> renegotiate" \
1364 -s "=> renegotiate" \
1365 -s "write hello request"
1366
Hanno Beckere8f3d932017-10-25 09:38:00 +01001367requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001368run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001369 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001370 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001371 0 \
1372 -c "client hello, adding renegotiation extension" \
1373 -c "found renegotiation extension" \
1374 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001375 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001376 -C "error" \
1377 -c "HTTP/1.0 200 [Oo][Kk]"
1378
Paul Bakker539d9722015-02-08 16:18:35 +01001379requires_gnutls
Hanno Beckere8f3d932017-10-25 09:38:00 +01001380requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001381run_test "Renegotiation: gnutls server strict, client-initiated" \
1382 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001383 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001384 0 \
1385 -c "client hello, adding renegotiation extension" \
1386 -c "found renegotiation extension" \
1387 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001388 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001389 -C "error" \
1390 -c "HTTP/1.0 200 [Oo][Kk]"
1391
Paul Bakker539d9722015-02-08 16:18:35 +01001392requires_gnutls
Hanno Beckere8f3d932017-10-25 09:38:00 +01001393requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001394run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1395 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1396 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1397 1 \
1398 -c "client hello, adding renegotiation extension" \
1399 -C "found renegotiation extension" \
1400 -c "=> renegotiate" \
1401 -c "ssl_handshake() returned" \
1402 -c "error" \
1403 -C "HTTP/1.0 200 [Oo][Kk]"
1404
Paul Bakker539d9722015-02-08 16:18:35 +01001405requires_gnutls
Hanno Beckere8f3d932017-10-25 09:38:00 +01001406requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001407run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1408 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1409 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1410 allow_legacy=0" \
1411 1 \
1412 -c "client hello, adding renegotiation extension" \
1413 -C "found renegotiation extension" \
1414 -c "=> renegotiate" \
1415 -c "ssl_handshake() returned" \
1416 -c "error" \
1417 -C "HTTP/1.0 200 [Oo][Kk]"
1418
Paul Bakker539d9722015-02-08 16:18:35 +01001419requires_gnutls
Hanno Beckere8f3d932017-10-25 09:38:00 +01001420requires_config_disabled POLARSSL_SSL_DISABLE_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001421run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1422 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1423 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1424 allow_legacy=1" \
1425 0 \
1426 -c "client hello, adding renegotiation extension" \
1427 -C "found renegotiation extension" \
1428 -c "=> renegotiate" \
1429 -C "ssl_hanshake() returned" \
1430 -C "error" \
1431 -c "HTTP/1.0 200 [Oo][Kk]"
1432
1433# Test for the "secure renegotation" extension only (no actual renegotiation)
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 strict, client default" \
1437 "$G_SRV --priority=NORMAL:%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 default" \
1446 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1447 "$P_CLI debug_level=3" \
1448 0 \
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 server unsafe, client break legacy" \
1455 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1456 "$P_CLI debug_level=3 allow_legacy=-1" \
1457 1 \
1458 -C "found renegotiation extension" \
1459 -c "error" \
1460 -C "HTTP/1.0 200 [Oo][Kk]"
1461
Paul Bakker539d9722015-02-08 16:18:35 +01001462requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001463run_test "Renego ext: gnutls client strict, server default" \
1464 "$P_SRV debug_level=3" \
1465 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1466 0 \
1467 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1468 -s "server hello, secure renegotiation extension"
1469
Paul Bakker539d9722015-02-08 16:18:35 +01001470requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001471run_test "Renego ext: gnutls client unsafe, server default" \
1472 "$P_SRV debug_level=3" \
1473 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1474 0 \
1475 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1476 -S "server hello, secure renegotiation extension"
1477
Paul Bakker539d9722015-02-08 16:18:35 +01001478requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001479run_test "Renego ext: gnutls client unsafe, server break legacy" \
1480 "$P_SRV debug_level=3 allow_legacy=-1" \
1481 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1482 1 \
1483 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1484 -S "server hello, secure renegotiation extension"
1485
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001486# Tests for auth_mode
1487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001488run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001489 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001490 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001491 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001492 1 \
1493 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001494 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001495 -c "! ssl_handshake returned" \
1496 -c "X509 - Certificate verification failed"
1497
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001498run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001499 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001500 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001501 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001502 0 \
1503 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001504 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001505 -C "! ssl_handshake returned" \
1506 -C "X509 - Certificate verification failed"
1507
Hanno Becker6fd6d242017-05-25 17:51:31 +01001508run_test "Authentication: server goodcert, client optional, no trusted CA" \
1509 "$P_SRV" \
1510 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1511 0 \
1512 -c "x509_verify_cert() returned" \
1513 -c "! The certificate is not correctly signed by the trusted CA" \
1514 -c "! Certificate verification flags"\
1515 -C "! ssl_handshake returned" \
1516 -C "X509 - Certificate verification failed" \
1517 -C "SSL - No CA Chain is set, but required to operate"
1518
1519run_test "Authentication: server goodcert, client required, no trusted CA" \
1520 "$P_SRV" \
1521 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1522 1 \
1523 -c "x509_verify_cert() returned" \
1524 -c "! The certificate is not correctly signed by the trusted CA" \
1525 -c "! Certificate verification flags"\
1526 -c "! ssl_handshake returned" \
1527 -c "SSL - No CA Chain is set, but required to operate"
1528
1529# The purpose of the next two tests is to test the client's behaviour when receiving a server
1530# certificate with an unsupported elliptic curve. This should usually not happen because
1531# the client informs the server about the supported curves - it does, though, in the
1532# corner case of a static ECDH suite, because the server doesn't check the curve on that
1533# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1534# different means to have the server ignoring the client's supported curve list.
1535
1536requires_config_enabled POLARSSL_SSL_SET_CURVES
1537run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1538 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1539 crt_file=data_files/server5.ku-ka.crt" \
1540 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1541 1 \
1542 -c "bad certificate (EC key curve)"\
1543 -c "! Certificate verification flags"\
1544 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1545
1546requires_config_enabled POLARSSL_SSL_SET_CURVES
1547run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1548 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1549 crt_file=data_files/server5.ku-ka.crt" \
1550 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1551 1 \
1552 -c "bad certificate (EC key curve)"\
1553 -c "! Certificate verification flags"\
1554 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001556run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001557 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001558 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001559 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001560 0 \
1561 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001562 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001563 -C "! ssl_handshake returned" \
1564 -C "X509 - Certificate verification failed"
1565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001566run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001567 "$P_SRV debug_level=3 auth_mode=required" \
1568 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001569 key_file=data_files/server5.key" \
1570 1 \
1571 -S "skip write certificate request" \
1572 -C "skip parse certificate request" \
1573 -c "got a certificate request" \
1574 -C "skip write certificate" \
1575 -C "skip write certificate verify" \
1576 -S "skip parse certificate verify" \
1577 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001578 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001579 -s "! ssl_handshake returned" \
1580 -c "! ssl_handshake returned" \
1581 -s "X509 - Certificate verification failed"
1582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001583run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001584 "$P_SRV debug_level=3 auth_mode=optional" \
1585 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001586 key_file=data_files/server5.key" \
1587 0 \
1588 -S "skip write certificate request" \
1589 -C "skip parse certificate request" \
1590 -c "got a certificate request" \
1591 -C "skip write certificate" \
1592 -C "skip write certificate verify" \
1593 -S "skip parse certificate verify" \
1594 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001595 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001596 -S "! ssl_handshake returned" \
1597 -C "! ssl_handshake returned" \
1598 -S "X509 - Certificate verification failed"
1599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001600run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001601 "$P_SRV debug_level=3 auth_mode=none" \
1602 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001603 key_file=data_files/server5.key" \
1604 0 \
1605 -s "skip write certificate request" \
1606 -C "skip parse certificate request" \
1607 -c "got no certificate request" \
1608 -c "skip write certificate" \
1609 -c "skip write certificate verify" \
1610 -s "skip parse certificate verify" \
1611 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001612 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001613 -S "! ssl_handshake returned" \
1614 -C "! ssl_handshake returned" \
1615 -S "X509 - Certificate verification failed"
1616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001617run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001618 "$P_SRV debug_level=3 auth_mode=optional" \
1619 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001620 0 \
1621 -S "skip write certificate request" \
1622 -C "skip parse certificate request" \
1623 -c "got a certificate request" \
1624 -C "skip write certificate$" \
1625 -C "got no certificate to send" \
1626 -S "SSLv3 client has no certificate" \
1627 -c "skip write certificate verify" \
1628 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001629 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001630 -S "! ssl_handshake returned" \
1631 -C "! ssl_handshake returned" \
1632 -S "X509 - Certificate verification failed"
1633
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001634run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001635 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001636 "$O_CLI" \
1637 0 \
1638 -S "skip write certificate request" \
1639 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001640 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001641 -S "! ssl_handshake returned" \
1642 -S "X509 - Certificate verification failed"
1643
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001644run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001645 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001646 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001647 0 \
1648 -C "skip parse certificate request" \
1649 -c "got a certificate request" \
1650 -C "skip write certificate$" \
1651 -c "skip write certificate verify" \
1652 -C "! ssl_handshake returned"
1653
Janos Follath4dfecab2016-03-14 13:40:43 +00001654requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001655run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001656 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001657 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001658 0 \
1659 -S "skip write certificate request" \
1660 -C "skip parse certificate request" \
1661 -c "got a certificate request" \
1662 -C "skip write certificate$" \
1663 -c "skip write certificate verify" \
1664 -c "got no certificate to send" \
1665 -s "SSLv3 client has no certificate" \
1666 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001667 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001668 -S "! ssl_handshake returned" \
1669 -C "! ssl_handshake returned" \
1670 -S "X509 - Certificate verification failed"
1671
Manuel Pégourié-Gonnarda68d5912017-07-10 11:31:43 +02001672run_test "Authentication: server max_int chain, client default" \
1673 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
1674 key_file=data_files/dir-maxpath/09.key" \
1675 "$P_CLI server_name=CA09 server_addr=127.0.0.1 \
1676 ca_file=data_files/dir-maxpath/00.crt" \
1677 0 \
1678 -C "X509 - A fatal error occured"
1679
1680run_test "Authentication: server max_int+1 chain, client default" \
1681 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
1682 key_file=data_files/dir-maxpath/10.key" \
1683 "$P_CLI server_name=CA10 server_addr=127.0.0.1 \
1684 ca_file=data_files/dir-maxpath/00.crt" \
1685 1 \
1686 -c "X509 - A fatal error occured"
1687
1688run_test "Authentication: server max_int+1 chain, client optional" \
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 \
1692 ca_file=data_files/dir-maxpath/00.crt \
1693 auth_mode=optional" \
1694 1 \
1695 -c "X509 - A fatal error occured"
1696
1697run_test "Authentication: server max_int+1 chain, client none" \
1698 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
1699 key_file=data_files/dir-maxpath/10.key" \
1700 "$P_CLI server_name=CA10 server_addr=127.0.0.1 ca_file=data_files/dir-maxpath/00.crt \
1701 auth_mode=none" \
1702 0 \
1703 -C "X509 - A fatal error occured"
1704
1705run_test "Authentication: client max_int+1 chain, server none" \
1706 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=none" \
1707 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
1708 key_file=data_files/dir-maxpath/10.key" \
1709 0 \
1710 -S "X509 - A fatal error occured"
1711
1712run_test "Authentication: client max_int+1 chain, server optional" \
1713 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
1714 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
1715 key_file=data_files/dir-maxpath/10.key" \
1716 1 \
1717 -s "X509 - A fatal error occured"
1718
1719run_test "Authentication: client max_int+1 chain, server required" \
1720 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
1721 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
1722 key_file=data_files/dir-maxpath/10.key" \
1723 1 \
1724 -s "X509 - A fatal error occured"
1725
1726run_test "Authentication: client max_int chain, server required" \
1727 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
1728 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
1729 key_file=data_files/dir-maxpath/09.key" \
1730 0 \
1731 -S "X509 - A fatal error occured"
1732
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001733# Tests for certificate selection based on SHA verson
1734
1735run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1736 "$P_SRV crt_file=data_files/server5.crt \
1737 key_file=data_files/server5.key \
1738 crt_file2=data_files/server5-sha1.crt \
1739 key_file2=data_files/server5.key" \
1740 "$P_CLI force_version=tls1_2" \
1741 0 \
1742 -c "signed using.*ECDSA with SHA256" \
1743 -C "signed using.*ECDSA with SHA1"
1744
1745run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1746 "$P_SRV crt_file=data_files/server5.crt \
1747 key_file=data_files/server5.key \
1748 crt_file2=data_files/server5-sha1.crt \
1749 key_file2=data_files/server5.key" \
1750 "$P_CLI force_version=tls1_1" \
1751 0 \
1752 -C "signed using.*ECDSA with SHA256" \
1753 -c "signed using.*ECDSA with SHA1"
1754
1755run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1756 "$P_SRV crt_file=data_files/server5.crt \
1757 key_file=data_files/server5.key \
1758 crt_file2=data_files/server5-sha1.crt \
1759 key_file2=data_files/server5.key" \
1760 "$P_CLI force_version=tls1" \
1761 0 \
1762 -C "signed using.*ECDSA with SHA256" \
1763 -c "signed using.*ECDSA with SHA1"
1764
1765run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1766 "$P_SRV crt_file=data_files/server5.crt \
1767 key_file=data_files/server5.key \
1768 crt_file2=data_files/server6.crt \
1769 key_file2=data_files/server6.key" \
1770 "$P_CLI force_version=tls1_1" \
1771 0 \
1772 -c "serial number.*09" \
1773 -c "signed using.*ECDSA with SHA256" \
1774 -C "signed using.*ECDSA with SHA1"
1775
1776run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1777 "$P_SRV crt_file=data_files/server6.crt \
1778 key_file=data_files/server6.key \
1779 crt_file2=data_files/server5.crt \
1780 key_file2=data_files/server5.key" \
1781 "$P_CLI force_version=tls1_1" \
1782 0 \
1783 -c "serial number.*0A" \
1784 -c "signed using.*ECDSA with SHA256" \
1785 -C "signed using.*ECDSA with SHA1"
1786
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001787# tests for SNI
1788
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001789run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001790 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001791 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001792 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001793 server_name=localhost" \
1794 0 \
1795 -S "parse ServerName extension" \
1796 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1797 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001799run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001800 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001801 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001802 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 +01001803 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001804 server_name=localhost" \
1805 0 \
1806 -s "parse ServerName extension" \
1807 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1808 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1809
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001810run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001811 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001812 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001813 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 +01001814 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001815 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001816 0 \
1817 -s "parse ServerName extension" \
1818 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001819 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001820
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001821run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001822 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001823 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001824 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 +01001825 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001826 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001827 1 \
1828 -s "parse ServerName extension" \
1829 -s "ssl_sni_wrapper() returned" \
1830 -s "ssl_handshake returned" \
1831 -c "ssl_handshake returned" \
1832 -c "SSL - A fatal alert message was received from our peer"
1833
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001834# Tests for non-blocking I/O: exercise a variety of handshake flows
1835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001836run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001837 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1838 "$P_CLI nbio=2 tickets=0" \
1839 0 \
1840 -S "ssl_handshake returned" \
1841 -C "ssl_handshake returned" \
1842 -c "Read from server: .* bytes read"
1843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001844run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001845 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1846 "$P_CLI nbio=2 tickets=0" \
1847 0 \
1848 -S "ssl_handshake returned" \
1849 -C "ssl_handshake returned" \
1850 -c "Read from server: .* bytes read"
1851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001852run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001853 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1854 "$P_CLI nbio=2 tickets=1" \
1855 0 \
1856 -S "ssl_handshake returned" \
1857 -C "ssl_handshake returned" \
1858 -c "Read from server: .* bytes read"
1859
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001860run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001861 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1862 "$P_CLI nbio=2 tickets=1" \
1863 0 \
1864 -S "ssl_handshake returned" \
1865 -C "ssl_handshake returned" \
1866 -c "Read from server: .* bytes read"
1867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001868run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001869 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1870 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1871 0 \
1872 -S "ssl_handshake returned" \
1873 -C "ssl_handshake returned" \
1874 -c "Read from server: .* bytes read"
1875
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001876run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001877 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1878 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1879 0 \
1880 -S "ssl_handshake returned" \
1881 -C "ssl_handshake returned" \
1882 -c "Read from server: .* bytes read"
1883
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001884run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001885 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1886 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1887 0 \
1888 -S "ssl_handshake returned" \
1889 -C "ssl_handshake returned" \
1890 -c "Read from server: .* bytes read"
1891
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001892# Tests for version negotiation
1893
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001894run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001895 "$P_SRV" \
1896 "$P_CLI" \
1897 0 \
1898 -S "ssl_handshake returned" \
1899 -C "ssl_handshake returned" \
1900 -s "Protocol is TLSv1.2" \
1901 -c "Protocol is TLSv1.2"
1902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001903run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001904 "$P_SRV" \
1905 "$P_CLI max_version=tls1_1" \
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: 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" \
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+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001922 "$P_SRV max_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 max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001931 "$P_SRV min_version=tls1_1" \
1932 "$P_CLI max_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.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001940 "$P_SRV max_version=tls1_1" \
1941 "$P_CLI min_version=tls1_1" \
1942 0 \
1943 -S "ssl_handshake returned" \
1944 -C "ssl_handshake returned" \
1945 -s "Protocol is TLSv1.1" \
1946 -c "Protocol is TLSv1.1"
1947
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001948run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001949 "$P_SRV max_version=tls1_1" \
1950 "$P_CLI min_version=tls1_2" \
1951 1 \
1952 -s "ssl_handshake returned" \
1953 -c "ssl_handshake returned" \
1954 -c "SSL - Handshake protocol not within min/max boundaries"
1955
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001956run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001957 "$P_SRV min_version=tls1_2" \
1958 "$P_CLI max_version=tls1_1" \
1959 1 \
1960 -s "ssl_handshake returned" \
1961 -c "ssl_handshake returned" \
1962 -s "SSL - Handshake protocol not within min/max boundaries"
1963
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001964# Tests for ALPN extension
1965
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001966if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001968run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001969 "$P_SRV debug_level=3" \
1970 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001971 0 \
1972 -C "client hello, adding alpn extension" \
1973 -S "found alpn extension" \
1974 -C "got an alert message, type: \\[2:120]" \
1975 -S "server hello, adding alpn extension" \
1976 -C "found alpn extension " \
1977 -C "Application Layer Protocol is" \
1978 -S "Application Layer Protocol is"
1979
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001980run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001981 "$P_SRV debug_level=3" \
1982 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001983 0 \
1984 -c "client hello, adding alpn extension" \
1985 -s "found alpn extension" \
1986 -C "got an alert message, type: \\[2:120]" \
1987 -S "server hello, adding alpn extension" \
1988 -C "found alpn extension " \
1989 -c "Application Layer Protocol is (none)" \
1990 -S "Application Layer Protocol is"
1991
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001992run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001993 "$P_SRV debug_level=3 alpn=abc,1234" \
1994 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001995 0 \
1996 -C "client hello, adding alpn extension" \
1997 -S "found alpn extension" \
1998 -C "got an alert message, type: \\[2:120]" \
1999 -S "server hello, adding alpn extension" \
2000 -C "found alpn extension " \
2001 -C "Application Layer Protocol is" \
2002 -s "Application Layer Protocol is (none)"
2003
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002004run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002005 "$P_SRV debug_level=3 alpn=abc,1234" \
2006 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002007 0 \
2008 -c "client hello, adding alpn extension" \
2009 -s "found alpn extension" \
2010 -C "got an alert message, type: \\[2:120]" \
2011 -s "server hello, adding alpn extension" \
2012 -c "found alpn extension" \
2013 -c "Application Layer Protocol is abc" \
2014 -s "Application Layer Protocol is abc"
2015
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002016run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002017 "$P_SRV debug_level=3 alpn=abc,1234" \
2018 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002019 0 \
2020 -c "client hello, adding alpn extension" \
2021 -s "found alpn extension" \
2022 -C "got an alert message, type: \\[2:120]" \
2023 -s "server hello, adding alpn extension" \
2024 -c "found alpn extension" \
2025 -c "Application Layer Protocol is abc" \
2026 -s "Application Layer Protocol is abc"
2027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002028run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002029 "$P_SRV debug_level=3 alpn=abc,1234" \
2030 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002031 0 \
2032 -c "client hello, adding alpn extension" \
2033 -s "found alpn extension" \
2034 -C "got an alert message, type: \\[2:120]" \
2035 -s "server hello, adding alpn extension" \
2036 -c "found alpn extension" \
2037 -c "Application Layer Protocol is 1234" \
2038 -s "Application Layer Protocol is 1234"
2039
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002040run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002041 "$P_SRV debug_level=3 alpn=abc,123" \
2042 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002043 1 \
2044 -c "client hello, adding alpn extension" \
2045 -s "found alpn extension" \
2046 -c "got an alert message, type: \\[2:120]" \
2047 -S "server hello, adding alpn extension" \
2048 -C "found alpn extension" \
2049 -C "Application Layer Protocol is 1234" \
2050 -S "Application Layer Protocol is 1234"
2051
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002052fi
2053
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002054# Tests for keyUsage in leaf certificates, part 1:
2055# server-side certificate/suite selection
2056
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002057run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002058 "$P_SRV key_file=data_files/server2.key \
2059 crt_file=data_files/server2.ku-ds.crt" \
2060 "$P_CLI" \
2061 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002062 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002063
2064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002065run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002066 "$P_SRV key_file=data_files/server2.key \
2067 crt_file=data_files/server2.ku-ke.crt" \
2068 "$P_CLI" \
2069 0 \
2070 -c "Ciphersuite is TLS-RSA-WITH-"
2071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002072run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002073 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002074 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002075 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002076 1 \
2077 -C "Ciphersuite is "
2078
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002079run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002080 "$P_SRV key_file=data_files/server5.key \
2081 crt_file=data_files/server5.ku-ds.crt" \
2082 "$P_CLI" \
2083 0 \
2084 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2085
2086
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002087run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002088 "$P_SRV key_file=data_files/server5.key \
2089 crt_file=data_files/server5.ku-ka.crt" \
2090 "$P_CLI" \
2091 0 \
2092 -c "Ciphersuite is TLS-ECDH-"
2093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002094run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002095 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002096 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002097 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002098 1 \
2099 -C "Ciphersuite is "
2100
2101# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002102# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002104run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002105 "$O_SRV -key data_files/server2.key \
2106 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002107 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002108 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2109 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002110 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002111 -C "Processing of the Certificate handshake message failed" \
2112 -c "Ciphersuite is TLS-"
2113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002114run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002115 "$O_SRV -key data_files/server2.key \
2116 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002117 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002118 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2119 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002120 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002121 -C "Processing of the Certificate handshake message failed" \
2122 -c "Ciphersuite is TLS-"
2123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002124run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002125 "$O_SRV -key data_files/server2.key \
2126 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002127 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002128 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2129 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002130 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002131 -C "Processing of the Certificate handshake message failed" \
2132 -c "Ciphersuite is TLS-"
2133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002134run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002135 "$O_SRV -key data_files/server2.key \
2136 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002137 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002138 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2139 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002140 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002141 -c "Processing of the Certificate handshake message failed" \
2142 -C "Ciphersuite is TLS-"
2143
Manuel Pégourié-Gonnarde16b62c2015-04-17 16:55:53 +02002144run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2145 "$O_SRV -key data_files/server2.key \
2146 -cert data_files/server2.ku-ke.crt" \
2147 "$P_CLI debug_level=1 auth_mode=optional \
2148 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2149 0 \
2150 -c "bad certificate (usage extensions)" \
2151 -C "Processing of the Certificate handshake message failed" \
2152 -c "Ciphersuite is TLS-" \
2153 -c "! Usage does not match the keyUsage extension"
2154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002155run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002156 "$O_SRV -key data_files/server2.key \
2157 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002158 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002159 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2160 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002161 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002162 -C "Processing of the Certificate handshake message failed" \
2163 -c "Ciphersuite is TLS-"
2164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002165run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002166 "$O_SRV -key data_files/server2.key \
2167 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002168 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002169 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2170 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002171 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002172 -c "Processing of the Certificate handshake message failed" \
2173 -C "Ciphersuite is TLS-"
2174
Manuel Pégourié-Gonnarde16b62c2015-04-17 16:55:53 +02002175run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2176 "$O_SRV -key data_files/server2.key \
2177 -cert data_files/server2.ku-ds.crt" \
2178 "$P_CLI debug_level=1 auth_mode=optional \
2179 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2180 0 \
2181 -c "bad certificate (usage extensions)" \
2182 -C "Processing of the Certificate handshake message failed" \
2183 -c "Ciphersuite is TLS-" \
2184 -c "! Usage does not match the keyUsage extension"
2185
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002186# Tests for keyUsage in leaf certificates, part 3:
2187# server-side checking of client cert
2188
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002189run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002190 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002191 "$O_CLI -key data_files/server2.key \
2192 -cert data_files/server2.ku-ds.crt" \
2193 0 \
2194 -S "bad certificate (usage extensions)" \
2195 -S "Processing of the Certificate handshake message failed"
2196
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002197run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002198 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002199 "$O_CLI -key data_files/server2.key \
2200 -cert data_files/server2.ku-ke.crt" \
2201 0 \
2202 -s "bad certificate (usage extensions)" \
2203 -S "Processing of the Certificate handshake message failed"
2204
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002205run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002206 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002207 "$O_CLI -key data_files/server2.key \
2208 -cert data_files/server2.ku-ke.crt" \
2209 1 \
2210 -s "bad certificate (usage extensions)" \
2211 -s "Processing of the Certificate handshake message failed"
2212
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002213run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002214 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002215 "$O_CLI -key data_files/server5.key \
2216 -cert data_files/server5.ku-ds.crt" \
2217 0 \
2218 -S "bad certificate (usage extensions)" \
2219 -S "Processing of the Certificate handshake message failed"
2220
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002221run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002222 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002223 "$O_CLI -key data_files/server5.key \
2224 -cert data_files/server5.ku-ka.crt" \
2225 0 \
2226 -s "bad certificate (usage extensions)" \
2227 -S "Processing of the Certificate handshake message failed"
2228
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002229# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2230
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002231run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002232 "$P_SRV key_file=data_files/server5.key \
2233 crt_file=data_files/server5.eku-srv.crt" \
2234 "$P_CLI" \
2235 0
2236
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002237run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002238 "$P_SRV key_file=data_files/server5.key \
2239 crt_file=data_files/server5.eku-srv.crt" \
2240 "$P_CLI" \
2241 0
2242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002243run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002244 "$P_SRV key_file=data_files/server5.key \
2245 crt_file=data_files/server5.eku-cs_any.crt" \
2246 "$P_CLI" \
2247 0
2248
2249# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002250run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002251 "$P_SRV psk=abc123 key_file=data_files/server5.key \
2252 crt_file=data_files/server5.eku-cli.crt" \
2253 "$P_CLI psk=badbad" \
2254 1
2255
2256# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2257
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002258run_test "extKeyUsage cli: serverAuth -> 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.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: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002268 "$O_SRV -key data_files/server5.key \
2269 -cert data_files/server5.eku-srv_cli.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,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002277 "$O_SRV -key data_files/server5.key \
2278 -cert data_files/server5.eku-cs_any.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 0 \
2281 -C "bad certificate (usage extensions)" \
2282 -C "Processing of the Certificate handshake message failed" \
2283 -c "Ciphersuite is TLS-"
2284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002285run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002286 "$O_SRV -key data_files/server5.key \
2287 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002288 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002289 1 \
2290 -c "bad certificate (usage extensions)" \
2291 -c "Processing of the Certificate handshake message failed" \
2292 -C "Ciphersuite is TLS-"
2293
2294# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002296run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002297 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002298 "$O_CLI -key data_files/server5.key \
2299 -cert data_files/server5.eku-cli.crt" \
2300 0 \
2301 -S "bad certificate (usage extensions)" \
2302 -S "Processing of the Certificate handshake message failed"
2303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002304run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002305 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002306 "$O_CLI -key data_files/server5.key \
2307 -cert data_files/server5.eku-srv_cli.crt" \
2308 0 \
2309 -S "bad certificate (usage extensions)" \
2310 -S "Processing of the Certificate handshake message failed"
2311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002312run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002313 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002314 "$O_CLI -key data_files/server5.key \
2315 -cert data_files/server5.eku-cs_any.crt" \
2316 0 \
2317 -S "bad certificate (usage extensions)" \
2318 -S "Processing of the Certificate handshake message failed"
2319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002320run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002321 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002322 "$O_CLI -key data_files/server5.key \
2323 -cert data_files/server5.eku-cs.crt" \
2324 0 \
2325 -s "bad certificate (usage extensions)" \
2326 -S "Processing of the Certificate handshake message failed"
2327
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002328run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002329 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002330 "$O_CLI -key data_files/server5.key \
2331 -cert data_files/server5.eku-cs.crt" \
2332 1 \
2333 -s "bad certificate (usage extensions)" \
2334 -s "Processing of the Certificate handshake message failed"
2335
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002336# Tests for DHM parameters loading
2337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002338run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002339 "$P_SRV" \
2340 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2341 debug_level=3" \
2342 0 \
2343 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker11f740a2017-10-13 16:56:15 +01002344 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002346run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002347 "$P_SRV dhm_file=data_files/dhparams.pem" \
2348 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2349 debug_level=3" \
2350 0 \
2351 -c "value of 'DHM: P ' (1024 bits)" \
2352 -c "value of 'DHM: G ' (2 bits)"
2353
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002354# Tests for PSK callback
2355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002356run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002357 "$P_SRV psk=abc123 psk_identity=foo" \
2358 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2359 psk_identity=foo psk=abc123" \
2360 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002361 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +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: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002366 "$P_SRV" \
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: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002375 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2376 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2377 psk_identity=foo psk=abc123" \
2378 1 \
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: first 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=abc psk=dead" \
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: second id matches" \
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=def psk=beef" \
2396 0 \
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: no match" \
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=ghi 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"
2409
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002410run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002411 "$P_SRV psk_list=abc,dead,def,beef" \
2412 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2413 psk_identity=abc psk=beef" \
2414 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002415 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002416 -S "SSL - Unknown identity received" \
2417 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002418
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002419# Tests for ciphersuites per version
2420
Janos Follath4dfecab2016-03-14 13:40:43 +00002421requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002422run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002423 "$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 +02002424 "$P_CLI force_version=ssl3" \
2425 0 \
2426 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2427
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002428run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002429 "$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" \
2430 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002431 0 \
2432 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002434run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002435 "$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" \
2436 "$P_CLI force_version=tls1_1" \
2437 0 \
2438 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002440run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002441 "$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" \
2442 "$P_CLI force_version=tls1_2" \
2443 0 \
2444 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2445
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002446# Tests for ssl_get_bytes_avail()
2447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002448run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002449 "$P_SRV" \
2450 "$P_CLI request_size=100" \
2451 0 \
2452 -s "Read from client: 100 bytes read$"
2453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002454run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002455 "$P_SRV" \
2456 "$P_CLI request_size=500" \
2457 0 \
2458 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002459
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002460# Tests for small packets
2461
Janos Follath4dfecab2016-03-14 13:40:43 +00002462requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002463run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002464 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002465 "$P_CLI request_size=1 force_version=ssl3 \
2466 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2467 0 \
2468 -s "Read from client: 1 bytes read"
2469
Janos Follath4dfecab2016-03-14 13:40:43 +00002470requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002471run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002472 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002473 "$P_CLI request_size=1 force_version=ssl3 \
2474 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2475 0 \
2476 -s "Read from client: 1 bytes read"
2477
2478run_test "Small packet TLS 1.0 BlockCipher" \
2479 "$P_SRV" \
2480 "$P_CLI request_size=1 force_version=tls1 \
2481 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2482 0 \
2483 -s "Read from client: 1 bytes read"
2484
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002485run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2486 "$P_SRV" \
2487 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2488 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2489 0 \
2490 -s "Read from client: 1 bytes read"
2491
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002492run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2493 "$P_SRV" \
2494 "$P_CLI request_size=1 force_version=tls1 \
2495 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2496 trunc_hmac=1" \
2497 0 \
2498 -s "Read from client: 1 bytes read"
2499
2500run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002501 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002502 "$P_CLI request_size=1 force_version=tls1 \
2503 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2504 trunc_hmac=1" \
2505 0 \
2506 -s "Read from client: 1 bytes read"
2507
2508run_test "Small packet TLS 1.1 BlockCipher" \
2509 "$P_SRV" \
2510 "$P_CLI request_size=1 force_version=tls1_1 \
2511 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2512 0 \
2513 -s "Read from client: 1 bytes read"
2514
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002515run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2516 "$P_SRV" \
2517 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2518 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2519 0 \
2520 -s "Read from client: 1 bytes read"
2521
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002522run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002523 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002524 "$P_CLI request_size=1 force_version=tls1_1 \
2525 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2526 0 \
2527 -s "Read from client: 1 bytes read"
2528
2529run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2530 "$P_SRV" \
2531 "$P_CLI request_size=1 force_version=tls1_1 \
2532 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2533 trunc_hmac=1" \
2534 0 \
2535 -s "Read from client: 1 bytes read"
2536
2537run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002538 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002539 "$P_CLI request_size=1 force_version=tls1_1 \
2540 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2541 trunc_hmac=1" \
2542 0 \
2543 -s "Read from client: 1 bytes read"
2544
2545run_test "Small packet TLS 1.2 BlockCipher" \
2546 "$P_SRV" \
2547 "$P_CLI request_size=1 force_version=tls1_2 \
2548 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2549 0 \
2550 -s "Read from client: 1 bytes read"
2551
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002552run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2553 "$P_SRV" \
2554 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2555 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2556 0 \
2557 -s "Read from client: 1 bytes read"
2558
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002559run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2560 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002561 "$P_CLI request_size=1 force_version=tls1_2 \
2562 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002563 0 \
2564 -s "Read from client: 1 bytes read"
2565
2566run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2567 "$P_SRV" \
2568 "$P_CLI request_size=1 force_version=tls1_2 \
2569 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2570 trunc_hmac=1" \
2571 0 \
2572 -s "Read from client: 1 bytes read"
2573
2574run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002575 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002576 "$P_CLI request_size=1 force_version=tls1_2 \
2577 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2578 0 \
2579 -s "Read from client: 1 bytes read"
2580
2581run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002582 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002583 "$P_CLI request_size=1 force_version=tls1_2 \
2584 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2585 trunc_hmac=1" \
2586 0 \
2587 -s "Read from client: 1 bytes read"
2588
2589run_test "Small packet TLS 1.2 AEAD" \
2590 "$P_SRV" \
2591 "$P_CLI request_size=1 force_version=tls1_2 \
2592 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2593 0 \
2594 -s "Read from client: 1 bytes read"
2595
2596run_test "Small packet TLS 1.2 AEAD shorter tag" \
2597 "$P_SRV" \
2598 "$P_CLI request_size=1 force_version=tls1_2 \
2599 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2600 0 \
2601 -s "Read from client: 1 bytes read"
2602
Janos Follath8abaa8b2016-05-06 13:48:23 +01002603# A test for extensions in SSLv3
2604
Hanno Becker6fd6d242017-05-25 17:51:31 +01002605requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Janos Follath8abaa8b2016-05-06 13:48:23 +01002606run_test "SSLv3 with extensions, server side" \
2607 "$P_SRV min_version=ssl3 debug_level=3" \
2608 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2609 0 \
2610 -S "dumping 'client hello extensions'" \
2611 -S "server hello, total extension length:"
2612
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002613# Test for large packets
2614
Janos Follath4dfecab2016-03-14 13:40:43 +00002615requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002616run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002617 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002618 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002619 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2620 0 \
2621 -s "Read from client: 16384 bytes read"
2622
Janos Follath4dfecab2016-03-14 13:40:43 +00002623requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002624run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002625 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002626 "$P_CLI request_size=16384 force_version=ssl3 \
2627 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2628 0 \
2629 -s "Read from client: 16384 bytes read"
2630
2631run_test "Large packet TLS 1.0 BlockCipher" \
2632 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002633 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002634 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2635 0 \
2636 -s "Read from client: 16384 bytes read"
2637
2638run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2639 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002640 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002641 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2642 trunc_hmac=1" \
2643 0 \
2644 -s "Read from client: 16384 bytes read"
2645
2646run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002647 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002648 "$P_CLI request_size=16384 force_version=tls1 \
2649 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2650 trunc_hmac=1" \
2651 0 \
2652 -s "Read from client: 16384 bytes read"
2653
2654run_test "Large packet TLS 1.1 BlockCipher" \
2655 "$P_SRV" \
2656 "$P_CLI request_size=16384 force_version=tls1_1 \
2657 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2658 0 \
2659 -s "Read from client: 16384 bytes read"
2660
2661run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002662 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002663 "$P_CLI request_size=16384 force_version=tls1_1 \
2664 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2665 0 \
2666 -s "Read from client: 16384 bytes read"
2667
2668run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2669 "$P_SRV" \
2670 "$P_CLI request_size=16384 force_version=tls1_1 \
2671 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2672 trunc_hmac=1" \
2673 0 \
2674 -s "Read from client: 16384 bytes read"
2675
2676run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002677 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002678 "$P_CLI request_size=16384 force_version=tls1_1 \
2679 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2680 trunc_hmac=1" \
2681 0 \
2682 -s "Read from client: 16384 bytes read"
2683
2684run_test "Large packet TLS 1.2 BlockCipher" \
2685 "$P_SRV" \
2686 "$P_CLI request_size=16384 force_version=tls1_2 \
2687 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2688 0 \
2689 -s "Read from client: 16384 bytes read"
2690
2691run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2692 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002693 "$P_CLI request_size=16384 force_version=tls1_2 \
2694 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002695 0 \
2696 -s "Read from client: 16384 bytes read"
2697
2698run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2699 "$P_SRV" \
2700 "$P_CLI request_size=16384 force_version=tls1_2 \
2701 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2702 trunc_hmac=1" \
2703 0 \
2704 -s "Read from client: 16384 bytes read"
2705
2706run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002707 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002708 "$P_CLI request_size=16384 force_version=tls1_2 \
2709 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2710 0 \
2711 -s "Read from client: 16384 bytes read"
2712
2713run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002714 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002715 "$P_CLI request_size=16384 force_version=tls1_2 \
2716 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2717 trunc_hmac=1" \
2718 0 \
2719 -s "Read from client: 16384 bytes read"
2720
2721run_test "Large packet TLS 1.2 AEAD" \
2722 "$P_SRV" \
2723 "$P_CLI request_size=16384 force_version=tls1_2 \
2724 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2725 0 \
2726 -s "Read from client: 16384 bytes read"
2727
2728run_test "Large packet TLS 1.2 AEAD shorter tag" \
2729 "$P_SRV" \
2730 "$P_CLI request_size=16384 force_version=tls1_2 \
2731 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2732 0 \
2733 -s "Read from client: 16384 bytes read"
2734
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002735# Final report
2736
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002737echo "------------------------------------------------------------------------"
2738
2739if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002740 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002741else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002742 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002743fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002744PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002745echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002746
2747exit $FAILS