blob: ed695cb6de820423ce90f8151d4df0aceb413af3 [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
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020078# skip next test if OpenSSL can't send SSLv2 ClientHello
79requires_openssl_with_sslv2() {
80 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020081 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020082 OPENSSL_HAS_SSL2="YES"
83 else
84 OPENSSL_HAS_SSL2="NO"
85 fi
86 fi
87 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
88 SKIP_NEXT="YES"
89 fi
90}
91
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020092# skip next test if OpenSSL doesn't support FALLBACK_SCSV
93requires_openssl_with_fallback_scsv() {
94 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
95 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
96 then
97 OPENSSL_HAS_FBSCSV="YES"
98 else
99 OPENSSL_HAS_FBSCSV="NO"
100 fi
101 fi
102 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
103 SKIP_NEXT="YES"
104 fi
105}
106
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200107# skip next test if GnuTLS isn't available
108requires_gnutls() {
109 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
110 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
111 GNUTLS_AVAILABLE="YES"
112 else
113 GNUTLS_AVAILABLE="NO"
114 fi
115 fi
116 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
117 SKIP_NEXT="YES"
118 fi
119}
120
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100121# print_name <name>
122print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100123 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200124 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100125 for i in `seq 1 $LEN`; do printf '.'; done
126 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100127
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200128 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100129}
130
131# fail <message>
132fail() {
133 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100134 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100135
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200136 mv $SRV_OUT o-srv-${TESTS}.log
137 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100138 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100139
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200140 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
141 echo " ! server output:"
142 cat o-srv-${TESTS}.log
143 echo " ! ============================================================"
144 echo " ! client output:"
145 cat o-cli-${TESTS}.log
146 fi
147
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200148 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100149}
150
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100151# is_polar <cmd_line>
152is_polar() {
153 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
154}
155
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100156# has_mem_err <log_file_name>
157has_mem_err() {
158 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
159 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
160 then
161 return 1 # false: does not have errors
162 else
163 return 0 # true: has errors
164 fi
165}
166
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200167# wait for server to start: two versions depending on lsof availability
168wait_server_start() {
Manuel Pégourié-Gonnard84690c32015-08-04 20:34:39 +0200169 if which lsof >/dev/null 2>&1; then
170 START_TIME=$( date +%s )
171 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200172
173 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard84690c32015-08-04 20:34:39 +0200174 while [ $DONE -eq 0 ]; do
175 if lsof -nbi TCP:"$PORT" 2>/dev/null | grep LISTEN >/dev/null
176 then
177 DONE=1
178 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
179 echo "SERVERSTART TIMEOUT"
180 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
181 DONE=1
182 fi
183 done
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200184 else
185 sleep "$START_DELAY"
186 fi
187}
188
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200189# wait for client to terminate and set CLI_EXIT
190# must be called right after starting the client
191wait_client_done() {
192 CLI_PID=$!
193
194 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
195 WATCHDOG_PID=$!
196
197 wait $CLI_PID
198 CLI_EXIT=$?
199
200 kill $WATCHDOG_PID
201 wait $WATCHDOG_PID
202
203 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
204}
205
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100206# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100207# Options: -s pattern pattern that must be present in server output
208# -c pattern pattern that must be present in client output
Simon Butcher696f92e2016-10-13 14:13:17 +0100209# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100210# -S pattern pattern that must be absent in server output
211# -C pattern pattern that must be absent in client output
Simon Butcher696f92e2016-10-13 14:13:17 +0100212# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100213run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100214 NAME="$1"
215 SRV_CMD="$2"
216 CLI_CMD="$3"
217 CLI_EXPECT="$4"
218 shift 4
219
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100220 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
221 else
Manuel Pégourié-Gonnard33e8d342017-07-10 11:55:31 +0200222 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100223 return
224 fi
225
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100226 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100227
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200228 # should we skip?
229 if [ "X$SKIP_NEXT" = "XYES" ]; then
230 SKIP_NEXT="NO"
231 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200232 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200233 return
234 fi
235
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100236 # prepend valgrind to our commands if active
237 if [ "$MEMCHECK" -gt 0 ]; then
238 if is_polar "$SRV_CMD"; then
239 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
240 fi
241 if is_polar "$CLI_CMD"; then
242 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
243 fi
244 fi
245
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100246 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200247 echo "$SRV_CMD" > $SRV_OUT
248 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100249 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200250 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200251
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200252 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200253 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
254 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100255
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200256 # kill the server
257 kill $SRV_PID
258 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100259
260 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200261 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100262 # expected client exit to incorrectly succeed in case of catastrophic
263 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100264 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200265 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100266 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100267 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100268 return
269 fi
270 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100271 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200272 if grep "Performing the SSL/TLS handshake" $CLI_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
278
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100279 # check server exit code
280 if [ $? != 0 ]; then
281 fail "server fail"
282 return
283 fi
284
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100285 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100286 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
287 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100288 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100289 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100290 return
291 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100292
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100293 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200294 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100295 while [ $# -gt 0 ]
296 do
297 case $1 in
298 "-s")
Simon Butcher696f92e2016-10-13 14:13:17 +0100299 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
300 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100301 return
302 fi
303 ;;
304
305 "-c")
Simon Butcher696f92e2016-10-13 14:13:17 +0100306 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
307 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100308 return
309 fi
310 ;;
311
312 "-S")
Simon Butcher696f92e2016-10-13 14:13:17 +0100313 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
314 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100315 return
316 fi
317 ;;
318
319 "-C")
Simon Butcher696f92e2016-10-13 14:13:17 +0100320 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
321 fail "pattern '$2' MUST NOT be present in the Client output"
322 return
323 fi
324 ;;
325
326 # The filtering in the following two options (-u and -U) do the following
327 # - ignore valgrind output
328 # - filter out everything but lines right after the pattern occurances
329 # - keep one of each non-unique line
330 # - count how many lines remain
331 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
332 # if there were no duplicates.
333 "-U")
334 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
335 fail "lines following pattern '$2' must be unique in Server output"
336 return
337 fi
338 ;;
339
340 "-u")
341 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
342 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100343 return
344 fi
345 ;;
346
347 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200348 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100349 exit 1
350 esac
351 shift 2
352 done
353
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100354 # check valgrind's results
355 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200356 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100357 fail "Server has memory errors"
358 return
359 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200360 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100361 fail "Client has memory errors"
362 return
363 fi
364 fi
365
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100366 # if we're here, everything is ok
367 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200368 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100369}
370
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100371cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200372 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200373 kill $SRV_PID >/dev/null 2>&1
374 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100375 exit 1
376}
377
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100378#
379# MAIN
380#
381
Manuel Pégourié-Gonnard751286b2015-03-10 13:41:04 +0000382if cd $( dirname $0 ); then :; else
383 echo "cd $( dirname $0 ) failed" >&2
384 exit 1
385fi
386
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100387get_options "$@"
388
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100389# sanity checks, avoid an avalanche of errors
390if [ ! -x "$P_SRV" ]; then
391 echo "Command '$P_SRV' is not an executable file"
392 exit 1
393fi
394if [ ! -x "$P_CLI" ]; then
395 echo "Command '$P_CLI' is not an executable file"
396 exit 1
397fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100398if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
399 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100400 exit 1
401fi
402
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200403# used by watchdog
404MAIN_PID="$$"
405
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200406# be more patient with valgrind
407if [ "$MEMCHECK" -gt 0 ]; then
408 START_DELAY=3
409 DOG_DELAY=30
410else
411 START_DELAY=1
412 DOG_DELAY=10
413fi
414
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200415# Pick a "unique" port in the range 10000-19999.
416PORT="0000$$"
Manuel Pégourié-Gonnarddc370e42015-01-22 10:24:59 +0000417PORT="1$( printf $PORT | tail -c 4 )"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200418
419# fix commands to use this port
420P_SRV="$P_SRV server_port=$PORT"
421P_CLI="$P_CLI server_port=$PORT"
422O_SRV="$O_SRV -accept $PORT"
423O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200424G_SRV="$G_SRV -p $PORT"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100425G_CLI="$G_CLI -p $PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200426
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200427# Also pick a unique name for intermediate files
428SRV_OUT="srv_out.$$"
429CLI_OUT="cli_out.$$"
430SESSION="session.$$"
431
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200432SKIP_NEXT="NO"
433
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100434trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100435
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200436# Basic test
437
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200438# Checks that:
439# - things work with all ciphersuites active (used with config-full in all.sh)
440# - the expected (highest security) parameters are selected
441# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200442run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200443 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200444 "$P_CLI" \
445 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200446 -s "Protocol is TLSv1.2" \
447 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
448 -s "client hello v3, signature_algorithm ext: 6" \
449 -s "ECDHE curve: secp521r1" \
450 -S "error" \
451 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200452
Simon Butcher696f92e2016-10-13 14:13:17 +0100453# Test for uniqueness of IVs in AEAD ciphersuites
454run_test "Unique IV in GCM" \
455 "$P_SRV exchanges=20 debug_level=4" \
456 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
457 0 \
458 -u "IV used" \
459 -U "IV used"
460
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100461# Tests for rc4 option
462
463run_test "RC4: server disabled, client enabled" \
464 "$P_SRV" \
465 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
466 1 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100467 -s "SSL - None of the common ciphersuites is usable"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100468
469run_test "RC4: server enabled, client disabled" \
470 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
471 "$P_CLI" \
472 1 \
473 -s "SSL - The server has no ciphersuites in common"
474
475run_test "RC4: both enabled" \
476 "$P_SRV arc4=1" \
477 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
478 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100479 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100480 -S "SSL - The server has no ciphersuites in common"
481
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100482# Test for SSLv2 ClientHello
483
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200484requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200485run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100486 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100487 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100488 0 \
489 -S "parse client hello v2" \
490 -S "ssl_handshake returned"
491
492# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200493requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200494run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200495 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100496 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100497 0 \
498 -s "parse client hello v2" \
499 -S "ssl_handshake returned"
500
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100501# Tests for Truncated HMAC extension
502
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100503run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200504 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100505 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100506 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100507 -s "dumping 'computed mac' (20 bytes)" \
508 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100509
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100510run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200511 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100512 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
513 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100514 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100515 -s "dumping 'computed mac' (20 bytes)" \
516 -S "dumping 'computed mac' (10 bytes)"
517
518run_test "Truncated HMAC: client enabled, server default" \
519 "$P_SRV debug_level=4" \
520 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
521 trunc_hmac=1" \
522 0 \
523 -S "dumping 'computed mac' (20 bytes)" \
524 -s "dumping 'computed mac' (10 bytes)"
525
526run_test "Truncated HMAC: client enabled, server disabled" \
527 "$P_SRV debug_level=4 trunc_hmac=0" \
528 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
529 trunc_hmac=1" \
530 0 \
531 -s "dumping 'computed mac' (20 bytes)" \
532 -S "dumping 'computed mac' (10 bytes)"
533
534run_test "Truncated HMAC: client enabled, server enabled" \
535 "$P_SRV debug_level=4 trunc_hmac=1" \
536 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
537 trunc_hmac=1" \
538 0 \
539 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100540 -s "dumping 'computed mac' (10 bytes)"
541
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100542# Tests for Encrypt-then-MAC extension
543
544run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100545 "$P_SRV debug_level=3 \
546 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100547 "$P_CLI debug_level=3" \
548 0 \
549 -c "client hello, adding encrypt_then_mac extension" \
550 -s "found encrypt then mac extension" \
551 -s "server hello, adding encrypt then mac extension" \
552 -c "found encrypt_then_mac extension" \
553 -c "using encrypt then mac" \
554 -s "using encrypt then mac"
555
556run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100557 "$P_SRV debug_level=3 etm=0 \
558 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100559 "$P_CLI debug_level=3 etm=1" \
560 0 \
561 -c "client hello, adding encrypt_then_mac extension" \
562 -s "found encrypt then mac extension" \
563 -S "server hello, adding encrypt then mac extension" \
564 -C "found encrypt_then_mac extension" \
565 -C "using encrypt then mac" \
566 -S "using encrypt then mac"
567
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100568run_test "Encrypt then MAC: client enabled, aead cipher" \
569 "$P_SRV debug_level=3 etm=1 \
570 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
571 "$P_CLI debug_level=3 etm=1" \
572 0 \
573 -c "client hello, adding encrypt_then_mac extension" \
574 -s "found encrypt then mac extension" \
575 -S "server hello, adding encrypt then mac extension" \
576 -C "found encrypt_then_mac extension" \
577 -C "using encrypt then mac" \
578 -S "using encrypt then mac"
579
580run_test "Encrypt then MAC: client enabled, stream cipher" \
581 "$P_SRV debug_level=3 etm=1 \
582 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100583 "$P_CLI debug_level=3 etm=1 arc4=1" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100584 0 \
585 -c "client hello, adding encrypt_then_mac extension" \
586 -s "found encrypt then mac extension" \
587 -S "server hello, adding encrypt then mac extension" \
588 -C "found encrypt_then_mac extension" \
589 -C "using encrypt then mac" \
590 -S "using encrypt then mac"
591
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100592run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100593 "$P_SRV debug_level=3 etm=1 \
594 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100595 "$P_CLI debug_level=3 etm=0" \
596 0 \
597 -C "client hello, adding encrypt_then_mac extension" \
598 -S "found encrypt then mac extension" \
599 -S "server hello, adding encrypt then mac extension" \
600 -C "found encrypt_then_mac extension" \
601 -C "using encrypt then mac" \
602 -S "using encrypt then mac"
603
Janos Follath4dfecab2016-03-14 13:40:43 +0000604requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100605run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100606 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100607 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100608 "$P_CLI debug_level=3 force_version=ssl3" \
609 0 \
610 -C "client hello, adding encrypt_then_mac extension" \
611 -S "found encrypt then mac extension" \
612 -S "server hello, adding encrypt then mac extension" \
613 -C "found encrypt_then_mac extension" \
614 -C "using encrypt then mac" \
615 -S "using encrypt then mac"
616
Janos Follath4dfecab2016-03-14 13:40:43 +0000617requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100618run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100619 "$P_SRV debug_level=3 force_version=ssl3 \
620 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100621 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100622 0 \
623 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath8abaa8b2016-05-06 13:48:23 +0100624 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100625 -S "server hello, adding encrypt then mac extension" \
626 -C "found encrypt_then_mac extension" \
627 -C "using encrypt then mac" \
628 -S "using encrypt then mac"
629
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200630# Tests for Extended Master Secret extension
631
632run_test "Extended Master Secret: default" \
633 "$P_SRV debug_level=3" \
634 "$P_CLI debug_level=3" \
635 0 \
636 -c "client hello, adding extended_master_secret extension" \
637 -s "found extended master secret extension" \
638 -s "server hello, adding extended master secret extension" \
639 -c "found extended_master_secret extension" \
640 -c "using extended master secret" \
641 -s "using extended master secret"
642
643run_test "Extended Master Secret: client enabled, server disabled" \
644 "$P_SRV debug_level=3 extended_ms=0" \
645 "$P_CLI debug_level=3 extended_ms=1" \
646 0 \
647 -c "client hello, adding extended_master_secret extension" \
648 -s "found extended master secret extension" \
649 -S "server hello, adding extended master secret extension" \
650 -C "found extended_master_secret extension" \
651 -C "using extended master secret" \
652 -S "using extended master secret"
653
654run_test "Extended Master Secret: client disabled, server enabled" \
655 "$P_SRV debug_level=3 extended_ms=1" \
656 "$P_CLI debug_level=3 extended_ms=0" \
657 0 \
658 -C "client hello, adding extended_master_secret extension" \
659 -S "found extended master secret extension" \
660 -S "server hello, adding extended master secret extension" \
661 -C "found extended_master_secret extension" \
662 -C "using extended master secret" \
663 -S "using extended master secret"
664
Janos Follath4dfecab2016-03-14 13:40:43 +0000665requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200666run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100667 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200668 "$P_CLI debug_level=3 force_version=ssl3" \
669 0 \
670 -C "client hello, adding extended_master_secret extension" \
671 -S "found extended master secret extension" \
672 -S "server hello, adding extended master secret extension" \
673 -C "found extended_master_secret extension" \
674 -C "using extended master secret" \
675 -S "using extended master secret"
676
Janos Follath4dfecab2016-03-14 13:40:43 +0000677requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200678run_test "Extended Master Secret: client enabled, server SSLv3" \
679 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100680 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200681 0 \
682 -c "client hello, adding extended_master_secret extension" \
Janos Follath8abaa8b2016-05-06 13:48:23 +0100683 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200684 -S "server hello, adding extended master secret extension" \
685 -C "found extended_master_secret extension" \
686 -C "using extended master secret" \
687 -S "using extended master secret"
688
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200689# Tests for FALLBACK_SCSV
690
691run_test "Fallback SCSV: default" \
692 "$P_SRV" \
693 "$P_CLI debug_level=3 force_version=tls1_1" \
694 0 \
695 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200696 -S "received FALLBACK_SCSV" \
697 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200698 -C "is a fatal alert message (msg 86)"
699
700run_test "Fallback SCSV: explicitly disabled" \
701 "$P_SRV" \
702 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
703 0 \
704 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200705 -S "received FALLBACK_SCSV" \
706 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200707 -C "is a fatal alert message (msg 86)"
708
709run_test "Fallback SCSV: enabled" \
710 "$P_SRV" \
711 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200712 1 \
713 -c "adding FALLBACK_SCSV" \
714 -s "received FALLBACK_SCSV" \
715 -s "inapropriate fallback" \
716 -c "is a fatal alert message (msg 86)"
717
718run_test "Fallback SCSV: enabled, max version" \
719 "$P_SRV" \
720 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200721 0 \
722 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200723 -s "received FALLBACK_SCSV" \
724 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200725 -C "is a fatal alert message (msg 86)"
726
727requires_openssl_with_fallback_scsv
728run_test "Fallback SCSV: default, openssl server" \
729 "$O_SRV" \
730 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
731 0 \
732 -C "adding FALLBACK_SCSV" \
733 -C "is a fatal alert message (msg 86)"
734
735requires_openssl_with_fallback_scsv
736run_test "Fallback SCSV: enabled, openssl server" \
737 "$O_SRV" \
738 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
739 1 \
740 -c "adding FALLBACK_SCSV" \
741 -c "is a fatal alert message (msg 86)"
742
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200743requires_openssl_with_fallback_scsv
744run_test "Fallback SCSV: disabled, openssl client" \
745 "$P_SRV" \
746 "$O_CLI -tls1_1" \
747 0 \
748 -S "received FALLBACK_SCSV" \
749 -S "inapropriate fallback"
750
751requires_openssl_with_fallback_scsv
752run_test "Fallback SCSV: enabled, openssl client" \
753 "$P_SRV" \
754 "$O_CLI -tls1_1 -fallback_scsv" \
755 1 \
756 -s "received FALLBACK_SCSV" \
757 -s "inapropriate fallback"
758
759requires_openssl_with_fallback_scsv
760run_test "Fallback SCSV: enabled, max version, openssl client" \
761 "$P_SRV" \
762 "$O_CLI -fallback_scsv" \
763 0 \
764 -s "received FALLBACK_SCSV" \
765 -S "inapropriate fallback"
766
Gilles Peskinea1cf6c82017-05-17 14:50:38 +0200767## ClientHello generated with
768## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
769## then manually twiddling the ciphersuite list.
770## The ClientHello content is spelled out below as a hex string as
771## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
772## The expected response is an inappropriate_fallback alert.
773requires_openssl_with_fallback_scsv
774run_test "Fallback SCSV: beginning of list" \
775 "$P_SRV debug_level=2" \
776 "$TCP_CLIENT localhost $PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
777 0 \
778 -s "received FALLBACK_SCSV" \
779 -s "inapropriate fallback"
780
781requires_openssl_with_fallback_scsv
782run_test "Fallback SCSV: end of list" \
783 "$P_SRV debug_level=2" \
784 "$TCP_CLIENT localhost $PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
785 0 \
786 -s "received FALLBACK_SCSV" \
787 -s "inapropriate fallback"
788
789## Here the expected response is a valid ServerHello prefix, up to the random.
790requires_openssl_with_fallback_scsv
791run_test "Fallback SCSV: not in list" \
792 "$P_SRV debug_level=2" \
793 "$TCP_CLIENT localhost $PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
794 0 \
795 -S "received FALLBACK_SCSV" \
796 -S "inapropriate fallback"
797
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100798# Tests for CBC 1/n-1 record splitting
799
800run_test "CBC Record splitting: TLS 1.2, no splitting" \
801 "$P_SRV" \
802 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
803 request_size=123 force_version=tls1_2" \
804 0 \
805 -s "Read from client: 123 bytes read" \
806 -S "Read from client: 1 bytes read" \
807 -S "122 bytes read"
808
809run_test "CBC Record splitting: TLS 1.1, no splitting" \
810 "$P_SRV" \
811 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
812 request_size=123 force_version=tls1_1" \
813 0 \
814 -s "Read from client: 123 bytes read" \
815 -S "Read from client: 1 bytes read" \
816 -S "122 bytes read"
817
818run_test "CBC Record splitting: TLS 1.0, splitting" \
819 "$P_SRV" \
820 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
821 request_size=123 force_version=tls1" \
822 0 \
823 -S "Read from client: 123 bytes read" \
824 -s "Read from client: 1 bytes read" \
825 -s "122 bytes read"
826
Janos Follath4dfecab2016-03-14 13:40:43 +0000827requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100828run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100829 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100830 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
831 request_size=123 force_version=ssl3" \
832 0 \
833 -S "Read from client: 123 bytes read" \
834 -s "Read from client: 1 bytes read" \
835 -s "122 bytes read"
836
837run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100838 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100839 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
840 request_size=123 force_version=tls1" \
841 0 \
842 -s "Read from client: 123 bytes read" \
843 -S "Read from client: 1 bytes read" \
844 -S "122 bytes read"
845
846run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
847 "$P_SRV" \
848 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
849 request_size=123 force_version=tls1 recsplit=0" \
850 0 \
851 -s "Read from client: 123 bytes read" \
852 -S "Read from client: 1 bytes read" \
853 -S "122 bytes read"
854
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100855run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
856 "$P_SRV nbio=2" \
857 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
858 request_size=123 force_version=tls1" \
859 0 \
860 -S "Read from client: 123 bytes read" \
861 -s "Read from client: 1 bytes read" \
862 -s "122 bytes read"
863
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100864# Tests for Session Tickets
865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200866run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200867 "$P_SRV debug_level=3 tickets=1" \
868 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100869 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100870 -c "client hello, adding session ticket extension" \
871 -s "found session ticket extension" \
872 -s "server hello, adding session ticket extension" \
873 -c "found session_ticket extension" \
874 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100875 -S "session successfully restored from cache" \
876 -s "session successfully restored from ticket" \
877 -s "a session has been resumed" \
878 -c "a session has been resumed"
879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200880run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200881 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
882 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100883 0 \
884 -c "client hello, adding session ticket extension" \
885 -s "found session ticket extension" \
886 -s "server hello, adding session ticket extension" \
887 -c "found session_ticket extension" \
888 -c "parse new session ticket" \
889 -S "session successfully restored from cache" \
890 -s "session successfully restored from ticket" \
891 -s "a session has been resumed" \
892 -c "a session has been resumed"
893
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200894run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200895 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
896 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100897 0 \
898 -c "client hello, adding session ticket extension" \
899 -s "found session ticket extension" \
900 -s "server hello, adding session ticket extension" \
901 -c "found session_ticket extension" \
902 -c "parse new session ticket" \
903 -S "session successfully restored from cache" \
904 -S "session successfully restored from ticket" \
905 -S "a session has been resumed" \
906 -C "a session has been resumed"
907
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200908run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100909 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200910 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100911 0 \
912 -c "client hello, adding session ticket extension" \
913 -c "found session_ticket extension" \
914 -c "parse new session ticket" \
915 -c "a session has been resumed"
916
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200917run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200918 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200919 "( $O_CLI -sess_out $SESSION; \
920 $O_CLI -sess_in $SESSION; \
921 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100922 0 \
923 -s "found session ticket extension" \
924 -s "server hello, adding session ticket extension" \
925 -S "session successfully restored from cache" \
926 -s "session successfully restored from ticket" \
927 -s "a session has been resumed"
928
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100929# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100930
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200931run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200932 "$P_SRV debug_level=3 tickets=0" \
933 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100934 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100935 -c "client hello, adding session ticket extension" \
936 -s "found session ticket extension" \
937 -S "server hello, adding session ticket extension" \
938 -C "found session_ticket extension" \
939 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100940 -s "session successfully restored from cache" \
941 -S "session successfully restored from ticket" \
942 -s "a session has been resumed" \
943 -c "a session has been resumed"
944
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200945run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200946 "$P_SRV debug_level=3 tickets=1" \
947 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100948 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100949 -C "client hello, adding session ticket extension" \
950 -S "found session ticket extension" \
951 -S "server hello, adding session ticket extension" \
952 -C "found session_ticket extension" \
953 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100954 -s "session successfully restored from cache" \
955 -S "session successfully restored from ticket" \
956 -s "a session has been resumed" \
957 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100958
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200959run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200960 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
961 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100962 0 \
963 -S "session successfully restored from cache" \
964 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100965 -S "a session has been resumed" \
966 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200968run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200969 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
970 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100971 0 \
972 -s "session successfully restored from cache" \
973 -S "session successfully restored from ticket" \
974 -s "a session has been resumed" \
975 -c "a session has been resumed"
976
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200977run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200978 "$P_SRV debug_level=3 tickets=0" \
979 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100980 0 \
981 -s "session successfully restored from cache" \
982 -S "session successfully restored from ticket" \
983 -s "a session has been resumed" \
984 -c "a session has been resumed"
985
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200986run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200987 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
988 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100989 0 \
990 -S "session successfully restored from cache" \
991 -S "session successfully restored from ticket" \
992 -S "a session has been resumed" \
993 -C "a session has been resumed"
994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200995run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200996 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
997 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100998 0 \
999 -s "session successfully restored from cache" \
1000 -S "session successfully restored from ticket" \
1001 -s "a session has been resumed" \
1002 -c "a session has been resumed"
1003
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001004run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001005 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001006 "( $O_CLI -sess_out $SESSION; \
1007 $O_CLI -sess_in $SESSION; \
1008 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001009 0 \
1010 -s "found session ticket extension" \
1011 -S "server hello, adding session ticket extension" \
1012 -s "session successfully restored from cache" \
1013 -S "session successfully restored from ticket" \
1014 -s "a session has been resumed"
1015
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001016run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001017 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001018 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001019 0 \
1020 -C "found session_ticket extension" \
1021 -C "parse new session ticket" \
1022 -c "a session has been resumed"
1023
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001024# Tests for Max Fragment Length extension
1025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001026run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001027 "$P_SRV debug_level=3" \
1028 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001029 0 \
1030 -C "client hello, adding max_fragment_length extension" \
1031 -S "found max fragment length extension" \
1032 -S "server hello, max_fragment_length extension" \
1033 -C "found max_fragment_length extension"
1034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001035run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001036 "$P_SRV debug_level=3" \
1037 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001038 0 \
1039 -c "client hello, adding max_fragment_length extension" \
1040 -s "found max fragment length extension" \
1041 -s "server hello, max_fragment_length extension" \
1042 -c "found max_fragment_length extension"
1043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001044run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001045 "$P_SRV debug_level=3 max_frag_len=4096" \
1046 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001047 0 \
1048 -C "client hello, adding max_fragment_length extension" \
1049 -S "found max fragment length extension" \
1050 -S "server hello, max_fragment_length extension" \
1051 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001053requires_gnutls
1054run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001055 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001056 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001057 0 \
1058 -c "client hello, adding max_fragment_length extension" \
1059 -c "found max_fragment_length extension"
1060
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001061# Tests for renegotiation
1062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001063run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001064 "$P_SRV debug_level=3 exchanges=2" \
1065 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001066 0 \
1067 -C "client hello, adding renegotiation extension" \
1068 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1069 -S "found renegotiation extension" \
1070 -s "server hello, secure renegotiation extension" \
1071 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001072 -C "=> renegotiate" \
1073 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001074 -S "write hello request"
1075
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001076run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001077 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
1078 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001079 0 \
1080 -c "client hello, adding renegotiation extension" \
1081 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1082 -s "found renegotiation extension" \
1083 -s "server hello, secure renegotiation extension" \
1084 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001085 -c "=> renegotiate" \
1086 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001087 -S "write hello request"
1088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001089run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001090 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1091 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001092 0 \
1093 -c "client hello, adding renegotiation extension" \
1094 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1095 -s "found renegotiation extension" \
1096 -s "server hello, secure renegotiation extension" \
1097 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001098 -c "=> renegotiate" \
1099 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001100 -s "write hello request"
1101
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001102run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001103 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1104 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001105 0 \
1106 -c "client hello, adding renegotiation extension" \
1107 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1108 -s "found renegotiation extension" \
1109 -s "server hello, secure renegotiation extension" \
1110 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001111 -c "=> renegotiate" \
1112 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001113 -s "write hello request"
1114
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001115run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001116 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1117 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001118 1 \
1119 -c "client hello, adding renegotiation extension" \
1120 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1121 -S "found renegotiation extension" \
1122 -s "server hello, secure renegotiation extension" \
1123 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001124 -c "=> renegotiate" \
1125 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001126 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001127 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001128 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001129
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001130run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001131 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1132 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001133 0 \
1134 -C "client hello, adding renegotiation extension" \
1135 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1136 -S "found renegotiation extension" \
1137 -s "server hello, secure renegotiation extension" \
1138 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001139 -C "=> renegotiate" \
1140 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001141 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001142 -S "SSL - An unexpected message was received from our peer" \
1143 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001144
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001145run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001146 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001147 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001148 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001149 0 \
1150 -C "client hello, adding renegotiation extension" \
1151 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1152 -S "found renegotiation extension" \
1153 -s "server hello, secure renegotiation extension" \
1154 -c "found renegotiation extension" \
1155 -C "=> renegotiate" \
1156 -S "=> renegotiate" \
1157 -s "write hello request" \
1158 -S "SSL - An unexpected message was received from our peer" \
1159 -S "failed"
1160
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001161# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001162run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001163 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001164 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001165 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001166 0 \
1167 -C "client hello, adding renegotiation extension" \
1168 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1169 -S "found renegotiation extension" \
1170 -s "server hello, secure renegotiation extension" \
1171 -c "found renegotiation extension" \
1172 -C "=> renegotiate" \
1173 -S "=> renegotiate" \
1174 -s "write hello request" \
1175 -S "SSL - An unexpected message was received from our peer" \
1176 -S "failed"
1177
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001178run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001179 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001180 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001181 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001182 0 \
1183 -C "client hello, adding renegotiation extension" \
1184 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1185 -S "found renegotiation extension" \
1186 -s "server hello, secure renegotiation extension" \
1187 -c "found renegotiation extension" \
1188 -C "=> renegotiate" \
1189 -S "=> renegotiate" \
1190 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001191 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001193run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001194 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001195 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001196 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001197 0 \
1198 -c "client hello, adding renegotiation extension" \
1199 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1200 -s "found renegotiation extension" \
1201 -s "server hello, secure renegotiation extension" \
1202 -c "found renegotiation extension" \
1203 -c "=> renegotiate" \
1204 -s "=> renegotiate" \
1205 -s "write hello request" \
1206 -S "SSL - An unexpected message was received from our peer" \
1207 -S "failed"
1208
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001209run_test "Renegotiation: periodic, just below period" \
1210 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1211 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1212 0 \
1213 -C "client hello, adding renegotiation extension" \
1214 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1215 -S "found renegotiation extension" \
1216 -s "server hello, secure renegotiation extension" \
1217 -c "found renegotiation extension" \
1218 -S "record counter limit reached: renegotiate" \
1219 -C "=> renegotiate" \
1220 -S "=> renegotiate" \
1221 -S "write hello request" \
1222 -S "SSL - An unexpected message was received from our peer" \
1223 -S "failed"
1224
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001225# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001226run_test "Renegotiation: periodic, just above period" \
1227 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001228 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001229 0 \
1230 -c "client hello, adding renegotiation extension" \
1231 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1232 -s "found renegotiation extension" \
1233 -s "server hello, secure renegotiation extension" \
1234 -c "found renegotiation extension" \
1235 -s "record counter limit reached: renegotiate" \
1236 -c "=> renegotiate" \
1237 -s "=> renegotiate" \
1238 -s "write hello request" \
1239 -S "SSL - An unexpected message was received from our peer" \
1240 -S "failed"
1241
1242run_test "Renegotiation: periodic, two times period" \
1243 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001244 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001245 0 \
1246 -c "client hello, adding renegotiation extension" \
1247 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1248 -s "found renegotiation extension" \
1249 -s "server hello, secure renegotiation extension" \
1250 -c "found renegotiation extension" \
1251 -s "record counter limit reached: renegotiate" \
1252 -c "=> renegotiate" \
1253 -s "=> renegotiate" \
1254 -s "write hello request" \
1255 -S "SSL - An unexpected message was received from our peer" \
1256 -S "failed"
1257
1258run_test "Renegotiation: periodic, above period, disabled" \
1259 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1260 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1261 0 \
1262 -C "client hello, adding renegotiation extension" \
1263 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1264 -S "found renegotiation extension" \
1265 -s "server hello, secure renegotiation extension" \
1266 -c "found renegotiation extension" \
1267 -S "record counter limit reached: renegotiate" \
1268 -C "=> renegotiate" \
1269 -S "=> renegotiate" \
1270 -S "write hello request" \
1271 -S "SSL - An unexpected message was received from our peer" \
1272 -S "failed"
1273
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001274run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001275 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1276 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001277 0 \
1278 -c "client hello, adding renegotiation extension" \
1279 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1280 -s "found renegotiation extension" \
1281 -s "server hello, secure renegotiation extension" \
1282 -c "found renegotiation extension" \
1283 -c "=> renegotiate" \
1284 -s "=> renegotiate" \
1285 -S "write hello request"
1286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001287run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001288 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1289 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001290 0 \
1291 -c "client hello, adding renegotiation extension" \
1292 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1293 -s "found renegotiation extension" \
1294 -s "server hello, secure renegotiation extension" \
1295 -c "found renegotiation extension" \
1296 -c "=> renegotiate" \
1297 -s "=> renegotiate" \
1298 -s "write hello request"
1299
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001300run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001301 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001302 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001303 0 \
1304 -c "client hello, adding renegotiation extension" \
1305 -c "found renegotiation extension" \
1306 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001307 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001308 -C "error" \
1309 -c "HTTP/1.0 200 [Oo][Kk]"
1310
Paul Bakker539d9722015-02-08 16:18:35 +01001311requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001312run_test "Renegotiation: gnutls server strict, client-initiated" \
1313 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001314 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001315 0 \
1316 -c "client hello, adding renegotiation extension" \
1317 -c "found renegotiation extension" \
1318 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001319 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001320 -C "error" \
1321 -c "HTTP/1.0 200 [Oo][Kk]"
1322
Paul Bakker539d9722015-02-08 16:18:35 +01001323requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001324run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1325 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1326 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1327 1 \
1328 -c "client hello, adding renegotiation extension" \
1329 -C "found renegotiation extension" \
1330 -c "=> renegotiate" \
1331 -c "ssl_handshake() returned" \
1332 -c "error" \
1333 -C "HTTP/1.0 200 [Oo][Kk]"
1334
Paul Bakker539d9722015-02-08 16:18:35 +01001335requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001336run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1337 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1338 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1339 allow_legacy=0" \
1340 1 \
1341 -c "client hello, adding renegotiation extension" \
1342 -C "found renegotiation extension" \
1343 -c "=> renegotiate" \
1344 -c "ssl_handshake() returned" \
1345 -c "error" \
1346 -C "HTTP/1.0 200 [Oo][Kk]"
1347
Paul Bakker539d9722015-02-08 16:18:35 +01001348requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001349run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1350 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1351 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1352 allow_legacy=1" \
1353 0 \
1354 -c "client hello, adding renegotiation extension" \
1355 -C "found renegotiation extension" \
1356 -c "=> renegotiate" \
1357 -C "ssl_hanshake() returned" \
1358 -C "error" \
1359 -c "HTTP/1.0 200 [Oo][Kk]"
1360
1361# Test for the "secure renegotation" extension only (no actual renegotiation)
1362
Paul Bakker539d9722015-02-08 16:18:35 +01001363requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001364run_test "Renego ext: gnutls server strict, client default" \
1365 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1366 "$P_CLI debug_level=3" \
1367 0 \
1368 -c "found renegotiation extension" \
1369 -C "error" \
1370 -c "HTTP/1.0 200 [Oo][Kk]"
1371
Paul Bakker539d9722015-02-08 16:18:35 +01001372requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001373run_test "Renego ext: gnutls server unsafe, client default" \
1374 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1375 "$P_CLI debug_level=3" \
1376 0 \
1377 -C "found renegotiation extension" \
1378 -C "error" \
1379 -c "HTTP/1.0 200 [Oo][Kk]"
1380
Paul Bakker539d9722015-02-08 16:18:35 +01001381requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001382run_test "Renego ext: gnutls server unsafe, client break legacy" \
1383 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1384 "$P_CLI debug_level=3 allow_legacy=-1" \
1385 1 \
1386 -C "found renegotiation extension" \
1387 -c "error" \
1388 -C "HTTP/1.0 200 [Oo][Kk]"
1389
Paul Bakker539d9722015-02-08 16:18:35 +01001390requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001391run_test "Renego ext: gnutls client strict, server default" \
1392 "$P_SRV debug_level=3" \
1393 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1394 0 \
1395 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1396 -s "server hello, secure renegotiation extension"
1397
Paul Bakker539d9722015-02-08 16:18:35 +01001398requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001399run_test "Renego ext: gnutls client unsafe, server default" \
1400 "$P_SRV debug_level=3" \
1401 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1402 0 \
1403 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1404 -S "server hello, secure renegotiation extension"
1405
Paul Bakker539d9722015-02-08 16:18:35 +01001406requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001407run_test "Renego ext: gnutls client unsafe, server break legacy" \
1408 "$P_SRV debug_level=3 allow_legacy=-1" \
1409 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1410 1 \
1411 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1412 -S "server hello, secure renegotiation extension"
1413
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001414# Tests for auth_mode
1415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001416run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001417 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001418 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001419 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001420 1 \
1421 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001422 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001423 -c "! ssl_handshake returned" \
1424 -c "X509 - Certificate verification failed"
1425
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001426run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001427 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001428 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001429 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001430 0 \
1431 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001432 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001433 -C "! ssl_handshake returned" \
1434 -C "X509 - Certificate verification failed"
1435
Hanno Becker6fd6d242017-05-25 17:51:31 +01001436run_test "Authentication: server goodcert, client optional, no trusted CA" \
1437 "$P_SRV" \
1438 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1439 0 \
1440 -c "x509_verify_cert() returned" \
1441 -c "! The certificate is not correctly signed by the trusted CA" \
1442 -c "! Certificate verification flags"\
1443 -C "! ssl_handshake returned" \
1444 -C "X509 - Certificate verification failed" \
1445 -C "SSL - No CA Chain is set, but required to operate"
1446
1447run_test "Authentication: server goodcert, client required, no trusted CA" \
1448 "$P_SRV" \
1449 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1450 1 \
1451 -c "x509_verify_cert() returned" \
1452 -c "! The certificate is not correctly signed by the trusted CA" \
1453 -c "! Certificate verification flags"\
1454 -c "! ssl_handshake returned" \
1455 -c "SSL - No CA Chain is set, but required to operate"
1456
1457# The purpose of the next two tests is to test the client's behaviour when receiving a server
1458# certificate with an unsupported elliptic curve. This should usually not happen because
1459# the client informs the server about the supported curves - it does, though, in the
1460# corner case of a static ECDH suite, because the server doesn't check the curve on that
1461# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1462# different means to have the server ignoring the client's supported curve list.
1463
1464requires_config_enabled POLARSSL_SSL_SET_CURVES
1465run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1466 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1467 crt_file=data_files/server5.ku-ka.crt" \
1468 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1469 1 \
1470 -c "bad certificate (EC key curve)"\
1471 -c "! Certificate verification flags"\
1472 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1473
1474requires_config_enabled POLARSSL_SSL_SET_CURVES
1475run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1476 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1477 crt_file=data_files/server5.ku-ka.crt" \
1478 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1479 1 \
1480 -c "bad certificate (EC key curve)"\
1481 -c "! Certificate verification flags"\
1482 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1483
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001484run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001485 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001486 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001487 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001488 0 \
1489 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001490 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001491 -C "! ssl_handshake returned" \
1492 -C "X509 - Certificate verification failed"
1493
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001494run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001495 "$P_SRV debug_level=3 auth_mode=required" \
1496 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001497 key_file=data_files/server5.key" \
1498 1 \
1499 -S "skip write certificate request" \
1500 -C "skip parse certificate request" \
1501 -c "got a certificate request" \
1502 -C "skip write certificate" \
1503 -C "skip write certificate verify" \
1504 -S "skip parse certificate verify" \
1505 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001506 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001507 -s "! ssl_handshake returned" \
1508 -c "! ssl_handshake returned" \
1509 -s "X509 - Certificate verification failed"
1510
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001511run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001512 "$P_SRV debug_level=3 auth_mode=optional" \
1513 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001514 key_file=data_files/server5.key" \
1515 0 \
1516 -S "skip write certificate request" \
1517 -C "skip parse certificate request" \
1518 -c "got a certificate request" \
1519 -C "skip write certificate" \
1520 -C "skip write certificate verify" \
1521 -S "skip parse certificate verify" \
1522 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001523 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001524 -S "! ssl_handshake returned" \
1525 -C "! ssl_handshake returned" \
1526 -S "X509 - Certificate verification failed"
1527
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001528run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001529 "$P_SRV debug_level=3 auth_mode=none" \
1530 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001531 key_file=data_files/server5.key" \
1532 0 \
1533 -s "skip write certificate request" \
1534 -C "skip parse certificate request" \
1535 -c "got no certificate request" \
1536 -c "skip write certificate" \
1537 -c "skip write certificate verify" \
1538 -s "skip parse certificate verify" \
1539 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001540 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001541 -S "! ssl_handshake returned" \
1542 -C "! ssl_handshake returned" \
1543 -S "X509 - Certificate verification failed"
1544
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001545run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001546 "$P_SRV debug_level=3 auth_mode=optional" \
1547 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001548 0 \
1549 -S "skip write certificate request" \
1550 -C "skip parse certificate request" \
1551 -c "got a certificate request" \
1552 -C "skip write certificate$" \
1553 -C "got no certificate to send" \
1554 -S "SSLv3 client has no certificate" \
1555 -c "skip write certificate verify" \
1556 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001557 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001558 -S "! ssl_handshake returned" \
1559 -C "! ssl_handshake returned" \
1560 -S "X509 - Certificate verification failed"
1561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001562run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001563 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001564 "$O_CLI" \
1565 0 \
1566 -S "skip write certificate request" \
1567 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001568 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001569 -S "! ssl_handshake returned" \
1570 -S "X509 - Certificate verification failed"
1571
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001572run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001573 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001574 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001575 0 \
1576 -C "skip parse certificate request" \
1577 -c "got a certificate request" \
1578 -C "skip write certificate$" \
1579 -c "skip write certificate verify" \
1580 -C "! ssl_handshake returned"
1581
Janos Follath4dfecab2016-03-14 13:40:43 +00001582requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001583run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001584 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001585 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001586 0 \
1587 -S "skip write certificate request" \
1588 -C "skip parse certificate request" \
1589 -c "got a certificate request" \
1590 -C "skip write certificate$" \
1591 -c "skip write certificate verify" \
1592 -c "got no certificate to send" \
1593 -s "SSLv3 client has no certificate" \
1594 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001595 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001596 -S "! ssl_handshake returned" \
1597 -C "! ssl_handshake returned" \
1598 -S "X509 - Certificate verification failed"
1599
Manuel Pégourié-Gonnarda68d5912017-07-10 11:31:43 +02001600run_test "Authentication: server max_int chain, client default" \
1601 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
1602 key_file=data_files/dir-maxpath/09.key" \
1603 "$P_CLI server_name=CA09 server_addr=127.0.0.1 \
1604 ca_file=data_files/dir-maxpath/00.crt" \
1605 0 \
1606 -C "X509 - A fatal error occured"
1607
1608run_test "Authentication: server max_int+1 chain, client default" \
1609 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
1610 key_file=data_files/dir-maxpath/10.key" \
1611 "$P_CLI server_name=CA10 server_addr=127.0.0.1 \
1612 ca_file=data_files/dir-maxpath/00.crt" \
1613 1 \
1614 -c "X509 - A fatal error occured"
1615
1616run_test "Authentication: server max_int+1 chain, client optional" \
1617 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
1618 key_file=data_files/dir-maxpath/10.key" \
1619 "$P_CLI server_name=CA10 server_addr=127.0.0.1 \
1620 ca_file=data_files/dir-maxpath/00.crt \
1621 auth_mode=optional" \
1622 1 \
1623 -c "X509 - A fatal error occured"
1624
1625run_test "Authentication: server max_int+1 chain, client none" \
1626 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
1627 key_file=data_files/dir-maxpath/10.key" \
1628 "$P_CLI server_name=CA10 server_addr=127.0.0.1 ca_file=data_files/dir-maxpath/00.crt \
1629 auth_mode=none" \
1630 0 \
1631 -C "X509 - A fatal error occured"
1632
1633run_test "Authentication: client max_int+1 chain, server none" \
1634 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=none" \
1635 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
1636 key_file=data_files/dir-maxpath/10.key" \
1637 0 \
1638 -S "X509 - A fatal error occured"
1639
1640run_test "Authentication: client max_int+1 chain, server optional" \
1641 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
1642 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
1643 key_file=data_files/dir-maxpath/10.key" \
1644 1 \
1645 -s "X509 - A fatal error occured"
1646
1647run_test "Authentication: client max_int+1 chain, server required" \
1648 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
1649 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
1650 key_file=data_files/dir-maxpath/10.key" \
1651 1 \
1652 -s "X509 - A fatal error occured"
1653
1654run_test "Authentication: client max_int chain, server required" \
1655 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
1656 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
1657 key_file=data_files/dir-maxpath/09.key" \
1658 0 \
1659 -S "X509 - A fatal error occured"
1660
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001661# Tests for certificate selection based on SHA verson
1662
1663run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1664 "$P_SRV crt_file=data_files/server5.crt \
1665 key_file=data_files/server5.key \
1666 crt_file2=data_files/server5-sha1.crt \
1667 key_file2=data_files/server5.key" \
1668 "$P_CLI force_version=tls1_2" \
1669 0 \
1670 -c "signed using.*ECDSA with SHA256" \
1671 -C "signed using.*ECDSA with SHA1"
1672
1673run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1674 "$P_SRV crt_file=data_files/server5.crt \
1675 key_file=data_files/server5.key \
1676 crt_file2=data_files/server5-sha1.crt \
1677 key_file2=data_files/server5.key" \
1678 "$P_CLI force_version=tls1_1" \
1679 0 \
1680 -C "signed using.*ECDSA with SHA256" \
1681 -c "signed using.*ECDSA with SHA1"
1682
1683run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1684 "$P_SRV crt_file=data_files/server5.crt \
1685 key_file=data_files/server5.key \
1686 crt_file2=data_files/server5-sha1.crt \
1687 key_file2=data_files/server5.key" \
1688 "$P_CLI force_version=tls1" \
1689 0 \
1690 -C "signed using.*ECDSA with SHA256" \
1691 -c "signed using.*ECDSA with SHA1"
1692
1693run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1694 "$P_SRV crt_file=data_files/server5.crt \
1695 key_file=data_files/server5.key \
1696 crt_file2=data_files/server6.crt \
1697 key_file2=data_files/server6.key" \
1698 "$P_CLI force_version=tls1_1" \
1699 0 \
1700 -c "serial number.*09" \
1701 -c "signed using.*ECDSA with SHA256" \
1702 -C "signed using.*ECDSA with SHA1"
1703
1704run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1705 "$P_SRV crt_file=data_files/server6.crt \
1706 key_file=data_files/server6.key \
1707 crt_file2=data_files/server5.crt \
1708 key_file2=data_files/server5.key" \
1709 "$P_CLI force_version=tls1_1" \
1710 0 \
1711 -c "serial number.*0A" \
1712 -c "signed using.*ECDSA with SHA256" \
1713 -C "signed using.*ECDSA with SHA1"
1714
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001715# tests for SNI
1716
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001717run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001718 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001719 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001720 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001721 server_name=localhost" \
1722 0 \
1723 -S "parse ServerName extension" \
1724 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1725 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1726
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001727run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001728 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001729 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001730 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 +01001731 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001732 server_name=localhost" \
1733 0 \
1734 -s "parse ServerName extension" \
1735 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1736 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1737
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001738run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001739 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001740 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001741 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 +01001742 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001743 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001744 0 \
1745 -s "parse ServerName extension" \
1746 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001747 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001749run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001750 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001751 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001752 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 +01001753 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001754 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001755 1 \
1756 -s "parse ServerName extension" \
1757 -s "ssl_sni_wrapper() returned" \
1758 -s "ssl_handshake returned" \
1759 -c "ssl_handshake returned" \
1760 -c "SSL - A fatal alert message was received from our peer"
1761
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001762# Tests for non-blocking I/O: exercise a variety of handshake flows
1763
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001764run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001765 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1766 "$P_CLI nbio=2 tickets=0" \
1767 0 \
1768 -S "ssl_handshake returned" \
1769 -C "ssl_handshake returned" \
1770 -c "Read from server: .* bytes read"
1771
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001772run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001773 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1774 "$P_CLI nbio=2 tickets=0" \
1775 0 \
1776 -S "ssl_handshake returned" \
1777 -C "ssl_handshake returned" \
1778 -c "Read from server: .* bytes read"
1779
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001780run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001781 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1782 "$P_CLI nbio=2 tickets=1" \
1783 0 \
1784 -S "ssl_handshake returned" \
1785 -C "ssl_handshake returned" \
1786 -c "Read from server: .* bytes read"
1787
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001788run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001789 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1790 "$P_CLI nbio=2 tickets=1" \
1791 0 \
1792 -S "ssl_handshake returned" \
1793 -C "ssl_handshake returned" \
1794 -c "Read from server: .* bytes read"
1795
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001796run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001797 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1798 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1799 0 \
1800 -S "ssl_handshake returned" \
1801 -C "ssl_handshake returned" \
1802 -c "Read from server: .* bytes read"
1803
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001804run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001805 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1806 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1807 0 \
1808 -S "ssl_handshake returned" \
1809 -C "ssl_handshake returned" \
1810 -c "Read from server: .* bytes read"
1811
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001812run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001813 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1814 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1815 0 \
1816 -S "ssl_handshake returned" \
1817 -C "ssl_handshake returned" \
1818 -c "Read from server: .* bytes read"
1819
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001820# Tests for version negotiation
1821
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001822run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001823 "$P_SRV" \
1824 "$P_CLI" \
1825 0 \
1826 -S "ssl_handshake returned" \
1827 -C "ssl_handshake returned" \
1828 -s "Protocol is TLSv1.2" \
1829 -c "Protocol is TLSv1.2"
1830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001831run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001832 "$P_SRV" \
1833 "$P_CLI max_version=tls1_1" \
1834 0 \
1835 -S "ssl_handshake returned" \
1836 -C "ssl_handshake returned" \
1837 -s "Protocol is TLSv1.1" \
1838 -c "Protocol is TLSv1.1"
1839
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001840run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001841 "$P_SRV max_version=tls1_1" \
1842 "$P_CLI" \
1843 0 \
1844 -S "ssl_handshake returned" \
1845 -C "ssl_handshake returned" \
1846 -s "Protocol is TLSv1.1" \
1847 -c "Protocol is TLSv1.1"
1848
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001849run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001850 "$P_SRV max_version=tls1_1" \
1851 "$P_CLI max_version=tls1_1" \
1852 0 \
1853 -S "ssl_handshake returned" \
1854 -C "ssl_handshake returned" \
1855 -s "Protocol is TLSv1.1" \
1856 -c "Protocol is TLSv1.1"
1857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001858run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001859 "$P_SRV min_version=tls1_1" \
1860 "$P_CLI max_version=tls1_1" \
1861 0 \
1862 -S "ssl_handshake returned" \
1863 -C "ssl_handshake returned" \
1864 -s "Protocol is TLSv1.1" \
1865 -c "Protocol is TLSv1.1"
1866
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001867run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001868 "$P_SRV max_version=tls1_1" \
1869 "$P_CLI min_version=tls1_1" \
1870 0 \
1871 -S "ssl_handshake returned" \
1872 -C "ssl_handshake returned" \
1873 -s "Protocol is TLSv1.1" \
1874 -c "Protocol is TLSv1.1"
1875
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001876run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001877 "$P_SRV max_version=tls1_1" \
1878 "$P_CLI min_version=tls1_2" \
1879 1 \
1880 -s "ssl_handshake returned" \
1881 -c "ssl_handshake returned" \
1882 -c "SSL - Handshake protocol not within min/max boundaries"
1883
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001884run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001885 "$P_SRV min_version=tls1_2" \
1886 "$P_CLI max_version=tls1_1" \
1887 1 \
1888 -s "ssl_handshake returned" \
1889 -c "ssl_handshake returned" \
1890 -s "SSL - Handshake protocol not within min/max boundaries"
1891
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001892# Tests for ALPN extension
1893
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001894if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001896run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001897 "$P_SRV debug_level=3" \
1898 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001899 0 \
1900 -C "client hello, adding alpn extension" \
1901 -S "found alpn extension" \
1902 -C "got an alert message, type: \\[2:120]" \
1903 -S "server hello, adding alpn extension" \
1904 -C "found alpn extension " \
1905 -C "Application Layer Protocol is" \
1906 -S "Application Layer Protocol is"
1907
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001908run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001909 "$P_SRV debug_level=3" \
1910 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001911 0 \
1912 -c "client hello, adding alpn extension" \
1913 -s "found alpn extension" \
1914 -C "got an alert message, type: \\[2:120]" \
1915 -S "server hello, adding alpn extension" \
1916 -C "found alpn extension " \
1917 -c "Application Layer Protocol is (none)" \
1918 -S "Application Layer Protocol is"
1919
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001920run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001921 "$P_SRV debug_level=3 alpn=abc,1234" \
1922 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001923 0 \
1924 -C "client hello, adding alpn extension" \
1925 -S "found alpn extension" \
1926 -C "got an alert message, type: \\[2:120]" \
1927 -S "server hello, adding alpn extension" \
1928 -C "found alpn extension " \
1929 -C "Application Layer Protocol is" \
1930 -s "Application Layer Protocol is (none)"
1931
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001932run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001933 "$P_SRV debug_level=3 alpn=abc,1234" \
1934 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001935 0 \
1936 -c "client hello, adding alpn extension" \
1937 -s "found alpn extension" \
1938 -C "got an alert message, type: \\[2:120]" \
1939 -s "server hello, adding alpn extension" \
1940 -c "found alpn extension" \
1941 -c "Application Layer Protocol is abc" \
1942 -s "Application Layer Protocol is abc"
1943
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001944run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001945 "$P_SRV debug_level=3 alpn=abc,1234" \
1946 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001947 0 \
1948 -c "client hello, adding alpn extension" \
1949 -s "found alpn extension" \
1950 -C "got an alert message, type: \\[2:120]" \
1951 -s "server hello, adding alpn extension" \
1952 -c "found alpn extension" \
1953 -c "Application Layer Protocol is abc" \
1954 -s "Application Layer Protocol is abc"
1955
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001956run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001957 "$P_SRV debug_level=3 alpn=abc,1234" \
1958 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001959 0 \
1960 -c "client hello, adding alpn extension" \
1961 -s "found alpn extension" \
1962 -C "got an alert message, type: \\[2:120]" \
1963 -s "server hello, adding alpn extension" \
1964 -c "found alpn extension" \
1965 -c "Application Layer Protocol is 1234" \
1966 -s "Application Layer Protocol is 1234"
1967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001968run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001969 "$P_SRV debug_level=3 alpn=abc,123" \
1970 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001971 1 \
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 1234" \
1978 -S "Application Layer Protocol is 1234"
1979
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001980fi
1981
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001982# Tests for keyUsage in leaf certificates, part 1:
1983# server-side certificate/suite selection
1984
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001985run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001986 "$P_SRV key_file=data_files/server2.key \
1987 crt_file=data_files/server2.ku-ds.crt" \
1988 "$P_CLI" \
1989 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001990 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001991
1992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001993run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001994 "$P_SRV key_file=data_files/server2.key \
1995 crt_file=data_files/server2.ku-ke.crt" \
1996 "$P_CLI" \
1997 0 \
1998 -c "Ciphersuite is TLS-RSA-WITH-"
1999
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002000run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002001 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002002 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002003 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002004 1 \
2005 -C "Ciphersuite is "
2006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002007run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002008 "$P_SRV key_file=data_files/server5.key \
2009 crt_file=data_files/server5.ku-ds.crt" \
2010 "$P_CLI" \
2011 0 \
2012 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2013
2014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002015run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002016 "$P_SRV key_file=data_files/server5.key \
2017 crt_file=data_files/server5.ku-ka.crt" \
2018 "$P_CLI" \
2019 0 \
2020 -c "Ciphersuite is TLS-ECDH-"
2021
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002022run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002023 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002024 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002025 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002026 1 \
2027 -C "Ciphersuite is "
2028
2029# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002030# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002031
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002032run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002033 "$O_SRV -key data_files/server2.key \
2034 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002035 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002036 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2037 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002038 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002039 -C "Processing of the Certificate handshake message failed" \
2040 -c "Ciphersuite is TLS-"
2041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002042run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002043 "$O_SRV -key data_files/server2.key \
2044 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002045 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002046 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2047 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002048 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002049 -C "Processing of the Certificate handshake message failed" \
2050 -c "Ciphersuite is TLS-"
2051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002052run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002053 "$O_SRV -key data_files/server2.key \
2054 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002055 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002056 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2057 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002058 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002059 -C "Processing of the Certificate handshake message failed" \
2060 -c "Ciphersuite is TLS-"
2061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002062run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002063 "$O_SRV -key data_files/server2.key \
2064 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002065 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002066 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2067 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002068 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002069 -c "Processing of the Certificate handshake message failed" \
2070 -C "Ciphersuite is TLS-"
2071
Manuel Pégourié-Gonnarde16b62c2015-04-17 16:55:53 +02002072run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2073 "$O_SRV -key data_files/server2.key \
2074 -cert data_files/server2.ku-ke.crt" \
2075 "$P_CLI debug_level=1 auth_mode=optional \
2076 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2077 0 \
2078 -c "bad certificate (usage extensions)" \
2079 -C "Processing of the Certificate handshake message failed" \
2080 -c "Ciphersuite is TLS-" \
2081 -c "! Usage does not match the keyUsage extension"
2082
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002083run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002084 "$O_SRV -key data_files/server2.key \
2085 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002086 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002087 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2088 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002089 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002090 -C "Processing of the Certificate handshake message failed" \
2091 -c "Ciphersuite is TLS-"
2092
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002093run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002094 "$O_SRV -key data_files/server2.key \
2095 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002096 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002097 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2098 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002099 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002100 -c "Processing of the Certificate handshake message failed" \
2101 -C "Ciphersuite is TLS-"
2102
Manuel Pégourié-Gonnarde16b62c2015-04-17 16:55:53 +02002103run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2104 "$O_SRV -key data_files/server2.key \
2105 -cert data_files/server2.ku-ds.crt" \
2106 "$P_CLI debug_level=1 auth_mode=optional \
2107 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2108 0 \
2109 -c "bad certificate (usage extensions)" \
2110 -C "Processing of the Certificate handshake message failed" \
2111 -c "Ciphersuite is TLS-" \
2112 -c "! Usage does not match the keyUsage extension"
2113
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002114# Tests for keyUsage in leaf certificates, part 3:
2115# server-side checking of client cert
2116
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002117run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002118 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002119 "$O_CLI -key data_files/server2.key \
2120 -cert data_files/server2.ku-ds.crt" \
2121 0 \
2122 -S "bad certificate (usage extensions)" \
2123 -S "Processing of the Certificate handshake message failed"
2124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002125run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002126 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002127 "$O_CLI -key data_files/server2.key \
2128 -cert data_files/server2.ku-ke.crt" \
2129 0 \
2130 -s "bad certificate (usage extensions)" \
2131 -S "Processing of the Certificate handshake message failed"
2132
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002133run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002134 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002135 "$O_CLI -key data_files/server2.key \
2136 -cert data_files/server2.ku-ke.crt" \
2137 1 \
2138 -s "bad certificate (usage extensions)" \
2139 -s "Processing of the Certificate handshake message failed"
2140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002141run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002142 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002143 "$O_CLI -key data_files/server5.key \
2144 -cert data_files/server5.ku-ds.crt" \
2145 0 \
2146 -S "bad certificate (usage extensions)" \
2147 -S "Processing of the Certificate handshake message failed"
2148
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002149run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002150 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002151 "$O_CLI -key data_files/server5.key \
2152 -cert data_files/server5.ku-ka.crt" \
2153 0 \
2154 -s "bad certificate (usage extensions)" \
2155 -S "Processing of the Certificate handshake message failed"
2156
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002157# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2158
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002159run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002160 "$P_SRV key_file=data_files/server5.key \
2161 crt_file=data_files/server5.eku-srv.crt" \
2162 "$P_CLI" \
2163 0
2164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002165run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002166 "$P_SRV key_file=data_files/server5.key \
2167 crt_file=data_files/server5.eku-srv.crt" \
2168 "$P_CLI" \
2169 0
2170
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002171run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002172 "$P_SRV key_file=data_files/server5.key \
2173 crt_file=data_files/server5.eku-cs_any.crt" \
2174 "$P_CLI" \
2175 0
2176
2177# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002178run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002179 "$P_SRV psk=abc123 key_file=data_files/server5.key \
2180 crt_file=data_files/server5.eku-cli.crt" \
2181 "$P_CLI psk=badbad" \
2182 1
2183
2184# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2185
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002186run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002187 "$O_SRV -key data_files/server5.key \
2188 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002189 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002190 0 \
2191 -C "bad certificate (usage extensions)" \
2192 -C "Processing of the Certificate handshake message failed" \
2193 -c "Ciphersuite is TLS-"
2194
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002195run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002196 "$O_SRV -key data_files/server5.key \
2197 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002198 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002199 0 \
2200 -C "bad certificate (usage extensions)" \
2201 -C "Processing of the Certificate handshake message failed" \
2202 -c "Ciphersuite is TLS-"
2203
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002204run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002205 "$O_SRV -key data_files/server5.key \
2206 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002207 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002208 0 \
2209 -C "bad certificate (usage extensions)" \
2210 -C "Processing of the Certificate handshake message failed" \
2211 -c "Ciphersuite is TLS-"
2212
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002213run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002214 "$O_SRV -key data_files/server5.key \
2215 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002216 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002217 1 \
2218 -c "bad certificate (usage extensions)" \
2219 -c "Processing of the Certificate handshake message failed" \
2220 -C "Ciphersuite is TLS-"
2221
2222# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002224run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002225 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002226 "$O_CLI -key data_files/server5.key \
2227 -cert data_files/server5.eku-cli.crt" \
2228 0 \
2229 -S "bad certificate (usage extensions)" \
2230 -S "Processing of the Certificate handshake message failed"
2231
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002232run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002233 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002234 "$O_CLI -key data_files/server5.key \
2235 -cert data_files/server5.eku-srv_cli.crt" \
2236 0 \
2237 -S "bad certificate (usage extensions)" \
2238 -S "Processing of the Certificate handshake message failed"
2239
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002240run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002241 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002242 "$O_CLI -key data_files/server5.key \
2243 -cert data_files/server5.eku-cs_any.crt" \
2244 0 \
2245 -S "bad certificate (usage extensions)" \
2246 -S "Processing of the Certificate handshake message failed"
2247
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002248run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002249 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002250 "$O_CLI -key data_files/server5.key \
2251 -cert data_files/server5.eku-cs.crt" \
2252 0 \
2253 -s "bad certificate (usage extensions)" \
2254 -S "Processing of the Certificate handshake message failed"
2255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002256run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002257 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002258 "$O_CLI -key data_files/server5.key \
2259 -cert data_files/server5.eku-cs.crt" \
2260 1 \
2261 -s "bad certificate (usage extensions)" \
2262 -s "Processing of the Certificate handshake message failed"
2263
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002264# Tests for DHM parameters loading
2265
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002266run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002267 "$P_SRV" \
2268 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2269 debug_level=3" \
2270 0 \
2271 -c "value of 'DHM: P ' (2048 bits)" \
2272 -c "value of 'DHM: G ' (2048 bits)"
2273
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002274run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002275 "$P_SRV dhm_file=data_files/dhparams.pem" \
2276 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2277 debug_level=3" \
2278 0 \
2279 -c "value of 'DHM: P ' (1024 bits)" \
2280 -c "value of 'DHM: G ' (2 bits)"
2281
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002282# Tests for PSK callback
2283
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002284run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002285 "$P_SRV psk=abc123 psk_identity=foo" \
2286 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2287 psk_identity=foo psk=abc123" \
2288 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002289 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002290 -S "SSL - Unknown identity received" \
2291 -S "SSL - Verification of the message MAC failed"
2292
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002293run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002294 "$P_SRV" \
2295 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2296 psk_identity=foo psk=abc123" \
2297 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002298 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002299 -S "SSL - Unknown identity received" \
2300 -S "SSL - Verification of the message MAC failed"
2301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002302run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002303 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2304 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2305 psk_identity=foo psk=abc123" \
2306 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002307 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002308 -s "SSL - Unknown identity received" \
2309 -S "SSL - Verification of the message MAC failed"
2310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002311run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002312 "$P_SRV psk_list=abc,dead,def,beef" \
2313 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2314 psk_identity=abc psk=dead" \
2315 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002316 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002317 -S "SSL - Unknown identity received" \
2318 -S "SSL - Verification of the message MAC failed"
2319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002320run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002321 "$P_SRV psk_list=abc,dead,def,beef" \
2322 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2323 psk_identity=def psk=beef" \
2324 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002325 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002326 -S "SSL - Unknown identity received" \
2327 -S "SSL - Verification of the message MAC failed"
2328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002329run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002330 "$P_SRV psk_list=abc,dead,def,beef" \
2331 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2332 psk_identity=ghi psk=beef" \
2333 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002334 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002335 -s "SSL - Unknown identity received" \
2336 -S "SSL - Verification of the message MAC failed"
2337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002338run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002339 "$P_SRV psk_list=abc,dead,def,beef" \
2340 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2341 psk_identity=abc psk=beef" \
2342 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002343 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002344 -S "SSL - Unknown identity received" \
2345 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002346
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002347# Tests for ciphersuites per version
2348
Janos Follath4dfecab2016-03-14 13:40:43 +00002349requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002350run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002351 "$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 +02002352 "$P_CLI force_version=ssl3" \
2353 0 \
2354 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002356run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002357 "$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" \
2358 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002359 0 \
2360 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2361
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002362run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002363 "$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" \
2364 "$P_CLI force_version=tls1_1" \
2365 0 \
2366 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2367
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002368run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002369 "$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" \
2370 "$P_CLI force_version=tls1_2" \
2371 0 \
2372 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2373
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002374# Tests for ssl_get_bytes_avail()
2375
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002376run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002377 "$P_SRV" \
2378 "$P_CLI request_size=100" \
2379 0 \
2380 -s "Read from client: 100 bytes read$"
2381
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002382run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002383 "$P_SRV" \
2384 "$P_CLI request_size=500" \
2385 0 \
2386 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002387
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002388# Tests for small packets
2389
Janos Follath4dfecab2016-03-14 13:40:43 +00002390requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002391run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002392 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002393 "$P_CLI request_size=1 force_version=ssl3 \
2394 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2395 0 \
2396 -s "Read from client: 1 bytes read"
2397
Janos Follath4dfecab2016-03-14 13:40:43 +00002398requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002399run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002400 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002401 "$P_CLI request_size=1 force_version=ssl3 \
2402 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2403 0 \
2404 -s "Read from client: 1 bytes read"
2405
2406run_test "Small packet TLS 1.0 BlockCipher" \
2407 "$P_SRV" \
2408 "$P_CLI request_size=1 force_version=tls1 \
2409 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2410 0 \
2411 -s "Read from client: 1 bytes read"
2412
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002413run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2414 "$P_SRV" \
2415 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2416 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2417 0 \
2418 -s "Read from client: 1 bytes read"
2419
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002420run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2421 "$P_SRV" \
2422 "$P_CLI request_size=1 force_version=tls1 \
2423 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2424 trunc_hmac=1" \
2425 0 \
2426 -s "Read from client: 1 bytes read"
2427
2428run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002429 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002430 "$P_CLI request_size=1 force_version=tls1 \
2431 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2432 trunc_hmac=1" \
2433 0 \
2434 -s "Read from client: 1 bytes read"
2435
2436run_test "Small packet TLS 1.1 BlockCipher" \
2437 "$P_SRV" \
2438 "$P_CLI request_size=1 force_version=tls1_1 \
2439 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2440 0 \
2441 -s "Read from client: 1 bytes read"
2442
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002443run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2444 "$P_SRV" \
2445 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2446 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2447 0 \
2448 -s "Read from client: 1 bytes read"
2449
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002450run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002451 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002452 "$P_CLI request_size=1 force_version=tls1_1 \
2453 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2454 0 \
2455 -s "Read from client: 1 bytes read"
2456
2457run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2458 "$P_SRV" \
2459 "$P_CLI request_size=1 force_version=tls1_1 \
2460 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2461 trunc_hmac=1" \
2462 0 \
2463 -s "Read from client: 1 bytes read"
2464
2465run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002466 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002467 "$P_CLI request_size=1 force_version=tls1_1 \
2468 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2469 trunc_hmac=1" \
2470 0 \
2471 -s "Read from client: 1 bytes read"
2472
2473run_test "Small packet TLS 1.2 BlockCipher" \
2474 "$P_SRV" \
2475 "$P_CLI request_size=1 force_version=tls1_2 \
2476 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2477 0 \
2478 -s "Read from client: 1 bytes read"
2479
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002480run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2481 "$P_SRV" \
2482 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2483 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2484 0 \
2485 -s "Read from client: 1 bytes read"
2486
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002487run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2488 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002489 "$P_CLI request_size=1 force_version=tls1_2 \
2490 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002491 0 \
2492 -s "Read from client: 1 bytes read"
2493
2494run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2495 "$P_SRV" \
2496 "$P_CLI request_size=1 force_version=tls1_2 \
2497 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2498 trunc_hmac=1" \
2499 0 \
2500 -s "Read from client: 1 bytes read"
2501
2502run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002503 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002504 "$P_CLI request_size=1 force_version=tls1_2 \
2505 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2506 0 \
2507 -s "Read from client: 1 bytes read"
2508
2509run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002510 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002511 "$P_CLI request_size=1 force_version=tls1_2 \
2512 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2513 trunc_hmac=1" \
2514 0 \
2515 -s "Read from client: 1 bytes read"
2516
2517run_test "Small packet TLS 1.2 AEAD" \
2518 "$P_SRV" \
2519 "$P_CLI request_size=1 force_version=tls1_2 \
2520 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2521 0 \
2522 -s "Read from client: 1 bytes read"
2523
2524run_test "Small packet TLS 1.2 AEAD shorter tag" \
2525 "$P_SRV" \
2526 "$P_CLI request_size=1 force_version=tls1_2 \
2527 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2528 0 \
2529 -s "Read from client: 1 bytes read"
2530
Janos Follath8abaa8b2016-05-06 13:48:23 +01002531# A test for extensions in SSLv3
2532
Hanno Becker6fd6d242017-05-25 17:51:31 +01002533requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Janos Follath8abaa8b2016-05-06 13:48:23 +01002534run_test "SSLv3 with extensions, server side" \
2535 "$P_SRV min_version=ssl3 debug_level=3" \
2536 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2537 0 \
2538 -S "dumping 'client hello extensions'" \
2539 -S "server hello, total extension length:"
2540
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002541# Test for large packets
2542
Janos Follath4dfecab2016-03-14 13:40:43 +00002543requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002544run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002545 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002546 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002547 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2548 0 \
2549 -s "Read from client: 16384 bytes read"
2550
Janos Follath4dfecab2016-03-14 13:40:43 +00002551requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002552run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002553 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002554 "$P_CLI request_size=16384 force_version=ssl3 \
2555 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2556 0 \
2557 -s "Read from client: 16384 bytes read"
2558
2559run_test "Large packet TLS 1.0 BlockCipher" \
2560 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002561 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002562 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2563 0 \
2564 -s "Read from client: 16384 bytes read"
2565
2566run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2567 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002568 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002569 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2570 trunc_hmac=1" \
2571 0 \
2572 -s "Read from client: 16384 bytes read"
2573
2574run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002575 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002576 "$P_CLI request_size=16384 force_version=tls1 \
2577 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2578 trunc_hmac=1" \
2579 0 \
2580 -s "Read from client: 16384 bytes read"
2581
2582run_test "Large packet TLS 1.1 BlockCipher" \
2583 "$P_SRV" \
2584 "$P_CLI request_size=16384 force_version=tls1_1 \
2585 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2586 0 \
2587 -s "Read from client: 16384 bytes read"
2588
2589run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002590 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002591 "$P_CLI request_size=16384 force_version=tls1_1 \
2592 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2593 0 \
2594 -s "Read from client: 16384 bytes read"
2595
2596run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2597 "$P_SRV" \
2598 "$P_CLI request_size=16384 force_version=tls1_1 \
2599 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2600 trunc_hmac=1" \
2601 0 \
2602 -s "Read from client: 16384 bytes read"
2603
2604run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002605 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002606 "$P_CLI request_size=16384 force_version=tls1_1 \
2607 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2608 trunc_hmac=1" \
2609 0 \
2610 -s "Read from client: 16384 bytes read"
2611
2612run_test "Large packet TLS 1.2 BlockCipher" \
2613 "$P_SRV" \
2614 "$P_CLI request_size=16384 force_version=tls1_2 \
2615 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2616 0 \
2617 -s "Read from client: 16384 bytes read"
2618
2619run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2620 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002621 "$P_CLI request_size=16384 force_version=tls1_2 \
2622 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002623 0 \
2624 -s "Read from client: 16384 bytes read"
2625
2626run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2627 "$P_SRV" \
2628 "$P_CLI request_size=16384 force_version=tls1_2 \
2629 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2630 trunc_hmac=1" \
2631 0 \
2632 -s "Read from client: 16384 bytes read"
2633
2634run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002635 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002636 "$P_CLI request_size=16384 force_version=tls1_2 \
2637 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2638 0 \
2639 -s "Read from client: 16384 bytes read"
2640
2641run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002642 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002643 "$P_CLI request_size=16384 force_version=tls1_2 \
2644 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2645 trunc_hmac=1" \
2646 0 \
2647 -s "Read from client: 16384 bytes read"
2648
2649run_test "Large packet TLS 1.2 AEAD" \
2650 "$P_SRV" \
2651 "$P_CLI request_size=16384 force_version=tls1_2 \
2652 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2653 0 \
2654 -s "Read from client: 16384 bytes read"
2655
2656run_test "Large packet TLS 1.2 AEAD shorter tag" \
2657 "$P_SRV" \
2658 "$P_CLI request_size=16384 force_version=tls1_2 \
2659 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2660 0 \
2661 -s "Read from client: 16384 bytes read"
2662
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002663# Final report
2664
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002665echo "------------------------------------------------------------------------"
2666
2667if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002668 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002669else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002670 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002671fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002672PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002673echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002674
2675exit $FAILS