blob: cd4f6a67f745397ea0aca2ddd207f064ebb2c906 [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é-Gonnard3ff78232015-01-08 11:15:09 +0100665# Tests for CBC 1/n-1 record splitting
666
667run_test "CBC Record splitting: TLS 1.2, no splitting" \
668 "$P_SRV" \
669 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
670 request_size=123 force_version=tls1_2" \
671 0 \
672 -s "Read from client: 123 bytes read" \
673 -S "Read from client: 1 bytes read" \
674 -S "122 bytes read"
675
676run_test "CBC Record splitting: TLS 1.1, no splitting" \
677 "$P_SRV" \
678 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
679 request_size=123 force_version=tls1_1" \
680 0 \
681 -s "Read from client: 123 bytes read" \
682 -S "Read from client: 1 bytes read" \
683 -S "122 bytes read"
684
685run_test "CBC Record splitting: TLS 1.0, splitting" \
686 "$P_SRV" \
687 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
688 request_size=123 force_version=tls1" \
689 0 \
690 -S "Read from client: 123 bytes read" \
691 -s "Read from client: 1 bytes read" \
692 -s "122 bytes read"
693
694run_test "CBC Record splitting: SSLv3, splitting" \
695 "$P_SRV" \
696 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
697 request_size=123 force_version=ssl3" \
698 0 \
699 -S "Read from client: 123 bytes read" \
700 -s "Read from client: 1 bytes read" \
701 -s "122 bytes read"
702
703run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
704 "$P_SRV" \
705 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
706 request_size=123 force_version=tls1" \
707 0 \
708 -s "Read from client: 123 bytes read" \
709 -S "Read from client: 1 bytes read" \
710 -S "122 bytes read"
711
712run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
713 "$P_SRV" \
714 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
715 request_size=123 force_version=tls1 recsplit=0" \
716 0 \
717 -s "Read from client: 123 bytes read" \
718 -S "Read from client: 1 bytes read" \
719 -S "122 bytes read"
720
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100721# Tests for Session Tickets
722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200723run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200724 "$P_SRV debug_level=3 tickets=1" \
725 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100726 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100727 -c "client hello, adding session ticket extension" \
728 -s "found session ticket extension" \
729 -s "server hello, adding session ticket extension" \
730 -c "found session_ticket extension" \
731 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100732 -S "session successfully restored from cache" \
733 -s "session successfully restored from ticket" \
734 -s "a session has been resumed" \
735 -c "a session has been resumed"
736
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200737run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200738 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
739 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100740 0 \
741 -c "client hello, adding session ticket extension" \
742 -s "found session ticket extension" \
743 -s "server hello, adding session ticket extension" \
744 -c "found session_ticket extension" \
745 -c "parse new session ticket" \
746 -S "session successfully restored from cache" \
747 -s "session successfully restored from ticket" \
748 -s "a session has been resumed" \
749 -c "a session has been resumed"
750
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200751run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200752 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
753 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100754 0 \
755 -c "client hello, adding session ticket extension" \
756 -s "found session ticket extension" \
757 -s "server hello, adding session ticket extension" \
758 -c "found session_ticket extension" \
759 -c "parse new session ticket" \
760 -S "session successfully restored from cache" \
761 -S "session successfully restored from ticket" \
762 -S "a session has been resumed" \
763 -C "a session has been resumed"
764
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200765run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100766 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200767 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100768 0 \
769 -c "client hello, adding session ticket extension" \
770 -c "found session_ticket extension" \
771 -c "parse new session ticket" \
772 -c "a session has been resumed"
773
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200774run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200775 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200776 "( $O_CLI -sess_out $SESSION; \
777 $O_CLI -sess_in $SESSION; \
778 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100779 0 \
780 -s "found session ticket extension" \
781 -s "server hello, adding session ticket extension" \
782 -S "session successfully restored from cache" \
783 -s "session successfully restored from ticket" \
784 -s "a session has been resumed"
785
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100786# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100787
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200788run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200789 "$P_SRV debug_level=3 tickets=0" \
790 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100791 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100792 -c "client hello, adding session ticket extension" \
793 -s "found session ticket extension" \
794 -S "server hello, adding session ticket extension" \
795 -C "found session_ticket extension" \
796 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100797 -s "session successfully restored from cache" \
798 -S "session successfully restored from ticket" \
799 -s "a session has been resumed" \
800 -c "a session has been resumed"
801
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200802run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200803 "$P_SRV debug_level=3 tickets=1" \
804 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100805 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100806 -C "client hello, adding session ticket extension" \
807 -S "found session ticket extension" \
808 -S "server hello, adding session ticket extension" \
809 -C "found session_ticket extension" \
810 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100811 -s "session successfully restored from cache" \
812 -S "session successfully restored from ticket" \
813 -s "a session has been resumed" \
814 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100815
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200816run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200817 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
818 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100819 0 \
820 -S "session successfully restored from cache" \
821 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100822 -S "a session has been resumed" \
823 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200825run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200826 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
827 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100828 0 \
829 -s "session successfully restored from cache" \
830 -S "session successfully restored from ticket" \
831 -s "a session has been resumed" \
832 -c "a session has been resumed"
833
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200834run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200835 "$P_SRV debug_level=3 tickets=0" \
836 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100837 0 \
838 -s "session successfully restored from cache" \
839 -S "session successfully restored from ticket" \
840 -s "a session has been resumed" \
841 -c "a session has been resumed"
842
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200843run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200844 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
845 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100846 0 \
847 -S "session successfully restored from cache" \
848 -S "session successfully restored from ticket" \
849 -S "a session has been resumed" \
850 -C "a session has been resumed"
851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200852run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200853 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
854 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100855 0 \
856 -s "session successfully restored from cache" \
857 -S "session successfully restored from ticket" \
858 -s "a session has been resumed" \
859 -c "a session has been resumed"
860
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200861run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200862 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200863 "( $O_CLI -sess_out $SESSION; \
864 $O_CLI -sess_in $SESSION; \
865 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100866 0 \
867 -s "found session ticket extension" \
868 -S "server hello, adding session ticket extension" \
869 -s "session successfully restored from cache" \
870 -S "session successfully restored from ticket" \
871 -s "a session has been resumed"
872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200873run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100874 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200875 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100876 0 \
877 -C "found session_ticket extension" \
878 -C "parse new session ticket" \
879 -c "a session has been resumed"
880
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100881# Tests for Max Fragment Length extension
882
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200883run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200884 "$P_SRV debug_level=3" \
885 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100886 0 \
887 -C "client hello, adding max_fragment_length extension" \
888 -S "found max fragment length extension" \
889 -S "server hello, max_fragment_length extension" \
890 -C "found max_fragment_length extension"
891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200892run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200893 "$P_SRV debug_level=3" \
894 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100895 0 \
896 -c "client hello, adding max_fragment_length extension" \
897 -s "found max fragment length extension" \
898 -s "server hello, max_fragment_length extension" \
899 -c "found max_fragment_length extension"
900
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200901run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200902 "$P_SRV debug_level=3 max_frag_len=4096" \
903 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100904 0 \
905 -C "client hello, adding max_fragment_length extension" \
906 -S "found max fragment length extension" \
907 -S "server hello, max_fragment_length extension" \
908 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100909
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200910requires_gnutls
911run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200912 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200913 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200914 0 \
915 -c "client hello, adding max_fragment_length extension" \
916 -c "found max_fragment_length extension"
917
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100918# Tests for renegotiation
919
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200920run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200921 "$P_SRV debug_level=3 exchanges=2" \
922 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100923 0 \
924 -C "client hello, adding renegotiation extension" \
925 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
926 -S "found renegotiation extension" \
927 -s "server hello, secure renegotiation extension" \
928 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100929 -C "=> renegotiate" \
930 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100931 -S "write hello request"
932
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200933run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200934 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
935 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100936 0 \
937 -c "client hello, adding renegotiation extension" \
938 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
939 -s "found renegotiation extension" \
940 -s "server hello, secure renegotiation extension" \
941 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100942 -c "=> renegotiate" \
943 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100944 -S "write hello request"
945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200946run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200947 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
948 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100949 0 \
950 -c "client hello, adding renegotiation extension" \
951 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
952 -s "found renegotiation extension" \
953 -s "server hello, secure renegotiation extension" \
954 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100955 -c "=> renegotiate" \
956 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100957 -s "write hello request"
958
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200959run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200960 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
961 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100962 0 \
963 -c "client hello, adding renegotiation extension" \
964 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
965 -s "found renegotiation extension" \
966 -s "server hello, secure renegotiation extension" \
967 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100968 -c "=> renegotiate" \
969 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100970 -s "write hello request"
971
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200972run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200973 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
974 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100975 1 \
976 -c "client hello, adding renegotiation extension" \
977 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
978 -S "found renegotiation extension" \
979 -s "server hello, secure renegotiation extension" \
980 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100981 -c "=> renegotiate" \
982 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200983 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200984 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200985 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100986
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200987run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200988 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
989 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100990 0 \
991 -C "client hello, adding renegotiation extension" \
992 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
993 -S "found renegotiation extension" \
994 -s "server hello, secure renegotiation extension" \
995 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100996 -C "=> renegotiate" \
997 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100998 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +0200999 -S "SSL - An unexpected message was received from our peer" \
1000 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001002run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001003 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001004 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001005 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001006 0 \
1007 -C "client hello, adding renegotiation extension" \
1008 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1009 -S "found renegotiation extension" \
1010 -s "server hello, secure renegotiation extension" \
1011 -c "found renegotiation extension" \
1012 -C "=> renegotiate" \
1013 -S "=> renegotiate" \
1014 -s "write hello request" \
1015 -S "SSL - An unexpected message was received from our peer" \
1016 -S "failed"
1017
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001018# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001019run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001020 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001021 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001022 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001023 0 \
1024 -C "client hello, adding renegotiation extension" \
1025 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1026 -S "found renegotiation extension" \
1027 -s "server hello, secure renegotiation extension" \
1028 -c "found renegotiation extension" \
1029 -C "=> renegotiate" \
1030 -S "=> renegotiate" \
1031 -s "write hello request" \
1032 -S "SSL - An unexpected message was received from our peer" \
1033 -S "failed"
1034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001035run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001036 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001037 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001038 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001039 0 \
1040 -C "client hello, adding renegotiation extension" \
1041 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1042 -S "found renegotiation extension" \
1043 -s "server hello, secure renegotiation extension" \
1044 -c "found renegotiation extension" \
1045 -C "=> renegotiate" \
1046 -S "=> renegotiate" \
1047 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001048 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001050run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001051 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001052 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001053 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001054 0 \
1055 -c "client hello, adding renegotiation extension" \
1056 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1057 -s "found renegotiation extension" \
1058 -s "server hello, secure renegotiation extension" \
1059 -c "found renegotiation extension" \
1060 -c "=> renegotiate" \
1061 -s "=> renegotiate" \
1062 -s "write hello request" \
1063 -S "SSL - An unexpected message was received from our peer" \
1064 -S "failed"
1065
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001066run_test "Renegotiation: periodic, just below period" \
1067 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1068 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1069 0 \
1070 -C "client hello, adding renegotiation extension" \
1071 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1072 -S "found renegotiation extension" \
1073 -s "server hello, secure renegotiation extension" \
1074 -c "found renegotiation extension" \
1075 -S "record counter limit reached: renegotiate" \
1076 -C "=> renegotiate" \
1077 -S "=> renegotiate" \
1078 -S "write hello request" \
1079 -S "SSL - An unexpected message was received from our peer" \
1080 -S "failed"
1081
1082run_test "Renegotiation: periodic, just above period" \
1083 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1084 "$P_CLI debug_level=3 exchanges=3 renegotiation=1" \
1085 0 \
1086 -c "client hello, adding renegotiation extension" \
1087 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1088 -s "found renegotiation extension" \
1089 -s "server hello, secure renegotiation extension" \
1090 -c "found renegotiation extension" \
1091 -s "record counter limit reached: renegotiate" \
1092 -c "=> renegotiate" \
1093 -s "=> renegotiate" \
1094 -s "write hello request" \
1095 -S "SSL - An unexpected message was received from our peer" \
1096 -S "failed"
1097
1098run_test "Renegotiation: periodic, two times period" \
1099 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1100 "$P_CLI debug_level=3 exchanges=6 renegotiation=1" \
1101 0 \
1102 -c "client hello, adding renegotiation extension" \
1103 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1104 -s "found renegotiation extension" \
1105 -s "server hello, secure renegotiation extension" \
1106 -c "found renegotiation extension" \
1107 -s "record counter limit reached: renegotiate" \
1108 -c "=> renegotiate" \
1109 -s "=> renegotiate" \
1110 -s "write hello request" \
1111 -S "SSL - An unexpected message was received from our peer" \
1112 -S "failed"
1113
1114run_test "Renegotiation: periodic, above period, disabled" \
1115 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1116 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1117 0 \
1118 -C "client hello, adding renegotiation extension" \
1119 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1120 -S "found renegotiation extension" \
1121 -s "server hello, secure renegotiation extension" \
1122 -c "found renegotiation extension" \
1123 -S "record counter limit reached: renegotiate" \
1124 -C "=> renegotiate" \
1125 -S "=> renegotiate" \
1126 -S "write hello request" \
1127 -S "SSL - An unexpected message was received from our peer" \
1128 -S "failed"
1129
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001130run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001131 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1132 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001133 0 \
1134 -c "client hello, adding renegotiation extension" \
1135 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1136 -s "found renegotiation extension" \
1137 -s "server hello, secure renegotiation extension" \
1138 -c "found renegotiation extension" \
1139 -c "=> renegotiate" \
1140 -s "=> renegotiate" \
1141 -S "write hello request"
1142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001143run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001144 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1145 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001146 0 \
1147 -c "client hello, adding renegotiation extension" \
1148 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1149 -s "found renegotiation extension" \
1150 -s "server hello, secure renegotiation extension" \
1151 -c "found renegotiation extension" \
1152 -c "=> renegotiate" \
1153 -s "=> renegotiate" \
1154 -s "write hello request"
1155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001156run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001157 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001158 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001159 0 \
1160 -c "client hello, adding renegotiation extension" \
1161 -c "found renegotiation extension" \
1162 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001163 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001164 -C "error" \
1165 -c "HTTP/1.0 200 [Oo][Kk]"
1166
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001167run_test "Renegotiation: gnutls server strict, client-initiated" \
1168 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001169 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001170 0 \
1171 -c "client hello, adding renegotiation extension" \
1172 -c "found renegotiation extension" \
1173 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001174 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001175 -C "error" \
1176 -c "HTTP/1.0 200 [Oo][Kk]"
1177
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001178run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1179 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1180 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1181 1 \
1182 -c "client hello, adding renegotiation extension" \
1183 -C "found renegotiation extension" \
1184 -c "=> renegotiate" \
1185 -c "ssl_handshake() returned" \
1186 -c "error" \
1187 -C "HTTP/1.0 200 [Oo][Kk]"
1188
1189run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1190 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1191 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1192 allow_legacy=0" \
1193 1 \
1194 -c "client hello, adding renegotiation extension" \
1195 -C "found renegotiation extension" \
1196 -c "=> renegotiate" \
1197 -c "ssl_handshake() returned" \
1198 -c "error" \
1199 -C "HTTP/1.0 200 [Oo][Kk]"
1200
1201run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1202 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1203 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1204 allow_legacy=1" \
1205 0 \
1206 -c "client hello, adding renegotiation extension" \
1207 -C "found renegotiation extension" \
1208 -c "=> renegotiate" \
1209 -C "ssl_hanshake() returned" \
1210 -C "error" \
1211 -c "HTTP/1.0 200 [Oo][Kk]"
1212
1213# Test for the "secure renegotation" extension only (no actual renegotiation)
1214
1215run_test "Renego ext: gnutls server strict, client default" \
1216 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1217 "$P_CLI debug_level=3" \
1218 0 \
1219 -c "found renegotiation extension" \
1220 -C "error" \
1221 -c "HTTP/1.0 200 [Oo][Kk]"
1222
1223run_test "Renego ext: gnutls server unsafe, client default" \
1224 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1225 "$P_CLI debug_level=3" \
1226 0 \
1227 -C "found renegotiation extension" \
1228 -C "error" \
1229 -c "HTTP/1.0 200 [Oo][Kk]"
1230
1231run_test "Renego ext: gnutls server unsafe, client break legacy" \
1232 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1233 "$P_CLI debug_level=3 allow_legacy=-1" \
1234 1 \
1235 -C "found renegotiation extension" \
1236 -c "error" \
1237 -C "HTTP/1.0 200 [Oo][Kk]"
1238
1239run_test "Renego ext: gnutls client strict, server default" \
1240 "$P_SRV debug_level=3" \
1241 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1242 0 \
1243 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1244 -s "server hello, secure renegotiation extension"
1245
1246run_test "Renego ext: gnutls client unsafe, server default" \
1247 "$P_SRV debug_level=3" \
1248 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1249 0 \
1250 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1251 -S "server hello, secure renegotiation extension"
1252
1253run_test "Renego ext: gnutls client unsafe, server break legacy" \
1254 "$P_SRV debug_level=3 allow_legacy=-1" \
1255 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1256 1 \
1257 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1258 -S "server hello, secure renegotiation extension"
1259
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001260# Tests for auth_mode
1261
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001262run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001263 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001264 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001265 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001266 1 \
1267 -c "x509_verify_cert() returned" \
1268 -c "! self-signed or not signed by a trusted CA" \
1269 -c "! ssl_handshake returned" \
1270 -c "X509 - Certificate verification failed"
1271
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001272run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001273 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001274 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001275 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001276 0 \
1277 -c "x509_verify_cert() returned" \
1278 -c "! self-signed or not signed by a trusted CA" \
1279 -C "! ssl_handshake returned" \
1280 -C "X509 - Certificate verification failed"
1281
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001282run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001283 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001284 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001285 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001286 0 \
1287 -C "x509_verify_cert() returned" \
1288 -C "! self-signed or not signed by a trusted CA" \
1289 -C "! ssl_handshake returned" \
1290 -C "X509 - Certificate verification failed"
1291
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001292run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001293 "$P_SRV debug_level=3 auth_mode=required" \
1294 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001295 key_file=data_files/server5.key" \
1296 1 \
1297 -S "skip write certificate request" \
1298 -C "skip parse certificate request" \
1299 -c "got a certificate request" \
1300 -C "skip write certificate" \
1301 -C "skip write certificate verify" \
1302 -S "skip parse certificate verify" \
1303 -s "x509_verify_cert() returned" \
1304 -S "! self-signed or not signed by a trusted CA" \
1305 -s "! ssl_handshake returned" \
1306 -c "! ssl_handshake returned" \
1307 -s "X509 - Certificate verification failed"
1308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001309run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001310 "$P_SRV debug_level=3 auth_mode=optional" \
1311 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001312 key_file=data_files/server5.key" \
1313 0 \
1314 -S "skip write certificate request" \
1315 -C "skip parse certificate request" \
1316 -c "got a certificate request" \
1317 -C "skip write certificate" \
1318 -C "skip write certificate verify" \
1319 -S "skip parse certificate verify" \
1320 -s "x509_verify_cert() returned" \
1321 -s "! self-signed or not signed by a trusted CA" \
1322 -S "! ssl_handshake returned" \
1323 -C "! ssl_handshake returned" \
1324 -S "X509 - Certificate verification failed"
1325
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001326run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001327 "$P_SRV debug_level=3 auth_mode=none" \
1328 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001329 key_file=data_files/server5.key" \
1330 0 \
1331 -s "skip write certificate request" \
1332 -C "skip parse certificate request" \
1333 -c "got no certificate request" \
1334 -c "skip write certificate" \
1335 -c "skip write certificate verify" \
1336 -s "skip parse certificate verify" \
1337 -S "x509_verify_cert() returned" \
1338 -S "! self-signed or not signed by a trusted CA" \
1339 -S "! ssl_handshake returned" \
1340 -C "! ssl_handshake returned" \
1341 -S "X509 - Certificate verification failed"
1342
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001343run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001344 "$P_SRV debug_level=3 auth_mode=optional" \
1345 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001346 0 \
1347 -S "skip write certificate request" \
1348 -C "skip parse certificate request" \
1349 -c "got a certificate request" \
1350 -C "skip write certificate$" \
1351 -C "got no certificate to send" \
1352 -S "SSLv3 client has no certificate" \
1353 -c "skip write certificate verify" \
1354 -s "skip parse certificate verify" \
1355 -s "! no client certificate sent" \
1356 -S "! ssl_handshake returned" \
1357 -C "! ssl_handshake returned" \
1358 -S "X509 - Certificate verification failed"
1359
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001360run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001361 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001362 "$O_CLI" \
1363 0 \
1364 -S "skip write certificate request" \
1365 -s "skip parse certificate verify" \
1366 -s "! no client certificate sent" \
1367 -S "! ssl_handshake returned" \
1368 -S "X509 - Certificate verification failed"
1369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001370run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001371 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001372 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001373 0 \
1374 -C "skip parse certificate request" \
1375 -c "got a certificate request" \
1376 -C "skip write certificate$" \
1377 -c "skip write certificate verify" \
1378 -C "! ssl_handshake returned"
1379
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001380run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001381 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1382 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001383 0 \
1384 -S "skip write certificate request" \
1385 -C "skip parse certificate request" \
1386 -c "got a certificate request" \
1387 -C "skip write certificate$" \
1388 -c "skip write certificate verify" \
1389 -c "got no certificate to send" \
1390 -s "SSLv3 client has no certificate" \
1391 -s "skip parse certificate verify" \
1392 -s "! no client certificate sent" \
1393 -S "! ssl_handshake returned" \
1394 -C "! ssl_handshake returned" \
1395 -S "X509 - Certificate verification failed"
1396
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001397# tests for SNI
1398
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001399run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001400 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001401 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001402 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001403 server_name=localhost" \
1404 0 \
1405 -S "parse ServerName extension" \
1406 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1407 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1408
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001409run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001410 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001411 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001412 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 +01001413 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001414 server_name=localhost" \
1415 0 \
1416 -s "parse ServerName extension" \
1417 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1418 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1419
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001420run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001421 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001422 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001423 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 +01001424 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001425 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001426 0 \
1427 -s "parse ServerName extension" \
1428 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001429 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001431run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001432 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001433 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001434 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 +01001435 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001436 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001437 1 \
1438 -s "parse ServerName extension" \
1439 -s "ssl_sni_wrapper() returned" \
1440 -s "ssl_handshake returned" \
1441 -c "ssl_handshake returned" \
1442 -c "SSL - A fatal alert message was received from our peer"
1443
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001444# Tests for non-blocking I/O: exercise a variety of handshake flows
1445
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001446run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001447 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1448 "$P_CLI nbio=2 tickets=0" \
1449 0 \
1450 -S "ssl_handshake returned" \
1451 -C "ssl_handshake returned" \
1452 -c "Read from server: .* bytes read"
1453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001454run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001455 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1456 "$P_CLI nbio=2 tickets=0" \
1457 0 \
1458 -S "ssl_handshake returned" \
1459 -C "ssl_handshake returned" \
1460 -c "Read from server: .* bytes read"
1461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001462run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001463 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1464 "$P_CLI nbio=2 tickets=1" \
1465 0 \
1466 -S "ssl_handshake returned" \
1467 -C "ssl_handshake returned" \
1468 -c "Read from server: .* bytes read"
1469
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001470run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001471 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1472 "$P_CLI nbio=2 tickets=1" \
1473 0 \
1474 -S "ssl_handshake returned" \
1475 -C "ssl_handshake returned" \
1476 -c "Read from server: .* bytes read"
1477
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001478run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001479 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1480 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1481 0 \
1482 -S "ssl_handshake returned" \
1483 -C "ssl_handshake returned" \
1484 -c "Read from server: .* bytes read"
1485
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001486run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001487 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1488 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1489 0 \
1490 -S "ssl_handshake returned" \
1491 -C "ssl_handshake returned" \
1492 -c "Read from server: .* bytes read"
1493
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001494run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001495 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1496 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1497 0 \
1498 -S "ssl_handshake returned" \
1499 -C "ssl_handshake returned" \
1500 -c "Read from server: .* bytes read"
1501
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001502# Tests for version negotiation
1503
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001504run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001505 "$P_SRV" \
1506 "$P_CLI" \
1507 0 \
1508 -S "ssl_handshake returned" \
1509 -C "ssl_handshake returned" \
1510 -s "Protocol is TLSv1.2" \
1511 -c "Protocol is TLSv1.2"
1512
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001513run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001514 "$P_SRV" \
1515 "$P_CLI max_version=tls1_1" \
1516 0 \
1517 -S "ssl_handshake returned" \
1518 -C "ssl_handshake returned" \
1519 -s "Protocol is TLSv1.1" \
1520 -c "Protocol is TLSv1.1"
1521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001522run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001523 "$P_SRV max_version=tls1_1" \
1524 "$P_CLI" \
1525 0 \
1526 -S "ssl_handshake returned" \
1527 -C "ssl_handshake returned" \
1528 -s "Protocol is TLSv1.1" \
1529 -c "Protocol is TLSv1.1"
1530
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001531run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001532 "$P_SRV max_version=tls1_1" \
1533 "$P_CLI max_version=tls1_1" \
1534 0 \
1535 -S "ssl_handshake returned" \
1536 -C "ssl_handshake returned" \
1537 -s "Protocol is TLSv1.1" \
1538 -c "Protocol is TLSv1.1"
1539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001540run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001541 "$P_SRV min_version=tls1_1" \
1542 "$P_CLI max_version=tls1_1" \
1543 0 \
1544 -S "ssl_handshake returned" \
1545 -C "ssl_handshake returned" \
1546 -s "Protocol is TLSv1.1" \
1547 -c "Protocol is TLSv1.1"
1548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001549run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001550 "$P_SRV max_version=tls1_1" \
1551 "$P_CLI min_version=tls1_1" \
1552 0 \
1553 -S "ssl_handshake returned" \
1554 -C "ssl_handshake returned" \
1555 -s "Protocol is TLSv1.1" \
1556 -c "Protocol is TLSv1.1"
1557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001558run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001559 "$P_SRV max_version=tls1_1" \
1560 "$P_CLI min_version=tls1_2" \
1561 1 \
1562 -s "ssl_handshake returned" \
1563 -c "ssl_handshake returned" \
1564 -c "SSL - Handshake protocol not within min/max boundaries"
1565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001566run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001567 "$P_SRV min_version=tls1_2" \
1568 "$P_CLI max_version=tls1_1" \
1569 1 \
1570 -s "ssl_handshake returned" \
1571 -c "ssl_handshake returned" \
1572 -s "SSL - Handshake protocol not within min/max boundaries"
1573
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001574# Tests for ALPN extension
1575
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001576if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1577
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001578run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001579 "$P_SRV debug_level=3" \
1580 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001581 0 \
1582 -C "client hello, adding alpn extension" \
1583 -S "found alpn extension" \
1584 -C "got an alert message, type: \\[2:120]" \
1585 -S "server hello, adding alpn extension" \
1586 -C "found alpn extension " \
1587 -C "Application Layer Protocol is" \
1588 -S "Application Layer Protocol is"
1589
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001590run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001591 "$P_SRV debug_level=3" \
1592 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001593 0 \
1594 -c "client hello, adding alpn extension" \
1595 -s "found alpn extension" \
1596 -C "got an alert message, type: \\[2:120]" \
1597 -S "server hello, adding alpn extension" \
1598 -C "found alpn extension " \
1599 -c "Application Layer Protocol is (none)" \
1600 -S "Application Layer Protocol is"
1601
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001602run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001603 "$P_SRV debug_level=3 alpn=abc,1234" \
1604 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001605 0 \
1606 -C "client hello, adding alpn extension" \
1607 -S "found alpn extension" \
1608 -C "got an alert message, type: \\[2:120]" \
1609 -S "server hello, adding alpn extension" \
1610 -C "found alpn extension " \
1611 -C "Application Layer Protocol is" \
1612 -s "Application Layer Protocol is (none)"
1613
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001614run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001615 "$P_SRV debug_level=3 alpn=abc,1234" \
1616 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001617 0 \
1618 -c "client hello, adding alpn extension" \
1619 -s "found alpn extension" \
1620 -C "got an alert message, type: \\[2:120]" \
1621 -s "server hello, adding alpn extension" \
1622 -c "found alpn extension" \
1623 -c "Application Layer Protocol is abc" \
1624 -s "Application Layer Protocol is abc"
1625
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001626run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001627 "$P_SRV debug_level=3 alpn=abc,1234" \
1628 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001629 0 \
1630 -c "client hello, adding alpn extension" \
1631 -s "found alpn extension" \
1632 -C "got an alert message, type: \\[2:120]" \
1633 -s "server hello, adding alpn extension" \
1634 -c "found alpn extension" \
1635 -c "Application Layer Protocol is abc" \
1636 -s "Application Layer Protocol is abc"
1637
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001638run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001639 "$P_SRV debug_level=3 alpn=abc,1234" \
1640 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001641 0 \
1642 -c "client hello, adding alpn extension" \
1643 -s "found alpn extension" \
1644 -C "got an alert message, type: \\[2:120]" \
1645 -s "server hello, adding alpn extension" \
1646 -c "found alpn extension" \
1647 -c "Application Layer Protocol is 1234" \
1648 -s "Application Layer Protocol is 1234"
1649
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001650run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001651 "$P_SRV debug_level=3 alpn=abc,123" \
1652 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001653 1 \
1654 -c "client hello, adding alpn extension" \
1655 -s "found alpn extension" \
1656 -c "got an alert message, type: \\[2:120]" \
1657 -S "server hello, adding alpn extension" \
1658 -C "found alpn extension" \
1659 -C "Application Layer Protocol is 1234" \
1660 -S "Application Layer Protocol is 1234"
1661
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001662fi
1663
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001664# Tests for keyUsage in leaf certificates, part 1:
1665# server-side certificate/suite selection
1666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001667run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001668 "$P_SRV key_file=data_files/server2.key \
1669 crt_file=data_files/server2.ku-ds.crt" \
1670 "$P_CLI" \
1671 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001672 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001673
1674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001675run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001676 "$P_SRV key_file=data_files/server2.key \
1677 crt_file=data_files/server2.ku-ke.crt" \
1678 "$P_CLI" \
1679 0 \
1680 -c "Ciphersuite is TLS-RSA-WITH-"
1681
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001682run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001683 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001684 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001685 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001686 1 \
1687 -C "Ciphersuite is "
1688
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001689run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001690 "$P_SRV key_file=data_files/server5.key \
1691 crt_file=data_files/server5.ku-ds.crt" \
1692 "$P_CLI" \
1693 0 \
1694 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1695
1696
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001697run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001698 "$P_SRV key_file=data_files/server5.key \
1699 crt_file=data_files/server5.ku-ka.crt" \
1700 "$P_CLI" \
1701 0 \
1702 -c "Ciphersuite is TLS-ECDH-"
1703
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001704run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001705 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001706 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001707 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001708 1 \
1709 -C "Ciphersuite is "
1710
1711# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001712# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001713
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001714run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001715 "$O_SRV -key data_files/server2.key \
1716 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001717 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001718 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1719 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001720 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001721 -C "Processing of the Certificate handshake message failed" \
1722 -c "Ciphersuite is TLS-"
1723
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001724run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001725 "$O_SRV -key data_files/server2.key \
1726 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001727 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001728 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1729 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001730 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001731 -C "Processing of the Certificate handshake message failed" \
1732 -c "Ciphersuite is TLS-"
1733
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001734run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001735 "$O_SRV -key data_files/server2.key \
1736 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001737 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001738 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1739 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001740 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001741 -C "Processing of the Certificate handshake message failed" \
1742 -c "Ciphersuite is TLS-"
1743
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001744run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001745 "$O_SRV -key data_files/server2.key \
1746 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001747 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001748 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1749 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001750 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001751 -c "Processing of the Certificate handshake message failed" \
1752 -C "Ciphersuite is TLS-"
1753
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001754run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001755 "$O_SRV -key data_files/server2.key \
1756 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001757 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001758 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1759 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001760 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001761 -C "Processing of the Certificate handshake message failed" \
1762 -c "Ciphersuite is TLS-"
1763
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001764run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001765 "$O_SRV -key data_files/server2.key \
1766 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001767 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001768 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1769 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001770 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001771 -c "Processing of the Certificate handshake message failed" \
1772 -C "Ciphersuite is TLS-"
1773
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001774# Tests for keyUsage in leaf certificates, part 3:
1775# server-side checking of client cert
1776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001777run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001778 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001779 "$O_CLI -key data_files/server2.key \
1780 -cert data_files/server2.ku-ds.crt" \
1781 0 \
1782 -S "bad certificate (usage extensions)" \
1783 -S "Processing of the Certificate handshake message failed"
1784
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001785run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001786 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001787 "$O_CLI -key data_files/server2.key \
1788 -cert data_files/server2.ku-ke.crt" \
1789 0 \
1790 -s "bad certificate (usage extensions)" \
1791 -S "Processing of the Certificate handshake message failed"
1792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001793run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001794 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001795 "$O_CLI -key data_files/server2.key \
1796 -cert data_files/server2.ku-ke.crt" \
1797 1 \
1798 -s "bad certificate (usage extensions)" \
1799 -s "Processing of the Certificate handshake message failed"
1800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001801run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001802 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001803 "$O_CLI -key data_files/server5.key \
1804 -cert data_files/server5.ku-ds.crt" \
1805 0 \
1806 -S "bad certificate (usage extensions)" \
1807 -S "Processing of the Certificate handshake message failed"
1808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001809run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001810 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001811 "$O_CLI -key data_files/server5.key \
1812 -cert data_files/server5.ku-ka.crt" \
1813 0 \
1814 -s "bad certificate (usage extensions)" \
1815 -S "Processing of the Certificate handshake message failed"
1816
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001817# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1818
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001819run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001820 "$P_SRV key_file=data_files/server5.key \
1821 crt_file=data_files/server5.eku-srv.crt" \
1822 "$P_CLI" \
1823 0
1824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001825run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001826 "$P_SRV key_file=data_files/server5.key \
1827 crt_file=data_files/server5.eku-srv.crt" \
1828 "$P_CLI" \
1829 0
1830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001831run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001832 "$P_SRV key_file=data_files/server5.key \
1833 crt_file=data_files/server5.eku-cs_any.crt" \
1834 "$P_CLI" \
1835 0
1836
1837# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001838run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001839 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1840 crt_file=data_files/server5.eku-cli.crt" \
1841 "$P_CLI psk=badbad" \
1842 1
1843
1844# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001846run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001847 "$O_SRV -key data_files/server5.key \
1848 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001849 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001850 0 \
1851 -C "bad certificate (usage extensions)" \
1852 -C "Processing of the Certificate handshake message failed" \
1853 -c "Ciphersuite is TLS-"
1854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001855run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001856 "$O_SRV -key data_files/server5.key \
1857 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001858 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001859 0 \
1860 -C "bad certificate (usage extensions)" \
1861 -C "Processing of the Certificate handshake message failed" \
1862 -c "Ciphersuite is TLS-"
1863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001864run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001865 "$O_SRV -key data_files/server5.key \
1866 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001867 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001868 0 \
1869 -C "bad certificate (usage extensions)" \
1870 -C "Processing of the Certificate handshake message failed" \
1871 -c "Ciphersuite is TLS-"
1872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001873run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001874 "$O_SRV -key data_files/server5.key \
1875 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001876 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001877 1 \
1878 -c "bad certificate (usage extensions)" \
1879 -c "Processing of the Certificate handshake message failed" \
1880 -C "Ciphersuite is TLS-"
1881
1882# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1883
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001884run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001885 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001886 "$O_CLI -key data_files/server5.key \
1887 -cert data_files/server5.eku-cli.crt" \
1888 0 \
1889 -S "bad certificate (usage extensions)" \
1890 -S "Processing of the Certificate handshake message failed"
1891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001892run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001893 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001894 "$O_CLI -key data_files/server5.key \
1895 -cert data_files/server5.eku-srv_cli.crt" \
1896 0 \
1897 -S "bad certificate (usage extensions)" \
1898 -S "Processing of the Certificate handshake message failed"
1899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001900run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001901 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001902 "$O_CLI -key data_files/server5.key \
1903 -cert data_files/server5.eku-cs_any.crt" \
1904 0 \
1905 -S "bad certificate (usage extensions)" \
1906 -S "Processing of the Certificate handshake message failed"
1907
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001908run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001909 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001910 "$O_CLI -key data_files/server5.key \
1911 -cert data_files/server5.eku-cs.crt" \
1912 0 \
1913 -s "bad certificate (usage extensions)" \
1914 -S "Processing of the Certificate handshake message failed"
1915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001916run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001917 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001918 "$O_CLI -key data_files/server5.key \
1919 -cert data_files/server5.eku-cs.crt" \
1920 1 \
1921 -s "bad certificate (usage extensions)" \
1922 -s "Processing of the Certificate handshake message failed"
1923
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001924# Tests for DHM parameters loading
1925
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001926run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001927 "$P_SRV" \
1928 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1929 debug_level=3" \
1930 0 \
1931 -c "value of 'DHM: P ' (2048 bits)" \
1932 -c "value of 'DHM: G ' (2048 bits)"
1933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001934run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001935 "$P_SRV dhm_file=data_files/dhparams.pem" \
1936 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1937 debug_level=3" \
1938 0 \
1939 -c "value of 'DHM: P ' (1024 bits)" \
1940 -c "value of 'DHM: G ' (2 bits)"
1941
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001942# Tests for PSK callback
1943
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001944run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001945 "$P_SRV psk=abc123 psk_identity=foo" \
1946 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1947 psk_identity=foo psk=abc123" \
1948 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001949 -S "SSL - The server has no ciphersuites in common" \
1950 -S "SSL - Unknown identity received" \
1951 -S "SSL - Verification of the message MAC failed"
1952
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001953run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001954 "$P_SRV" \
1955 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1956 psk_identity=foo psk=abc123" \
1957 1 \
1958 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001959 -S "SSL - Unknown identity received" \
1960 -S "SSL - Verification of the message MAC failed"
1961
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001962run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001963 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1964 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1965 psk_identity=foo psk=abc123" \
1966 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001967 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001968 -s "SSL - Unknown identity received" \
1969 -S "SSL - Verification of the message MAC failed"
1970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001971run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001972 "$P_SRV psk_list=abc,dead,def,beef" \
1973 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1974 psk_identity=abc psk=dead" \
1975 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001976 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001977 -S "SSL - Unknown identity received" \
1978 -S "SSL - Verification of the message MAC failed"
1979
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001980run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001981 "$P_SRV psk_list=abc,dead,def,beef" \
1982 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1983 psk_identity=def psk=beef" \
1984 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001985 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001986 -S "SSL - Unknown identity received" \
1987 -S "SSL - Verification of the message MAC failed"
1988
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001989run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001990 "$P_SRV psk_list=abc,dead,def,beef" \
1991 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1992 psk_identity=ghi psk=beef" \
1993 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001994 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001995 -s "SSL - Unknown identity received" \
1996 -S "SSL - Verification of the message MAC failed"
1997
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001998run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001999 "$P_SRV psk_list=abc,dead,def,beef" \
2000 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2001 psk_identity=abc psk=beef" \
2002 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002003 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002004 -S "SSL - Unknown identity received" \
2005 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002006
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002007# Tests for ciphersuites per version
2008
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002009run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002010 "$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" \
2011 "$P_CLI force_version=ssl3" \
2012 0 \
2013 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002015run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002016 "$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" \
2017 "$P_CLI force_version=tls1" \
2018 0 \
2019 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002021run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002022 "$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" \
2023 "$P_CLI force_version=tls1_1" \
2024 0 \
2025 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2026
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002027run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002028 "$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" \
2029 "$P_CLI force_version=tls1_2" \
2030 0 \
2031 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2032
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002033# Tests for ssl_get_bytes_avail()
2034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002035run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002036 "$P_SRV" \
2037 "$P_CLI request_size=100" \
2038 0 \
2039 -s "Read from client: 100 bytes read$"
2040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002041run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002042 "$P_SRV" \
2043 "$P_CLI request_size=500" \
2044 0 \
2045 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002046
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002047# Tests for small packets
2048
2049run_test "Small packet SSLv3 BlockCipher" \
2050 "$P_SRV" \
2051 "$P_CLI request_size=1 force_version=ssl3 \
2052 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2053 0 \
2054 -s "Read from client: 1 bytes read"
2055
2056run_test "Small packet SSLv3 StreamCipher" \
2057 "$P_SRV" \
2058 "$P_CLI request_size=1 force_version=ssl3 \
2059 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2060 0 \
2061 -s "Read from client: 1 bytes read"
2062
2063run_test "Small packet TLS 1.0 BlockCipher" \
2064 "$P_SRV" \
2065 "$P_CLI request_size=1 force_version=tls1 \
2066 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2067 0 \
2068 -s "Read from client: 1 bytes read"
2069
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002070run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2071 "$P_SRV" \
2072 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2073 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2074 0 \
2075 -s "Read from client: 1 bytes read"
2076
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002077run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2078 "$P_SRV" \
2079 "$P_CLI request_size=1 force_version=tls1 \
2080 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2081 trunc_hmac=1" \
2082 0 \
2083 -s "Read from client: 1 bytes read"
2084
2085run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
2086 "$P_SRV" \
2087 "$P_CLI request_size=1 force_version=tls1 \
2088 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2089 trunc_hmac=1" \
2090 0 \
2091 -s "Read from client: 1 bytes read"
2092
2093run_test "Small packet TLS 1.1 BlockCipher" \
2094 "$P_SRV" \
2095 "$P_CLI request_size=1 force_version=tls1_1 \
2096 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2097 0 \
2098 -s "Read from client: 1 bytes read"
2099
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002100run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2101 "$P_SRV" \
2102 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2103 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2104 0 \
2105 -s "Read from client: 1 bytes read"
2106
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002107run_test "Small packet TLS 1.1 StreamCipher" \
2108 "$P_SRV" \
2109 "$P_CLI request_size=1 force_version=tls1_1 \
2110 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2111 0 \
2112 -s "Read from client: 1 bytes read"
2113
2114run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2115 "$P_SRV" \
2116 "$P_CLI request_size=1 force_version=tls1_1 \
2117 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2118 trunc_hmac=1" \
2119 0 \
2120 -s "Read from client: 1 bytes read"
2121
2122run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
2123 "$P_SRV" \
2124 "$P_CLI request_size=1 force_version=tls1_1 \
2125 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2126 trunc_hmac=1" \
2127 0 \
2128 -s "Read from client: 1 bytes read"
2129
2130run_test "Small packet TLS 1.2 BlockCipher" \
2131 "$P_SRV" \
2132 "$P_CLI request_size=1 force_version=tls1_2 \
2133 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2134 0 \
2135 -s "Read from client: 1 bytes read"
2136
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002137run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2138 "$P_SRV" \
2139 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2140 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2141 0 \
2142 -s "Read from client: 1 bytes read"
2143
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002144run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2145 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002146 "$P_CLI request_size=1 force_version=tls1_2 \
2147 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002148 0 \
2149 -s "Read from client: 1 bytes read"
2150
2151run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2152 "$P_SRV" \
2153 "$P_CLI request_size=1 force_version=tls1_2 \
2154 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2155 trunc_hmac=1" \
2156 0 \
2157 -s "Read from client: 1 bytes read"
2158
2159run_test "Small packet TLS 1.2 StreamCipher" \
2160 "$P_SRV" \
2161 "$P_CLI request_size=1 force_version=tls1_2 \
2162 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2163 0 \
2164 -s "Read from client: 1 bytes read"
2165
2166run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
2167 "$P_SRV" \
2168 "$P_CLI request_size=1 force_version=tls1_2 \
2169 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2170 trunc_hmac=1" \
2171 0 \
2172 -s "Read from client: 1 bytes read"
2173
2174run_test "Small packet TLS 1.2 AEAD" \
2175 "$P_SRV" \
2176 "$P_CLI request_size=1 force_version=tls1_2 \
2177 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2178 0 \
2179 -s "Read from client: 1 bytes read"
2180
2181run_test "Small packet TLS 1.2 AEAD shorter tag" \
2182 "$P_SRV" \
2183 "$P_CLI request_size=1 force_version=tls1_2 \
2184 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2185 0 \
2186 -s "Read from client: 1 bytes read"
2187
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002188# Test for large packets
2189
2190run_test "Large packet SSLv3 BlockCipher" \
2191 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002192 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002193 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2194 0 \
2195 -s "Read from client: 16384 bytes read"
2196
2197run_test "Large packet SSLv3 StreamCipher" \
2198 "$P_SRV" \
2199 "$P_CLI request_size=16384 force_version=ssl3 \
2200 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2201 0 \
2202 -s "Read from client: 16384 bytes read"
2203
2204run_test "Large packet TLS 1.0 BlockCipher" \
2205 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002206 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002207 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2208 0 \
2209 -s "Read from client: 16384 bytes read"
2210
2211run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2212 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002213 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002214 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2215 trunc_hmac=1" \
2216 0 \
2217 -s "Read from client: 16384 bytes read"
2218
2219run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
2220 "$P_SRV" \
2221 "$P_CLI request_size=16384 force_version=tls1 \
2222 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2223 trunc_hmac=1" \
2224 0 \
2225 -s "Read from client: 16384 bytes read"
2226
2227run_test "Large packet TLS 1.1 BlockCipher" \
2228 "$P_SRV" \
2229 "$P_CLI request_size=16384 force_version=tls1_1 \
2230 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2231 0 \
2232 -s "Read from client: 16384 bytes read"
2233
2234run_test "Large packet TLS 1.1 StreamCipher" \
2235 "$P_SRV" \
2236 "$P_CLI request_size=16384 force_version=tls1_1 \
2237 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2238 0 \
2239 -s "Read from client: 16384 bytes read"
2240
2241run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2242 "$P_SRV" \
2243 "$P_CLI request_size=16384 force_version=tls1_1 \
2244 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2245 trunc_hmac=1" \
2246 0 \
2247 -s "Read from client: 16384 bytes read"
2248
2249run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
2250 "$P_SRV" \
2251 "$P_CLI request_size=16384 force_version=tls1_1 \
2252 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2253 trunc_hmac=1" \
2254 0 \
2255 -s "Read from client: 16384 bytes read"
2256
2257run_test "Large packet TLS 1.2 BlockCipher" \
2258 "$P_SRV" \
2259 "$P_CLI request_size=16384 force_version=tls1_2 \
2260 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2261 0 \
2262 -s "Read from client: 16384 bytes read"
2263
2264run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2265 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002266 "$P_CLI request_size=16384 force_version=tls1_2 \
2267 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002268 0 \
2269 -s "Read from client: 16384 bytes read"
2270
2271run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2272 "$P_SRV" \
2273 "$P_CLI request_size=16384 force_version=tls1_2 \
2274 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2275 trunc_hmac=1" \
2276 0 \
2277 -s "Read from client: 16384 bytes read"
2278
2279run_test "Large packet TLS 1.2 StreamCipher" \
2280 "$P_SRV" \
2281 "$P_CLI request_size=16384 force_version=tls1_2 \
2282 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2283 0 \
2284 -s "Read from client: 16384 bytes read"
2285
2286run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
2287 "$P_SRV" \
2288 "$P_CLI request_size=16384 force_version=tls1_2 \
2289 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2290 trunc_hmac=1" \
2291 0 \
2292 -s "Read from client: 16384 bytes read"
2293
2294run_test "Large packet TLS 1.2 AEAD" \
2295 "$P_SRV" \
2296 "$P_CLI request_size=16384 force_version=tls1_2 \
2297 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2298 0 \
2299 -s "Read from client: 16384 bytes read"
2300
2301run_test "Large packet TLS 1.2 AEAD shorter tag" \
2302 "$P_SRV" \
2303 "$P_CLI request_size=16384 force_version=tls1_2 \
2304 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2305 0 \
2306 -s "Read from client: 16384 bytes read"
2307
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002308# Final report
2309
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002310echo "------------------------------------------------------------------------"
2311
2312if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002313 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002314else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002315 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002316fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002317PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002318echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002319
2320exit $FAILS