blob: a018f64a26cf5d3a3d160f77bc149215b8727ac1 [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}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010019
Manuel Pégourié-Gonnard6461f362015-06-29 16:20:13 +020020O_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 +010021O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020022G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010023G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010024
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010025TESTS=0
26FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020027SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020029CONFIG_H='../include/polarssl/config.h'
30
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010031MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010032FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020033EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034
35print_usage() {
36 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010037 printf " -h|--help\tPrint this help.\n"
38 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
39 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
40 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041}
42
43get_options() {
44 while [ $# -gt 0 ]; do
45 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046 -f|--filter)
47 shift; FILTER=$1
48 ;;
49 -e|--exclude)
50 shift; EXCLUDE=$1
51 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052 -m|--memcheck)
53 MEMCHECK=1
54 ;;
55 -h|--help)
56 print_usage
57 exit 0
58 ;;
59 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020060 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061 print_usage
62 exit 1
63 ;;
64 esac
65 shift
66 done
67}
68
Janos Follath4dfecab2016-03-14 13:40:43 +000069# skip next test if the flag is not enabled in config.h
70requires_config_enabled() {
71 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
72 SKIP_NEXT="YES"
73 fi
74}
75
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020076# skip next test if OpenSSL can't send SSLv2 ClientHello
77requires_openssl_with_sslv2() {
78 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020079 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020080 OPENSSL_HAS_SSL2="YES"
81 else
82 OPENSSL_HAS_SSL2="NO"
83 fi
84 fi
85 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
86 SKIP_NEXT="YES"
87 fi
88}
89
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020090# skip next test if OpenSSL doesn't support FALLBACK_SCSV
91requires_openssl_with_fallback_scsv() {
92 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
93 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
94 then
95 OPENSSL_HAS_FBSCSV="YES"
96 else
97 OPENSSL_HAS_FBSCSV="NO"
98 fi
99 fi
100 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
101 SKIP_NEXT="YES"
102 fi
103}
104
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200105# skip next test if GnuTLS isn't available
106requires_gnutls() {
107 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
108 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
109 GNUTLS_AVAILABLE="YES"
110 else
111 GNUTLS_AVAILABLE="NO"
112 fi
113 fi
114 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
115 SKIP_NEXT="YES"
116 fi
117}
118
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100119# print_name <name>
120print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100121 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200122 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100123 for i in `seq 1 $LEN`; do printf '.'; done
124 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100125
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200126 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100127}
128
129# fail <message>
130fail() {
131 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100132 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100133
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200134 mv $SRV_OUT o-srv-${TESTS}.log
135 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100136 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100137
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200138 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
139 echo " ! server output:"
140 cat o-srv-${TESTS}.log
141 echo " ! ============================================================"
142 echo " ! client output:"
143 cat o-cli-${TESTS}.log
144 fi
145
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200146 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100147}
148
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100149# is_polar <cmd_line>
150is_polar() {
151 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
152}
153
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100154# has_mem_err <log_file_name>
155has_mem_err() {
156 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
157 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
158 then
159 return 1 # false: does not have errors
160 else
161 return 0 # true: has errors
162 fi
163}
164
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200165# wait for server to start: two versions depending on lsof availability
166wait_server_start() {
Manuel Pégourié-Gonnard84690c32015-08-04 20:34:39 +0200167 if which lsof >/dev/null 2>&1; then
168 START_TIME=$( date +%s )
169 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200170
171 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard84690c32015-08-04 20:34:39 +0200172 while [ $DONE -eq 0 ]; do
173 if lsof -nbi TCP:"$PORT" 2>/dev/null | grep LISTEN >/dev/null
174 then
175 DONE=1
176 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
177 echo "SERVERSTART TIMEOUT"
178 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
179 DONE=1
180 fi
181 done
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200182 else
183 sleep "$START_DELAY"
184 fi
185}
186
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200187# wait for client to terminate and set CLI_EXIT
188# must be called right after starting the client
189wait_client_done() {
190 CLI_PID=$!
191
192 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
193 WATCHDOG_PID=$!
194
195 wait $CLI_PID
196 CLI_EXIT=$?
197
198 kill $WATCHDOG_PID
199 wait $WATCHDOG_PID
200
201 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
202}
203
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100204# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100205# Options: -s pattern pattern that must be present in server output
206# -c pattern pattern that must be present in client output
Simon Butcher696f92e2016-10-13 14:13:17 +0100207# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100208# -S pattern pattern that must be absent in server output
209# -C pattern pattern that must be absent in client output
Simon Butcher696f92e2016-10-13 14:13:17 +0100210# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100211run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100212 NAME="$1"
213 SRV_CMD="$2"
214 CLI_CMD="$3"
215 CLI_EXPECT="$4"
216 shift 4
217
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100218 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
219 else
220 return
221 fi
222
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100223 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100224
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200225 # should we skip?
226 if [ "X$SKIP_NEXT" = "XYES" ]; then
227 SKIP_NEXT="NO"
228 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200229 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200230 return
231 fi
232
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100233 # prepend valgrind to our commands if active
234 if [ "$MEMCHECK" -gt 0 ]; then
235 if is_polar "$SRV_CMD"; then
236 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
237 fi
238 if is_polar "$CLI_CMD"; then
239 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
240 fi
241 fi
242
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100243 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200244 echo "$SRV_CMD" > $SRV_OUT
245 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100246 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200247 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200248
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200249 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200250 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
251 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100252
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200253 # kill the server
254 kill $SRV_PID
255 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100256
257 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200258 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100259 # expected client exit to incorrectly succeed in case of catastrophic
260 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100261 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200262 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100263 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100264 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100265 return
266 fi
267 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100268 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200269 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100270 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100271 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100272 return
273 fi
274 fi
275
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100276 # check server exit code
277 if [ $? != 0 ]; then
278 fail "server fail"
279 return
280 fi
281
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100282 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100283 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
284 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100285 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100286 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100287 return
288 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100289
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100290 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200291 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100292 while [ $# -gt 0 ]
293 do
294 case $1 in
295 "-s")
Simon Butcher696f92e2016-10-13 14:13:17 +0100296 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
297 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100298 return
299 fi
300 ;;
301
302 "-c")
Simon Butcher696f92e2016-10-13 14:13:17 +0100303 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
304 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100305 return
306 fi
307 ;;
308
309 "-S")
Simon Butcher696f92e2016-10-13 14:13:17 +0100310 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
311 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100312 return
313 fi
314 ;;
315
316 "-C")
Simon Butcher696f92e2016-10-13 14:13:17 +0100317 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
318 fail "pattern '$2' MUST NOT be present in the Client output"
319 return
320 fi
321 ;;
322
323 # The filtering in the following two options (-u and -U) do the following
324 # - ignore valgrind output
325 # - filter out everything but lines right after the pattern occurances
326 # - keep one of each non-unique line
327 # - count how many lines remain
328 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
329 # if there were no duplicates.
330 "-U")
331 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
332 fail "lines following pattern '$2' must be unique in Server output"
333 return
334 fi
335 ;;
336
337 "-u")
338 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
339 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100340 return
341 fi
342 ;;
343
344 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200345 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100346 exit 1
347 esac
348 shift 2
349 done
350
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100351 # check valgrind's results
352 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200353 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100354 fail "Server has memory errors"
355 return
356 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200357 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100358 fail "Client has memory errors"
359 return
360 fi
361 fi
362
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100363 # if we're here, everything is ok
364 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200365 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100366}
367
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100368cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200369 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200370 kill $SRV_PID >/dev/null 2>&1
371 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100372 exit 1
373}
374
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100375#
376# MAIN
377#
378
Manuel Pégourié-Gonnard751286b2015-03-10 13:41:04 +0000379if cd $( dirname $0 ); then :; else
380 echo "cd $( dirname $0 ) failed" >&2
381 exit 1
382fi
383
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100384get_options "$@"
385
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100386# sanity checks, avoid an avalanche of errors
387if [ ! -x "$P_SRV" ]; then
388 echo "Command '$P_SRV' is not an executable file"
389 exit 1
390fi
391if [ ! -x "$P_CLI" ]; then
392 echo "Command '$P_CLI' is not an executable file"
393 exit 1
394fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100395if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
396 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100397 exit 1
398fi
399
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200400# used by watchdog
401MAIN_PID="$$"
402
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200403# be more patient with valgrind
404if [ "$MEMCHECK" -gt 0 ]; then
405 START_DELAY=3
406 DOG_DELAY=30
407else
408 START_DELAY=1
409 DOG_DELAY=10
410fi
411
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200412# Pick a "unique" port in the range 10000-19999.
413PORT="0000$$"
Manuel Pégourié-Gonnarddc370e42015-01-22 10:24:59 +0000414PORT="1$( printf $PORT | tail -c 4 )"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200415
416# fix commands to use this port
417P_SRV="$P_SRV server_port=$PORT"
418P_CLI="$P_CLI server_port=$PORT"
419O_SRV="$O_SRV -accept $PORT"
420O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200421G_SRV="$G_SRV -p $PORT"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100422G_CLI="$G_CLI -p $PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200423
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200424# Also pick a unique name for intermediate files
425SRV_OUT="srv_out.$$"
426CLI_OUT="cli_out.$$"
427SESSION="session.$$"
428
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200429SKIP_NEXT="NO"
430
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100431trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100432
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200433# Basic test
434
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200435# Checks that:
436# - things work with all ciphersuites active (used with config-full in all.sh)
437# - the expected (highest security) parameters are selected
438# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200439run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200440 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200441 "$P_CLI" \
442 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200443 -s "Protocol is TLSv1.2" \
444 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
445 -s "client hello v3, signature_algorithm ext: 6" \
446 -s "ECDHE curve: secp521r1" \
447 -S "error" \
448 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200449
Simon Butcher696f92e2016-10-13 14:13:17 +0100450# Test for uniqueness of IVs in AEAD ciphersuites
451run_test "Unique IV in GCM" \
452 "$P_SRV exchanges=20 debug_level=4" \
453 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
454 0 \
455 -u "IV used" \
456 -U "IV used"
457
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100458# Tests for rc4 option
459
460run_test "RC4: server disabled, client enabled" \
461 "$P_SRV" \
462 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
463 1 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100464 -s "SSL - None of the common ciphersuites is usable"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100465
466run_test "RC4: server enabled, client disabled" \
467 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
468 "$P_CLI" \
469 1 \
470 -s "SSL - The server has no ciphersuites in common"
471
472run_test "RC4: both enabled" \
473 "$P_SRV arc4=1" \
474 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
475 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100476 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100477 -S "SSL - The server has no ciphersuites in common"
478
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100479# Test for SSLv2 ClientHello
480
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200481requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200482run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100483 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100484 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100485 0 \
486 -S "parse client hello v2" \
487 -S "ssl_handshake returned"
488
489# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200490requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200491run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200492 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100493 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100494 0 \
495 -s "parse client hello v2" \
496 -S "ssl_handshake returned"
497
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100498# Tests for Truncated HMAC extension
499
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100500run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200501 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100502 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100503 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100504 -s "dumping 'computed mac' (20 bytes)" \
505 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100506
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100507run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200508 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100509 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
510 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100511 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100512 -s "dumping 'computed mac' (20 bytes)" \
513 -S "dumping 'computed mac' (10 bytes)"
514
515run_test "Truncated HMAC: client enabled, server default" \
516 "$P_SRV debug_level=4" \
517 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
518 trunc_hmac=1" \
519 0 \
520 -S "dumping 'computed mac' (20 bytes)" \
521 -s "dumping 'computed mac' (10 bytes)"
522
523run_test "Truncated HMAC: client enabled, server disabled" \
524 "$P_SRV debug_level=4 trunc_hmac=0" \
525 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
526 trunc_hmac=1" \
527 0 \
528 -s "dumping 'computed mac' (20 bytes)" \
529 -S "dumping 'computed mac' (10 bytes)"
530
531run_test "Truncated HMAC: client enabled, server enabled" \
532 "$P_SRV debug_level=4 trunc_hmac=1" \
533 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
534 trunc_hmac=1" \
535 0 \
536 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100537 -s "dumping 'computed mac' (10 bytes)"
538
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100539# Tests for Encrypt-then-MAC extension
540
541run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100542 "$P_SRV debug_level=3 \
543 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100544 "$P_CLI debug_level=3" \
545 0 \
546 -c "client hello, adding encrypt_then_mac extension" \
547 -s "found encrypt then mac extension" \
548 -s "server hello, adding encrypt then mac extension" \
549 -c "found encrypt_then_mac extension" \
550 -c "using encrypt then mac" \
551 -s "using encrypt then mac"
552
553run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100554 "$P_SRV debug_level=3 etm=0 \
555 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100556 "$P_CLI debug_level=3 etm=1" \
557 0 \
558 -c "client hello, adding encrypt_then_mac extension" \
559 -s "found encrypt then mac extension" \
560 -S "server hello, adding encrypt then mac extension" \
561 -C "found encrypt_then_mac extension" \
562 -C "using encrypt then mac" \
563 -S "using encrypt then mac"
564
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100565run_test "Encrypt then MAC: client enabled, aead cipher" \
566 "$P_SRV debug_level=3 etm=1 \
567 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
568 "$P_CLI debug_level=3 etm=1" \
569 0 \
570 -c "client hello, adding encrypt_then_mac extension" \
571 -s "found encrypt then mac extension" \
572 -S "server hello, adding encrypt then mac extension" \
573 -C "found encrypt_then_mac extension" \
574 -C "using encrypt then mac" \
575 -S "using encrypt then mac"
576
577run_test "Encrypt then MAC: client enabled, stream cipher" \
578 "$P_SRV debug_level=3 etm=1 \
579 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100580 "$P_CLI debug_level=3 etm=1 arc4=1" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100581 0 \
582 -c "client hello, adding encrypt_then_mac extension" \
583 -s "found encrypt then mac extension" \
584 -S "server hello, adding encrypt then mac extension" \
585 -C "found encrypt_then_mac extension" \
586 -C "using encrypt then mac" \
587 -S "using encrypt then mac"
588
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100589run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100590 "$P_SRV debug_level=3 etm=1 \
591 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100592 "$P_CLI debug_level=3 etm=0" \
593 0 \
594 -C "client hello, adding encrypt_then_mac extension" \
595 -S "found encrypt then mac extension" \
596 -S "server hello, adding encrypt then mac extension" \
597 -C "found encrypt_then_mac extension" \
598 -C "using encrypt then mac" \
599 -S "using encrypt then mac"
600
Janos Follath4dfecab2016-03-14 13:40:43 +0000601requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100602run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100603 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100604 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100605 "$P_CLI debug_level=3 force_version=ssl3" \
606 0 \
607 -C "client hello, adding encrypt_then_mac extension" \
608 -S "found encrypt then mac extension" \
609 -S "server hello, adding encrypt then mac extension" \
610 -C "found encrypt_then_mac extension" \
611 -C "using encrypt then mac" \
612 -S "using encrypt then mac"
613
Janos Follath4dfecab2016-03-14 13:40:43 +0000614requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100615run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100616 "$P_SRV debug_level=3 force_version=ssl3 \
617 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100618 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100619 0 \
620 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath8abaa8b2016-05-06 13:48:23 +0100621 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100622 -S "server hello, adding encrypt then mac extension" \
623 -C "found encrypt_then_mac extension" \
624 -C "using encrypt then mac" \
625 -S "using encrypt then mac"
626
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200627# Tests for Extended Master Secret extension
628
629run_test "Extended Master Secret: default" \
630 "$P_SRV debug_level=3" \
631 "$P_CLI debug_level=3" \
632 0 \
633 -c "client hello, adding extended_master_secret extension" \
634 -s "found extended master secret extension" \
635 -s "server hello, adding extended master secret extension" \
636 -c "found extended_master_secret extension" \
637 -c "using extended master secret" \
638 -s "using extended master secret"
639
640run_test "Extended Master Secret: client enabled, server disabled" \
641 "$P_SRV debug_level=3 extended_ms=0" \
642 "$P_CLI debug_level=3 extended_ms=1" \
643 0 \
644 -c "client hello, adding extended_master_secret extension" \
645 -s "found extended master secret extension" \
646 -S "server hello, adding extended master secret extension" \
647 -C "found extended_master_secret extension" \
648 -C "using extended master secret" \
649 -S "using extended master secret"
650
651run_test "Extended Master Secret: client disabled, server enabled" \
652 "$P_SRV debug_level=3 extended_ms=1" \
653 "$P_CLI debug_level=3 extended_ms=0" \
654 0 \
655 -C "client hello, adding extended_master_secret extension" \
656 -S "found extended master secret extension" \
657 -S "server hello, adding extended master secret extension" \
658 -C "found extended_master_secret extension" \
659 -C "using extended master secret" \
660 -S "using extended master secret"
661
Janos Follath4dfecab2016-03-14 13:40:43 +0000662requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200663run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100664 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200665 "$P_CLI debug_level=3 force_version=ssl3" \
666 0 \
667 -C "client hello, adding extended_master_secret extension" \
668 -S "found extended master secret extension" \
669 -S "server hello, adding extended master secret extension" \
670 -C "found extended_master_secret extension" \
671 -C "using extended master secret" \
672 -S "using extended master secret"
673
Janos Follath4dfecab2016-03-14 13:40:43 +0000674requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200675run_test "Extended Master Secret: client enabled, server SSLv3" \
676 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100677 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200678 0 \
679 -c "client hello, adding extended_master_secret extension" \
Janos Follath8abaa8b2016-05-06 13:48:23 +0100680 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200681 -S "server hello, adding extended master secret extension" \
682 -C "found extended_master_secret extension" \
683 -C "using extended master secret" \
684 -S "using extended master secret"
685
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200686# Tests for FALLBACK_SCSV
687
688run_test "Fallback SCSV: default" \
689 "$P_SRV" \
690 "$P_CLI debug_level=3 force_version=tls1_1" \
691 0 \
692 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200693 -S "received FALLBACK_SCSV" \
694 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200695 -C "is a fatal alert message (msg 86)"
696
697run_test "Fallback SCSV: explicitly disabled" \
698 "$P_SRV" \
699 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
700 0 \
701 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200702 -S "received FALLBACK_SCSV" \
703 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200704 -C "is a fatal alert message (msg 86)"
705
706run_test "Fallback SCSV: enabled" \
707 "$P_SRV" \
708 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200709 1 \
710 -c "adding FALLBACK_SCSV" \
711 -s "received FALLBACK_SCSV" \
712 -s "inapropriate fallback" \
713 -c "is a fatal alert message (msg 86)"
714
715run_test "Fallback SCSV: enabled, max version" \
716 "$P_SRV" \
717 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200718 0 \
719 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200720 -s "received FALLBACK_SCSV" \
721 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200722 -C "is a fatal alert message (msg 86)"
723
724requires_openssl_with_fallback_scsv
725run_test "Fallback SCSV: default, openssl server" \
726 "$O_SRV" \
727 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
728 0 \
729 -C "adding FALLBACK_SCSV" \
730 -C "is a fatal alert message (msg 86)"
731
732requires_openssl_with_fallback_scsv
733run_test "Fallback SCSV: enabled, openssl server" \
734 "$O_SRV" \
735 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
736 1 \
737 -c "adding FALLBACK_SCSV" \
738 -c "is a fatal alert message (msg 86)"
739
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200740requires_openssl_with_fallback_scsv
741run_test "Fallback SCSV: disabled, openssl client" \
742 "$P_SRV" \
743 "$O_CLI -tls1_1" \
744 0 \
745 -S "received FALLBACK_SCSV" \
746 -S "inapropriate fallback"
747
748requires_openssl_with_fallback_scsv
749run_test "Fallback SCSV: enabled, openssl client" \
750 "$P_SRV" \
751 "$O_CLI -tls1_1 -fallback_scsv" \
752 1 \
753 -s "received FALLBACK_SCSV" \
754 -s "inapropriate fallback"
755
756requires_openssl_with_fallback_scsv
757run_test "Fallback SCSV: enabled, max version, openssl client" \
758 "$P_SRV" \
759 "$O_CLI -fallback_scsv" \
760 0 \
761 -s "received FALLBACK_SCSV" \
762 -S "inapropriate fallback"
763
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100764# Tests for CBC 1/n-1 record splitting
765
766run_test "CBC Record splitting: TLS 1.2, no splitting" \
767 "$P_SRV" \
768 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
769 request_size=123 force_version=tls1_2" \
770 0 \
771 -s "Read from client: 123 bytes read" \
772 -S "Read from client: 1 bytes read" \
773 -S "122 bytes read"
774
775run_test "CBC Record splitting: TLS 1.1, no splitting" \
776 "$P_SRV" \
777 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
778 request_size=123 force_version=tls1_1" \
779 0 \
780 -s "Read from client: 123 bytes read" \
781 -S "Read from client: 1 bytes read" \
782 -S "122 bytes read"
783
784run_test "CBC Record splitting: TLS 1.0, splitting" \
785 "$P_SRV" \
786 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
787 request_size=123 force_version=tls1" \
788 0 \
789 -S "Read from client: 123 bytes read" \
790 -s "Read from client: 1 bytes read" \
791 -s "122 bytes read"
792
Janos Follath4dfecab2016-03-14 13:40:43 +0000793requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100794run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100795 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100796 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
797 request_size=123 force_version=ssl3" \
798 0 \
799 -S "Read from client: 123 bytes read" \
800 -s "Read from client: 1 bytes read" \
801 -s "122 bytes read"
802
803run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100804 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100805 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
806 request_size=123 force_version=tls1" \
807 0 \
808 -s "Read from client: 123 bytes read" \
809 -S "Read from client: 1 bytes read" \
810 -S "122 bytes read"
811
812run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
813 "$P_SRV" \
814 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
815 request_size=123 force_version=tls1 recsplit=0" \
816 0 \
817 -s "Read from client: 123 bytes read" \
818 -S "Read from client: 1 bytes read" \
819 -S "122 bytes read"
820
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100821run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
822 "$P_SRV nbio=2" \
823 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
824 request_size=123 force_version=tls1" \
825 0 \
826 -S "Read from client: 123 bytes read" \
827 -s "Read from client: 1 bytes read" \
828 -s "122 bytes read"
829
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100830# Tests for Session Tickets
831
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200832run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200833 "$P_SRV debug_level=3 tickets=1" \
834 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100835 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100836 -c "client hello, adding session ticket extension" \
837 -s "found session ticket extension" \
838 -s "server hello, adding session ticket extension" \
839 -c "found session_ticket extension" \
840 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100841 -S "session successfully restored from cache" \
842 -s "session successfully restored from ticket" \
843 -s "a session has been resumed" \
844 -c "a session has been resumed"
845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200846run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200847 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
848 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100849 0 \
850 -c "client hello, adding session ticket extension" \
851 -s "found session ticket extension" \
852 -s "server hello, adding session ticket extension" \
853 -c "found session_ticket extension" \
854 -c "parse new session ticket" \
855 -S "session successfully restored from cache" \
856 -s "session successfully restored from ticket" \
857 -s "a session has been resumed" \
858 -c "a session has been resumed"
859
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200860run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200861 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
862 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100863 0 \
864 -c "client hello, adding session ticket extension" \
865 -s "found session ticket extension" \
866 -s "server hello, adding session ticket extension" \
867 -c "found session_ticket extension" \
868 -c "parse new session ticket" \
869 -S "session successfully restored from cache" \
870 -S "session successfully restored from ticket" \
871 -S "a session has been resumed" \
872 -C "a session has been resumed"
873
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200874run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100875 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200876 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100877 0 \
878 -c "client hello, adding session ticket extension" \
879 -c "found session_ticket extension" \
880 -c "parse new session ticket" \
881 -c "a session has been resumed"
882
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200883run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200884 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200885 "( $O_CLI -sess_out $SESSION; \
886 $O_CLI -sess_in $SESSION; \
887 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100888 0 \
889 -s "found session ticket extension" \
890 -s "server hello, adding session ticket extension" \
891 -S "session successfully restored from cache" \
892 -s "session successfully restored from ticket" \
893 -s "a session has been resumed"
894
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100895# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200897run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200898 "$P_SRV debug_level=3 tickets=0" \
899 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100900 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100901 -c "client hello, adding session ticket extension" \
902 -s "found session ticket extension" \
903 -S "server hello, adding session ticket extension" \
904 -C "found session_ticket extension" \
905 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100906 -s "session successfully restored from cache" \
907 -S "session successfully restored from ticket" \
908 -s "a session has been resumed" \
909 -c "a session has been resumed"
910
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200911run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200912 "$P_SRV debug_level=3 tickets=1" \
913 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100914 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100915 -C "client hello, adding session ticket extension" \
916 -S "found session ticket extension" \
917 -S "server hello, adding session ticket extension" \
918 -C "found session_ticket extension" \
919 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100920 -s "session successfully restored from cache" \
921 -S "session successfully restored from ticket" \
922 -s "a session has been resumed" \
923 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200925run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200926 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
927 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100928 0 \
929 -S "session successfully restored from cache" \
930 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100931 -S "a session has been resumed" \
932 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200934run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200935 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
936 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100937 0 \
938 -s "session successfully restored from cache" \
939 -S "session successfully restored from ticket" \
940 -s "a session has been resumed" \
941 -c "a session has been resumed"
942
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200943run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200944 "$P_SRV debug_level=3 tickets=0" \
945 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100946 0 \
947 -s "session successfully restored from cache" \
948 -S "session successfully restored from ticket" \
949 -s "a session has been resumed" \
950 -c "a session has been resumed"
951
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200952run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200953 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
954 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100955 0 \
956 -S "session successfully restored from cache" \
957 -S "session successfully restored from ticket" \
958 -S "a session has been resumed" \
959 -C "a session has been resumed"
960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200961run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200962 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
963 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100964 0 \
965 -s "session successfully restored from cache" \
966 -S "session successfully restored from ticket" \
967 -s "a session has been resumed" \
968 -c "a session has been resumed"
969
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200970run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200971 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200972 "( $O_CLI -sess_out $SESSION; \
973 $O_CLI -sess_in $SESSION; \
974 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100975 0 \
976 -s "found session ticket extension" \
977 -S "server hello, adding session ticket extension" \
978 -s "session successfully restored from cache" \
979 -S "session successfully restored from ticket" \
980 -s "a session has been resumed"
981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200982run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100983 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200984 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100985 0 \
986 -C "found session_ticket extension" \
987 -C "parse new session ticket" \
988 -c "a session has been resumed"
989
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100990# Tests for Max Fragment Length extension
991
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200992run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200993 "$P_SRV debug_level=3" \
994 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100995 0 \
996 -C "client hello, adding max_fragment_length extension" \
997 -S "found max fragment length extension" \
998 -S "server hello, max_fragment_length extension" \
999 -C "found max_fragment_length extension"
1000
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001001run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001002 "$P_SRV debug_level=3" \
1003 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001004 0 \
1005 -c "client hello, adding max_fragment_length extension" \
1006 -s "found max fragment length extension" \
1007 -s "server hello, max_fragment_length extension" \
1008 -c "found max_fragment_length extension"
1009
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001010run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001011 "$P_SRV debug_level=3 max_frag_len=4096" \
1012 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001013 0 \
1014 -C "client hello, adding max_fragment_length extension" \
1015 -S "found max fragment length extension" \
1016 -S "server hello, max_fragment_length extension" \
1017 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001019requires_gnutls
1020run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001021 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001022 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001023 0 \
1024 -c "client hello, adding max_fragment_length extension" \
1025 -c "found max_fragment_length extension"
1026
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001027# Tests for renegotiation
1028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001029run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001030 "$P_SRV debug_level=3 exchanges=2" \
1031 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001032 0 \
1033 -C "client hello, adding renegotiation extension" \
1034 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1035 -S "found renegotiation extension" \
1036 -s "server hello, secure renegotiation extension" \
1037 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001038 -C "=> renegotiate" \
1039 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001040 -S "write hello request"
1041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001042run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001043 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
1044 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001045 0 \
1046 -c "client hello, adding renegotiation extension" \
1047 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1048 -s "found renegotiation extension" \
1049 -s "server hello, secure renegotiation extension" \
1050 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001051 -c "=> renegotiate" \
1052 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001053 -S "write hello request"
1054
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001055run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001056 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1057 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001058 0 \
1059 -c "client hello, adding renegotiation extension" \
1060 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1061 -s "found renegotiation extension" \
1062 -s "server hello, secure renegotiation extension" \
1063 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001064 -c "=> renegotiate" \
1065 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001066 -s "write hello request"
1067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001068run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001069 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1070 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001071 0 \
1072 -c "client hello, adding renegotiation extension" \
1073 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1074 -s "found renegotiation extension" \
1075 -s "server hello, secure renegotiation extension" \
1076 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001077 -c "=> renegotiate" \
1078 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001079 -s "write hello request"
1080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001081run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001082 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1083 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001084 1 \
1085 -c "client hello, adding renegotiation extension" \
1086 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1087 -S "found renegotiation extension" \
1088 -s "server hello, secure renegotiation extension" \
1089 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001090 -c "=> renegotiate" \
1091 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001092 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001093 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001094 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001095
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001096run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001097 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1098 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001099 0 \
1100 -C "client hello, adding renegotiation extension" \
1101 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1102 -S "found renegotiation extension" \
1103 -s "server hello, secure renegotiation extension" \
1104 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001105 -C "=> renegotiate" \
1106 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001107 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001108 -S "SSL - An unexpected message was received from our peer" \
1109 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001110
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001111run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001112 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001113 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001114 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001115 0 \
1116 -C "client hello, adding renegotiation extension" \
1117 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1118 -S "found renegotiation extension" \
1119 -s "server hello, secure renegotiation extension" \
1120 -c "found renegotiation extension" \
1121 -C "=> renegotiate" \
1122 -S "=> renegotiate" \
1123 -s "write hello request" \
1124 -S "SSL - An unexpected message was received from our peer" \
1125 -S "failed"
1126
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001127# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001128run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001129 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001130 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001131 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001132 0 \
1133 -C "client hello, adding renegotiation extension" \
1134 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1135 -S "found renegotiation extension" \
1136 -s "server hello, secure renegotiation extension" \
1137 -c "found renegotiation extension" \
1138 -C "=> renegotiate" \
1139 -S "=> renegotiate" \
1140 -s "write hello request" \
1141 -S "SSL - An unexpected message was received from our peer" \
1142 -S "failed"
1143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001144run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001145 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001146 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001147 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001148 0 \
1149 -C "client hello, adding renegotiation extension" \
1150 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1151 -S "found renegotiation extension" \
1152 -s "server hello, secure renegotiation extension" \
1153 -c "found renegotiation extension" \
1154 -C "=> renegotiate" \
1155 -S "=> renegotiate" \
1156 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001157 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001158
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001159run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001160 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001161 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001162 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001163 0 \
1164 -c "client hello, adding renegotiation extension" \
1165 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1166 -s "found renegotiation extension" \
1167 -s "server hello, secure renegotiation extension" \
1168 -c "found renegotiation extension" \
1169 -c "=> renegotiate" \
1170 -s "=> renegotiate" \
1171 -s "write hello request" \
1172 -S "SSL - An unexpected message was received from our peer" \
1173 -S "failed"
1174
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001175run_test "Renegotiation: periodic, just below period" \
1176 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1177 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1178 0 \
1179 -C "client hello, adding renegotiation extension" \
1180 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1181 -S "found renegotiation extension" \
1182 -s "server hello, secure renegotiation extension" \
1183 -c "found renegotiation extension" \
1184 -S "record counter limit reached: renegotiate" \
1185 -C "=> renegotiate" \
1186 -S "=> renegotiate" \
1187 -S "write hello request" \
1188 -S "SSL - An unexpected message was received from our peer" \
1189 -S "failed"
1190
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001191# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001192run_test "Renegotiation: periodic, just above period" \
1193 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001194 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001195 0 \
1196 -c "client hello, adding renegotiation extension" \
1197 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1198 -s "found renegotiation extension" \
1199 -s "server hello, secure renegotiation extension" \
1200 -c "found renegotiation extension" \
1201 -s "record counter limit reached: renegotiate" \
1202 -c "=> renegotiate" \
1203 -s "=> renegotiate" \
1204 -s "write hello request" \
1205 -S "SSL - An unexpected message was received from our peer" \
1206 -S "failed"
1207
1208run_test "Renegotiation: periodic, two times period" \
1209 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001210 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001211 0 \
1212 -c "client hello, adding renegotiation extension" \
1213 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1214 -s "found renegotiation extension" \
1215 -s "server hello, secure renegotiation extension" \
1216 -c "found renegotiation extension" \
1217 -s "record counter limit reached: renegotiate" \
1218 -c "=> renegotiate" \
1219 -s "=> renegotiate" \
1220 -s "write hello request" \
1221 -S "SSL - An unexpected message was received from our peer" \
1222 -S "failed"
1223
1224run_test "Renegotiation: periodic, above period, disabled" \
1225 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1226 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1227 0 \
1228 -C "client hello, adding renegotiation extension" \
1229 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1230 -S "found renegotiation extension" \
1231 -s "server hello, secure renegotiation extension" \
1232 -c "found renegotiation extension" \
1233 -S "record counter limit reached: renegotiate" \
1234 -C "=> renegotiate" \
1235 -S "=> renegotiate" \
1236 -S "write hello request" \
1237 -S "SSL - An unexpected message was received from our peer" \
1238 -S "failed"
1239
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001240run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001241 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1242 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001243 0 \
1244 -c "client hello, adding renegotiation extension" \
1245 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1246 -s "found renegotiation extension" \
1247 -s "server hello, secure renegotiation extension" \
1248 -c "found renegotiation extension" \
1249 -c "=> renegotiate" \
1250 -s "=> renegotiate" \
1251 -S "write hello request"
1252
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001253run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001254 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1255 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001256 0 \
1257 -c "client hello, adding renegotiation extension" \
1258 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1259 -s "found renegotiation extension" \
1260 -s "server hello, secure renegotiation extension" \
1261 -c "found renegotiation extension" \
1262 -c "=> renegotiate" \
1263 -s "=> renegotiate" \
1264 -s "write hello request"
1265
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001266run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001267 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001268 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001269 0 \
1270 -c "client hello, adding renegotiation extension" \
1271 -c "found renegotiation extension" \
1272 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001273 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001274 -C "error" \
1275 -c "HTTP/1.0 200 [Oo][Kk]"
1276
Paul Bakker539d9722015-02-08 16:18:35 +01001277requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001278run_test "Renegotiation: gnutls server strict, client-initiated" \
1279 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001280 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001281 0 \
1282 -c "client hello, adding renegotiation extension" \
1283 -c "found renegotiation extension" \
1284 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001285 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001286 -C "error" \
1287 -c "HTTP/1.0 200 [Oo][Kk]"
1288
Paul Bakker539d9722015-02-08 16:18:35 +01001289requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001290run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1291 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1292 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1293 1 \
1294 -c "client hello, adding renegotiation extension" \
1295 -C "found renegotiation extension" \
1296 -c "=> renegotiate" \
1297 -c "ssl_handshake() returned" \
1298 -c "error" \
1299 -C "HTTP/1.0 200 [Oo][Kk]"
1300
Paul Bakker539d9722015-02-08 16:18:35 +01001301requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001302run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1303 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1304 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1305 allow_legacy=0" \
1306 1 \
1307 -c "client hello, adding renegotiation extension" \
1308 -C "found renegotiation extension" \
1309 -c "=> renegotiate" \
1310 -c "ssl_handshake() returned" \
1311 -c "error" \
1312 -C "HTTP/1.0 200 [Oo][Kk]"
1313
Paul Bakker539d9722015-02-08 16:18:35 +01001314requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001315run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1316 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1317 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1318 allow_legacy=1" \
1319 0 \
1320 -c "client hello, adding renegotiation extension" \
1321 -C "found renegotiation extension" \
1322 -c "=> renegotiate" \
1323 -C "ssl_hanshake() returned" \
1324 -C "error" \
1325 -c "HTTP/1.0 200 [Oo][Kk]"
1326
1327# Test for the "secure renegotation" extension only (no actual renegotiation)
1328
Paul Bakker539d9722015-02-08 16:18:35 +01001329requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001330run_test "Renego ext: gnutls server strict, client default" \
1331 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1332 "$P_CLI debug_level=3" \
1333 0 \
1334 -c "found renegotiation extension" \
1335 -C "error" \
1336 -c "HTTP/1.0 200 [Oo][Kk]"
1337
Paul Bakker539d9722015-02-08 16:18:35 +01001338requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001339run_test "Renego ext: gnutls server unsafe, client default" \
1340 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1341 "$P_CLI debug_level=3" \
1342 0 \
1343 -C "found renegotiation extension" \
1344 -C "error" \
1345 -c "HTTP/1.0 200 [Oo][Kk]"
1346
Paul Bakker539d9722015-02-08 16:18:35 +01001347requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001348run_test "Renego ext: gnutls server unsafe, client break legacy" \
1349 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1350 "$P_CLI debug_level=3 allow_legacy=-1" \
1351 1 \
1352 -C "found renegotiation extension" \
1353 -c "error" \
1354 -C "HTTP/1.0 200 [Oo][Kk]"
1355
Paul Bakker539d9722015-02-08 16:18:35 +01001356requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001357run_test "Renego ext: gnutls client strict, server default" \
1358 "$P_SRV debug_level=3" \
1359 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1360 0 \
1361 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1362 -s "server hello, secure renegotiation extension"
1363
Paul Bakker539d9722015-02-08 16:18:35 +01001364requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001365run_test "Renego ext: gnutls client unsafe, server default" \
1366 "$P_SRV debug_level=3" \
1367 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1368 0 \
1369 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1370 -S "server hello, secure renegotiation extension"
1371
Paul Bakker539d9722015-02-08 16:18:35 +01001372requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001373run_test "Renego ext: gnutls client unsafe, server break legacy" \
1374 "$P_SRV debug_level=3 allow_legacy=-1" \
1375 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1376 1 \
1377 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1378 -S "server hello, secure renegotiation extension"
1379
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001380# Tests for auth_mode
1381
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001382run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001383 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001384 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001385 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001386 1 \
1387 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001388 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001389 -c "! ssl_handshake returned" \
1390 -c "X509 - Certificate verification failed"
1391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001392run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001393 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001394 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001395 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001396 0 \
1397 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001398 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001399 -C "! ssl_handshake returned" \
1400 -C "X509 - Certificate verification failed"
1401
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001402run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001403 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001404 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001405 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001406 0 \
1407 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001408 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001409 -C "! ssl_handshake returned" \
1410 -C "X509 - Certificate verification failed"
1411
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001412run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001413 "$P_SRV debug_level=3 auth_mode=required" \
1414 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001415 key_file=data_files/server5.key" \
1416 1 \
1417 -S "skip write certificate request" \
1418 -C "skip parse certificate request" \
1419 -c "got a certificate request" \
1420 -C "skip write certificate" \
1421 -C "skip write certificate verify" \
1422 -S "skip parse certificate verify" \
1423 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001424 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001425 -s "! ssl_handshake returned" \
1426 -c "! ssl_handshake returned" \
1427 -s "X509 - Certificate verification failed"
1428
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001429run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001430 "$P_SRV debug_level=3 auth_mode=optional" \
1431 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001432 key_file=data_files/server5.key" \
1433 0 \
1434 -S "skip write certificate request" \
1435 -C "skip parse certificate request" \
1436 -c "got a certificate request" \
1437 -C "skip write certificate" \
1438 -C "skip write certificate verify" \
1439 -S "skip parse certificate verify" \
1440 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001441 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001442 -S "! ssl_handshake returned" \
1443 -C "! ssl_handshake returned" \
1444 -S "X509 - Certificate verification failed"
1445
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001446run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001447 "$P_SRV debug_level=3 auth_mode=none" \
1448 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001449 key_file=data_files/server5.key" \
1450 0 \
1451 -s "skip write certificate request" \
1452 -C "skip parse certificate request" \
1453 -c "got no certificate request" \
1454 -c "skip write certificate" \
1455 -c "skip write certificate verify" \
1456 -s "skip parse certificate verify" \
1457 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001458 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001459 -S "! ssl_handshake returned" \
1460 -C "! ssl_handshake returned" \
1461 -S "X509 - Certificate verification failed"
1462
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001463run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001464 "$P_SRV debug_level=3 auth_mode=optional" \
1465 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001466 0 \
1467 -S "skip write certificate request" \
1468 -C "skip parse certificate request" \
1469 -c "got a certificate request" \
1470 -C "skip write certificate$" \
1471 -C "got no certificate to send" \
1472 -S "SSLv3 client has no certificate" \
1473 -c "skip write certificate verify" \
1474 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001475 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001476 -S "! ssl_handshake returned" \
1477 -C "! ssl_handshake returned" \
1478 -S "X509 - Certificate verification failed"
1479
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001480run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001481 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001482 "$O_CLI" \
1483 0 \
1484 -S "skip write certificate request" \
1485 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001486 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001487 -S "! ssl_handshake returned" \
1488 -S "X509 - Certificate verification failed"
1489
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001490run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001491 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001492 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001493 0 \
1494 -C "skip parse certificate request" \
1495 -c "got a certificate request" \
1496 -C "skip write certificate$" \
1497 -c "skip write certificate verify" \
1498 -C "! ssl_handshake returned"
1499
Janos Follath4dfecab2016-03-14 13:40:43 +00001500requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001501run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001502 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001503 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001504 0 \
1505 -S "skip write certificate request" \
1506 -C "skip parse certificate request" \
1507 -c "got a certificate request" \
1508 -C "skip write certificate$" \
1509 -c "skip write certificate verify" \
1510 -c "got no certificate to send" \
1511 -s "SSLv3 client has no certificate" \
1512 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard0c6ce2f2015-04-17 16:32:21 +02001513 -s "! Certificate was missing" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001514 -S "! ssl_handshake returned" \
1515 -C "! ssl_handshake returned" \
1516 -S "X509 - Certificate verification failed"
1517
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001518# Tests for certificate selection based on SHA verson
1519
1520run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1521 "$P_SRV crt_file=data_files/server5.crt \
1522 key_file=data_files/server5.key \
1523 crt_file2=data_files/server5-sha1.crt \
1524 key_file2=data_files/server5.key" \
1525 "$P_CLI force_version=tls1_2" \
1526 0 \
1527 -c "signed using.*ECDSA with SHA256" \
1528 -C "signed using.*ECDSA with SHA1"
1529
1530run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1531 "$P_SRV crt_file=data_files/server5.crt \
1532 key_file=data_files/server5.key \
1533 crt_file2=data_files/server5-sha1.crt \
1534 key_file2=data_files/server5.key" \
1535 "$P_CLI force_version=tls1_1" \
1536 0 \
1537 -C "signed using.*ECDSA with SHA256" \
1538 -c "signed using.*ECDSA with SHA1"
1539
1540run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1541 "$P_SRV crt_file=data_files/server5.crt \
1542 key_file=data_files/server5.key \
1543 crt_file2=data_files/server5-sha1.crt \
1544 key_file2=data_files/server5.key" \
1545 "$P_CLI force_version=tls1" \
1546 0 \
1547 -C "signed using.*ECDSA with SHA256" \
1548 -c "signed using.*ECDSA with SHA1"
1549
1550run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1551 "$P_SRV crt_file=data_files/server5.crt \
1552 key_file=data_files/server5.key \
1553 crt_file2=data_files/server6.crt \
1554 key_file2=data_files/server6.key" \
1555 "$P_CLI force_version=tls1_1" \
1556 0 \
1557 -c "serial number.*09" \
1558 -c "signed using.*ECDSA with SHA256" \
1559 -C "signed using.*ECDSA with SHA1"
1560
1561run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1562 "$P_SRV crt_file=data_files/server6.crt \
1563 key_file=data_files/server6.key \
1564 crt_file2=data_files/server5.crt \
1565 key_file2=data_files/server5.key" \
1566 "$P_CLI force_version=tls1_1" \
1567 0 \
1568 -c "serial number.*0A" \
1569 -c "signed using.*ECDSA with SHA256" \
1570 -C "signed using.*ECDSA with SHA1"
1571
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001572# tests for SNI
1573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001574run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001575 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001576 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001577 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001578 server_name=localhost" \
1579 0 \
1580 -S "parse ServerName extension" \
1581 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1582 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1583
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001584run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001585 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001586 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001587 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 +01001588 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001589 server_name=localhost" \
1590 0 \
1591 -s "parse ServerName extension" \
1592 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1593 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001595run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001596 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001597 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001598 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 +01001599 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001600 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001601 0 \
1602 -s "parse ServerName extension" \
1603 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001604 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001605
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001606run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001607 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001608 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001609 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 +01001610 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001611 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001612 1 \
1613 -s "parse ServerName extension" \
1614 -s "ssl_sni_wrapper() returned" \
1615 -s "ssl_handshake returned" \
1616 -c "ssl_handshake returned" \
1617 -c "SSL - A fatal alert message was received from our peer"
1618
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001619# Tests for non-blocking I/O: exercise a variety of handshake flows
1620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001621run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001622 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1623 "$P_CLI nbio=2 tickets=0" \
1624 0 \
1625 -S "ssl_handshake returned" \
1626 -C "ssl_handshake returned" \
1627 -c "Read from server: .* bytes read"
1628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001629run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001630 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1631 "$P_CLI nbio=2 tickets=0" \
1632 0 \
1633 -S "ssl_handshake returned" \
1634 -C "ssl_handshake returned" \
1635 -c "Read from server: .* bytes read"
1636
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001637run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001638 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1639 "$P_CLI nbio=2 tickets=1" \
1640 0 \
1641 -S "ssl_handshake returned" \
1642 -C "ssl_handshake returned" \
1643 -c "Read from server: .* bytes read"
1644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001645run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001646 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1647 "$P_CLI nbio=2 tickets=1" \
1648 0 \
1649 -S "ssl_handshake returned" \
1650 -C "ssl_handshake returned" \
1651 -c "Read from server: .* bytes read"
1652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001653run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001654 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1655 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1656 0 \
1657 -S "ssl_handshake returned" \
1658 -C "ssl_handshake returned" \
1659 -c "Read from server: .* bytes read"
1660
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001661run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001662 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1663 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1664 0 \
1665 -S "ssl_handshake returned" \
1666 -C "ssl_handshake returned" \
1667 -c "Read from server: .* bytes read"
1668
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001669run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001670 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1671 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1672 0 \
1673 -S "ssl_handshake returned" \
1674 -C "ssl_handshake returned" \
1675 -c "Read from server: .* bytes read"
1676
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001677# Tests for version negotiation
1678
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001679run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001680 "$P_SRV" \
1681 "$P_CLI" \
1682 0 \
1683 -S "ssl_handshake returned" \
1684 -C "ssl_handshake returned" \
1685 -s "Protocol is TLSv1.2" \
1686 -c "Protocol is TLSv1.2"
1687
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001688run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001689 "$P_SRV" \
1690 "$P_CLI max_version=tls1_1" \
1691 0 \
1692 -S "ssl_handshake returned" \
1693 -C "ssl_handshake returned" \
1694 -s "Protocol is TLSv1.1" \
1695 -c "Protocol is TLSv1.1"
1696
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001697run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001698 "$P_SRV max_version=tls1_1" \
1699 "$P_CLI" \
1700 0 \
1701 -S "ssl_handshake returned" \
1702 -C "ssl_handshake returned" \
1703 -s "Protocol is TLSv1.1" \
1704 -c "Protocol is TLSv1.1"
1705
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001706run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001707 "$P_SRV max_version=tls1_1" \
1708 "$P_CLI max_version=tls1_1" \
1709 0 \
1710 -S "ssl_handshake returned" \
1711 -C "ssl_handshake returned" \
1712 -s "Protocol is TLSv1.1" \
1713 -c "Protocol is TLSv1.1"
1714
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001715run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001716 "$P_SRV min_version=tls1_1" \
1717 "$P_CLI max_version=tls1_1" \
1718 0 \
1719 -S "ssl_handshake returned" \
1720 -C "ssl_handshake returned" \
1721 -s "Protocol is TLSv1.1" \
1722 -c "Protocol is TLSv1.1"
1723
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001724run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001725 "$P_SRV max_version=tls1_1" \
1726 "$P_CLI min_version=tls1_1" \
1727 0 \
1728 -S "ssl_handshake returned" \
1729 -C "ssl_handshake returned" \
1730 -s "Protocol is TLSv1.1" \
1731 -c "Protocol is TLSv1.1"
1732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001733run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001734 "$P_SRV max_version=tls1_1" \
1735 "$P_CLI min_version=tls1_2" \
1736 1 \
1737 -s "ssl_handshake returned" \
1738 -c "ssl_handshake returned" \
1739 -c "SSL - Handshake protocol not within min/max boundaries"
1740
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001741run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001742 "$P_SRV min_version=tls1_2" \
1743 "$P_CLI max_version=tls1_1" \
1744 1 \
1745 -s "ssl_handshake returned" \
1746 -c "ssl_handshake returned" \
1747 -s "SSL - Handshake protocol not within min/max boundaries"
1748
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001749# Tests for ALPN extension
1750
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001751if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1752
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001753run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001754 "$P_SRV debug_level=3" \
1755 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001756 0 \
1757 -C "client hello, adding alpn extension" \
1758 -S "found alpn extension" \
1759 -C "got an alert message, type: \\[2:120]" \
1760 -S "server hello, adding alpn extension" \
1761 -C "found alpn extension " \
1762 -C "Application Layer Protocol is" \
1763 -S "Application Layer Protocol is"
1764
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001765run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001766 "$P_SRV debug_level=3" \
1767 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001768 0 \
1769 -c "client hello, adding alpn extension" \
1770 -s "found alpn extension" \
1771 -C "got an alert message, type: \\[2:120]" \
1772 -S "server hello, adding alpn extension" \
1773 -C "found alpn extension " \
1774 -c "Application Layer Protocol is (none)" \
1775 -S "Application Layer Protocol is"
1776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001777run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001778 "$P_SRV debug_level=3 alpn=abc,1234" \
1779 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001780 0 \
1781 -C "client hello, adding alpn extension" \
1782 -S "found alpn extension" \
1783 -C "got an alert message, type: \\[2:120]" \
1784 -S "server hello, adding alpn extension" \
1785 -C "found alpn extension " \
1786 -C "Application Layer Protocol is" \
1787 -s "Application Layer Protocol is (none)"
1788
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001789run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001790 "$P_SRV debug_level=3 alpn=abc,1234" \
1791 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001792 0 \
1793 -c "client hello, adding alpn extension" \
1794 -s "found alpn extension" \
1795 -C "got an alert message, type: \\[2:120]" \
1796 -s "server hello, adding alpn extension" \
1797 -c "found alpn extension" \
1798 -c "Application Layer Protocol is abc" \
1799 -s "Application Layer Protocol is abc"
1800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001801run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001802 "$P_SRV debug_level=3 alpn=abc,1234" \
1803 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001804 0 \
1805 -c "client hello, adding alpn extension" \
1806 -s "found alpn extension" \
1807 -C "got an alert message, type: \\[2:120]" \
1808 -s "server hello, adding alpn extension" \
1809 -c "found alpn extension" \
1810 -c "Application Layer Protocol is abc" \
1811 -s "Application Layer Protocol is abc"
1812
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001813run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001814 "$P_SRV debug_level=3 alpn=abc,1234" \
1815 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001816 0 \
1817 -c "client hello, adding alpn extension" \
1818 -s "found alpn extension" \
1819 -C "got an alert message, type: \\[2:120]" \
1820 -s "server hello, adding alpn extension" \
1821 -c "found alpn extension" \
1822 -c "Application Layer Protocol is 1234" \
1823 -s "Application Layer Protocol is 1234"
1824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001825run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001826 "$P_SRV debug_level=3 alpn=abc,123" \
1827 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001828 1 \
1829 -c "client hello, adding alpn extension" \
1830 -s "found alpn extension" \
1831 -c "got an alert message, type: \\[2:120]" \
1832 -S "server hello, adding alpn extension" \
1833 -C "found alpn extension" \
1834 -C "Application Layer Protocol is 1234" \
1835 -S "Application Layer Protocol is 1234"
1836
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001837fi
1838
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001839# Tests for keyUsage in leaf certificates, part 1:
1840# server-side certificate/suite selection
1841
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001842run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001843 "$P_SRV key_file=data_files/server2.key \
1844 crt_file=data_files/server2.ku-ds.crt" \
1845 "$P_CLI" \
1846 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001847 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001848
1849
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001850run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001851 "$P_SRV key_file=data_files/server2.key \
1852 crt_file=data_files/server2.ku-ke.crt" \
1853 "$P_CLI" \
1854 0 \
1855 -c "Ciphersuite is TLS-RSA-WITH-"
1856
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001857run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001858 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001859 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001860 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001861 1 \
1862 -C "Ciphersuite is "
1863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001864run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001865 "$P_SRV key_file=data_files/server5.key \
1866 crt_file=data_files/server5.ku-ds.crt" \
1867 "$P_CLI" \
1868 0 \
1869 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1870
1871
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001872run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001873 "$P_SRV key_file=data_files/server5.key \
1874 crt_file=data_files/server5.ku-ka.crt" \
1875 "$P_CLI" \
1876 0 \
1877 -c "Ciphersuite is TLS-ECDH-"
1878
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001879run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001880 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001881 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001882 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001883 1 \
1884 -C "Ciphersuite is "
1885
1886# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001887# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001889run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001890 "$O_SRV -key data_files/server2.key \
1891 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001892 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001893 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1894 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001895 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001896 -C "Processing of the Certificate handshake message failed" \
1897 -c "Ciphersuite is TLS-"
1898
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001899run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001900 "$O_SRV -key data_files/server2.key \
1901 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001902 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001903 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1904 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001905 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001906 -C "Processing of the Certificate handshake message failed" \
1907 -c "Ciphersuite is TLS-"
1908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001909run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001910 "$O_SRV -key data_files/server2.key \
1911 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001912 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001913 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1914 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001915 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001916 -C "Processing of the Certificate handshake message failed" \
1917 -c "Ciphersuite is TLS-"
1918
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001919run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001920 "$O_SRV -key data_files/server2.key \
1921 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001922 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001923 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1924 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001925 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001926 -c "Processing of the Certificate handshake message failed" \
1927 -C "Ciphersuite is TLS-"
1928
Manuel Pégourié-Gonnarde16b62c2015-04-17 16:55:53 +02001929run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
1930 "$O_SRV -key data_files/server2.key \
1931 -cert data_files/server2.ku-ke.crt" \
1932 "$P_CLI debug_level=1 auth_mode=optional \
1933 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1934 0 \
1935 -c "bad certificate (usage extensions)" \
1936 -C "Processing of the Certificate handshake message failed" \
1937 -c "Ciphersuite is TLS-" \
1938 -c "! Usage does not match the keyUsage extension"
1939
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001940run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001941 "$O_SRV -key data_files/server2.key \
1942 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001943 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001944 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1945 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001946 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001947 -C "Processing of the Certificate handshake message failed" \
1948 -c "Ciphersuite is TLS-"
1949
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001950run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001951 "$O_SRV -key data_files/server2.key \
1952 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001953 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001954 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1955 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001956 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001957 -c "Processing of the Certificate handshake message failed" \
1958 -C "Ciphersuite is TLS-"
1959
Manuel Pégourié-Gonnarde16b62c2015-04-17 16:55:53 +02001960run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
1961 "$O_SRV -key data_files/server2.key \
1962 -cert data_files/server2.ku-ds.crt" \
1963 "$P_CLI debug_level=1 auth_mode=optional \
1964 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1965 0 \
1966 -c "bad certificate (usage extensions)" \
1967 -C "Processing of the Certificate handshake message failed" \
1968 -c "Ciphersuite is TLS-" \
1969 -c "! Usage does not match the keyUsage extension"
1970
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001971# Tests for keyUsage in leaf certificates, part 3:
1972# server-side checking of client cert
1973
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001974run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001975 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001976 "$O_CLI -key data_files/server2.key \
1977 -cert data_files/server2.ku-ds.crt" \
1978 0 \
1979 -S "bad certificate (usage extensions)" \
1980 -S "Processing of the Certificate handshake message failed"
1981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001982run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001983 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001984 "$O_CLI -key data_files/server2.key \
1985 -cert data_files/server2.ku-ke.crt" \
1986 0 \
1987 -s "bad certificate (usage extensions)" \
1988 -S "Processing of the Certificate handshake message failed"
1989
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001990run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001991 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001992 "$O_CLI -key data_files/server2.key \
1993 -cert data_files/server2.ku-ke.crt" \
1994 1 \
1995 -s "bad certificate (usage extensions)" \
1996 -s "Processing of the Certificate handshake message failed"
1997
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001998run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001999 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002000 "$O_CLI -key data_files/server5.key \
2001 -cert data_files/server5.ku-ds.crt" \
2002 0 \
2003 -S "bad certificate (usage extensions)" \
2004 -S "Processing of the Certificate handshake message failed"
2005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002006run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002007 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002008 "$O_CLI -key data_files/server5.key \
2009 -cert data_files/server5.ku-ka.crt" \
2010 0 \
2011 -s "bad certificate (usage extensions)" \
2012 -S "Processing of the Certificate handshake message failed"
2013
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002014# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2015
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002016run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002017 "$P_SRV key_file=data_files/server5.key \
2018 crt_file=data_files/server5.eku-srv.crt" \
2019 "$P_CLI" \
2020 0
2021
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002022run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002023 "$P_SRV key_file=data_files/server5.key \
2024 crt_file=data_files/server5.eku-srv.crt" \
2025 "$P_CLI" \
2026 0
2027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002028run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002029 "$P_SRV key_file=data_files/server5.key \
2030 crt_file=data_files/server5.eku-cs_any.crt" \
2031 "$P_CLI" \
2032 0
2033
2034# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002035run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002036 "$P_SRV psk=abc123 key_file=data_files/server5.key \
2037 crt_file=data_files/server5.eku-cli.crt" \
2038 "$P_CLI psk=badbad" \
2039 1
2040
2041# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2042
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002043run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002044 "$O_SRV -key data_files/server5.key \
2045 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002046 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002047 0 \
2048 -C "bad certificate (usage extensions)" \
2049 -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 "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002053 "$O_SRV -key data_files/server5.key \
2054 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002055 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002056 0 \
2057 -C "bad certificate (usage extensions)" \
2058 -C "Processing of the Certificate handshake message failed" \
2059 -c "Ciphersuite is TLS-"
2060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002061run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002062 "$O_SRV -key data_files/server5.key \
2063 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002064 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002065 0 \
2066 -C "bad certificate (usage extensions)" \
2067 -C "Processing of the Certificate handshake message failed" \
2068 -c "Ciphersuite is TLS-"
2069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002070run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002071 "$O_SRV -key data_files/server5.key \
2072 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002073 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002074 1 \
2075 -c "bad certificate (usage extensions)" \
2076 -c "Processing of the Certificate handshake message failed" \
2077 -C "Ciphersuite is TLS-"
2078
2079# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002081run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002082 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002083 "$O_CLI -key data_files/server5.key \
2084 -cert data_files/server5.eku-cli.crt" \
2085 0 \
2086 -S "bad certificate (usage extensions)" \
2087 -S "Processing of the Certificate handshake message failed"
2088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002089run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002090 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002091 "$O_CLI -key data_files/server5.key \
2092 -cert data_files/server5.eku-srv_cli.crt" \
2093 0 \
2094 -S "bad certificate (usage extensions)" \
2095 -S "Processing of the Certificate handshake message failed"
2096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002097run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002098 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002099 "$O_CLI -key data_files/server5.key \
2100 -cert data_files/server5.eku-cs_any.crt" \
2101 0 \
2102 -S "bad certificate (usage extensions)" \
2103 -S "Processing of the Certificate handshake message failed"
2104
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002105run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002106 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002107 "$O_CLI -key data_files/server5.key \
2108 -cert data_files/server5.eku-cs.crt" \
2109 0 \
2110 -s "bad certificate (usage extensions)" \
2111 -S "Processing of the Certificate handshake message failed"
2112
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002113run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002114 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002115 "$O_CLI -key data_files/server5.key \
2116 -cert data_files/server5.eku-cs.crt" \
2117 1 \
2118 -s "bad certificate (usage extensions)" \
2119 -s "Processing of the Certificate handshake message failed"
2120
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002121# Tests for DHM parameters loading
2122
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002123run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002124 "$P_SRV" \
2125 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2126 debug_level=3" \
2127 0 \
2128 -c "value of 'DHM: P ' (2048 bits)" \
2129 -c "value of 'DHM: G ' (2048 bits)"
2130
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002131run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002132 "$P_SRV dhm_file=data_files/dhparams.pem" \
2133 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2134 debug_level=3" \
2135 0 \
2136 -c "value of 'DHM: P ' (1024 bits)" \
2137 -c "value of 'DHM: G ' (2 bits)"
2138
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002139# Tests for PSK callback
2140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002141run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002142 "$P_SRV psk=abc123 psk_identity=foo" \
2143 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2144 psk_identity=foo psk=abc123" \
2145 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002146 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002147 -S "SSL - Unknown identity received" \
2148 -S "SSL - Verification of the message MAC failed"
2149
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002150run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002151 "$P_SRV" \
2152 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2153 psk_identity=foo psk=abc123" \
2154 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002155 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002156 -S "SSL - Unknown identity received" \
2157 -S "SSL - Verification of the message MAC failed"
2158
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002159run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002160 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2161 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2162 psk_identity=foo psk=abc123" \
2163 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002164 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002165 -s "SSL - Unknown identity received" \
2166 -S "SSL - Verification of the message MAC failed"
2167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002168run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002169 "$P_SRV psk_list=abc,dead,def,beef" \
2170 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2171 psk_identity=abc psk=dead" \
2172 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002173 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002174 -S "SSL - Unknown identity received" \
2175 -S "SSL - Verification of the message MAC failed"
2176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002177run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002178 "$P_SRV psk_list=abc,dead,def,beef" \
2179 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2180 psk_identity=def psk=beef" \
2181 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002182 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002183 -S "SSL - Unknown identity received" \
2184 -S "SSL - Verification of the message MAC failed"
2185
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002186run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002187 "$P_SRV psk_list=abc,dead,def,beef" \
2188 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2189 psk_identity=ghi psk=beef" \
2190 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002191 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002192 -s "SSL - Unknown identity received" \
2193 -S "SSL - Verification of the message MAC failed"
2194
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002195run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002196 "$P_SRV psk_list=abc,dead,def,beef" \
2197 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2198 psk_identity=abc psk=beef" \
2199 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002200 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002201 -S "SSL - Unknown identity received" \
2202 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002203
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002204# Tests for ciphersuites per version
2205
Janos Follath4dfecab2016-03-14 13:40:43 +00002206requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002207run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002208 "$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 +02002209 "$P_CLI force_version=ssl3" \
2210 0 \
2211 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2212
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002213run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002214 "$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" \
2215 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002216 0 \
2217 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2218
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002219run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002220 "$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" \
2221 "$P_CLI force_version=tls1_1" \
2222 0 \
2223 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2224
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002225run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002226 "$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" \
2227 "$P_CLI force_version=tls1_2" \
2228 0 \
2229 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2230
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002231# Tests for ssl_get_bytes_avail()
2232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002233run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002234 "$P_SRV" \
2235 "$P_CLI request_size=100" \
2236 0 \
2237 -s "Read from client: 100 bytes read$"
2238
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002239run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002240 "$P_SRV" \
2241 "$P_CLI request_size=500" \
2242 0 \
2243 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002244
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002245# Tests for small packets
2246
Janos Follath4dfecab2016-03-14 13:40:43 +00002247requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002248run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002249 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002250 "$P_CLI request_size=1 force_version=ssl3 \
2251 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2252 0 \
2253 -s "Read from client: 1 bytes read"
2254
Janos Follath4dfecab2016-03-14 13:40:43 +00002255requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002256run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002257 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002258 "$P_CLI request_size=1 force_version=ssl3 \
2259 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2260 0 \
2261 -s "Read from client: 1 bytes read"
2262
2263run_test "Small packet TLS 1.0 BlockCipher" \
2264 "$P_SRV" \
2265 "$P_CLI request_size=1 force_version=tls1 \
2266 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2267 0 \
2268 -s "Read from client: 1 bytes read"
2269
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002270run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2271 "$P_SRV" \
2272 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2273 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2274 0 \
2275 -s "Read from client: 1 bytes read"
2276
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002277run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2278 "$P_SRV" \
2279 "$P_CLI request_size=1 force_version=tls1 \
2280 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2281 trunc_hmac=1" \
2282 0 \
2283 -s "Read from client: 1 bytes read"
2284
2285run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002286 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002287 "$P_CLI request_size=1 force_version=tls1 \
2288 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2289 trunc_hmac=1" \
2290 0 \
2291 -s "Read from client: 1 bytes read"
2292
2293run_test "Small packet TLS 1.1 BlockCipher" \
2294 "$P_SRV" \
2295 "$P_CLI request_size=1 force_version=tls1_1 \
2296 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2297 0 \
2298 -s "Read from client: 1 bytes read"
2299
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002300run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2301 "$P_SRV" \
2302 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2303 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2304 0 \
2305 -s "Read from client: 1 bytes read"
2306
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002307run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002308 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002309 "$P_CLI request_size=1 force_version=tls1_1 \
2310 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2311 0 \
2312 -s "Read from client: 1 bytes read"
2313
2314run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2315 "$P_SRV" \
2316 "$P_CLI request_size=1 force_version=tls1_1 \
2317 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2318 trunc_hmac=1" \
2319 0 \
2320 -s "Read from client: 1 bytes read"
2321
2322run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002323 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002324 "$P_CLI request_size=1 force_version=tls1_1 \
2325 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2326 trunc_hmac=1" \
2327 0 \
2328 -s "Read from client: 1 bytes read"
2329
2330run_test "Small packet TLS 1.2 BlockCipher" \
2331 "$P_SRV" \
2332 "$P_CLI request_size=1 force_version=tls1_2 \
2333 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2334 0 \
2335 -s "Read from client: 1 bytes read"
2336
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002337run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2338 "$P_SRV" \
2339 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2340 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2341 0 \
2342 -s "Read from client: 1 bytes read"
2343
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002344run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2345 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002346 "$P_CLI request_size=1 force_version=tls1_2 \
2347 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002348 0 \
2349 -s "Read from client: 1 bytes read"
2350
2351run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2352 "$P_SRV" \
2353 "$P_CLI request_size=1 force_version=tls1_2 \
2354 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2355 trunc_hmac=1" \
2356 0 \
2357 -s "Read from client: 1 bytes read"
2358
2359run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002360 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002361 "$P_CLI request_size=1 force_version=tls1_2 \
2362 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2363 0 \
2364 -s "Read from client: 1 bytes read"
2365
2366run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002367 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002368 "$P_CLI request_size=1 force_version=tls1_2 \
2369 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2370 trunc_hmac=1" \
2371 0 \
2372 -s "Read from client: 1 bytes read"
2373
2374run_test "Small packet TLS 1.2 AEAD" \
2375 "$P_SRV" \
2376 "$P_CLI request_size=1 force_version=tls1_2 \
2377 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2378 0 \
2379 -s "Read from client: 1 bytes read"
2380
2381run_test "Small packet TLS 1.2 AEAD shorter tag" \
2382 "$P_SRV" \
2383 "$P_CLI request_size=1 force_version=tls1_2 \
2384 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2385 0 \
2386 -s "Read from client: 1 bytes read"
2387
Janos Follath8abaa8b2016-05-06 13:48:23 +01002388# A test for extensions in SSLv3
2389
2390requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2391run_test "SSLv3 with extensions, server side" \
2392 "$P_SRV min_version=ssl3 debug_level=3" \
2393 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2394 0 \
2395 -S "dumping 'client hello extensions'" \
2396 -S "server hello, total extension length:"
2397
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002398# Test for large packets
2399
Janos Follath4dfecab2016-03-14 13:40:43 +00002400requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002401run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002402 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002403 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002404 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2405 0 \
2406 -s "Read from client: 16384 bytes read"
2407
Janos Follath4dfecab2016-03-14 13:40:43 +00002408requires_config_enabled POLARSSL_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002409run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002410 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002411 "$P_CLI request_size=16384 force_version=ssl3 \
2412 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2413 0 \
2414 -s "Read from client: 16384 bytes read"
2415
2416run_test "Large packet TLS 1.0 BlockCipher" \
2417 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002418 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002419 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2420 0 \
2421 -s "Read from client: 16384 bytes read"
2422
2423run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2424 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002425 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002426 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2427 trunc_hmac=1" \
2428 0 \
2429 -s "Read from client: 16384 bytes read"
2430
2431run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002432 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002433 "$P_CLI request_size=16384 force_version=tls1 \
2434 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2435 trunc_hmac=1" \
2436 0 \
2437 -s "Read from client: 16384 bytes read"
2438
2439run_test "Large packet TLS 1.1 BlockCipher" \
2440 "$P_SRV" \
2441 "$P_CLI request_size=16384 force_version=tls1_1 \
2442 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2443 0 \
2444 -s "Read from client: 16384 bytes read"
2445
2446run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002447 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002448 "$P_CLI request_size=16384 force_version=tls1_1 \
2449 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2450 0 \
2451 -s "Read from client: 16384 bytes read"
2452
2453run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2454 "$P_SRV" \
2455 "$P_CLI request_size=16384 force_version=tls1_1 \
2456 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2457 trunc_hmac=1" \
2458 0 \
2459 -s "Read from client: 16384 bytes read"
2460
2461run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002462 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002463 "$P_CLI request_size=16384 force_version=tls1_1 \
2464 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2465 trunc_hmac=1" \
2466 0 \
2467 -s "Read from client: 16384 bytes read"
2468
2469run_test "Large packet TLS 1.2 BlockCipher" \
2470 "$P_SRV" \
2471 "$P_CLI request_size=16384 force_version=tls1_2 \
2472 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2473 0 \
2474 -s "Read from client: 16384 bytes read"
2475
2476run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2477 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002478 "$P_CLI request_size=16384 force_version=tls1_2 \
2479 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002480 0 \
2481 -s "Read from client: 16384 bytes read"
2482
2483run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2484 "$P_SRV" \
2485 "$P_CLI request_size=16384 force_version=tls1_2 \
2486 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2487 trunc_hmac=1" \
2488 0 \
2489 -s "Read from client: 16384 bytes read"
2490
2491run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002492 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002493 "$P_CLI request_size=16384 force_version=tls1_2 \
2494 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2495 0 \
2496 -s "Read from client: 16384 bytes read"
2497
2498run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002499 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002500 "$P_CLI request_size=16384 force_version=tls1_2 \
2501 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2502 trunc_hmac=1" \
2503 0 \
2504 -s "Read from client: 16384 bytes read"
2505
2506run_test "Large packet TLS 1.2 AEAD" \
2507 "$P_SRV" \
2508 "$P_CLI request_size=16384 force_version=tls1_2 \
2509 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2510 0 \
2511 -s "Read from client: 16384 bytes read"
2512
2513run_test "Large packet TLS 1.2 AEAD shorter tag" \
2514 "$P_SRV" \
2515 "$P_CLI request_size=16384 force_version=tls1_2 \
2516 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2517 0 \
2518 -s "Read from client: 16384 bytes read"
2519
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002520# Final report
2521
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002522echo "------------------------------------------------------------------------"
2523
2524if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002525 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002526else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002527 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002528fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002529PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002530echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002531
2532exit $FAILS