blob: 456dbabe1759cf4e894f4e24e423934bc3516f14 [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é-Gonnard74faf3c2014-03-13 18:47:44 +010020O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
21O_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
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020069# skip next test if OpenSSL can't send SSLv2 ClientHello
70requires_openssl_with_sslv2() {
71 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020072 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020073 OPENSSL_HAS_SSL2="YES"
74 else
75 OPENSSL_HAS_SSL2="NO"
76 fi
77 fi
78 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020083# skip next test if OpenSSL doesn't support FALLBACK_SCSV
84requires_openssl_with_fallback_scsv() {
85 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
86 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
87 then
88 OPENSSL_HAS_FBSCSV="YES"
89 else
90 OPENSSL_HAS_FBSCSV="NO"
91 fi
92 fi
93 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
94 SKIP_NEXT="YES"
95 fi
96}
97
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020098# skip next test if GnuTLS isn't available
99requires_gnutls() {
100 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
101 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
102 GNUTLS_AVAILABLE="YES"
103 else
104 GNUTLS_AVAILABLE="NO"
105 fi
106 fi
107 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
108 SKIP_NEXT="YES"
109 fi
110}
111
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100112# print_name <name>
113print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100114 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200115 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100116 for i in `seq 1 $LEN`; do printf '.'; done
117 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100118
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200119 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100120}
121
122# fail <message>
123fail() {
124 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100125 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100126
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200127 mv $SRV_OUT o-srv-${TESTS}.log
128 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100129 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100130
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200131 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
132 echo " ! server output:"
133 cat o-srv-${TESTS}.log
134 echo " ! ============================================================"
135 echo " ! client output:"
136 cat o-cli-${TESTS}.log
137 fi
138
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200139 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100140}
141
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100142# is_polar <cmd_line>
143is_polar() {
144 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
145}
146
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100147# has_mem_err <log_file_name>
148has_mem_err() {
149 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
150 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
151 then
152 return 1 # false: does not have errors
153 else
154 return 0 # true: has errors
155 fi
156}
157
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200158# wait for server to start: two versions depending on lsof availability
159wait_server_start() {
160 if which lsof >/dev/null; then
161 # make sure we don't loop forever
162 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
163 WATCHDOG_PID=$!
164
165 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100166 until lsof -nbi TCP:"$PORT" 2>/dev/null | grep LISTEN >/dev/null;
167 do :; done
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200168
169 kill $WATCHDOG_PID
170 wait $WATCHDOG_PID
171 else
172 sleep "$START_DELAY"
173 fi
174}
175
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200176# wait for client to terminate and set CLI_EXIT
177# must be called right after starting the client
178wait_client_done() {
179 CLI_PID=$!
180
181 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
182 WATCHDOG_PID=$!
183
184 wait $CLI_PID
185 CLI_EXIT=$?
186
187 kill $WATCHDOG_PID
188 wait $WATCHDOG_PID
189
190 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
191}
192
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100193# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100194# Options: -s pattern pattern that must be present in server output
195# -c pattern pattern that must be present in client output
196# -S pattern pattern that must be absent in server output
197# -C pattern pattern that must be absent in client output
198run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100199 NAME="$1"
200 SRV_CMD="$2"
201 CLI_CMD="$3"
202 CLI_EXPECT="$4"
203 shift 4
204
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100205 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
206 else
207 return
208 fi
209
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100210 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100211
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200212 # should we skip?
213 if [ "X$SKIP_NEXT" = "XYES" ]; then
214 SKIP_NEXT="NO"
215 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200216 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200217 return
218 fi
219
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100220 # prepend valgrind to our commands if active
221 if [ "$MEMCHECK" -gt 0 ]; then
222 if is_polar "$SRV_CMD"; then
223 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
224 fi
225 if is_polar "$CLI_CMD"; then
226 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
227 fi
228 fi
229
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100230 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200231 echo "$SRV_CMD" > $SRV_OUT
232 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100233 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200234 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200235
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200236 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200237 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
238 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100239
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200240 # kill the server
241 kill $SRV_PID
242 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100243
244 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200245 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100246 # expected client exit to incorrectly succeed in case of catastrophic
247 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100248 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200249 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100250 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100251 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100252 return
253 fi
254 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100255 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200256 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100257 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100258 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100259 return
260 fi
261 fi
262
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100263 # check server exit code
264 if [ $? != 0 ]; then
265 fail "server fail"
266 return
267 fi
268
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100269 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100270 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
271 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100272 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100273 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100274 return
275 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100276
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100277 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200278 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100279 while [ $# -gt 0 ]
280 do
281 case $1 in
282 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200283 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100284 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100285 return
286 fi
287 ;;
288
289 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200290 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100291 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100292 return
293 fi
294 ;;
295
296 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200297 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100298 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100299 return
300 fi
301 ;;
302
303 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200304 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100305 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100306 return
307 fi
308 ;;
309
310 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200311 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100312 exit 1
313 esac
314 shift 2
315 done
316
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100317 # check valgrind's results
318 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200319 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100320 fail "Server has memory errors"
321 return
322 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200323 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100324 fail "Client has memory errors"
325 return
326 fi
327 fi
328
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100329 # if we're here, everything is ok
330 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200331 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100332}
333
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100334cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200335 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200336 kill $SRV_PID >/dev/null 2>&1
337 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100338 exit 1
339}
340
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100341#
342# MAIN
343#
344
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100345get_options "$@"
346
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100347# sanity checks, avoid an avalanche of errors
348if [ ! -x "$P_SRV" ]; then
349 echo "Command '$P_SRV' is not an executable file"
350 exit 1
351fi
352if [ ! -x "$P_CLI" ]; then
353 echo "Command '$P_CLI' is not an executable file"
354 exit 1
355fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100356if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
357 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100358 exit 1
359fi
360
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200361# used by watchdog
362MAIN_PID="$$"
363
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200364# be more patient with valgrind
365if [ "$MEMCHECK" -gt 0 ]; then
366 START_DELAY=3
367 DOG_DELAY=30
368else
369 START_DELAY=1
370 DOG_DELAY=10
371fi
372
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200373# Pick a "unique" port in the range 10000-19999.
374PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200375PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200376
377# fix commands to use this port
378P_SRV="$P_SRV server_port=$PORT"
379P_CLI="$P_CLI server_port=$PORT"
380O_SRV="$O_SRV -accept $PORT"
381O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200382G_SRV="$G_SRV -p $PORT"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100383G_CLI="$G_CLI -p $PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200384
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200385# Also pick a unique name for intermediate files
386SRV_OUT="srv_out.$$"
387CLI_OUT="cli_out.$$"
388SESSION="session.$$"
389
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200390SKIP_NEXT="NO"
391
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100392trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100393
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200394# Basic test
395
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200396# Checks that:
397# - things work with all ciphersuites active (used with config-full in all.sh)
398# - the expected (highest security) parameters are selected
399# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200400run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200401 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200402 "$P_CLI" \
403 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200404 -s "Protocol is TLSv1.2" \
405 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
406 -s "client hello v3, signature_algorithm ext: 6" \
407 -s "ECDHE curve: secp521r1" \
408 -S "error" \
409 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200410
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100411# Test for SSLv2 ClientHello
412
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200413requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200414run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100415 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100416 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100417 0 \
418 -S "parse client hello v2" \
419 -S "ssl_handshake returned"
420
421# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200422requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200423run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200424 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100425 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100426 0 \
427 -s "parse client hello v2" \
428 -S "ssl_handshake returned"
429
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100430# Tests for Truncated HMAC extension
431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200432run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200433 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100434 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100435 0 \
436 -s "dumping 'computed mac' (20 bytes)"
437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200438run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200439 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100440 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100441 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100442 -s "dumping 'computed mac' (10 bytes)"
443
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100444# Tests for Encrypt-then-MAC extension
445
446run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100447 "$P_SRV debug_level=3 \
448 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100449 "$P_CLI debug_level=3" \
450 0 \
451 -c "client hello, adding encrypt_then_mac extension" \
452 -s "found encrypt then mac extension" \
453 -s "server hello, adding encrypt then mac extension" \
454 -c "found encrypt_then_mac extension" \
455 -c "using encrypt then mac" \
456 -s "using encrypt then mac"
457
458run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100459 "$P_SRV debug_level=3 etm=0 \
460 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100461 "$P_CLI debug_level=3 etm=1" \
462 0 \
463 -c "client hello, adding encrypt_then_mac extension" \
464 -s "found encrypt then mac extension" \
465 -S "server hello, adding encrypt then mac extension" \
466 -C "found encrypt_then_mac extension" \
467 -C "using encrypt then mac" \
468 -S "using encrypt then mac"
469
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100470run_test "Encrypt then MAC: client enabled, aead cipher" \
471 "$P_SRV debug_level=3 etm=1 \
472 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
473 "$P_CLI debug_level=3 etm=1" \
474 0 \
475 -c "client hello, adding encrypt_then_mac extension" \
476 -s "found encrypt then mac extension" \
477 -S "server hello, adding encrypt then mac extension" \
478 -C "found encrypt_then_mac extension" \
479 -C "using encrypt then mac" \
480 -S "using encrypt then mac"
481
482run_test "Encrypt then MAC: client enabled, stream cipher" \
483 "$P_SRV debug_level=3 etm=1 \
484 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
485 "$P_CLI debug_level=3 etm=1" \
486 0 \
487 -c "client hello, adding encrypt_then_mac extension" \
488 -s "found encrypt then mac extension" \
489 -S "server hello, adding encrypt then mac extension" \
490 -C "found encrypt_then_mac extension" \
491 -C "using encrypt then mac" \
492 -S "using encrypt then mac"
493
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100494run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100495 "$P_SRV debug_level=3 etm=1 \
496 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100497 "$P_CLI debug_level=3 etm=0" \
498 0 \
499 -C "client hello, adding encrypt_then_mac extension" \
500 -S "found encrypt then mac extension" \
501 -S "server hello, adding encrypt then mac extension" \
502 -C "found encrypt_then_mac extension" \
503 -C "using encrypt then mac" \
504 -S "using encrypt then mac"
505
506run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100507 "$P_SRV debug_level=3 \
508 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100509 "$P_CLI debug_level=3 force_version=ssl3" \
510 0 \
511 -C "client hello, adding encrypt_then_mac extension" \
512 -S "found encrypt then mac extension" \
513 -S "server hello, adding encrypt then mac extension" \
514 -C "found encrypt_then_mac extension" \
515 -C "using encrypt then mac" \
516 -S "using encrypt then mac"
517
518run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100519 "$P_SRV debug_level=3 force_version=ssl3 \
520 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100521 "$P_CLI debug_level=3" \
522 0 \
523 -c "client hello, adding encrypt_then_mac extension" \
524 -s "found encrypt then mac extension" \
525 -S "server hello, adding encrypt then mac extension" \
526 -C "found encrypt_then_mac extension" \
527 -C "using encrypt then mac" \
528 -S "using encrypt then mac"
529
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200530# Tests for Extended Master Secret extension
531
532run_test "Extended Master Secret: default" \
533 "$P_SRV debug_level=3" \
534 "$P_CLI debug_level=3" \
535 0 \
536 -c "client hello, adding extended_master_secret extension" \
537 -s "found extended master secret extension" \
538 -s "server hello, adding extended master secret extension" \
539 -c "found extended_master_secret extension" \
540 -c "using extended master secret" \
541 -s "using extended master secret"
542
543run_test "Extended Master Secret: client enabled, server disabled" \
544 "$P_SRV debug_level=3 extended_ms=0" \
545 "$P_CLI debug_level=3 extended_ms=1" \
546 0 \
547 -c "client hello, adding extended_master_secret extension" \
548 -s "found extended master secret extension" \
549 -S "server hello, adding extended master secret extension" \
550 -C "found extended_master_secret extension" \
551 -C "using extended master secret" \
552 -S "using extended master secret"
553
554run_test "Extended Master Secret: client disabled, server enabled" \
555 "$P_SRV debug_level=3 extended_ms=1" \
556 "$P_CLI debug_level=3 extended_ms=0" \
557 0 \
558 -C "client hello, adding extended_master_secret extension" \
559 -S "found extended master secret extension" \
560 -S "server hello, adding extended master secret extension" \
561 -C "found extended_master_secret extension" \
562 -C "using extended master secret" \
563 -S "using extended master secret"
564
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200565run_test "Extended Master Secret: client SSLv3, server enabled" \
566 "$P_SRV debug_level=3" \
567 "$P_CLI debug_level=3 force_version=ssl3" \
568 0 \
569 -C "client hello, adding extended_master_secret extension" \
570 -S "found extended master secret extension" \
571 -S "server hello, adding extended master secret extension" \
572 -C "found extended_master_secret extension" \
573 -C "using extended master secret" \
574 -S "using extended master secret"
575
576run_test "Extended Master Secret: client enabled, server SSLv3" \
577 "$P_SRV debug_level=3 force_version=ssl3" \
578 "$P_CLI debug_level=3" \
579 0 \
580 -c "client hello, adding extended_master_secret extension" \
581 -s "found extended master secret extension" \
582 -S "server hello, adding extended master secret extension" \
583 -C "found extended_master_secret extension" \
584 -C "using extended master secret" \
585 -S "using extended master secret"
586
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200587# Tests for FALLBACK_SCSV
588
589run_test "Fallback SCSV: default" \
590 "$P_SRV" \
591 "$P_CLI debug_level=3 force_version=tls1_1" \
592 0 \
593 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200594 -S "received FALLBACK_SCSV" \
595 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200596 -C "is a fatal alert message (msg 86)"
597
598run_test "Fallback SCSV: explicitly disabled" \
599 "$P_SRV" \
600 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
601 0 \
602 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200603 -S "received FALLBACK_SCSV" \
604 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200605 -C "is a fatal alert message (msg 86)"
606
607run_test "Fallback SCSV: enabled" \
608 "$P_SRV" \
609 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200610 1 \
611 -c "adding FALLBACK_SCSV" \
612 -s "received FALLBACK_SCSV" \
613 -s "inapropriate fallback" \
614 -c "is a fatal alert message (msg 86)"
615
616run_test "Fallback SCSV: enabled, max version" \
617 "$P_SRV" \
618 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200619 0 \
620 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200621 -s "received FALLBACK_SCSV" \
622 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200623 -C "is a fatal alert message (msg 86)"
624
625requires_openssl_with_fallback_scsv
626run_test "Fallback SCSV: default, openssl server" \
627 "$O_SRV" \
628 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
629 0 \
630 -C "adding FALLBACK_SCSV" \
631 -C "is a fatal alert message (msg 86)"
632
633requires_openssl_with_fallback_scsv
634run_test "Fallback SCSV: enabled, openssl server" \
635 "$O_SRV" \
636 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
637 1 \
638 -c "adding FALLBACK_SCSV" \
639 -c "is a fatal alert message (msg 86)"
640
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200641requires_openssl_with_fallback_scsv
642run_test "Fallback SCSV: disabled, openssl client" \
643 "$P_SRV" \
644 "$O_CLI -tls1_1" \
645 0 \
646 -S "received FALLBACK_SCSV" \
647 -S "inapropriate fallback"
648
649requires_openssl_with_fallback_scsv
650run_test "Fallback SCSV: enabled, openssl client" \
651 "$P_SRV" \
652 "$O_CLI -tls1_1 -fallback_scsv" \
653 1 \
654 -s "received FALLBACK_SCSV" \
655 -s "inapropriate fallback"
656
657requires_openssl_with_fallback_scsv
658run_test "Fallback SCSV: enabled, max version, openssl client" \
659 "$P_SRV" \
660 "$O_CLI -fallback_scsv" \
661 0 \
662 -s "received FALLBACK_SCSV" \
663 -S "inapropriate fallback"
664
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100665# Tests for Session Tickets
666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200667run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200668 "$P_SRV debug_level=3 tickets=1" \
669 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100670 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100671 -c "client hello, adding session ticket extension" \
672 -s "found session ticket extension" \
673 -s "server hello, adding session ticket extension" \
674 -c "found session_ticket extension" \
675 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100676 -S "session successfully restored from cache" \
677 -s "session successfully restored from ticket" \
678 -s "a session has been resumed" \
679 -c "a session has been resumed"
680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200681run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200682 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
683 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100684 0 \
685 -c "client hello, adding session ticket extension" \
686 -s "found session ticket extension" \
687 -s "server hello, adding session ticket extension" \
688 -c "found session_ticket extension" \
689 -c "parse new session ticket" \
690 -S "session successfully restored from cache" \
691 -s "session successfully restored from ticket" \
692 -s "a session has been resumed" \
693 -c "a session has been resumed"
694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200695run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200696 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
697 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100698 0 \
699 -c "client hello, adding session ticket extension" \
700 -s "found session ticket extension" \
701 -s "server hello, adding session ticket extension" \
702 -c "found session_ticket extension" \
703 -c "parse new session ticket" \
704 -S "session successfully restored from cache" \
705 -S "session successfully restored from ticket" \
706 -S "a session has been resumed" \
707 -C "a session has been resumed"
708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200709run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100710 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200711 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100712 0 \
713 -c "client hello, adding session ticket extension" \
714 -c "found session_ticket extension" \
715 -c "parse new session ticket" \
716 -c "a session has been resumed"
717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200718run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200719 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200720 "( $O_CLI -sess_out $SESSION; \
721 $O_CLI -sess_in $SESSION; \
722 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100723 0 \
724 -s "found session ticket extension" \
725 -s "server hello, adding session ticket extension" \
726 -S "session successfully restored from cache" \
727 -s "session successfully restored from ticket" \
728 -s "a session has been resumed"
729
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100730# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200732run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200733 "$P_SRV debug_level=3 tickets=0" \
734 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100735 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100736 -c "client hello, adding session ticket extension" \
737 -s "found session ticket extension" \
738 -S "server hello, adding session ticket extension" \
739 -C "found session_ticket extension" \
740 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100741 -s "session successfully restored from cache" \
742 -S "session successfully restored from ticket" \
743 -s "a session has been resumed" \
744 -c "a session has been resumed"
745
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200746run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200747 "$P_SRV debug_level=3 tickets=1" \
748 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100749 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100750 -C "client hello, adding session ticket extension" \
751 -S "found session ticket extension" \
752 -S "server hello, adding session ticket extension" \
753 -C "found session_ticket extension" \
754 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100755 -s "session successfully restored from cache" \
756 -S "session successfully restored from ticket" \
757 -s "a session has been resumed" \
758 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200760run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200761 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
762 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100763 0 \
764 -S "session successfully restored from cache" \
765 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100766 -S "a session has been resumed" \
767 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200769run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200770 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
771 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100772 0 \
773 -s "session successfully restored from cache" \
774 -S "session successfully restored from ticket" \
775 -s "a session has been resumed" \
776 -c "a session has been resumed"
777
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200778run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200779 "$P_SRV debug_level=3 tickets=0" \
780 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100781 0 \
782 -s "session successfully restored from cache" \
783 -S "session successfully restored from ticket" \
784 -s "a session has been resumed" \
785 -c "a session has been resumed"
786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200787run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200788 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
789 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100790 0 \
791 -S "session successfully restored from cache" \
792 -S "session successfully restored from ticket" \
793 -S "a session has been resumed" \
794 -C "a session has been resumed"
795
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200796run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200797 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
798 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100799 0 \
800 -s "session successfully restored from cache" \
801 -S "session successfully restored from ticket" \
802 -s "a session has been resumed" \
803 -c "a session has been resumed"
804
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200805run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200806 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200807 "( $O_CLI -sess_out $SESSION; \
808 $O_CLI -sess_in $SESSION; \
809 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100810 0 \
811 -s "found session ticket extension" \
812 -S "server hello, adding session ticket extension" \
813 -s "session successfully restored from cache" \
814 -S "session successfully restored from ticket" \
815 -s "a session has been resumed"
816
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200817run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100818 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200819 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100820 0 \
821 -C "found session_ticket extension" \
822 -C "parse new session ticket" \
823 -c "a session has been resumed"
824
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100825# Tests for Max Fragment Length extension
826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200827run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200828 "$P_SRV debug_level=3" \
829 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100830 0 \
831 -C "client hello, adding max_fragment_length extension" \
832 -S "found max fragment length extension" \
833 -S "server hello, max_fragment_length extension" \
834 -C "found max_fragment_length extension"
835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200836run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200837 "$P_SRV debug_level=3" \
838 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100839 0 \
840 -c "client hello, adding max_fragment_length extension" \
841 -s "found max fragment length extension" \
842 -s "server hello, max_fragment_length extension" \
843 -c "found max_fragment_length extension"
844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200845run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200846 "$P_SRV debug_level=3 max_frag_len=4096" \
847 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100848 0 \
849 -C "client hello, adding max_fragment_length extension" \
850 -S "found max fragment length extension" \
851 -S "server hello, max_fragment_length extension" \
852 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100853
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200854requires_gnutls
855run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200856 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200857 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200858 0 \
859 -c "client hello, adding max_fragment_length extension" \
860 -c "found max_fragment_length extension"
861
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100862# Tests for renegotiation
863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200864run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200865 "$P_SRV debug_level=3 exchanges=2" \
866 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100867 0 \
868 -C "client hello, adding renegotiation extension" \
869 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
870 -S "found renegotiation extension" \
871 -s "server hello, secure renegotiation extension" \
872 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100873 -C "=> renegotiate" \
874 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100875 -S "write hello request"
876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200877run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200878 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
879 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100880 0 \
881 -c "client hello, adding renegotiation extension" \
882 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
883 -s "found renegotiation extension" \
884 -s "server hello, secure renegotiation extension" \
885 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100886 -c "=> renegotiate" \
887 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100888 -S "write hello request"
889
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200890run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200891 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
892 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100893 0 \
894 -c "client hello, adding renegotiation extension" \
895 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
896 -s "found renegotiation extension" \
897 -s "server hello, secure renegotiation extension" \
898 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100899 -c "=> renegotiate" \
900 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100901 -s "write hello request"
902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200903run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200904 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
905 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100906 0 \
907 -c "client hello, adding renegotiation extension" \
908 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
909 -s "found renegotiation extension" \
910 -s "server hello, secure renegotiation extension" \
911 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100912 -c "=> renegotiate" \
913 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100914 -s "write hello request"
915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200916run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200917 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
918 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100919 1 \
920 -c "client hello, adding renegotiation extension" \
921 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
922 -S "found renegotiation extension" \
923 -s "server hello, secure renegotiation extension" \
924 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100925 -c "=> renegotiate" \
926 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200927 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200928 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200929 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100930
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200931run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200932 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
933 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100934 0 \
935 -C "client hello, adding renegotiation extension" \
936 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
937 -S "found renegotiation extension" \
938 -s "server hello, secure renegotiation extension" \
939 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100940 -C "=> renegotiate" \
941 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100942 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200943 -S "SSL - An unexpected message was received from our peer" \
944 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200946run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200947 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200948 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200949 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200950 0 \
951 -C "client hello, adding renegotiation extension" \
952 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
953 -S "found renegotiation extension" \
954 -s "server hello, secure renegotiation extension" \
955 -c "found renegotiation extension" \
956 -C "=> renegotiate" \
957 -S "=> renegotiate" \
958 -s "write hello request" \
959 -S "SSL - An unexpected message was received from our peer" \
960 -S "failed"
961
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200962# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200963run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200964 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200965 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200966 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200967 0 \
968 -C "client hello, adding renegotiation extension" \
969 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
970 -S "found renegotiation extension" \
971 -s "server hello, secure renegotiation extension" \
972 -c "found renegotiation extension" \
973 -C "=> renegotiate" \
974 -S "=> renegotiate" \
975 -s "write hello request" \
976 -S "SSL - An unexpected message was received from our peer" \
977 -S "failed"
978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200979run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200980 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200981 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200982 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200983 0 \
984 -C "client hello, adding renegotiation extension" \
985 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
986 -S "found renegotiation extension" \
987 -s "server hello, secure renegotiation extension" \
988 -c "found renegotiation extension" \
989 -C "=> renegotiate" \
990 -S "=> renegotiate" \
991 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +0200992 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200994run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200995 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200996 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200997 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200998 0 \
999 -c "client hello, adding renegotiation extension" \
1000 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1001 -s "found renegotiation extension" \
1002 -s "server hello, secure renegotiation extension" \
1003 -c "found renegotiation extension" \
1004 -c "=> renegotiate" \
1005 -s "=> renegotiate" \
1006 -s "write hello request" \
1007 -S "SSL - An unexpected message was received from our peer" \
1008 -S "failed"
1009
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001010run_test "Renegotiation: periodic, just below period" \
1011 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1012 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1013 0 \
1014 -C "client hello, adding renegotiation extension" \
1015 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1016 -S "found renegotiation extension" \
1017 -s "server hello, secure renegotiation extension" \
1018 -c "found renegotiation extension" \
1019 -S "record counter limit reached: renegotiate" \
1020 -C "=> renegotiate" \
1021 -S "=> renegotiate" \
1022 -S "write hello request" \
1023 -S "SSL - An unexpected message was received from our peer" \
1024 -S "failed"
1025
1026run_test "Renegotiation: periodic, just above period" \
1027 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1028 "$P_CLI debug_level=3 exchanges=3 renegotiation=1" \
1029 0 \
1030 -c "client hello, adding renegotiation extension" \
1031 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1032 -s "found renegotiation extension" \
1033 -s "server hello, secure renegotiation extension" \
1034 -c "found renegotiation extension" \
1035 -s "record counter limit reached: renegotiate" \
1036 -c "=> renegotiate" \
1037 -s "=> renegotiate" \
1038 -s "write hello request" \
1039 -S "SSL - An unexpected message was received from our peer" \
1040 -S "failed"
1041
1042run_test "Renegotiation: periodic, two times period" \
1043 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1044 "$P_CLI debug_level=3 exchanges=6 renegotiation=1" \
1045 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" \
1051 -s "record counter limit reached: renegotiate" \
1052 -c "=> renegotiate" \
1053 -s "=> renegotiate" \
1054 -s "write hello request" \
1055 -S "SSL - An unexpected message was received from our peer" \
1056 -S "failed"
1057
1058run_test "Renegotiation: periodic, above period, disabled" \
1059 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1060 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1061 0 \
1062 -C "client hello, adding renegotiation extension" \
1063 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1064 -S "found renegotiation extension" \
1065 -s "server hello, secure renegotiation extension" \
1066 -c "found renegotiation extension" \
1067 -S "record counter limit reached: renegotiate" \
1068 -C "=> renegotiate" \
1069 -S "=> renegotiate" \
1070 -S "write hello request" \
1071 -S "SSL - An unexpected message was received from our peer" \
1072 -S "failed"
1073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001074run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001075 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1076 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001077 0 \
1078 -c "client hello, adding renegotiation extension" \
1079 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1080 -s "found renegotiation extension" \
1081 -s "server hello, secure renegotiation extension" \
1082 -c "found renegotiation extension" \
1083 -c "=> renegotiate" \
1084 -s "=> renegotiate" \
1085 -S "write hello request"
1086
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001087run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001088 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1089 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001090 0 \
1091 -c "client hello, adding renegotiation extension" \
1092 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1093 -s "found renegotiation extension" \
1094 -s "server hello, secure renegotiation extension" \
1095 -c "found renegotiation extension" \
1096 -c "=> renegotiate" \
1097 -s "=> renegotiate" \
1098 -s "write hello request"
1099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001100run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001101 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001102 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001103 0 \
1104 -c "client hello, adding renegotiation extension" \
1105 -c "found renegotiation extension" \
1106 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001107 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001108 -C "error" \
1109 -c "HTTP/1.0 200 [Oo][Kk]"
1110
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001111run_test "Renegotiation: gnutls server strict, client-initiated" \
1112 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001113 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001114 0 \
1115 -c "client hello, adding renegotiation extension" \
1116 -c "found renegotiation extension" \
1117 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001118 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001119 -C "error" \
1120 -c "HTTP/1.0 200 [Oo][Kk]"
1121
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001122run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1123 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1124 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1125 1 \
1126 -c "client hello, adding renegotiation extension" \
1127 -C "found renegotiation extension" \
1128 -c "=> renegotiate" \
1129 -c "ssl_handshake() returned" \
1130 -c "error" \
1131 -C "HTTP/1.0 200 [Oo][Kk]"
1132
1133run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1134 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1135 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1136 allow_legacy=0" \
1137 1 \
1138 -c "client hello, adding renegotiation extension" \
1139 -C "found renegotiation extension" \
1140 -c "=> renegotiate" \
1141 -c "ssl_handshake() returned" \
1142 -c "error" \
1143 -C "HTTP/1.0 200 [Oo][Kk]"
1144
1145run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1146 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1147 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1148 allow_legacy=1" \
1149 0 \
1150 -c "client hello, adding renegotiation extension" \
1151 -C "found renegotiation extension" \
1152 -c "=> renegotiate" \
1153 -C "ssl_hanshake() returned" \
1154 -C "error" \
1155 -c "HTTP/1.0 200 [Oo][Kk]"
1156
1157# Test for the "secure renegotation" extension only (no actual renegotiation)
1158
1159run_test "Renego ext: gnutls server strict, client default" \
1160 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1161 "$P_CLI debug_level=3" \
1162 0 \
1163 -c "found renegotiation extension" \
1164 -C "error" \
1165 -c "HTTP/1.0 200 [Oo][Kk]"
1166
1167run_test "Renego ext: gnutls server unsafe, client default" \
1168 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1169 "$P_CLI debug_level=3" \
1170 0 \
1171 -C "found renegotiation extension" \
1172 -C "error" \
1173 -c "HTTP/1.0 200 [Oo][Kk]"
1174
1175run_test "Renego ext: gnutls server unsafe, client break legacy" \
1176 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1177 "$P_CLI debug_level=3 allow_legacy=-1" \
1178 1 \
1179 -C "found renegotiation extension" \
1180 -c "error" \
1181 -C "HTTP/1.0 200 [Oo][Kk]"
1182
1183run_test "Renego ext: gnutls client strict, server default" \
1184 "$P_SRV debug_level=3" \
1185 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1186 0 \
1187 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1188 -s "server hello, secure renegotiation extension"
1189
1190run_test "Renego ext: gnutls client unsafe, server default" \
1191 "$P_SRV debug_level=3" \
1192 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1193 0 \
1194 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1195 -S "server hello, secure renegotiation extension"
1196
1197run_test "Renego ext: gnutls client unsafe, server break legacy" \
1198 "$P_SRV debug_level=3 allow_legacy=-1" \
1199 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1200 1 \
1201 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1202 -S "server hello, secure renegotiation extension"
1203
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001204# Tests for auth_mode
1205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001206run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001207 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001208 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001209 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001210 1 \
1211 -c "x509_verify_cert() returned" \
1212 -c "! self-signed or not signed by a trusted CA" \
1213 -c "! ssl_handshake returned" \
1214 -c "X509 - Certificate verification failed"
1215
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001216run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001217 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001218 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001219 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001220 0 \
1221 -c "x509_verify_cert() returned" \
1222 -c "! self-signed or not signed by a trusted CA" \
1223 -C "! ssl_handshake returned" \
1224 -C "X509 - Certificate verification failed"
1225
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001226run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001227 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001228 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001229 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001230 0 \
1231 -C "x509_verify_cert() returned" \
1232 -C "! self-signed or not signed by a trusted CA" \
1233 -C "! ssl_handshake returned" \
1234 -C "X509 - Certificate verification failed"
1235
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001236run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001237 "$P_SRV debug_level=3 auth_mode=required" \
1238 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001239 key_file=data_files/server5.key" \
1240 1 \
1241 -S "skip write certificate request" \
1242 -C "skip parse certificate request" \
1243 -c "got a certificate request" \
1244 -C "skip write certificate" \
1245 -C "skip write certificate verify" \
1246 -S "skip parse certificate verify" \
1247 -s "x509_verify_cert() returned" \
1248 -S "! self-signed or not signed by a trusted CA" \
1249 -s "! ssl_handshake returned" \
1250 -c "! ssl_handshake returned" \
1251 -s "X509 - Certificate verification failed"
1252
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001253run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001254 "$P_SRV debug_level=3 auth_mode=optional" \
1255 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001256 key_file=data_files/server5.key" \
1257 0 \
1258 -S "skip write certificate request" \
1259 -C "skip parse certificate request" \
1260 -c "got a certificate request" \
1261 -C "skip write certificate" \
1262 -C "skip write certificate verify" \
1263 -S "skip parse certificate verify" \
1264 -s "x509_verify_cert() returned" \
1265 -s "! self-signed or not signed by a trusted CA" \
1266 -S "! ssl_handshake returned" \
1267 -C "! ssl_handshake returned" \
1268 -S "X509 - Certificate verification failed"
1269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001270run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001271 "$P_SRV debug_level=3 auth_mode=none" \
1272 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001273 key_file=data_files/server5.key" \
1274 0 \
1275 -s "skip write certificate request" \
1276 -C "skip parse certificate request" \
1277 -c "got no certificate request" \
1278 -c "skip write certificate" \
1279 -c "skip write certificate verify" \
1280 -s "skip parse certificate verify" \
1281 -S "x509_verify_cert() returned" \
1282 -S "! self-signed or not signed by a trusted CA" \
1283 -S "! ssl_handshake returned" \
1284 -C "! ssl_handshake returned" \
1285 -S "X509 - Certificate verification failed"
1286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001287run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001288 "$P_SRV debug_level=3 auth_mode=optional" \
1289 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001290 0 \
1291 -S "skip write certificate request" \
1292 -C "skip parse certificate request" \
1293 -c "got a certificate request" \
1294 -C "skip write certificate$" \
1295 -C "got no certificate to send" \
1296 -S "SSLv3 client has no certificate" \
1297 -c "skip write certificate verify" \
1298 -s "skip parse certificate verify" \
1299 -s "! no client certificate sent" \
1300 -S "! ssl_handshake returned" \
1301 -C "! ssl_handshake returned" \
1302 -S "X509 - Certificate verification failed"
1303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001304run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001305 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001306 "$O_CLI" \
1307 0 \
1308 -S "skip write certificate request" \
1309 -s "skip parse certificate verify" \
1310 -s "! no client certificate sent" \
1311 -S "! ssl_handshake returned" \
1312 -S "X509 - Certificate verification failed"
1313
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001314run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001315 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001316 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001317 0 \
1318 -C "skip parse certificate request" \
1319 -c "got a certificate request" \
1320 -C "skip write certificate$" \
1321 -c "skip write certificate verify" \
1322 -C "! ssl_handshake returned"
1323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001324run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001325 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1326 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001327 0 \
1328 -S "skip write certificate request" \
1329 -C "skip parse certificate request" \
1330 -c "got a certificate request" \
1331 -C "skip write certificate$" \
1332 -c "skip write certificate verify" \
1333 -c "got no certificate to send" \
1334 -s "SSLv3 client has no certificate" \
1335 -s "skip parse certificate verify" \
1336 -s "! no client certificate sent" \
1337 -S "! ssl_handshake returned" \
1338 -C "! ssl_handshake returned" \
1339 -S "X509 - Certificate verification failed"
1340
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001341# tests for SNI
1342
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001343run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001344 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001345 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001346 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001347 server_name=localhost" \
1348 0 \
1349 -S "parse ServerName extension" \
1350 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1351 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1352
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001353run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001354 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001355 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001356 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 +01001357 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001358 server_name=localhost" \
1359 0 \
1360 -s "parse ServerName extension" \
1361 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1362 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001364run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001365 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001366 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001367 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 +01001368 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001369 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001370 0 \
1371 -s "parse ServerName extension" \
1372 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001373 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001374
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001375run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001376 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001377 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001378 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 +01001379 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001380 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001381 1 \
1382 -s "parse ServerName extension" \
1383 -s "ssl_sni_wrapper() returned" \
1384 -s "ssl_handshake returned" \
1385 -c "ssl_handshake returned" \
1386 -c "SSL - A fatal alert message was received from our peer"
1387
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001388# Tests for non-blocking I/O: exercise a variety of handshake flows
1389
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001390run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001391 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1392 "$P_CLI nbio=2 tickets=0" \
1393 0 \
1394 -S "ssl_handshake returned" \
1395 -C "ssl_handshake returned" \
1396 -c "Read from server: .* bytes read"
1397
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001398run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001399 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1400 "$P_CLI nbio=2 tickets=0" \
1401 0 \
1402 -S "ssl_handshake returned" \
1403 -C "ssl_handshake returned" \
1404 -c "Read from server: .* bytes read"
1405
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001406run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001407 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1408 "$P_CLI nbio=2 tickets=1" \
1409 0 \
1410 -S "ssl_handshake returned" \
1411 -C "ssl_handshake returned" \
1412 -c "Read from server: .* bytes read"
1413
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001414run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001415 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1416 "$P_CLI nbio=2 tickets=1" \
1417 0 \
1418 -S "ssl_handshake returned" \
1419 -C "ssl_handshake returned" \
1420 -c "Read from server: .* bytes read"
1421
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001422run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001423 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1424 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1425 0 \
1426 -S "ssl_handshake returned" \
1427 -C "ssl_handshake returned" \
1428 -c "Read from server: .* bytes read"
1429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001430run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001431 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1432 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1433 0 \
1434 -S "ssl_handshake returned" \
1435 -C "ssl_handshake returned" \
1436 -c "Read from server: .* bytes read"
1437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001438run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001439 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1440 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1441 0 \
1442 -S "ssl_handshake returned" \
1443 -C "ssl_handshake returned" \
1444 -c "Read from server: .* bytes read"
1445
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001446# Tests for version negotiation
1447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001448run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001449 "$P_SRV" \
1450 "$P_CLI" \
1451 0 \
1452 -S "ssl_handshake returned" \
1453 -C "ssl_handshake returned" \
1454 -s "Protocol is TLSv1.2" \
1455 -c "Protocol is TLSv1.2"
1456
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001457run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001458 "$P_SRV" \
1459 "$P_CLI max_version=tls1_1" \
1460 0 \
1461 -S "ssl_handshake returned" \
1462 -C "ssl_handshake returned" \
1463 -s "Protocol is TLSv1.1" \
1464 -c "Protocol is TLSv1.1"
1465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001466run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001467 "$P_SRV max_version=tls1_1" \
1468 "$P_CLI" \
1469 0 \
1470 -S "ssl_handshake returned" \
1471 -C "ssl_handshake returned" \
1472 -s "Protocol is TLSv1.1" \
1473 -c "Protocol is TLSv1.1"
1474
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001475run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001476 "$P_SRV max_version=tls1_1" \
1477 "$P_CLI max_version=tls1_1" \
1478 0 \
1479 -S "ssl_handshake returned" \
1480 -C "ssl_handshake returned" \
1481 -s "Protocol is TLSv1.1" \
1482 -c "Protocol is TLSv1.1"
1483
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001484run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001485 "$P_SRV min_version=tls1_1" \
1486 "$P_CLI max_version=tls1_1" \
1487 0 \
1488 -S "ssl_handshake returned" \
1489 -C "ssl_handshake returned" \
1490 -s "Protocol is TLSv1.1" \
1491 -c "Protocol is TLSv1.1"
1492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001493run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001494 "$P_SRV max_version=tls1_1" \
1495 "$P_CLI min_version=tls1_1" \
1496 0 \
1497 -S "ssl_handshake returned" \
1498 -C "ssl_handshake returned" \
1499 -s "Protocol is TLSv1.1" \
1500 -c "Protocol is TLSv1.1"
1501
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001502run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001503 "$P_SRV max_version=tls1_1" \
1504 "$P_CLI min_version=tls1_2" \
1505 1 \
1506 -s "ssl_handshake returned" \
1507 -c "ssl_handshake returned" \
1508 -c "SSL - Handshake protocol not within min/max boundaries"
1509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001510run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001511 "$P_SRV min_version=tls1_2" \
1512 "$P_CLI max_version=tls1_1" \
1513 1 \
1514 -s "ssl_handshake returned" \
1515 -c "ssl_handshake returned" \
1516 -s "SSL - Handshake protocol not within min/max boundaries"
1517
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001518# Tests for ALPN extension
1519
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001520if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001522run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001523 "$P_SRV debug_level=3" \
1524 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001525 0 \
1526 -C "client hello, adding alpn extension" \
1527 -S "found alpn extension" \
1528 -C "got an alert message, type: \\[2:120]" \
1529 -S "server hello, adding alpn extension" \
1530 -C "found alpn extension " \
1531 -C "Application Layer Protocol is" \
1532 -S "Application Layer Protocol is"
1533
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001534run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001535 "$P_SRV debug_level=3" \
1536 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001537 0 \
1538 -c "client hello, adding alpn extension" \
1539 -s "found alpn extension" \
1540 -C "got an alert message, type: \\[2:120]" \
1541 -S "server hello, adding alpn extension" \
1542 -C "found alpn extension " \
1543 -c "Application Layer Protocol is (none)" \
1544 -S "Application Layer Protocol is"
1545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001546run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001547 "$P_SRV debug_level=3 alpn=abc,1234" \
1548 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001549 0 \
1550 -C "client hello, adding alpn extension" \
1551 -S "found alpn extension" \
1552 -C "got an alert message, type: \\[2:120]" \
1553 -S "server hello, adding alpn extension" \
1554 -C "found alpn extension " \
1555 -C "Application Layer Protocol is" \
1556 -s "Application Layer Protocol is (none)"
1557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001558run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001559 "$P_SRV debug_level=3 alpn=abc,1234" \
1560 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001561 0 \
1562 -c "client hello, adding alpn extension" \
1563 -s "found alpn extension" \
1564 -C "got an alert message, type: \\[2:120]" \
1565 -s "server hello, adding alpn extension" \
1566 -c "found alpn extension" \
1567 -c "Application Layer Protocol is abc" \
1568 -s "Application Layer Protocol is abc"
1569
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001570run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001571 "$P_SRV debug_level=3 alpn=abc,1234" \
1572 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001573 0 \
1574 -c "client hello, adding alpn extension" \
1575 -s "found alpn extension" \
1576 -C "got an alert message, type: \\[2:120]" \
1577 -s "server hello, adding alpn extension" \
1578 -c "found alpn extension" \
1579 -c "Application Layer Protocol is abc" \
1580 -s "Application Layer Protocol is abc"
1581
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001582run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001583 "$P_SRV debug_level=3 alpn=abc,1234" \
1584 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001585 0 \
1586 -c "client hello, adding alpn extension" \
1587 -s "found alpn extension" \
1588 -C "got an alert message, type: \\[2:120]" \
1589 -s "server hello, adding alpn extension" \
1590 -c "found alpn extension" \
1591 -c "Application Layer Protocol is 1234" \
1592 -s "Application Layer Protocol is 1234"
1593
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001594run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001595 "$P_SRV debug_level=3 alpn=abc,123" \
1596 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001597 1 \
1598 -c "client hello, adding alpn extension" \
1599 -s "found alpn extension" \
1600 -c "got an alert message, type: \\[2:120]" \
1601 -S "server hello, adding alpn extension" \
1602 -C "found alpn extension" \
1603 -C "Application Layer Protocol is 1234" \
1604 -S "Application Layer Protocol is 1234"
1605
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001606fi
1607
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001608# Tests for keyUsage in leaf certificates, part 1:
1609# server-side certificate/suite selection
1610
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001611run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001612 "$P_SRV key_file=data_files/server2.key \
1613 crt_file=data_files/server2.ku-ds.crt" \
1614 "$P_CLI" \
1615 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001616 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001617
1618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001619run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001620 "$P_SRV key_file=data_files/server2.key \
1621 crt_file=data_files/server2.ku-ke.crt" \
1622 "$P_CLI" \
1623 0 \
1624 -c "Ciphersuite is TLS-RSA-WITH-"
1625
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001626run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001627 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001628 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001629 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001630 1 \
1631 -C "Ciphersuite is "
1632
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001633run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001634 "$P_SRV key_file=data_files/server5.key \
1635 crt_file=data_files/server5.ku-ds.crt" \
1636 "$P_CLI" \
1637 0 \
1638 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1639
1640
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001641run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001642 "$P_SRV key_file=data_files/server5.key \
1643 crt_file=data_files/server5.ku-ka.crt" \
1644 "$P_CLI" \
1645 0 \
1646 -c "Ciphersuite is TLS-ECDH-"
1647
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001648run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001649 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001650 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001651 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001652 1 \
1653 -C "Ciphersuite is "
1654
1655# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001656# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001657
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001658run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001659 "$O_SRV -key data_files/server2.key \
1660 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001661 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001662 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1663 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001664 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001665 -C "Processing of the Certificate handshake message failed" \
1666 -c "Ciphersuite is TLS-"
1667
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001668run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001669 "$O_SRV -key data_files/server2.key \
1670 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001671 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001672 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1673 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001674 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001675 -C "Processing of the Certificate handshake message failed" \
1676 -c "Ciphersuite is TLS-"
1677
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001678run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001679 "$O_SRV -key data_files/server2.key \
1680 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001681 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001682 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1683 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001684 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001685 -C "Processing of the Certificate handshake message failed" \
1686 -c "Ciphersuite is TLS-"
1687
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001688run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001689 "$O_SRV -key data_files/server2.key \
1690 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001691 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001692 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1693 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001694 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001695 -c "Processing of the Certificate handshake message failed" \
1696 -C "Ciphersuite is TLS-"
1697
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001698run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001699 "$O_SRV -key data_files/server2.key \
1700 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001701 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001702 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1703 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001704 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001705 -C "Processing of the Certificate handshake message failed" \
1706 -c "Ciphersuite is TLS-"
1707
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001708run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001709 "$O_SRV -key data_files/server2.key \
1710 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001711 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001712 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1713 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001714 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001715 -c "Processing of the Certificate handshake message failed" \
1716 -C "Ciphersuite is TLS-"
1717
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001718# Tests for keyUsage in leaf certificates, part 3:
1719# server-side checking of client cert
1720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001721run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001722 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001723 "$O_CLI -key data_files/server2.key \
1724 -cert data_files/server2.ku-ds.crt" \
1725 0 \
1726 -S "bad certificate (usage extensions)" \
1727 -S "Processing of the Certificate handshake message failed"
1728
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001729run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001730 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001731 "$O_CLI -key data_files/server2.key \
1732 -cert data_files/server2.ku-ke.crt" \
1733 0 \
1734 -s "bad certificate (usage extensions)" \
1735 -S "Processing of the Certificate handshake message failed"
1736
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001737run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001738 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001739 "$O_CLI -key data_files/server2.key \
1740 -cert data_files/server2.ku-ke.crt" \
1741 1 \
1742 -s "bad certificate (usage extensions)" \
1743 -s "Processing of the Certificate handshake message failed"
1744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001745run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001746 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001747 "$O_CLI -key data_files/server5.key \
1748 -cert data_files/server5.ku-ds.crt" \
1749 0 \
1750 -S "bad certificate (usage extensions)" \
1751 -S "Processing of the Certificate handshake message failed"
1752
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001753run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001754 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001755 "$O_CLI -key data_files/server5.key \
1756 -cert data_files/server5.ku-ka.crt" \
1757 0 \
1758 -s "bad certificate (usage extensions)" \
1759 -S "Processing of the Certificate handshake message failed"
1760
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001761# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1762
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001763run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001764 "$P_SRV key_file=data_files/server5.key \
1765 crt_file=data_files/server5.eku-srv.crt" \
1766 "$P_CLI" \
1767 0
1768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001769run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001770 "$P_SRV key_file=data_files/server5.key \
1771 crt_file=data_files/server5.eku-srv.crt" \
1772 "$P_CLI" \
1773 0
1774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001775run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001776 "$P_SRV key_file=data_files/server5.key \
1777 crt_file=data_files/server5.eku-cs_any.crt" \
1778 "$P_CLI" \
1779 0
1780
1781# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001782run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001783 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1784 crt_file=data_files/server5.eku-cli.crt" \
1785 "$P_CLI psk=badbad" \
1786 1
1787
1788# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001790run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001791 "$O_SRV -key data_files/server5.key \
1792 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001793 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001794 0 \
1795 -C "bad certificate (usage extensions)" \
1796 -C "Processing of the Certificate handshake message failed" \
1797 -c "Ciphersuite is TLS-"
1798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001799run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001800 "$O_SRV -key data_files/server5.key \
1801 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001802 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001803 0 \
1804 -C "bad certificate (usage extensions)" \
1805 -C "Processing of the Certificate handshake message failed" \
1806 -c "Ciphersuite is TLS-"
1807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001808run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001809 "$O_SRV -key data_files/server5.key \
1810 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001811 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001812 0 \
1813 -C "bad certificate (usage extensions)" \
1814 -C "Processing of the Certificate handshake message failed" \
1815 -c "Ciphersuite is TLS-"
1816
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001817run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001818 "$O_SRV -key data_files/server5.key \
1819 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001820 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001821 1 \
1822 -c "bad certificate (usage extensions)" \
1823 -c "Processing of the Certificate handshake message failed" \
1824 -C "Ciphersuite is TLS-"
1825
1826# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1827
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001828run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001829 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001830 "$O_CLI -key data_files/server5.key \
1831 -cert data_files/server5.eku-cli.crt" \
1832 0 \
1833 -S "bad certificate (usage extensions)" \
1834 -S "Processing of the Certificate handshake message failed"
1835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001836run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001837 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001838 "$O_CLI -key data_files/server5.key \
1839 -cert data_files/server5.eku-srv_cli.crt" \
1840 0 \
1841 -S "bad certificate (usage extensions)" \
1842 -S "Processing of the Certificate handshake message failed"
1843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001844run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001845 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001846 "$O_CLI -key data_files/server5.key \
1847 -cert data_files/server5.eku-cs_any.crt" \
1848 0 \
1849 -S "bad certificate (usage extensions)" \
1850 -S "Processing of the Certificate handshake message failed"
1851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001852run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001853 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001854 "$O_CLI -key data_files/server5.key \
1855 -cert data_files/server5.eku-cs.crt" \
1856 0 \
1857 -s "bad certificate (usage extensions)" \
1858 -S "Processing of the Certificate handshake message failed"
1859
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001860run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001861 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001862 "$O_CLI -key data_files/server5.key \
1863 -cert data_files/server5.eku-cs.crt" \
1864 1 \
1865 -s "bad certificate (usage extensions)" \
1866 -s "Processing of the Certificate handshake message failed"
1867
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001868# Tests for DHM parameters loading
1869
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001870run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001871 "$P_SRV" \
1872 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1873 debug_level=3" \
1874 0 \
1875 -c "value of 'DHM: P ' (2048 bits)" \
1876 -c "value of 'DHM: G ' (2048 bits)"
1877
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001878run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001879 "$P_SRV dhm_file=data_files/dhparams.pem" \
1880 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1881 debug_level=3" \
1882 0 \
1883 -c "value of 'DHM: P ' (1024 bits)" \
1884 -c "value of 'DHM: G ' (2 bits)"
1885
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001886# Tests for PSK callback
1887
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001888run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001889 "$P_SRV psk=abc123 psk_identity=foo" \
1890 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1891 psk_identity=foo psk=abc123" \
1892 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001893 -S "SSL - The server has no ciphersuites in common" \
1894 -S "SSL - Unknown identity received" \
1895 -S "SSL - Verification of the message MAC failed"
1896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001897run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001898 "$P_SRV" \
1899 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1900 psk_identity=foo psk=abc123" \
1901 1 \
1902 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001903 -S "SSL - Unknown identity received" \
1904 -S "SSL - Verification of the message MAC failed"
1905
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001906run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001907 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1908 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1909 psk_identity=foo psk=abc123" \
1910 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001911 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001912 -s "SSL - Unknown identity received" \
1913 -S "SSL - Verification of the message MAC failed"
1914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001915run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001916 "$P_SRV psk_list=abc,dead,def,beef" \
1917 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1918 psk_identity=abc psk=dead" \
1919 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001920 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001921 -S "SSL - Unknown identity received" \
1922 -S "SSL - Verification of the message MAC failed"
1923
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001924run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001925 "$P_SRV psk_list=abc,dead,def,beef" \
1926 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1927 psk_identity=def psk=beef" \
1928 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001929 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001930 -S "SSL - Unknown identity received" \
1931 -S "SSL - Verification of the message MAC failed"
1932
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001933run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001934 "$P_SRV psk_list=abc,dead,def,beef" \
1935 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1936 psk_identity=ghi psk=beef" \
1937 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001938 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001939 -s "SSL - Unknown identity received" \
1940 -S "SSL - Verification of the message MAC failed"
1941
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001942run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001943 "$P_SRV psk_list=abc,dead,def,beef" \
1944 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1945 psk_identity=abc psk=beef" \
1946 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001947 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001948 -S "SSL - Unknown identity received" \
1949 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001950
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001951# Tests for ciphersuites per version
1952
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001953run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001954 "$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" \
1955 "$P_CLI force_version=ssl3" \
1956 0 \
1957 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
1958
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001959run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001960 "$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" \
1961 "$P_CLI force_version=tls1" \
1962 0 \
1963 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
1964
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001965run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001966 "$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" \
1967 "$P_CLI force_version=tls1_1" \
1968 0 \
1969 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
1970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001971run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001972 "$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" \
1973 "$P_CLI force_version=tls1_2" \
1974 0 \
1975 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
1976
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001977# Tests for ssl_get_bytes_avail()
1978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001979run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001980 "$P_SRV" \
1981 "$P_CLI request_size=100" \
1982 0 \
1983 -s "Read from client: 100 bytes read$"
1984
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001985run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02001986 "$P_SRV" \
1987 "$P_CLI request_size=500" \
1988 0 \
1989 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02001990
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02001991# Tests for small packets
1992
1993run_test "Small packet SSLv3 BlockCipher" \
1994 "$P_SRV" \
1995 "$P_CLI request_size=1 force_version=ssl3 \
1996 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
1997 0 \
1998 -s "Read from client: 1 bytes read"
1999
2000run_test "Small packet SSLv3 StreamCipher" \
2001 "$P_SRV" \
2002 "$P_CLI request_size=1 force_version=ssl3 \
2003 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2004 0 \
2005 -s "Read from client: 1 bytes read"
2006
2007run_test "Small packet TLS 1.0 BlockCipher" \
2008 "$P_SRV" \
2009 "$P_CLI request_size=1 force_version=tls1 \
2010 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2011 0 \
2012 -s "Read from client: 1 bytes read"
2013
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002014run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2015 "$P_SRV" \
2016 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2017 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2018 0 \
2019 -s "Read from client: 1 bytes read"
2020
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002021run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2022 "$P_SRV" \
2023 "$P_CLI request_size=1 force_version=tls1 \
2024 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2025 trunc_hmac=1" \
2026 0 \
2027 -s "Read from client: 1 bytes read"
2028
2029run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
2030 "$P_SRV" \
2031 "$P_CLI request_size=1 force_version=tls1 \
2032 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2033 trunc_hmac=1" \
2034 0 \
2035 -s "Read from client: 1 bytes read"
2036
2037run_test "Small packet TLS 1.1 BlockCipher" \
2038 "$P_SRV" \
2039 "$P_CLI request_size=1 force_version=tls1_1 \
2040 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2041 0 \
2042 -s "Read from client: 1 bytes read"
2043
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002044run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2045 "$P_SRV" \
2046 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2047 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2048 0 \
2049 -s "Read from client: 1 bytes read"
2050
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002051run_test "Small packet TLS 1.1 StreamCipher" \
2052 "$P_SRV" \
2053 "$P_CLI request_size=1 force_version=tls1_1 \
2054 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2055 0 \
2056 -s "Read from client: 1 bytes read"
2057
2058run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2059 "$P_SRV" \
2060 "$P_CLI request_size=1 force_version=tls1_1 \
2061 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2062 trunc_hmac=1" \
2063 0 \
2064 -s "Read from client: 1 bytes read"
2065
2066run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
2067 "$P_SRV" \
2068 "$P_CLI request_size=1 force_version=tls1_1 \
2069 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2070 trunc_hmac=1" \
2071 0 \
2072 -s "Read from client: 1 bytes read"
2073
2074run_test "Small packet TLS 1.2 BlockCipher" \
2075 "$P_SRV" \
2076 "$P_CLI request_size=1 force_version=tls1_2 \
2077 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2078 0 \
2079 -s "Read from client: 1 bytes read"
2080
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002081run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2082 "$P_SRV" \
2083 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2084 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2085 0 \
2086 -s "Read from client: 1 bytes read"
2087
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002088run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2089 "$P_SRV" \
2090 "$P_CLI request_size=1 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
2091 0 \
2092 -s "Read from client: 1 bytes read"
2093
2094run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2095 "$P_SRV" \
2096 "$P_CLI request_size=1 force_version=tls1_2 \
2097 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2098 trunc_hmac=1" \
2099 0 \
2100 -s "Read from client: 1 bytes read"
2101
2102run_test "Small packet TLS 1.2 StreamCipher" \
2103 "$P_SRV" \
2104 "$P_CLI request_size=1 force_version=tls1_2 \
2105 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2106 0 \
2107 -s "Read from client: 1 bytes read"
2108
2109run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
2110 "$P_SRV" \
2111 "$P_CLI request_size=1 force_version=tls1_2 \
2112 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2113 trunc_hmac=1" \
2114 0 \
2115 -s "Read from client: 1 bytes read"
2116
2117run_test "Small packet TLS 1.2 AEAD" \
2118 "$P_SRV" \
2119 "$P_CLI request_size=1 force_version=tls1_2 \
2120 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2121 0 \
2122 -s "Read from client: 1 bytes read"
2123
2124run_test "Small packet TLS 1.2 AEAD shorter tag" \
2125 "$P_SRV" \
2126 "$P_CLI request_size=1 force_version=tls1_2 \
2127 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2128 0 \
2129 -s "Read from client: 1 bytes read"
2130
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002131# Test for large packets
2132
2133run_test "Large packet SSLv3 BlockCipher" \
2134 "$P_SRV" \
2135 "$P_CLI request_size=16384 force_version=ssl3 \
2136 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2137 0 \
2138 -s "Read from client: 16384 bytes read"
2139
2140run_test "Large packet SSLv3 StreamCipher" \
2141 "$P_SRV" \
2142 "$P_CLI request_size=16384 force_version=ssl3 \
2143 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2144 0 \
2145 -s "Read from client: 16384 bytes read"
2146
2147run_test "Large packet TLS 1.0 BlockCipher" \
2148 "$P_SRV" \
2149 "$P_CLI request_size=16384 force_version=tls1 \
2150 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2151 0 \
2152 -s "Read from client: 16384 bytes read"
2153
2154run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2155 "$P_SRV" \
2156 "$P_CLI request_size=16384 force_version=tls1 \
2157 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2158 trunc_hmac=1" \
2159 0 \
2160 -s "Read from client: 16384 bytes read"
2161
2162run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
2163 "$P_SRV" \
2164 "$P_CLI request_size=16384 force_version=tls1 \
2165 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2166 trunc_hmac=1" \
2167 0 \
2168 -s "Read from client: 16384 bytes read"
2169
2170run_test "Large packet TLS 1.1 BlockCipher" \
2171 "$P_SRV" \
2172 "$P_CLI request_size=16384 force_version=tls1_1 \
2173 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2174 0 \
2175 -s "Read from client: 16384 bytes read"
2176
2177run_test "Large packet TLS 1.1 StreamCipher" \
2178 "$P_SRV" \
2179 "$P_CLI request_size=16384 force_version=tls1_1 \
2180 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2181 0 \
2182 -s "Read from client: 16384 bytes read"
2183
2184run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2185 "$P_SRV" \
2186 "$P_CLI request_size=16384 force_version=tls1_1 \
2187 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2188 trunc_hmac=1" \
2189 0 \
2190 -s "Read from client: 16384 bytes read"
2191
2192run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
2193 "$P_SRV" \
2194 "$P_CLI request_size=16384 force_version=tls1_1 \
2195 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2196 trunc_hmac=1" \
2197 0 \
2198 -s "Read from client: 16384 bytes read"
2199
2200run_test "Large packet TLS 1.2 BlockCipher" \
2201 "$P_SRV" \
2202 "$P_CLI request_size=16384 force_version=tls1_2 \
2203 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2204 0 \
2205 -s "Read from client: 16384 bytes read"
2206
2207run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2208 "$P_SRV" \
2209 "$P_CLI request_size=16384 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
2210 0 \
2211 -s "Read from client: 16384 bytes read"
2212
2213run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2214 "$P_SRV" \
2215 "$P_CLI request_size=16384 force_version=tls1_2 \
2216 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2217 trunc_hmac=1" \
2218 0 \
2219 -s "Read from client: 16384 bytes read"
2220
2221run_test "Large packet TLS 1.2 StreamCipher" \
2222 "$P_SRV" \
2223 "$P_CLI request_size=16384 force_version=tls1_2 \
2224 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2225 0 \
2226 -s "Read from client: 16384 bytes read"
2227
2228run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
2229 "$P_SRV" \
2230 "$P_CLI request_size=16384 force_version=tls1_2 \
2231 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2232 trunc_hmac=1" \
2233 0 \
2234 -s "Read from client: 16384 bytes read"
2235
2236run_test "Large packet TLS 1.2 AEAD" \
2237 "$P_SRV" \
2238 "$P_CLI request_size=16384 force_version=tls1_2 \
2239 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2240 0 \
2241 -s "Read from client: 16384 bytes read"
2242
2243run_test "Large packet TLS 1.2 AEAD shorter tag" \
2244 "$P_SRV" \
2245 "$P_CLI request_size=16384 force_version=tls1_2 \
2246 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2247 0 \
2248 -s "Read from client: 16384 bytes read"
2249
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002250# Final report
2251
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002252echo "------------------------------------------------------------------------"
2253
2254if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002255 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002256else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002257 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002258fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002259PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002260echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002261
2262exit $FAILS