blob: 8bf7d97bffa393bf29f116d4882f191ee1e5e8e9 [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é-Gonnarda852cf42015-01-13 20:56:15 +0100721run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
722 "$P_SRV nbio=2" \
723 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
724 request_size=123 force_version=tls1" \
725 0 \
726 -S "Read from client: 123 bytes read" \
727 -s "Read from client: 1 bytes read" \
728 -s "122 bytes read"
729
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100730# Tests for Session Tickets
731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200732run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200733 "$P_SRV debug_level=3 tickets=1" \
734 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100735 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100736 -c "client hello, adding session ticket extension" \
737 -s "found session ticket extension" \
738 -s "server hello, adding session ticket extension" \
739 -c "found session_ticket extension" \
740 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100741 -S "session successfully restored from cache" \
742 -s "session successfully restored from ticket" \
743 -s "a session has been resumed" \
744 -c "a session has been resumed"
745
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200746run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200747 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
748 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100749 0 \
750 -c "client hello, adding session ticket extension" \
751 -s "found session ticket extension" \
752 -s "server hello, adding session ticket extension" \
753 -c "found session_ticket extension" \
754 -c "parse new session ticket" \
755 -S "session successfully restored from cache" \
756 -s "session successfully restored from ticket" \
757 -s "a session has been resumed" \
758 -c "a session has been resumed"
759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200760run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200761 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
762 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100763 0 \
764 -c "client hello, adding session ticket extension" \
765 -s "found session ticket extension" \
766 -s "server hello, adding session ticket extension" \
767 -c "found session_ticket extension" \
768 -c "parse new session ticket" \
769 -S "session successfully restored from cache" \
770 -S "session successfully restored from ticket" \
771 -S "a session has been resumed" \
772 -C "a session has been resumed"
773
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200774run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100775 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200776 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100777 0 \
778 -c "client hello, adding session ticket extension" \
779 -c "found session_ticket extension" \
780 -c "parse new session ticket" \
781 -c "a session has been resumed"
782
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200783run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200784 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200785 "( $O_CLI -sess_out $SESSION; \
786 $O_CLI -sess_in $SESSION; \
787 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100788 0 \
789 -s "found session ticket extension" \
790 -s "server hello, adding session ticket extension" \
791 -S "session successfully restored from cache" \
792 -s "session successfully restored from ticket" \
793 -s "a session has been resumed"
794
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100795# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100796
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200797run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200798 "$P_SRV debug_level=3 tickets=0" \
799 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100800 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100801 -c "client hello, adding session ticket extension" \
802 -s "found session ticket extension" \
803 -S "server hello, adding session ticket extension" \
804 -C "found session_ticket extension" \
805 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100806 -s "session successfully restored from cache" \
807 -S "session successfully restored from ticket" \
808 -s "a session has been resumed" \
809 -c "a session has been resumed"
810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200811run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200812 "$P_SRV debug_level=3 tickets=1" \
813 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100814 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100815 -C "client hello, adding session ticket extension" \
816 -S "found session ticket extension" \
817 -S "server hello, adding session ticket extension" \
818 -C "found session_ticket extension" \
819 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100820 -s "session successfully restored from cache" \
821 -S "session successfully restored from ticket" \
822 -s "a session has been resumed" \
823 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200825run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200826 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
827 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100828 0 \
829 -S "session successfully restored from cache" \
830 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100831 -S "a session has been resumed" \
832 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100833
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200834run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200835 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
836 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
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: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200844 "$P_SRV debug_level=3 tickets=0" \
845 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
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: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200853 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
854 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +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: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200862 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
863 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100864 0 \
865 -s "session successfully restored from cache" \
866 -S "session successfully restored from ticket" \
867 -s "a session has been resumed" \
868 -c "a session has been resumed"
869
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200870run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200871 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200872 "( $O_CLI -sess_out $SESSION; \
873 $O_CLI -sess_in $SESSION; \
874 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100875 0 \
876 -s "found session ticket extension" \
877 -S "server hello, adding session ticket extension" \
878 -s "session successfully restored from cache" \
879 -S "session successfully restored from ticket" \
880 -s "a session has been resumed"
881
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200882run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100883 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200884 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100885 0 \
886 -C "found session_ticket extension" \
887 -C "parse new session ticket" \
888 -c "a session has been resumed"
889
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100890# Tests for Max Fragment Length extension
891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200892run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200893 "$P_SRV debug_level=3" \
894 "$P_CLI debug_level=3" \
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 client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200902 "$P_SRV debug_level=3" \
903 "$P_CLI debug_level=3 max_frag_len=4096" \
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"
909
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200910run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200911 "$P_SRV debug_level=3 max_frag_len=4096" \
912 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100913 0 \
914 -C "client hello, adding max_fragment_length extension" \
915 -S "found max fragment length extension" \
916 -S "server hello, max_fragment_length extension" \
917 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100918
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200919requires_gnutls
920run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200921 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200922 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200923 0 \
924 -c "client hello, adding max_fragment_length extension" \
925 -c "found max_fragment_length extension"
926
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100927# Tests for renegotiation
928
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200929run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200930 "$P_SRV debug_level=3 exchanges=2" \
931 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100932 0 \
933 -C "client hello, adding renegotiation extension" \
934 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
935 -S "found renegotiation extension" \
936 -s "server hello, secure renegotiation extension" \
937 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100938 -C "=> renegotiate" \
939 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100940 -S "write hello request"
941
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200942run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200943 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
944 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100945 0 \
946 -c "client hello, adding renegotiation extension" \
947 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
948 -s "found renegotiation extension" \
949 -s "server hello, secure renegotiation extension" \
950 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100951 -c "=> renegotiate" \
952 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100953 -S "write hello request"
954
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200955run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200956 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
957 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100958 0 \
959 -c "client hello, adding renegotiation extension" \
960 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
961 -s "found renegotiation extension" \
962 -s "server hello, secure renegotiation extension" \
963 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100964 -c "=> renegotiate" \
965 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100966 -s "write hello request"
967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200968run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200969 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
970 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100971 0 \
972 -c "client hello, adding renegotiation extension" \
973 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
974 -s "found renegotiation extension" \
975 -s "server hello, secure renegotiation extension" \
976 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100977 -c "=> renegotiate" \
978 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100979 -s "write hello request"
980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200981run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200982 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
983 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100984 1 \
985 -c "client hello, adding renegotiation extension" \
986 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
987 -S "found renegotiation extension" \
988 -s "server hello, secure renegotiation extension" \
989 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100990 -c "=> renegotiate" \
991 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200992 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200993 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200994 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100995
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200996run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200997 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
998 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100999 0 \
1000 -C "client hello, adding renegotiation extension" \
1001 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1002 -S "found renegotiation extension" \
1003 -s "server hello, secure renegotiation extension" \
1004 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001005 -C "=> renegotiate" \
1006 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001007 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001008 -S "SSL - An unexpected message was received from our peer" \
1009 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001011run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001012 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001013 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001014 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001015 0 \
1016 -C "client hello, adding renegotiation extension" \
1017 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1018 -S "found renegotiation extension" \
1019 -s "server hello, secure renegotiation extension" \
1020 -c "found renegotiation extension" \
1021 -C "=> renegotiate" \
1022 -S "=> renegotiate" \
1023 -s "write hello request" \
1024 -S "SSL - An unexpected message was received from our peer" \
1025 -S "failed"
1026
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001027# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001028run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001029 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001030 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001031 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001032 0 \
1033 -C "client hello, adding renegotiation extension" \
1034 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1035 -S "found renegotiation extension" \
1036 -s "server hello, secure renegotiation extension" \
1037 -c "found renegotiation extension" \
1038 -C "=> renegotiate" \
1039 -S "=> renegotiate" \
1040 -s "write hello request" \
1041 -S "SSL - An unexpected message was received from our peer" \
1042 -S "failed"
1043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001044run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001045 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001046 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001047 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001048 0 \
1049 -C "client hello, adding renegotiation extension" \
1050 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1051 -S "found renegotiation extension" \
1052 -s "server hello, secure renegotiation extension" \
1053 -c "found renegotiation extension" \
1054 -C "=> renegotiate" \
1055 -S "=> renegotiate" \
1056 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001057 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001059run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001060 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001061 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001062 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001063 0 \
1064 -c "client hello, adding renegotiation extension" \
1065 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1066 -s "found renegotiation extension" \
1067 -s "server hello, secure renegotiation extension" \
1068 -c "found renegotiation extension" \
1069 -c "=> renegotiate" \
1070 -s "=> renegotiate" \
1071 -s "write hello request" \
1072 -S "SSL - An unexpected message was received from our peer" \
1073 -S "failed"
1074
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001075run_test "Renegotiation: periodic, just below period" \
1076 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1077 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1078 0 \
1079 -C "client hello, adding renegotiation extension" \
1080 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1081 -S "found renegotiation extension" \
1082 -s "server hello, secure renegotiation extension" \
1083 -c "found renegotiation extension" \
1084 -S "record counter limit reached: renegotiate" \
1085 -C "=> renegotiate" \
1086 -S "=> renegotiate" \
1087 -S "write hello request" \
1088 -S "SSL - An unexpected message was received from our peer" \
1089 -S "failed"
1090
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001091# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001092run_test "Renegotiation: periodic, just above period" \
1093 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001094 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001095 0 \
1096 -c "client hello, adding renegotiation extension" \
1097 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1098 -s "found renegotiation extension" \
1099 -s "server hello, secure renegotiation extension" \
1100 -c "found renegotiation extension" \
1101 -s "record counter limit reached: renegotiate" \
1102 -c "=> renegotiate" \
1103 -s "=> renegotiate" \
1104 -s "write hello request" \
1105 -S "SSL - An unexpected message was received from our peer" \
1106 -S "failed"
1107
1108run_test "Renegotiation: periodic, two times period" \
1109 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001110 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001111 0 \
1112 -c "client hello, adding renegotiation extension" \
1113 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1114 -s "found renegotiation extension" \
1115 -s "server hello, secure renegotiation extension" \
1116 -c "found renegotiation extension" \
1117 -s "record counter limit reached: renegotiate" \
1118 -c "=> renegotiate" \
1119 -s "=> renegotiate" \
1120 -s "write hello request" \
1121 -S "SSL - An unexpected message was received from our peer" \
1122 -S "failed"
1123
1124run_test "Renegotiation: periodic, above period, disabled" \
1125 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1126 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1127 0 \
1128 -C "client hello, adding renegotiation extension" \
1129 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1130 -S "found renegotiation extension" \
1131 -s "server hello, secure renegotiation extension" \
1132 -c "found renegotiation extension" \
1133 -S "record counter limit reached: renegotiate" \
1134 -C "=> renegotiate" \
1135 -S "=> renegotiate" \
1136 -S "write hello request" \
1137 -S "SSL - An unexpected message was received from our peer" \
1138 -S "failed"
1139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001140run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001141 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1142 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001143 0 \
1144 -c "client hello, adding renegotiation extension" \
1145 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1146 -s "found renegotiation extension" \
1147 -s "server hello, secure renegotiation extension" \
1148 -c "found renegotiation extension" \
1149 -c "=> renegotiate" \
1150 -s "=> renegotiate" \
1151 -S "write hello request"
1152
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001153run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001154 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1155 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001156 0 \
1157 -c "client hello, adding renegotiation extension" \
1158 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1159 -s "found renegotiation extension" \
1160 -s "server hello, secure renegotiation extension" \
1161 -c "found renegotiation extension" \
1162 -c "=> renegotiate" \
1163 -s "=> renegotiate" \
1164 -s "write hello request"
1165
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001166run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001167 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001168 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001169 0 \
1170 -c "client hello, adding renegotiation extension" \
1171 -c "found renegotiation extension" \
1172 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001173 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001174 -C "error" \
1175 -c "HTTP/1.0 200 [Oo][Kk]"
1176
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001177run_test "Renegotiation: gnutls server strict, client-initiated" \
1178 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001179 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001180 0 \
1181 -c "client hello, adding renegotiation extension" \
1182 -c "found renegotiation extension" \
1183 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001184 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001185 -C "error" \
1186 -c "HTTP/1.0 200 [Oo][Kk]"
1187
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001188run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1189 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1190 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1191 1 \
1192 -c "client hello, adding renegotiation extension" \
1193 -C "found renegotiation extension" \
1194 -c "=> renegotiate" \
1195 -c "ssl_handshake() returned" \
1196 -c "error" \
1197 -C "HTTP/1.0 200 [Oo][Kk]"
1198
1199run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1200 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1201 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1202 allow_legacy=0" \
1203 1 \
1204 -c "client hello, adding renegotiation extension" \
1205 -C "found renegotiation extension" \
1206 -c "=> renegotiate" \
1207 -c "ssl_handshake() returned" \
1208 -c "error" \
1209 -C "HTTP/1.0 200 [Oo][Kk]"
1210
1211run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1212 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1213 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1214 allow_legacy=1" \
1215 0 \
1216 -c "client hello, adding renegotiation extension" \
1217 -C "found renegotiation extension" \
1218 -c "=> renegotiate" \
1219 -C "ssl_hanshake() returned" \
1220 -C "error" \
1221 -c "HTTP/1.0 200 [Oo][Kk]"
1222
1223# Test for the "secure renegotation" extension only (no actual renegotiation)
1224
1225run_test "Renego ext: gnutls server strict, client default" \
1226 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1227 "$P_CLI debug_level=3" \
1228 0 \
1229 -c "found renegotiation extension" \
1230 -C "error" \
1231 -c "HTTP/1.0 200 [Oo][Kk]"
1232
1233run_test "Renego ext: gnutls server unsafe, client default" \
1234 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1235 "$P_CLI debug_level=3" \
1236 0 \
1237 -C "found renegotiation extension" \
1238 -C "error" \
1239 -c "HTTP/1.0 200 [Oo][Kk]"
1240
1241run_test "Renego ext: gnutls server unsafe, client break legacy" \
1242 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1243 "$P_CLI debug_level=3 allow_legacy=-1" \
1244 1 \
1245 -C "found renegotiation extension" \
1246 -c "error" \
1247 -C "HTTP/1.0 200 [Oo][Kk]"
1248
1249run_test "Renego ext: gnutls client strict, server default" \
1250 "$P_SRV debug_level=3" \
1251 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1252 0 \
1253 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1254 -s "server hello, secure renegotiation extension"
1255
1256run_test "Renego ext: gnutls client unsafe, server default" \
1257 "$P_SRV debug_level=3" \
1258 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1259 0 \
1260 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1261 -S "server hello, secure renegotiation extension"
1262
1263run_test "Renego ext: gnutls client unsafe, server break legacy" \
1264 "$P_SRV debug_level=3 allow_legacy=-1" \
1265 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1266 1 \
1267 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1268 -S "server hello, secure renegotiation extension"
1269
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001270# Tests for auth_mode
1271
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001272run_test "Authentication: server badcert, client required" \
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=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001276 1 \
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 optional" \
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=optional" \
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: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001293 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001294 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001295 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001296 0 \
1297 -C "x509_verify_cert() returned" \
1298 -C "! self-signed or not signed by a trusted CA" \
1299 -C "! ssl_handshake returned" \
1300 -C "X509 - Certificate verification failed"
1301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001302run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001303 "$P_SRV debug_level=3 auth_mode=required" \
1304 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001305 key_file=data_files/server5.key" \
1306 1 \
1307 -S "skip write certificate request" \
1308 -C "skip parse certificate request" \
1309 -c "got a certificate request" \
1310 -C "skip write certificate" \
1311 -C "skip write certificate verify" \
1312 -S "skip parse certificate verify" \
1313 -s "x509_verify_cert() returned" \
1314 -S "! self-signed or not signed by a trusted CA" \
1315 -s "! ssl_handshake returned" \
1316 -c "! ssl_handshake returned" \
1317 -s "X509 - Certificate verification failed"
1318
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001319run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001320 "$P_SRV debug_level=3 auth_mode=optional" \
1321 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001322 key_file=data_files/server5.key" \
1323 0 \
1324 -S "skip write certificate request" \
1325 -C "skip parse certificate request" \
1326 -c "got a certificate request" \
1327 -C "skip write certificate" \
1328 -C "skip write certificate verify" \
1329 -S "skip parse certificate verify" \
1330 -s "x509_verify_cert() returned" \
1331 -s "! self-signed or not signed by a trusted CA" \
1332 -S "! ssl_handshake returned" \
1333 -C "! ssl_handshake returned" \
1334 -S "X509 - Certificate verification failed"
1335
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001336run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001337 "$P_SRV debug_level=3 auth_mode=none" \
1338 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001339 key_file=data_files/server5.key" \
1340 0 \
1341 -s "skip write certificate request" \
1342 -C "skip parse certificate request" \
1343 -c "got no certificate request" \
1344 -c "skip write certificate" \
1345 -c "skip write certificate verify" \
1346 -s "skip parse certificate verify" \
1347 -S "x509_verify_cert() returned" \
1348 -S "! self-signed or not signed by a trusted CA" \
1349 -S "! ssl_handshake returned" \
1350 -C "! ssl_handshake returned" \
1351 -S "X509 - Certificate verification failed"
1352
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001353run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001354 "$P_SRV debug_level=3 auth_mode=optional" \
1355 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001356 0 \
1357 -S "skip write certificate request" \
1358 -C "skip parse certificate request" \
1359 -c "got a certificate request" \
1360 -C "skip write certificate$" \
1361 -C "got no certificate to send" \
1362 -S "SSLv3 client has no certificate" \
1363 -c "skip write certificate verify" \
1364 -s "skip parse certificate verify" \
1365 -s "! no client certificate sent" \
1366 -S "! ssl_handshake returned" \
1367 -C "! ssl_handshake returned" \
1368 -S "X509 - Certificate verification failed"
1369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001370run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001371 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001372 "$O_CLI" \
1373 0 \
1374 -S "skip write certificate request" \
1375 -s "skip parse certificate verify" \
1376 -s "! no client certificate sent" \
1377 -S "! ssl_handshake returned" \
1378 -S "X509 - Certificate verification failed"
1379
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001380run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001381 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001382 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001383 0 \
1384 -C "skip parse certificate request" \
1385 -c "got a certificate request" \
1386 -C "skip write certificate$" \
1387 -c "skip write certificate verify" \
1388 -C "! ssl_handshake returned"
1389
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001390run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001391 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1392 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001393 0 \
1394 -S "skip write certificate request" \
1395 -C "skip parse certificate request" \
1396 -c "got a certificate request" \
1397 -C "skip write certificate$" \
1398 -c "skip write certificate verify" \
1399 -c "got no certificate to send" \
1400 -s "SSLv3 client has no certificate" \
1401 -s "skip parse certificate verify" \
1402 -s "! no client certificate sent" \
1403 -S "! ssl_handshake returned" \
1404 -C "! ssl_handshake returned" \
1405 -S "X509 - Certificate verification failed"
1406
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001407# tests for SNI
1408
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001409run_test "SNI: no SNI callback" \
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é-Gonnardc1da6642014-02-25 14:18:30 +01001412 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001413 server_name=localhost" \
1414 0 \
1415 -S "parse ServerName extension" \
1416 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1417 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1418
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001419run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001420 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001421 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001422 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 +01001423 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001424 server_name=localhost" \
1425 0 \
1426 -s "parse ServerName extension" \
1427 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1428 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001430run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001431 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001432 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001433 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 +01001434 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001435 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001436 0 \
1437 -s "parse ServerName extension" \
1438 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001439 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001440
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001441run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001442 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001443 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001444 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 +01001445 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001446 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001447 1 \
1448 -s "parse ServerName extension" \
1449 -s "ssl_sni_wrapper() returned" \
1450 -s "ssl_handshake returned" \
1451 -c "ssl_handshake returned" \
1452 -c "SSL - A fatal alert message was received from our peer"
1453
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001454# Tests for non-blocking I/O: exercise a variety of handshake flows
1455
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001456run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001457 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1458 "$P_CLI nbio=2 tickets=0" \
1459 0 \
1460 -S "ssl_handshake returned" \
1461 -C "ssl_handshake returned" \
1462 -c "Read from server: .* bytes read"
1463
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001464run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001465 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1466 "$P_CLI nbio=2 tickets=0" \
1467 0 \
1468 -S "ssl_handshake returned" \
1469 -C "ssl_handshake returned" \
1470 -c "Read from server: .* bytes read"
1471
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001472run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001473 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1474 "$P_CLI nbio=2 tickets=1" \
1475 0 \
1476 -S "ssl_handshake returned" \
1477 -C "ssl_handshake returned" \
1478 -c "Read from server: .* bytes read"
1479
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001480run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001481 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1482 "$P_CLI nbio=2 tickets=1" \
1483 0 \
1484 -S "ssl_handshake returned" \
1485 -C "ssl_handshake returned" \
1486 -c "Read from server: .* bytes read"
1487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001488run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001489 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1490 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1491 0 \
1492 -S "ssl_handshake returned" \
1493 -C "ssl_handshake returned" \
1494 -c "Read from server: .* bytes read"
1495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001496run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001497 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1498 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1499 0 \
1500 -S "ssl_handshake returned" \
1501 -C "ssl_handshake returned" \
1502 -c "Read from server: .* bytes read"
1503
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001504run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001505 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1506 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1507 0 \
1508 -S "ssl_handshake returned" \
1509 -C "ssl_handshake returned" \
1510 -c "Read from server: .* bytes read"
1511
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001512# Tests for version negotiation
1513
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001514run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001515 "$P_SRV" \
1516 "$P_CLI" \
1517 0 \
1518 -S "ssl_handshake returned" \
1519 -C "ssl_handshake returned" \
1520 -s "Protocol is TLSv1.2" \
1521 -c "Protocol is TLSv1.2"
1522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001523run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001524 "$P_SRV" \
1525 "$P_CLI max_version=tls1_1" \
1526 0 \
1527 -S "ssl_handshake returned" \
1528 -C "ssl_handshake returned" \
1529 -s "Protocol is TLSv1.1" \
1530 -c "Protocol is TLSv1.1"
1531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001532run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001533 "$P_SRV max_version=tls1_1" \
1534 "$P_CLI" \
1535 0 \
1536 -S "ssl_handshake returned" \
1537 -C "ssl_handshake returned" \
1538 -s "Protocol is TLSv1.1" \
1539 -c "Protocol is TLSv1.1"
1540
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001541run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001542 "$P_SRV max_version=tls1_1" \
1543 "$P_CLI max_version=tls1_1" \
1544 0 \
1545 -S "ssl_handshake returned" \
1546 -C "ssl_handshake returned" \
1547 -s "Protocol is TLSv1.1" \
1548 -c "Protocol is TLSv1.1"
1549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001550run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001551 "$P_SRV min_version=tls1_1" \
1552 "$P_CLI max_version=tls1_1" \
1553 0 \
1554 -S "ssl_handshake returned" \
1555 -C "ssl_handshake returned" \
1556 -s "Protocol is TLSv1.1" \
1557 -c "Protocol is TLSv1.1"
1558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001559run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001560 "$P_SRV max_version=tls1_1" \
1561 "$P_CLI min_version=tls1_1" \
1562 0 \
1563 -S "ssl_handshake returned" \
1564 -C "ssl_handshake returned" \
1565 -s "Protocol is TLSv1.1" \
1566 -c "Protocol is TLSv1.1"
1567
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001568run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001569 "$P_SRV max_version=tls1_1" \
1570 "$P_CLI min_version=tls1_2" \
1571 1 \
1572 -s "ssl_handshake returned" \
1573 -c "ssl_handshake returned" \
1574 -c "SSL - Handshake protocol not within min/max boundaries"
1575
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001576run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001577 "$P_SRV min_version=tls1_2" \
1578 "$P_CLI max_version=tls1_1" \
1579 1 \
1580 -s "ssl_handshake returned" \
1581 -c "ssl_handshake returned" \
1582 -s "SSL - Handshake protocol not within min/max boundaries"
1583
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001584# Tests for ALPN extension
1585
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001586if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1587
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001588run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001589 "$P_SRV debug_level=3" \
1590 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001591 0 \
1592 -C "client hello, adding alpn extension" \
1593 -S "found alpn extension" \
1594 -C "got an alert message, type: \\[2:120]" \
1595 -S "server hello, adding alpn extension" \
1596 -C "found alpn extension " \
1597 -C "Application Layer Protocol is" \
1598 -S "Application Layer Protocol is"
1599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001600run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001601 "$P_SRV debug_level=3" \
1602 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001603 0 \
1604 -c "client hello, adding alpn extension" \
1605 -s "found alpn extension" \
1606 -C "got an alert message, type: \\[2:120]" \
1607 -S "server hello, adding alpn extension" \
1608 -C "found alpn extension " \
1609 -c "Application Layer Protocol is (none)" \
1610 -S "Application Layer Protocol is"
1611
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001612run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001613 "$P_SRV debug_level=3 alpn=abc,1234" \
1614 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001615 0 \
1616 -C "client hello, adding alpn extension" \
1617 -S "found alpn extension" \
1618 -C "got an alert message, type: \\[2:120]" \
1619 -S "server hello, adding alpn extension" \
1620 -C "found alpn extension " \
1621 -C "Application Layer Protocol is" \
1622 -s "Application Layer Protocol is (none)"
1623
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001624run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001625 "$P_SRV debug_level=3 alpn=abc,1234" \
1626 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001627 0 \
1628 -c "client hello, adding alpn extension" \
1629 -s "found alpn extension" \
1630 -C "got an alert message, type: \\[2:120]" \
1631 -s "server hello, adding alpn extension" \
1632 -c "found alpn extension" \
1633 -c "Application Layer Protocol is abc" \
1634 -s "Application Layer Protocol is abc"
1635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001636run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001637 "$P_SRV debug_level=3 alpn=abc,1234" \
1638 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001639 0 \
1640 -c "client hello, adding alpn extension" \
1641 -s "found alpn extension" \
1642 -C "got an alert message, type: \\[2:120]" \
1643 -s "server hello, adding alpn extension" \
1644 -c "found alpn extension" \
1645 -c "Application Layer Protocol is abc" \
1646 -s "Application Layer Protocol is abc"
1647
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001648run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001649 "$P_SRV debug_level=3 alpn=abc,1234" \
1650 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001651 0 \
1652 -c "client hello, adding alpn extension" \
1653 -s "found alpn extension" \
1654 -C "got an alert message, type: \\[2:120]" \
1655 -s "server hello, adding alpn extension" \
1656 -c "found alpn extension" \
1657 -c "Application Layer Protocol is 1234" \
1658 -s "Application Layer Protocol is 1234"
1659
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001660run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001661 "$P_SRV debug_level=3 alpn=abc,123" \
1662 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001663 1 \
1664 -c "client hello, adding alpn extension" \
1665 -s "found alpn extension" \
1666 -c "got an alert message, type: \\[2:120]" \
1667 -S "server hello, adding alpn extension" \
1668 -C "found alpn extension" \
1669 -C "Application Layer Protocol is 1234" \
1670 -S "Application Layer Protocol is 1234"
1671
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001672fi
1673
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001674# Tests for keyUsage in leaf certificates, part 1:
1675# server-side certificate/suite selection
1676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001677run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001678 "$P_SRV key_file=data_files/server2.key \
1679 crt_file=data_files/server2.ku-ds.crt" \
1680 "$P_CLI" \
1681 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001682 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001683
1684
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001685run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001686 "$P_SRV key_file=data_files/server2.key \
1687 crt_file=data_files/server2.ku-ke.crt" \
1688 "$P_CLI" \
1689 0 \
1690 -c "Ciphersuite is TLS-RSA-WITH-"
1691
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001692run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001693 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001694 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001695 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001696 1 \
1697 -C "Ciphersuite is "
1698
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001699run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001700 "$P_SRV key_file=data_files/server5.key \
1701 crt_file=data_files/server5.ku-ds.crt" \
1702 "$P_CLI" \
1703 0 \
1704 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1705
1706
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001707run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001708 "$P_SRV key_file=data_files/server5.key \
1709 crt_file=data_files/server5.ku-ka.crt" \
1710 "$P_CLI" \
1711 0 \
1712 -c "Ciphersuite is TLS-ECDH-"
1713
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001714run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001715 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001716 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001717 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001718 1 \
1719 -C "Ciphersuite is "
1720
1721# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001722# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001723
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001724run_test "keyUsage cli: DigitalSignature+KeyEncipherment, 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-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: DigitalSignature+KeyEncipherment, DHE-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-ds_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-DHE-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, RSA: OK" \
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-RSA-WITH-AES-128-CBC-SHA" \
1749 0 \
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: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001755 "$O_SRV -key data_files/server2.key \
1756 -cert data_files/server2.ku-ke.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 1 \
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, DHE-RSA: OK" \
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-DHE-RSA-WITH-AES-128-CBC-SHA" \
1769 0 \
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é-Gonnard8e03c712014-08-30 21:42:40 +02001774run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001775 "$O_SRV -key data_files/server2.key \
1776 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001777 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001778 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1779 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001780 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001781 -c "Processing of the Certificate handshake message failed" \
1782 -C "Ciphersuite is TLS-"
1783
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001784# Tests for keyUsage in leaf certificates, part 3:
1785# server-side checking of client cert
1786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001787run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001788 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001789 "$O_CLI -key data_files/server2.key \
1790 -cert data_files/server2.ku-ds.crt" \
1791 0 \
1792 -S "bad certificate (usage extensions)" \
1793 -S "Processing of the Certificate handshake message failed"
1794
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001795run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001796 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001797 "$O_CLI -key data_files/server2.key \
1798 -cert data_files/server2.ku-ke.crt" \
1799 0 \
1800 -s "bad certificate (usage extensions)" \
1801 -S "Processing of the Certificate handshake message failed"
1802
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001803run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001804 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001805 "$O_CLI -key data_files/server2.key \
1806 -cert data_files/server2.ku-ke.crt" \
1807 1 \
1808 -s "bad certificate (usage extensions)" \
1809 -s "Processing of the Certificate handshake message failed"
1810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001811run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001812 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001813 "$O_CLI -key data_files/server5.key \
1814 -cert data_files/server5.ku-ds.crt" \
1815 0 \
1816 -S "bad certificate (usage extensions)" \
1817 -S "Processing of the Certificate handshake message failed"
1818
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001819run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001820 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001821 "$O_CLI -key data_files/server5.key \
1822 -cert data_files/server5.ku-ka.crt" \
1823 0 \
1824 -s "bad certificate (usage extensions)" \
1825 -S "Processing of the Certificate handshake message failed"
1826
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001827# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1828
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001829run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001830 "$P_SRV key_file=data_files/server5.key \
1831 crt_file=data_files/server5.eku-srv.crt" \
1832 "$P_CLI" \
1833 0
1834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001835run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001836 "$P_SRV key_file=data_files/server5.key \
1837 crt_file=data_files/server5.eku-srv.crt" \
1838 "$P_CLI" \
1839 0
1840
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001841run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001842 "$P_SRV key_file=data_files/server5.key \
1843 crt_file=data_files/server5.eku-cs_any.crt" \
1844 "$P_CLI" \
1845 0
1846
1847# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001848run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001849 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1850 crt_file=data_files/server5.eku-cli.crt" \
1851 "$P_CLI psk=badbad" \
1852 1
1853
1854# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1855
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001856run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001857 "$O_SRV -key data_files/server5.key \
1858 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001859 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001860 0 \
1861 -C "bad certificate (usage extensions)" \
1862 -C "Processing of the Certificate handshake message failed" \
1863 -c "Ciphersuite is TLS-"
1864
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001865run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001866 "$O_SRV -key data_files/server5.key \
1867 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001868 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001869 0 \
1870 -C "bad certificate (usage extensions)" \
1871 -C "Processing of the Certificate handshake message failed" \
1872 -c "Ciphersuite is TLS-"
1873
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001874run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001875 "$O_SRV -key data_files/server5.key \
1876 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001877 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001878 0 \
1879 -C "bad certificate (usage extensions)" \
1880 -C "Processing of the Certificate handshake message failed" \
1881 -c "Ciphersuite is TLS-"
1882
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001883run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001884 "$O_SRV -key data_files/server5.key \
1885 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001886 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001887 1 \
1888 -c "bad certificate (usage extensions)" \
1889 -c "Processing of the Certificate handshake message failed" \
1890 -C "Ciphersuite is TLS-"
1891
1892# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1893
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001894run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001895 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001896 "$O_CLI -key data_files/server5.key \
1897 -cert data_files/server5.eku-cli.crt" \
1898 0 \
1899 -S "bad certificate (usage extensions)" \
1900 -S "Processing of the Certificate handshake message failed"
1901
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001902run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001903 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001904 "$O_CLI -key data_files/server5.key \
1905 -cert data_files/server5.eku-srv_cli.crt" \
1906 0 \
1907 -S "bad certificate (usage extensions)" \
1908 -S "Processing of the Certificate handshake message failed"
1909
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001910run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001911 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001912 "$O_CLI -key data_files/server5.key \
1913 -cert data_files/server5.eku-cs_any.crt" \
1914 0 \
1915 -S "bad certificate (usage extensions)" \
1916 -S "Processing of the Certificate handshake message failed"
1917
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001918run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001919 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001920 "$O_CLI -key data_files/server5.key \
1921 -cert data_files/server5.eku-cs.crt" \
1922 0 \
1923 -s "bad certificate (usage extensions)" \
1924 -S "Processing of the Certificate handshake message failed"
1925
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001926run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001927 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001928 "$O_CLI -key data_files/server5.key \
1929 -cert data_files/server5.eku-cs.crt" \
1930 1 \
1931 -s "bad certificate (usage extensions)" \
1932 -s "Processing of the Certificate handshake message failed"
1933
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001934# Tests for DHM parameters loading
1935
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001936run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001937 "$P_SRV" \
1938 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1939 debug_level=3" \
1940 0 \
1941 -c "value of 'DHM: P ' (2048 bits)" \
1942 -c "value of 'DHM: G ' (2048 bits)"
1943
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001944run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001945 "$P_SRV dhm_file=data_files/dhparams.pem" \
1946 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1947 debug_level=3" \
1948 0 \
1949 -c "value of 'DHM: P ' (1024 bits)" \
1950 -c "value of 'DHM: G ' (2 bits)"
1951
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001952# Tests for PSK callback
1953
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001954run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001955 "$P_SRV psk=abc123 psk_identity=foo" \
1956 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1957 psk_identity=foo psk=abc123" \
1958 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001959 -S "SSL - The server has no ciphersuites in common" \
1960 -S "SSL - Unknown identity received" \
1961 -S "SSL - Verification of the message MAC failed"
1962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001963run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001964 "$P_SRV" \
1965 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1966 psk_identity=foo psk=abc123" \
1967 1 \
1968 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001969 -S "SSL - Unknown identity received" \
1970 -S "SSL - Verification of the message MAC failed"
1971
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001972run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001973 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1974 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1975 psk_identity=foo psk=abc123" \
1976 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001977 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001978 -s "SSL - Unknown identity received" \
1979 -S "SSL - Verification of the message MAC failed"
1980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001981run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001982 "$P_SRV psk_list=abc,dead,def,beef" \
1983 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1984 psk_identity=abc psk=dead" \
1985 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001986 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001987 -S "SSL - Unknown identity received" \
1988 -S "SSL - Verification of the message MAC failed"
1989
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001990run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001991 "$P_SRV psk_list=abc,dead,def,beef" \
1992 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1993 psk_identity=def psk=beef" \
1994 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001995 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001996 -S "SSL - Unknown identity received" \
1997 -S "SSL - Verification of the message MAC failed"
1998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001999run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002000 "$P_SRV psk_list=abc,dead,def,beef" \
2001 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2002 psk_identity=ghi psk=beef" \
2003 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002004 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002005 -s "SSL - Unknown identity received" \
2006 -S "SSL - Verification of the message MAC failed"
2007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002008run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002009 "$P_SRV psk_list=abc,dead,def,beef" \
2010 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2011 psk_identity=abc psk=beef" \
2012 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002013 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002014 -S "SSL - Unknown identity received" \
2015 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002016
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002017# Tests for ciphersuites per version
2018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002019run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002020 "$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" \
2021 "$P_CLI force_version=ssl3" \
2022 0 \
2023 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2024
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002025run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002026 "$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" \
2027 "$P_CLI force_version=tls1" \
2028 0 \
2029 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002031run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002032 "$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" \
2033 "$P_CLI force_version=tls1_1" \
2034 0 \
2035 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2036
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002037run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002038 "$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" \
2039 "$P_CLI force_version=tls1_2" \
2040 0 \
2041 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2042
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002043# Tests for ssl_get_bytes_avail()
2044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002045run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002046 "$P_SRV" \
2047 "$P_CLI request_size=100" \
2048 0 \
2049 -s "Read from client: 100 bytes read$"
2050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002051run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002052 "$P_SRV" \
2053 "$P_CLI request_size=500" \
2054 0 \
2055 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002056
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002057# Tests for small packets
2058
2059run_test "Small packet SSLv3 BlockCipher" \
2060 "$P_SRV" \
2061 "$P_CLI request_size=1 force_version=ssl3 \
2062 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2063 0 \
2064 -s "Read from client: 1 bytes read"
2065
2066run_test "Small packet SSLv3 StreamCipher" \
2067 "$P_SRV" \
2068 "$P_CLI request_size=1 force_version=ssl3 \
2069 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2070 0 \
2071 -s "Read from client: 1 bytes read"
2072
2073run_test "Small packet TLS 1.0 BlockCipher" \
2074 "$P_SRV" \
2075 "$P_CLI request_size=1 force_version=tls1 \
2076 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2077 0 \
2078 -s "Read from client: 1 bytes read"
2079
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002080run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2081 "$P_SRV" \
2082 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2083 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2084 0 \
2085 -s "Read from client: 1 bytes read"
2086
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002087run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2088 "$P_SRV" \
2089 "$P_CLI request_size=1 force_version=tls1 \
2090 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2091 trunc_hmac=1" \
2092 0 \
2093 -s "Read from client: 1 bytes read"
2094
2095run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
2096 "$P_SRV" \
2097 "$P_CLI request_size=1 force_version=tls1 \
2098 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2099 trunc_hmac=1" \
2100 0 \
2101 -s "Read from client: 1 bytes read"
2102
2103run_test "Small packet TLS 1.1 BlockCipher" \
2104 "$P_SRV" \
2105 "$P_CLI request_size=1 force_version=tls1_1 \
2106 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2107 0 \
2108 -s "Read from client: 1 bytes read"
2109
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002110run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2111 "$P_SRV" \
2112 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2113 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2114 0 \
2115 -s "Read from client: 1 bytes read"
2116
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002117run_test "Small packet TLS 1.1 StreamCipher" \
2118 "$P_SRV" \
2119 "$P_CLI request_size=1 force_version=tls1_1 \
2120 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2121 0 \
2122 -s "Read from client: 1 bytes read"
2123
2124run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2125 "$P_SRV" \
2126 "$P_CLI request_size=1 force_version=tls1_1 \
2127 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2128 trunc_hmac=1" \
2129 0 \
2130 -s "Read from client: 1 bytes read"
2131
2132run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
2133 "$P_SRV" \
2134 "$P_CLI request_size=1 force_version=tls1_1 \
2135 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2136 trunc_hmac=1" \
2137 0 \
2138 -s "Read from client: 1 bytes read"
2139
2140run_test "Small packet TLS 1.2 BlockCipher" \
2141 "$P_SRV" \
2142 "$P_CLI request_size=1 force_version=tls1_2 \
2143 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2144 0 \
2145 -s "Read from client: 1 bytes read"
2146
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002147run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2148 "$P_SRV" \
2149 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2150 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2151 0 \
2152 -s "Read from client: 1 bytes read"
2153
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002154run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2155 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002156 "$P_CLI request_size=1 force_version=tls1_2 \
2157 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002158 0 \
2159 -s "Read from client: 1 bytes read"
2160
2161run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2162 "$P_SRV" \
2163 "$P_CLI request_size=1 force_version=tls1_2 \
2164 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2165 trunc_hmac=1" \
2166 0 \
2167 -s "Read from client: 1 bytes read"
2168
2169run_test "Small packet TLS 1.2 StreamCipher" \
2170 "$P_SRV" \
2171 "$P_CLI request_size=1 force_version=tls1_2 \
2172 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2173 0 \
2174 -s "Read from client: 1 bytes read"
2175
2176run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
2177 "$P_SRV" \
2178 "$P_CLI request_size=1 force_version=tls1_2 \
2179 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2180 trunc_hmac=1" \
2181 0 \
2182 -s "Read from client: 1 bytes read"
2183
2184run_test "Small packet TLS 1.2 AEAD" \
2185 "$P_SRV" \
2186 "$P_CLI request_size=1 force_version=tls1_2 \
2187 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2188 0 \
2189 -s "Read from client: 1 bytes read"
2190
2191run_test "Small packet TLS 1.2 AEAD shorter tag" \
2192 "$P_SRV" \
2193 "$P_CLI request_size=1 force_version=tls1_2 \
2194 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2195 0 \
2196 -s "Read from client: 1 bytes read"
2197
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002198# Test for large packets
2199
2200run_test "Large packet SSLv3 BlockCipher" \
2201 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002202 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002203 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2204 0 \
2205 -s "Read from client: 16384 bytes read"
2206
2207run_test "Large packet SSLv3 StreamCipher" \
2208 "$P_SRV" \
2209 "$P_CLI request_size=16384 force_version=ssl3 \
2210 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2211 0 \
2212 -s "Read from client: 16384 bytes read"
2213
2214run_test "Large packet TLS 1.0 BlockCipher" \
2215 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002216 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002217 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2218 0 \
2219 -s "Read from client: 16384 bytes read"
2220
2221run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2222 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002223 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002224 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2225 trunc_hmac=1" \
2226 0 \
2227 -s "Read from client: 16384 bytes read"
2228
2229run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
2230 "$P_SRV" \
2231 "$P_CLI request_size=16384 force_version=tls1 \
2232 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2233 trunc_hmac=1" \
2234 0 \
2235 -s "Read from client: 16384 bytes read"
2236
2237run_test "Large packet TLS 1.1 BlockCipher" \
2238 "$P_SRV" \
2239 "$P_CLI request_size=16384 force_version=tls1_1 \
2240 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2241 0 \
2242 -s "Read from client: 16384 bytes read"
2243
2244run_test "Large packet TLS 1.1 StreamCipher" \
2245 "$P_SRV" \
2246 "$P_CLI request_size=16384 force_version=tls1_1 \
2247 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2248 0 \
2249 -s "Read from client: 16384 bytes read"
2250
2251run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2252 "$P_SRV" \
2253 "$P_CLI request_size=16384 force_version=tls1_1 \
2254 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2255 trunc_hmac=1" \
2256 0 \
2257 -s "Read from client: 16384 bytes read"
2258
2259run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
2260 "$P_SRV" \
2261 "$P_CLI request_size=16384 force_version=tls1_1 \
2262 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2263 trunc_hmac=1" \
2264 0 \
2265 -s "Read from client: 16384 bytes read"
2266
2267run_test "Large packet TLS 1.2 BlockCipher" \
2268 "$P_SRV" \
2269 "$P_CLI request_size=16384 force_version=tls1_2 \
2270 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2271 0 \
2272 -s "Read from client: 16384 bytes read"
2273
2274run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2275 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002276 "$P_CLI request_size=16384 force_version=tls1_2 \
2277 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002278 0 \
2279 -s "Read from client: 16384 bytes read"
2280
2281run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2282 "$P_SRV" \
2283 "$P_CLI request_size=16384 force_version=tls1_2 \
2284 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2285 trunc_hmac=1" \
2286 0 \
2287 -s "Read from client: 16384 bytes read"
2288
2289run_test "Large packet TLS 1.2 StreamCipher" \
2290 "$P_SRV" \
2291 "$P_CLI request_size=16384 force_version=tls1_2 \
2292 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2293 0 \
2294 -s "Read from client: 16384 bytes read"
2295
2296run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
2297 "$P_SRV" \
2298 "$P_CLI request_size=16384 force_version=tls1_2 \
2299 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2300 trunc_hmac=1" \
2301 0 \
2302 -s "Read from client: 16384 bytes read"
2303
2304run_test "Large packet TLS 1.2 AEAD" \
2305 "$P_SRV" \
2306 "$P_CLI request_size=16384 force_version=tls1_2 \
2307 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2308 0 \
2309 -s "Read from client: 16384 bytes read"
2310
2311run_test "Large packet TLS 1.2 AEAD shorter tag" \
2312 "$P_SRV" \
2313 "$P_CLI request_size=16384 force_version=tls1_2 \
2314 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2315 0 \
2316 -s "Read from client: 16384 bytes read"
2317
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002318# Final report
2319
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002320echo "------------------------------------------------------------------------"
2321
2322if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002323 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002324else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002325 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002326fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002327PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002328echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002329
2330exit $FAILS