blob: ebe1cec21a28542b6c800daa26a0183260dc201f [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é-Gonnarddc370e42015-01-22 10:24:59 +0000375PORT="1$( printf $PORT | tail -c 4 )"
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é-Gonnardbd47a582015-01-12 13:43:29 +0100411# Tests for rc4 option
412
413run_test "RC4: server disabled, client enabled" \
414 "$P_SRV" \
415 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
416 1 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100417 -s "SSL - None of the common ciphersuites is usable"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100418
419run_test "RC4: server enabled, client disabled" \
420 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
421 "$P_CLI" \
422 1 \
423 -s "SSL - The server has no ciphersuites in common"
424
425run_test "RC4: both enabled" \
426 "$P_SRV arc4=1" \
427 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
428 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100429 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100430 -S "SSL - The server has no ciphersuites in common"
431
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100432# Test for SSLv2 ClientHello
433
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200434requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200435run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100436 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100437 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100438 0 \
439 -S "parse client hello v2" \
440 -S "ssl_handshake returned"
441
442# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200443requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200444run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200445 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100446 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100447 0 \
448 -s "parse client hello v2" \
449 -S "ssl_handshake returned"
450
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100451# Tests for Truncated HMAC extension
452
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100453run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200454 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100455 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100456 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100457 -s "dumping 'computed mac' (20 bytes)" \
458 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100459
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100460run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200461 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100462 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
463 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100464 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100465 -s "dumping 'computed mac' (20 bytes)" \
466 -S "dumping 'computed mac' (10 bytes)"
467
468run_test "Truncated HMAC: client enabled, server default" \
469 "$P_SRV debug_level=4" \
470 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
471 trunc_hmac=1" \
472 0 \
473 -S "dumping 'computed mac' (20 bytes)" \
474 -s "dumping 'computed mac' (10 bytes)"
475
476run_test "Truncated HMAC: client enabled, server disabled" \
477 "$P_SRV debug_level=4 trunc_hmac=0" \
478 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
479 trunc_hmac=1" \
480 0 \
481 -s "dumping 'computed mac' (20 bytes)" \
482 -S "dumping 'computed mac' (10 bytes)"
483
484run_test "Truncated HMAC: client enabled, server enabled" \
485 "$P_SRV debug_level=4 trunc_hmac=1" \
486 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
487 trunc_hmac=1" \
488 0 \
489 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100490 -s "dumping 'computed mac' (10 bytes)"
491
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100492# Tests for Encrypt-then-MAC extension
493
494run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100495 "$P_SRV debug_level=3 \
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" \
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 enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100507 "$P_SRV debug_level=3 etm=0 \
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 etm=1" \
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
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100518run_test "Encrypt then MAC: client enabled, aead cipher" \
519 "$P_SRV debug_level=3 etm=1 \
520 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
521 "$P_CLI debug_level=3 etm=1" \
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
530run_test "Encrypt then MAC: client enabled, stream cipher" \
531 "$P_SRV debug_level=3 etm=1 \
532 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100533 "$P_CLI debug_level=3 etm=1 arc4=1" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100534 0 \
535 -c "client hello, adding encrypt_then_mac extension" \
536 -s "found encrypt then mac extension" \
537 -S "server hello, adding encrypt then mac extension" \
538 -C "found encrypt_then_mac extension" \
539 -C "using encrypt then mac" \
540 -S "using encrypt then mac"
541
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100542run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100543 "$P_SRV debug_level=3 etm=1 \
544 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100545 "$P_CLI debug_level=3 etm=0" \
546 0 \
547 -C "client hello, adding encrypt_then_mac extension" \
548 -S "found encrypt then mac extension" \
549 -S "server hello, adding encrypt then mac extension" \
550 -C "found encrypt_then_mac extension" \
551 -C "using encrypt then mac" \
552 -S "using encrypt then mac"
553
554run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100555 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100556 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100557 "$P_CLI debug_level=3 force_version=ssl3" \
558 0 \
559 -C "client hello, adding encrypt_then_mac extension" \
560 -S "found encrypt then mac extension" \
561 -S "server hello, adding encrypt then mac extension" \
562 -C "found encrypt_then_mac extension" \
563 -C "using encrypt then mac" \
564 -S "using encrypt then mac"
565
566run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100567 "$P_SRV debug_level=3 force_version=ssl3 \
568 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100569 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100570 0 \
571 -c "client hello, adding encrypt_then_mac extension" \
572 -s "found encrypt then mac extension" \
573 -S "server hello, adding encrypt then mac extension" \
574 -C "found encrypt_then_mac extension" \
575 -C "using encrypt then mac" \
576 -S "using encrypt then mac"
577
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200578# Tests for Extended Master Secret extension
579
580run_test "Extended Master Secret: default" \
581 "$P_SRV debug_level=3" \
582 "$P_CLI debug_level=3" \
583 0 \
584 -c "client hello, adding extended_master_secret extension" \
585 -s "found extended master secret extension" \
586 -s "server hello, adding extended master secret extension" \
587 -c "found extended_master_secret extension" \
588 -c "using extended master secret" \
589 -s "using extended master secret"
590
591run_test "Extended Master Secret: client enabled, server disabled" \
592 "$P_SRV debug_level=3 extended_ms=0" \
593 "$P_CLI debug_level=3 extended_ms=1" \
594 0 \
595 -c "client hello, adding extended_master_secret extension" \
596 -s "found extended master secret extension" \
597 -S "server hello, adding extended master secret extension" \
598 -C "found extended_master_secret extension" \
599 -C "using extended master secret" \
600 -S "using extended master secret"
601
602run_test "Extended Master Secret: client disabled, server enabled" \
603 "$P_SRV debug_level=3 extended_ms=1" \
604 "$P_CLI debug_level=3 extended_ms=0" \
605 0 \
606 -C "client hello, adding extended_master_secret extension" \
607 -S "found extended master secret extension" \
608 -S "server hello, adding extended master secret extension" \
609 -C "found extended_master_secret extension" \
610 -C "using extended master secret" \
611 -S "using extended master secret"
612
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200613run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100614 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200615 "$P_CLI debug_level=3 force_version=ssl3" \
616 0 \
617 -C "client hello, adding extended_master_secret extension" \
618 -S "found extended master secret extension" \
619 -S "server hello, adding extended master secret extension" \
620 -C "found extended_master_secret extension" \
621 -C "using extended master secret" \
622 -S "using extended master secret"
623
624run_test "Extended Master Secret: client enabled, server SSLv3" \
625 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100626 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200627 0 \
628 -c "client hello, adding extended_master_secret extension" \
629 -s "found extended master secret extension" \
630 -S "server hello, adding extended master secret extension" \
631 -C "found extended_master_secret extension" \
632 -C "using extended master secret" \
633 -S "using extended master secret"
634
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200635# Tests for FALLBACK_SCSV
636
637run_test "Fallback SCSV: default" \
638 "$P_SRV" \
639 "$P_CLI debug_level=3 force_version=tls1_1" \
640 0 \
641 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200642 -S "received FALLBACK_SCSV" \
643 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200644 -C "is a fatal alert message (msg 86)"
645
646run_test "Fallback SCSV: explicitly disabled" \
647 "$P_SRV" \
648 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
649 0 \
650 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200651 -S "received FALLBACK_SCSV" \
652 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200653 -C "is a fatal alert message (msg 86)"
654
655run_test "Fallback SCSV: enabled" \
656 "$P_SRV" \
657 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200658 1 \
659 -c "adding FALLBACK_SCSV" \
660 -s "received FALLBACK_SCSV" \
661 -s "inapropriate fallback" \
662 -c "is a fatal alert message (msg 86)"
663
664run_test "Fallback SCSV: enabled, max version" \
665 "$P_SRV" \
666 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200667 0 \
668 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200669 -s "received FALLBACK_SCSV" \
670 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200671 -C "is a fatal alert message (msg 86)"
672
673requires_openssl_with_fallback_scsv
674run_test "Fallback SCSV: default, openssl server" \
675 "$O_SRV" \
676 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
677 0 \
678 -C "adding FALLBACK_SCSV" \
679 -C "is a fatal alert message (msg 86)"
680
681requires_openssl_with_fallback_scsv
682run_test "Fallback SCSV: enabled, openssl server" \
683 "$O_SRV" \
684 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
685 1 \
686 -c "adding FALLBACK_SCSV" \
687 -c "is a fatal alert message (msg 86)"
688
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200689requires_openssl_with_fallback_scsv
690run_test "Fallback SCSV: disabled, openssl client" \
691 "$P_SRV" \
692 "$O_CLI -tls1_1" \
693 0 \
694 -S "received FALLBACK_SCSV" \
695 -S "inapropriate fallback"
696
697requires_openssl_with_fallback_scsv
698run_test "Fallback SCSV: enabled, openssl client" \
699 "$P_SRV" \
700 "$O_CLI -tls1_1 -fallback_scsv" \
701 1 \
702 -s "received FALLBACK_SCSV" \
703 -s "inapropriate fallback"
704
705requires_openssl_with_fallback_scsv
706run_test "Fallback SCSV: enabled, max version, openssl client" \
707 "$P_SRV" \
708 "$O_CLI -fallback_scsv" \
709 0 \
710 -s "received FALLBACK_SCSV" \
711 -S "inapropriate fallback"
712
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100713# Tests for CBC 1/n-1 record splitting
714
715run_test "CBC Record splitting: TLS 1.2, no splitting" \
716 "$P_SRV" \
717 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
718 request_size=123 force_version=tls1_2" \
719 0 \
720 -s "Read from client: 123 bytes read" \
721 -S "Read from client: 1 bytes read" \
722 -S "122 bytes read"
723
724run_test "CBC Record splitting: TLS 1.1, no splitting" \
725 "$P_SRV" \
726 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
727 request_size=123 force_version=tls1_1" \
728 0 \
729 -s "Read from client: 123 bytes read" \
730 -S "Read from client: 1 bytes read" \
731 -S "122 bytes read"
732
733run_test "CBC Record splitting: TLS 1.0, splitting" \
734 "$P_SRV" \
735 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
736 request_size=123 force_version=tls1" \
737 0 \
738 -S "Read from client: 123 bytes read" \
739 -s "Read from client: 1 bytes read" \
740 -s "122 bytes read"
741
742run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100743 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100744 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
745 request_size=123 force_version=ssl3" \
746 0 \
747 -S "Read from client: 123 bytes read" \
748 -s "Read from client: 1 bytes read" \
749 -s "122 bytes read"
750
751run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100752 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100753 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
754 request_size=123 force_version=tls1" \
755 0 \
756 -s "Read from client: 123 bytes read" \
757 -S "Read from client: 1 bytes read" \
758 -S "122 bytes read"
759
760run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
761 "$P_SRV" \
762 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
763 request_size=123 force_version=tls1 recsplit=0" \
764 0 \
765 -s "Read from client: 123 bytes read" \
766 -S "Read from client: 1 bytes read" \
767 -S "122 bytes read"
768
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100769run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
770 "$P_SRV nbio=2" \
771 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
772 request_size=123 force_version=tls1" \
773 0 \
774 -S "Read from client: 123 bytes read" \
775 -s "Read from client: 1 bytes read" \
776 -s "122 bytes read"
777
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100778# Tests for Session Tickets
779
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200780run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200781 "$P_SRV debug_level=3 tickets=1" \
782 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100783 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100784 -c "client hello, adding session ticket extension" \
785 -s "found session ticket extension" \
786 -s "server hello, adding session ticket extension" \
787 -c "found session_ticket extension" \
788 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100789 -S "session successfully restored from cache" \
790 -s "session successfully restored from ticket" \
791 -s "a session has been resumed" \
792 -c "a session has been resumed"
793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200794run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200795 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
796 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100797 0 \
798 -c "client hello, adding session ticket extension" \
799 -s "found session ticket extension" \
800 -s "server hello, adding session ticket extension" \
801 -c "found session_ticket extension" \
802 -c "parse new session ticket" \
803 -S "session successfully restored from cache" \
804 -s "session successfully restored from ticket" \
805 -s "a session has been resumed" \
806 -c "a session has been resumed"
807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200808run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200809 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
810 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100811 0 \
812 -c "client hello, adding session ticket extension" \
813 -s "found session ticket extension" \
814 -s "server hello, adding session ticket extension" \
815 -c "found session_ticket extension" \
816 -c "parse new session ticket" \
817 -S "session successfully restored from cache" \
818 -S "session successfully restored from ticket" \
819 -S "a session has been resumed" \
820 -C "a session has been resumed"
821
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200822run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100823 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200824 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100825 0 \
826 -c "client hello, adding session ticket extension" \
827 -c "found session_ticket extension" \
828 -c "parse new session ticket" \
829 -c "a session has been resumed"
830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200831run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200832 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200833 "( $O_CLI -sess_out $SESSION; \
834 $O_CLI -sess_in $SESSION; \
835 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100836 0 \
837 -s "found session ticket extension" \
838 -s "server hello, adding session ticket extension" \
839 -S "session successfully restored from cache" \
840 -s "session successfully restored from ticket" \
841 -s "a session has been resumed"
842
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100843# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200845run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200846 "$P_SRV debug_level=3 tickets=0" \
847 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100848 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100849 -c "client hello, adding session ticket extension" \
850 -s "found session ticket extension" \
851 -S "server hello, adding session ticket extension" \
852 -C "found session_ticket extension" \
853 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100854 -s "session successfully restored from cache" \
855 -S "session successfully restored from ticket" \
856 -s "a session has been resumed" \
857 -c "a session has been resumed"
858
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200859run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200860 "$P_SRV debug_level=3 tickets=1" \
861 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100862 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100863 -C "client hello, adding session ticket extension" \
864 -S "found session ticket extension" \
865 -S "server hello, adding session ticket extension" \
866 -C "found session_ticket extension" \
867 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100868 -s "session successfully restored from cache" \
869 -S "session successfully restored from ticket" \
870 -s "a session has been resumed" \
871 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200873run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200874 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
875 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100876 0 \
877 -S "session successfully restored from cache" \
878 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100879 -S "a session has been resumed" \
880 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100881
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200882run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200883 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
884 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100885 0 \
886 -s "session successfully restored from cache" \
887 -S "session successfully restored from ticket" \
888 -s "a session has been resumed" \
889 -c "a session has been resumed"
890
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200891run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200892 "$P_SRV debug_level=3 tickets=0" \
893 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100894 0 \
895 -s "session successfully restored from cache" \
896 -S "session successfully restored from ticket" \
897 -s "a session has been resumed" \
898 -c "a session has been resumed"
899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200900run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200901 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
902 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100903 0 \
904 -S "session successfully restored from cache" \
905 -S "session successfully restored from ticket" \
906 -S "a session has been resumed" \
907 -C "a session has been resumed"
908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200909run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200910 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
911 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100912 0 \
913 -s "session successfully restored from cache" \
914 -S "session successfully restored from ticket" \
915 -s "a session has been resumed" \
916 -c "a session has been resumed"
917
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200918run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200919 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200920 "( $O_CLI -sess_out $SESSION; \
921 $O_CLI -sess_in $SESSION; \
922 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100923 0 \
924 -s "found session ticket extension" \
925 -S "server hello, adding session ticket extension" \
926 -s "session successfully restored from cache" \
927 -S "session successfully restored from ticket" \
928 -s "a session has been resumed"
929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200930run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100931 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200932 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100933 0 \
934 -C "found session_ticket extension" \
935 -C "parse new session ticket" \
936 -c "a session has been resumed"
937
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100938# Tests for Max Fragment Length extension
939
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200940run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200941 "$P_SRV debug_level=3" \
942 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100943 0 \
944 -C "client hello, adding max_fragment_length extension" \
945 -S "found max fragment length extension" \
946 -S "server hello, max_fragment_length extension" \
947 -C "found max_fragment_length extension"
948
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200949run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200950 "$P_SRV debug_level=3" \
951 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100952 0 \
953 -c "client hello, adding max_fragment_length extension" \
954 -s "found max fragment length extension" \
955 -s "server hello, max_fragment_length extension" \
956 -c "found max_fragment_length extension"
957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200958run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200959 "$P_SRV debug_level=3 max_frag_len=4096" \
960 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100961 0 \
962 -C "client hello, adding max_fragment_length extension" \
963 -S "found max fragment length extension" \
964 -S "server hello, max_fragment_length extension" \
965 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100966
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200967requires_gnutls
968run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200969 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200970 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200971 0 \
972 -c "client hello, adding max_fragment_length extension" \
973 -c "found max_fragment_length extension"
974
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100975# Tests for renegotiation
976
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200977run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200978 "$P_SRV debug_level=3 exchanges=2" \
979 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100980 0 \
981 -C "client hello, adding renegotiation extension" \
982 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
983 -S "found renegotiation extension" \
984 -s "server hello, secure renegotiation extension" \
985 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100986 -C "=> renegotiate" \
987 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100988 -S "write hello request"
989
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200990run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200991 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
992 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100993 0 \
994 -c "client hello, adding renegotiation extension" \
995 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
996 -s "found renegotiation extension" \
997 -s "server hello, secure renegotiation extension" \
998 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100999 -c "=> renegotiate" \
1000 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001001 -S "write hello request"
1002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001003run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001004 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1005 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001006 0 \
1007 -c "client hello, adding renegotiation extension" \
1008 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1009 -s "found renegotiation extension" \
1010 -s "server hello, secure renegotiation extension" \
1011 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001012 -c "=> renegotiate" \
1013 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001014 -s "write hello request"
1015
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001016run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001017 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1018 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001019 0 \
1020 -c "client hello, adding renegotiation extension" \
1021 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1022 -s "found renegotiation extension" \
1023 -s "server hello, secure renegotiation extension" \
1024 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001025 -c "=> renegotiate" \
1026 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001027 -s "write hello request"
1028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001029run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001030 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1031 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001032 1 \
1033 -c "client hello, adding renegotiation extension" \
1034 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1035 -S "found renegotiation extension" \
1036 -s "server hello, secure renegotiation extension" \
1037 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001038 -c "=> renegotiate" \
1039 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001040 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001041 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001042 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001044run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001045 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1046 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001047 0 \
1048 -C "client hello, adding renegotiation extension" \
1049 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1050 -S "found renegotiation extension" \
1051 -s "server hello, secure renegotiation extension" \
1052 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001053 -C "=> renegotiate" \
1054 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001055 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001056 -S "SSL - An unexpected message was received from our peer" \
1057 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001059run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
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=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001062 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
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é-Gonnarda8c0a0d2014-08-15 12:07:38 +02001075# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001076run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001077 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001078 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001079 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001080 0 \
1081 -C "client hello, adding renegotiation extension" \
1082 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1083 -S "found renegotiation extension" \
1084 -s "server hello, secure renegotiation extension" \
1085 -c "found renegotiation extension" \
1086 -C "=> renegotiate" \
1087 -S "=> renegotiate" \
1088 -s "write hello request" \
1089 -S "SSL - An unexpected message was received from our peer" \
1090 -S "failed"
1091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001092run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001093 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001094 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001095 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001096 0 \
1097 -C "client hello, adding renegotiation extension" \
1098 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1099 -S "found renegotiation extension" \
1100 -s "server hello, secure renegotiation extension" \
1101 -c "found renegotiation extension" \
1102 -C "=> renegotiate" \
1103 -S "=> renegotiate" \
1104 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001105 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001107run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001108 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001109 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001110 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001111 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 -c "=> renegotiate" \
1118 -s "=> renegotiate" \
1119 -s "write hello request" \
1120 -S "SSL - An unexpected message was received from our peer" \
1121 -S "failed"
1122
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001123run_test "Renegotiation: periodic, just below period" \
1124 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1125 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1126 0 \
1127 -C "client hello, adding renegotiation extension" \
1128 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1129 -S "found renegotiation extension" \
1130 -s "server hello, secure renegotiation extension" \
1131 -c "found renegotiation extension" \
1132 -S "record counter limit reached: renegotiate" \
1133 -C "=> renegotiate" \
1134 -S "=> renegotiate" \
1135 -S "write hello request" \
1136 -S "SSL - An unexpected message was received from our peer" \
1137 -S "failed"
1138
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001139# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001140run_test "Renegotiation: periodic, just above period" \
1141 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001142 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001143 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 -s "record counter limit reached: renegotiate" \
1150 -c "=> renegotiate" \
1151 -s "=> renegotiate" \
1152 -s "write hello request" \
1153 -S "SSL - An unexpected message was received from our peer" \
1154 -S "failed"
1155
1156run_test "Renegotiation: periodic, two times period" \
1157 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001158 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001159 0 \
1160 -c "client hello, adding renegotiation extension" \
1161 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1162 -s "found renegotiation extension" \
1163 -s "server hello, secure renegotiation extension" \
1164 -c "found renegotiation extension" \
1165 -s "record counter limit reached: renegotiate" \
1166 -c "=> renegotiate" \
1167 -s "=> renegotiate" \
1168 -s "write hello request" \
1169 -S "SSL - An unexpected message was received from our peer" \
1170 -S "failed"
1171
1172run_test "Renegotiation: periodic, above period, disabled" \
1173 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1174 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1175 0 \
1176 -C "client hello, adding renegotiation extension" \
1177 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1178 -S "found renegotiation extension" \
1179 -s "server hello, secure renegotiation extension" \
1180 -c "found renegotiation extension" \
1181 -S "record counter limit reached: renegotiate" \
1182 -C "=> renegotiate" \
1183 -S "=> renegotiate" \
1184 -S "write hello request" \
1185 -S "SSL - An unexpected message was received from our peer" \
1186 -S "failed"
1187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001188run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001189 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1190 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001191 0 \
1192 -c "client hello, adding renegotiation extension" \
1193 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1194 -s "found renegotiation extension" \
1195 -s "server hello, secure renegotiation extension" \
1196 -c "found renegotiation extension" \
1197 -c "=> renegotiate" \
1198 -s "=> renegotiate" \
1199 -S "write hello request"
1200
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001201run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001202 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1203 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001204 0 \
1205 -c "client hello, adding renegotiation extension" \
1206 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1207 -s "found renegotiation extension" \
1208 -s "server hello, secure renegotiation extension" \
1209 -c "found renegotiation extension" \
1210 -c "=> renegotiate" \
1211 -s "=> renegotiate" \
1212 -s "write hello request"
1213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001214run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001215 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001216 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001217 0 \
1218 -c "client hello, adding renegotiation extension" \
1219 -c "found renegotiation extension" \
1220 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001221 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001222 -C "error" \
1223 -c "HTTP/1.0 200 [Oo][Kk]"
1224
Paul Bakker539d9722015-02-08 16:18:35 +01001225requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001226run_test "Renegotiation: gnutls server strict, client-initiated" \
1227 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001228 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001229 0 \
1230 -c "client hello, adding renegotiation extension" \
1231 -c "found renegotiation extension" \
1232 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001233 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001234 -C "error" \
1235 -c "HTTP/1.0 200 [Oo][Kk]"
1236
Paul Bakker539d9722015-02-08 16:18:35 +01001237requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001238run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1239 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1240 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1241 1 \
1242 -c "client hello, adding renegotiation extension" \
1243 -C "found renegotiation extension" \
1244 -c "=> renegotiate" \
1245 -c "ssl_handshake() returned" \
1246 -c "error" \
1247 -C "HTTP/1.0 200 [Oo][Kk]"
1248
Paul Bakker539d9722015-02-08 16:18:35 +01001249requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001250run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1251 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1252 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1253 allow_legacy=0" \
1254 1 \
1255 -c "client hello, adding renegotiation extension" \
1256 -C "found renegotiation extension" \
1257 -c "=> renegotiate" \
1258 -c "ssl_handshake() returned" \
1259 -c "error" \
1260 -C "HTTP/1.0 200 [Oo][Kk]"
1261
Paul Bakker539d9722015-02-08 16:18:35 +01001262requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001263run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1264 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1265 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1266 allow_legacy=1" \
1267 0 \
1268 -c "client hello, adding renegotiation extension" \
1269 -C "found renegotiation extension" \
1270 -c "=> renegotiate" \
1271 -C "ssl_hanshake() returned" \
1272 -C "error" \
1273 -c "HTTP/1.0 200 [Oo][Kk]"
1274
1275# Test for the "secure renegotation" extension only (no actual renegotiation)
1276
Paul Bakker539d9722015-02-08 16:18:35 +01001277requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001278run_test "Renego ext: gnutls server strict, client default" \
1279 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1280 "$P_CLI debug_level=3" \
1281 0 \
1282 -c "found renegotiation extension" \
1283 -C "error" \
1284 -c "HTTP/1.0 200 [Oo][Kk]"
1285
Paul Bakker539d9722015-02-08 16:18:35 +01001286requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001287run_test "Renego ext: gnutls server unsafe, client default" \
1288 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1289 "$P_CLI debug_level=3" \
1290 0 \
1291 -C "found renegotiation extension" \
1292 -C "error" \
1293 -c "HTTP/1.0 200 [Oo][Kk]"
1294
Paul Bakker539d9722015-02-08 16:18:35 +01001295requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001296run_test "Renego ext: gnutls server unsafe, client break legacy" \
1297 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1298 "$P_CLI debug_level=3 allow_legacy=-1" \
1299 1 \
1300 -C "found renegotiation extension" \
1301 -c "error" \
1302 -C "HTTP/1.0 200 [Oo][Kk]"
1303
Paul Bakker539d9722015-02-08 16:18:35 +01001304requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001305run_test "Renego ext: gnutls client strict, server default" \
1306 "$P_SRV debug_level=3" \
1307 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1308 0 \
1309 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1310 -s "server hello, secure renegotiation extension"
1311
Paul Bakker539d9722015-02-08 16:18:35 +01001312requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001313run_test "Renego ext: gnutls client unsafe, server default" \
1314 "$P_SRV debug_level=3" \
1315 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1316 0 \
1317 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1318 -S "server hello, secure renegotiation extension"
1319
Paul Bakker539d9722015-02-08 16:18:35 +01001320requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001321run_test "Renego ext: gnutls client unsafe, server break legacy" \
1322 "$P_SRV debug_level=3 allow_legacy=-1" \
1323 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1324 1 \
1325 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1326 -S "server hello, secure renegotiation extension"
1327
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001328# Tests for auth_mode
1329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001330run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001331 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001332 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001333 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001334 1 \
1335 -c "x509_verify_cert() returned" \
1336 -c "! self-signed or not signed by a trusted CA" \
1337 -c "! ssl_handshake returned" \
1338 -c "X509 - Certificate verification failed"
1339
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001340run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001341 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001342 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001343 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001344 0 \
1345 -c "x509_verify_cert() returned" \
1346 -c "! self-signed or not signed by a trusted CA" \
1347 -C "! ssl_handshake returned" \
1348 -C "X509 - Certificate verification failed"
1349
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001350run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001351 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001352 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001353 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001354 0 \
1355 -C "x509_verify_cert() returned" \
1356 -C "! self-signed or not signed by a trusted CA" \
1357 -C "! ssl_handshake returned" \
1358 -C "X509 - Certificate verification failed"
1359
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001360run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001361 "$P_SRV debug_level=3 auth_mode=required" \
1362 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001363 key_file=data_files/server5.key" \
1364 1 \
1365 -S "skip write certificate request" \
1366 -C "skip parse certificate request" \
1367 -c "got a certificate request" \
1368 -C "skip write certificate" \
1369 -C "skip write certificate verify" \
1370 -S "skip parse certificate verify" \
1371 -s "x509_verify_cert() returned" \
1372 -S "! self-signed or not signed by a trusted CA" \
1373 -s "! ssl_handshake returned" \
1374 -c "! ssl_handshake returned" \
1375 -s "X509 - Certificate verification failed"
1376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001377run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001378 "$P_SRV debug_level=3 auth_mode=optional" \
1379 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001380 key_file=data_files/server5.key" \
1381 0 \
1382 -S "skip write certificate request" \
1383 -C "skip parse certificate request" \
1384 -c "got a certificate request" \
1385 -C "skip write certificate" \
1386 -C "skip write certificate verify" \
1387 -S "skip parse certificate verify" \
1388 -s "x509_verify_cert() returned" \
1389 -s "! self-signed or not signed by a trusted CA" \
1390 -S "! ssl_handshake returned" \
1391 -C "! ssl_handshake returned" \
1392 -S "X509 - Certificate verification failed"
1393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001394run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001395 "$P_SRV debug_level=3 auth_mode=none" \
1396 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001397 key_file=data_files/server5.key" \
1398 0 \
1399 -s "skip write certificate request" \
1400 -C "skip parse certificate request" \
1401 -c "got no certificate request" \
1402 -c "skip write certificate" \
1403 -c "skip write certificate verify" \
1404 -s "skip parse certificate verify" \
1405 -S "x509_verify_cert() returned" \
1406 -S "! self-signed or not signed by a trusted CA" \
1407 -S "! ssl_handshake returned" \
1408 -C "! ssl_handshake returned" \
1409 -S "X509 - Certificate verification failed"
1410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001411run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001412 "$P_SRV debug_level=3 auth_mode=optional" \
1413 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001414 0 \
1415 -S "skip write certificate request" \
1416 -C "skip parse certificate request" \
1417 -c "got a certificate request" \
1418 -C "skip write certificate$" \
1419 -C "got no certificate to send" \
1420 -S "SSLv3 client has no certificate" \
1421 -c "skip write certificate verify" \
1422 -s "skip parse certificate verify" \
1423 -s "! no client certificate sent" \
1424 -S "! ssl_handshake returned" \
1425 -C "! ssl_handshake returned" \
1426 -S "X509 - Certificate verification failed"
1427
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001428run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001429 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001430 "$O_CLI" \
1431 0 \
1432 -S "skip write certificate request" \
1433 -s "skip parse certificate verify" \
1434 -s "! no client certificate sent" \
1435 -S "! ssl_handshake returned" \
1436 -S "X509 - Certificate verification failed"
1437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001438run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001439 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001440 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001441 0 \
1442 -C "skip parse certificate request" \
1443 -c "got a certificate request" \
1444 -C "skip write certificate$" \
1445 -c "skip write certificate verify" \
1446 -C "! ssl_handshake returned"
1447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001448run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001449 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001450 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001451 0 \
1452 -S "skip write certificate request" \
1453 -C "skip parse certificate request" \
1454 -c "got a certificate request" \
1455 -C "skip write certificate$" \
1456 -c "skip write certificate verify" \
1457 -c "got no certificate to send" \
1458 -s "SSLv3 client has no certificate" \
1459 -s "skip parse certificate verify" \
1460 -s "! no client certificate sent" \
1461 -S "! ssl_handshake returned" \
1462 -C "! ssl_handshake returned" \
1463 -S "X509 - Certificate verification failed"
1464
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001465# Tests for certificate selection based on SHA verson
1466
1467run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1468 "$P_SRV crt_file=data_files/server5.crt \
1469 key_file=data_files/server5.key \
1470 crt_file2=data_files/server5-sha1.crt \
1471 key_file2=data_files/server5.key" \
1472 "$P_CLI force_version=tls1_2" \
1473 0 \
1474 -c "signed using.*ECDSA with SHA256" \
1475 -C "signed using.*ECDSA with SHA1"
1476
1477run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1478 "$P_SRV crt_file=data_files/server5.crt \
1479 key_file=data_files/server5.key \
1480 crt_file2=data_files/server5-sha1.crt \
1481 key_file2=data_files/server5.key" \
1482 "$P_CLI force_version=tls1_1" \
1483 0 \
1484 -C "signed using.*ECDSA with SHA256" \
1485 -c "signed using.*ECDSA with SHA1"
1486
1487run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1488 "$P_SRV crt_file=data_files/server5.crt \
1489 key_file=data_files/server5.key \
1490 crt_file2=data_files/server5-sha1.crt \
1491 key_file2=data_files/server5.key" \
1492 "$P_CLI force_version=tls1" \
1493 0 \
1494 -C "signed using.*ECDSA with SHA256" \
1495 -c "signed using.*ECDSA with SHA1"
1496
1497run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1498 "$P_SRV crt_file=data_files/server5.crt \
1499 key_file=data_files/server5.key \
1500 crt_file2=data_files/server6.crt \
1501 key_file2=data_files/server6.key" \
1502 "$P_CLI force_version=tls1_1" \
1503 0 \
1504 -c "serial number.*09" \
1505 -c "signed using.*ECDSA with SHA256" \
1506 -C "signed using.*ECDSA with SHA1"
1507
1508run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1509 "$P_SRV crt_file=data_files/server6.crt \
1510 key_file=data_files/server6.key \
1511 crt_file2=data_files/server5.crt \
1512 key_file2=data_files/server5.key" \
1513 "$P_CLI force_version=tls1_1" \
1514 0 \
1515 -c "serial number.*0A" \
1516 -c "signed using.*ECDSA with SHA256" \
1517 -C "signed using.*ECDSA with SHA1"
1518
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001519# tests for SNI
1520
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001521run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001522 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001523 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001524 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001525 server_name=localhost" \
1526 0 \
1527 -S "parse ServerName extension" \
1528 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1529 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1530
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001531run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001532 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001533 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001534 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 +01001535 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001536 server_name=localhost" \
1537 0 \
1538 -s "parse ServerName extension" \
1539 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1540 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001542run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001543 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001544 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001545 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 +01001546 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001547 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001548 0 \
1549 -s "parse ServerName extension" \
1550 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001551 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001553run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001554 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001555 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001556 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 +01001557 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001558 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001559 1 \
1560 -s "parse ServerName extension" \
1561 -s "ssl_sni_wrapper() returned" \
1562 -s "ssl_handshake returned" \
1563 -c "ssl_handshake returned" \
1564 -c "SSL - A fatal alert message was received from our peer"
1565
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001566# Tests for non-blocking I/O: exercise a variety of handshake flows
1567
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001568run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001569 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1570 "$P_CLI nbio=2 tickets=0" \
1571 0 \
1572 -S "ssl_handshake returned" \
1573 -C "ssl_handshake returned" \
1574 -c "Read from server: .* bytes read"
1575
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001576run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001577 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1578 "$P_CLI nbio=2 tickets=0" \
1579 0 \
1580 -S "ssl_handshake returned" \
1581 -C "ssl_handshake returned" \
1582 -c "Read from server: .* bytes read"
1583
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001584run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001585 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1586 "$P_CLI nbio=2 tickets=1" \
1587 0 \
1588 -S "ssl_handshake returned" \
1589 -C "ssl_handshake returned" \
1590 -c "Read from server: .* bytes read"
1591
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001592run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001593 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1594 "$P_CLI nbio=2 tickets=1" \
1595 0 \
1596 -S "ssl_handshake returned" \
1597 -C "ssl_handshake returned" \
1598 -c "Read from server: .* bytes read"
1599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001600run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001601 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1602 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1603 0 \
1604 -S "ssl_handshake returned" \
1605 -C "ssl_handshake returned" \
1606 -c "Read from server: .* bytes read"
1607
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001608run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001609 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1610 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1611 0 \
1612 -S "ssl_handshake returned" \
1613 -C "ssl_handshake returned" \
1614 -c "Read from server: .* bytes read"
1615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001616run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001617 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1618 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1619 0 \
1620 -S "ssl_handshake returned" \
1621 -C "ssl_handshake returned" \
1622 -c "Read from server: .* bytes read"
1623
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001624# Tests for version negotiation
1625
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001626run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001627 "$P_SRV" \
1628 "$P_CLI" \
1629 0 \
1630 -S "ssl_handshake returned" \
1631 -C "ssl_handshake returned" \
1632 -s "Protocol is TLSv1.2" \
1633 -c "Protocol is TLSv1.2"
1634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001635run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001636 "$P_SRV" \
1637 "$P_CLI max_version=tls1_1" \
1638 0 \
1639 -S "ssl_handshake returned" \
1640 -C "ssl_handshake returned" \
1641 -s "Protocol is TLSv1.1" \
1642 -c "Protocol is TLSv1.1"
1643
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001644run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001645 "$P_SRV max_version=tls1_1" \
1646 "$P_CLI" \
1647 0 \
1648 -S "ssl_handshake returned" \
1649 -C "ssl_handshake returned" \
1650 -s "Protocol is TLSv1.1" \
1651 -c "Protocol is TLSv1.1"
1652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001653run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001654 "$P_SRV max_version=tls1_1" \
1655 "$P_CLI max_version=tls1_1" \
1656 0 \
1657 -S "ssl_handshake returned" \
1658 -C "ssl_handshake returned" \
1659 -s "Protocol is TLSv1.1" \
1660 -c "Protocol is TLSv1.1"
1661
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001662run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001663 "$P_SRV min_version=tls1_1" \
1664 "$P_CLI max_version=tls1_1" \
1665 0 \
1666 -S "ssl_handshake returned" \
1667 -C "ssl_handshake returned" \
1668 -s "Protocol is TLSv1.1" \
1669 -c "Protocol is TLSv1.1"
1670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001671run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001672 "$P_SRV max_version=tls1_1" \
1673 "$P_CLI min_version=tls1_1" \
1674 0 \
1675 -S "ssl_handshake returned" \
1676 -C "ssl_handshake returned" \
1677 -s "Protocol is TLSv1.1" \
1678 -c "Protocol is TLSv1.1"
1679
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001680run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001681 "$P_SRV max_version=tls1_1" \
1682 "$P_CLI min_version=tls1_2" \
1683 1 \
1684 -s "ssl_handshake returned" \
1685 -c "ssl_handshake returned" \
1686 -c "SSL - Handshake protocol not within min/max boundaries"
1687
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001688run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001689 "$P_SRV min_version=tls1_2" \
1690 "$P_CLI max_version=tls1_1" \
1691 1 \
1692 -s "ssl_handshake returned" \
1693 -c "ssl_handshake returned" \
1694 -s "SSL - Handshake protocol not within min/max boundaries"
1695
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001696# Tests for ALPN extension
1697
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001698if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1699
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001700run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001701 "$P_SRV debug_level=3" \
1702 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001703 0 \
1704 -C "client hello, adding alpn extension" \
1705 -S "found alpn extension" \
1706 -C "got an alert message, type: \\[2:120]" \
1707 -S "server hello, adding alpn extension" \
1708 -C "found alpn extension " \
1709 -C "Application Layer Protocol is" \
1710 -S "Application Layer Protocol is"
1711
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001712run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001713 "$P_SRV debug_level=3" \
1714 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001715 0 \
1716 -c "client hello, adding alpn extension" \
1717 -s "found alpn extension" \
1718 -C "got an alert message, type: \\[2:120]" \
1719 -S "server hello, adding alpn extension" \
1720 -C "found alpn extension " \
1721 -c "Application Layer Protocol is (none)" \
1722 -S "Application Layer Protocol is"
1723
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001724run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001725 "$P_SRV debug_level=3 alpn=abc,1234" \
1726 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001727 0 \
1728 -C "client hello, adding alpn extension" \
1729 -S "found alpn extension" \
1730 -C "got an alert message, type: \\[2:120]" \
1731 -S "server hello, adding alpn extension" \
1732 -C "found alpn extension " \
1733 -C "Application Layer Protocol is" \
1734 -s "Application Layer Protocol is (none)"
1735
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001736run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001737 "$P_SRV debug_level=3 alpn=abc,1234" \
1738 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001739 0 \
1740 -c "client hello, adding alpn extension" \
1741 -s "found alpn extension" \
1742 -C "got an alert message, type: \\[2:120]" \
1743 -s "server hello, adding alpn extension" \
1744 -c "found alpn extension" \
1745 -c "Application Layer Protocol is abc" \
1746 -s "Application Layer Protocol is abc"
1747
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001748run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001749 "$P_SRV debug_level=3 alpn=abc,1234" \
1750 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001751 0 \
1752 -c "client hello, adding alpn extension" \
1753 -s "found alpn extension" \
1754 -C "got an alert message, type: \\[2:120]" \
1755 -s "server hello, adding alpn extension" \
1756 -c "found alpn extension" \
1757 -c "Application Layer Protocol is abc" \
1758 -s "Application Layer Protocol is abc"
1759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001760run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001761 "$P_SRV debug_level=3 alpn=abc,1234" \
1762 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001763 0 \
1764 -c "client hello, adding alpn extension" \
1765 -s "found alpn extension" \
1766 -C "got an alert message, type: \\[2:120]" \
1767 -s "server hello, adding alpn extension" \
1768 -c "found alpn extension" \
1769 -c "Application Layer Protocol is 1234" \
1770 -s "Application Layer Protocol is 1234"
1771
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001772run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001773 "$P_SRV debug_level=3 alpn=abc,123" \
1774 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001775 1 \
1776 -c "client hello, adding alpn extension" \
1777 -s "found alpn extension" \
1778 -c "got an alert message, type: \\[2:120]" \
1779 -S "server hello, adding alpn extension" \
1780 -C "found alpn extension" \
1781 -C "Application Layer Protocol is 1234" \
1782 -S "Application Layer Protocol is 1234"
1783
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001784fi
1785
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001786# Tests for keyUsage in leaf certificates, part 1:
1787# server-side certificate/suite selection
1788
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001789run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001790 "$P_SRV key_file=data_files/server2.key \
1791 crt_file=data_files/server2.ku-ds.crt" \
1792 "$P_CLI" \
1793 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001794 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001795
1796
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001797run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001798 "$P_SRV key_file=data_files/server2.key \
1799 crt_file=data_files/server2.ku-ke.crt" \
1800 "$P_CLI" \
1801 0 \
1802 -c "Ciphersuite is TLS-RSA-WITH-"
1803
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001804run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001805 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001806 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001807 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001808 1 \
1809 -C "Ciphersuite is "
1810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001811run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001812 "$P_SRV key_file=data_files/server5.key \
1813 crt_file=data_files/server5.ku-ds.crt" \
1814 "$P_CLI" \
1815 0 \
1816 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1817
1818
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001819run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001820 "$P_SRV key_file=data_files/server5.key \
1821 crt_file=data_files/server5.ku-ka.crt" \
1822 "$P_CLI" \
1823 0 \
1824 -c "Ciphersuite is TLS-ECDH-"
1825
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001826run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001827 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001828 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001829 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001830 1 \
1831 -C "Ciphersuite is "
1832
1833# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001834# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001836run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001837 "$O_SRV -key data_files/server2.key \
1838 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001839 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001840 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1841 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001842 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001843 -C "Processing of the Certificate handshake message failed" \
1844 -c "Ciphersuite is TLS-"
1845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001846run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001847 "$O_SRV -key data_files/server2.key \
1848 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001849 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001850 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1851 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001852 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001853 -C "Processing of the Certificate handshake message failed" \
1854 -c "Ciphersuite is TLS-"
1855
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001856run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001857 "$O_SRV -key data_files/server2.key \
1858 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001859 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001860 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1861 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001862 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001863 -C "Processing of the Certificate handshake message failed" \
1864 -c "Ciphersuite is TLS-"
1865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001866run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001867 "$O_SRV -key data_files/server2.key \
1868 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001869 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001870 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1871 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001872 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001873 -c "Processing of the Certificate handshake message failed" \
1874 -C "Ciphersuite is TLS-"
1875
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001876run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001877 "$O_SRV -key data_files/server2.key \
1878 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001879 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001880 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1881 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001882 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001883 -C "Processing of the Certificate handshake message failed" \
1884 -c "Ciphersuite is TLS-"
1885
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001886run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001887 "$O_SRV -key data_files/server2.key \
1888 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001889 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001890 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1891 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001892 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001893 -c "Processing of the Certificate handshake message failed" \
1894 -C "Ciphersuite is TLS-"
1895
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001896# Tests for keyUsage in leaf certificates, part 3:
1897# server-side checking of client cert
1898
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001899run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001900 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001901 "$O_CLI -key data_files/server2.key \
1902 -cert data_files/server2.ku-ds.crt" \
1903 0 \
1904 -S "bad certificate (usage extensions)" \
1905 -S "Processing of the Certificate handshake message failed"
1906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001907run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001908 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001909 "$O_CLI -key data_files/server2.key \
1910 -cert data_files/server2.ku-ke.crt" \
1911 0 \
1912 -s "bad certificate (usage extensions)" \
1913 -S "Processing of the Certificate handshake message failed"
1914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001915run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001916 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001917 "$O_CLI -key data_files/server2.key \
1918 -cert data_files/server2.ku-ke.crt" \
1919 1 \
1920 -s "bad certificate (usage extensions)" \
1921 -s "Processing of the Certificate handshake message failed"
1922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001923run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001924 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001925 "$O_CLI -key data_files/server5.key \
1926 -cert data_files/server5.ku-ds.crt" \
1927 0 \
1928 -S "bad certificate (usage extensions)" \
1929 -S "Processing of the Certificate handshake message failed"
1930
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001931run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001932 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001933 "$O_CLI -key data_files/server5.key \
1934 -cert data_files/server5.ku-ka.crt" \
1935 0 \
1936 -s "bad certificate (usage extensions)" \
1937 -S "Processing of the Certificate handshake message failed"
1938
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001939# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1940
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001941run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001942 "$P_SRV key_file=data_files/server5.key \
1943 crt_file=data_files/server5.eku-srv.crt" \
1944 "$P_CLI" \
1945 0
1946
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001947run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001948 "$P_SRV key_file=data_files/server5.key \
1949 crt_file=data_files/server5.eku-srv.crt" \
1950 "$P_CLI" \
1951 0
1952
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001953run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001954 "$P_SRV key_file=data_files/server5.key \
1955 crt_file=data_files/server5.eku-cs_any.crt" \
1956 "$P_CLI" \
1957 0
1958
1959# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001960run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001961 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1962 crt_file=data_files/server5.eku-cli.crt" \
1963 "$P_CLI psk=badbad" \
1964 1
1965
1966# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001968run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001969 "$O_SRV -key data_files/server5.key \
1970 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001971 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001972 0 \
1973 -C "bad certificate (usage extensions)" \
1974 -C "Processing of the Certificate handshake message failed" \
1975 -c "Ciphersuite is TLS-"
1976
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001977run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001978 "$O_SRV -key data_files/server5.key \
1979 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001980 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001981 0 \
1982 -C "bad certificate (usage extensions)" \
1983 -C "Processing of the Certificate handshake message failed" \
1984 -c "Ciphersuite is TLS-"
1985
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001986run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001987 "$O_SRV -key data_files/server5.key \
1988 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001989 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001990 0 \
1991 -C "bad certificate (usage extensions)" \
1992 -C "Processing of the Certificate handshake message failed" \
1993 -c "Ciphersuite is TLS-"
1994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001995run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001996 "$O_SRV -key data_files/server5.key \
1997 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001998 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001999 1 \
2000 -c "bad certificate (usage extensions)" \
2001 -c "Processing of the Certificate handshake message failed" \
2002 -C "Ciphersuite is TLS-"
2003
2004# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002006run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002007 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002008 "$O_CLI -key data_files/server5.key \
2009 -cert data_files/server5.eku-cli.crt" \
2010 0 \
2011 -S "bad certificate (usage extensions)" \
2012 -S "Processing of the Certificate handshake message failed"
2013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002014run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002015 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002016 "$O_CLI -key data_files/server5.key \
2017 -cert data_files/server5.eku-srv_cli.crt" \
2018 0 \
2019 -S "bad certificate (usage extensions)" \
2020 -S "Processing of the Certificate handshake message failed"
2021
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002022run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002023 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002024 "$O_CLI -key data_files/server5.key \
2025 -cert data_files/server5.eku-cs_any.crt" \
2026 0 \
2027 -S "bad certificate (usage extensions)" \
2028 -S "Processing of the Certificate handshake message failed"
2029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002030run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002031 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002032 "$O_CLI -key data_files/server5.key \
2033 -cert data_files/server5.eku-cs.crt" \
2034 0 \
2035 -s "bad certificate (usage extensions)" \
2036 -S "Processing of the Certificate handshake message failed"
2037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002038run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002039 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002040 "$O_CLI -key data_files/server5.key \
2041 -cert data_files/server5.eku-cs.crt" \
2042 1 \
2043 -s "bad certificate (usage extensions)" \
2044 -s "Processing of the Certificate handshake message failed"
2045
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002046# Tests for DHM parameters loading
2047
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002048run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002049 "$P_SRV" \
2050 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2051 debug_level=3" \
2052 0 \
2053 -c "value of 'DHM: P ' (2048 bits)" \
2054 -c "value of 'DHM: G ' (2048 bits)"
2055
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002056run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002057 "$P_SRV dhm_file=data_files/dhparams.pem" \
2058 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2059 debug_level=3" \
2060 0 \
2061 -c "value of 'DHM: P ' (1024 bits)" \
2062 -c "value of 'DHM: G ' (2 bits)"
2063
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002064# Tests for PSK callback
2065
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002066run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002067 "$P_SRV psk=abc123 psk_identity=foo" \
2068 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2069 psk_identity=foo psk=abc123" \
2070 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002071 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002072 -S "SSL - Unknown identity received" \
2073 -S "SSL - Verification of the message MAC failed"
2074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002075run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002076 "$P_SRV" \
2077 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2078 psk_identity=foo psk=abc123" \
2079 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002080 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002081 -S "SSL - Unknown identity received" \
2082 -S "SSL - Verification of the message MAC failed"
2083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002084run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002085 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2086 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2087 psk_identity=foo psk=abc123" \
2088 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002089 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002090 -s "SSL - Unknown identity received" \
2091 -S "SSL - Verification of the message MAC failed"
2092
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002093run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002094 "$P_SRV psk_list=abc,dead,def,beef" \
2095 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2096 psk_identity=abc psk=dead" \
2097 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002098 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002099 -S "SSL - Unknown identity received" \
2100 -S "SSL - Verification of the message MAC failed"
2101
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002102run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002103 "$P_SRV psk_list=abc,dead,def,beef" \
2104 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2105 psk_identity=def psk=beef" \
2106 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002107 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002108 -S "SSL - Unknown identity received" \
2109 -S "SSL - Verification of the message MAC failed"
2110
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002111run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002112 "$P_SRV psk_list=abc,dead,def,beef" \
2113 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2114 psk_identity=ghi psk=beef" \
2115 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002116 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002117 -s "SSL - Unknown identity received" \
2118 -S "SSL - Verification of the message MAC failed"
2119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002120run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002121 "$P_SRV psk_list=abc,dead,def,beef" \
2122 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2123 psk_identity=abc psk=beef" \
2124 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002125 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002126 -S "SSL - Unknown identity received" \
2127 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002128
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002129# Tests for ciphersuites per version
2130
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002131run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002132 "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002133 "$P_CLI force_version=ssl3" \
2134 0 \
2135 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2136
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002137run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002138 "$P_SRV arc4=1 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
2139 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002140 0 \
2141 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002143run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002144 "$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" \
2145 "$P_CLI force_version=tls1_1" \
2146 0 \
2147 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2148
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002149run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002150 "$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" \
2151 "$P_CLI force_version=tls1_2" \
2152 0 \
2153 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2154
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002155# Tests for ssl_get_bytes_avail()
2156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002157run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002158 "$P_SRV" \
2159 "$P_CLI request_size=100" \
2160 0 \
2161 -s "Read from client: 100 bytes read$"
2162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002163run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002164 "$P_SRV" \
2165 "$P_CLI request_size=500" \
2166 0 \
2167 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002168
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002169# Tests for small packets
2170
2171run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002172 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002173 "$P_CLI request_size=1 force_version=ssl3 \
2174 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2175 0 \
2176 -s "Read from client: 1 bytes read"
2177
2178run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002179 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002180 "$P_CLI request_size=1 force_version=ssl3 \
2181 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2182 0 \
2183 -s "Read from client: 1 bytes read"
2184
2185run_test "Small packet TLS 1.0 BlockCipher" \
2186 "$P_SRV" \
2187 "$P_CLI request_size=1 force_version=tls1 \
2188 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2189 0 \
2190 -s "Read from client: 1 bytes read"
2191
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002192run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2193 "$P_SRV" \
2194 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2195 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2196 0 \
2197 -s "Read from client: 1 bytes read"
2198
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002199run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2200 "$P_SRV" \
2201 "$P_CLI request_size=1 force_version=tls1 \
2202 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2203 trunc_hmac=1" \
2204 0 \
2205 -s "Read from client: 1 bytes read"
2206
2207run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002208 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002209 "$P_CLI request_size=1 force_version=tls1 \
2210 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2211 trunc_hmac=1" \
2212 0 \
2213 -s "Read from client: 1 bytes read"
2214
2215run_test "Small packet TLS 1.1 BlockCipher" \
2216 "$P_SRV" \
2217 "$P_CLI request_size=1 force_version=tls1_1 \
2218 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2219 0 \
2220 -s "Read from client: 1 bytes read"
2221
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002222run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2223 "$P_SRV" \
2224 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2225 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2226 0 \
2227 -s "Read from client: 1 bytes read"
2228
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002229run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002230 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002231 "$P_CLI request_size=1 force_version=tls1_1 \
2232 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2233 0 \
2234 -s "Read from client: 1 bytes read"
2235
2236run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2237 "$P_SRV" \
2238 "$P_CLI request_size=1 force_version=tls1_1 \
2239 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2240 trunc_hmac=1" \
2241 0 \
2242 -s "Read from client: 1 bytes read"
2243
2244run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002245 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002246 "$P_CLI request_size=1 force_version=tls1_1 \
2247 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2248 trunc_hmac=1" \
2249 0 \
2250 -s "Read from client: 1 bytes read"
2251
2252run_test "Small packet TLS 1.2 BlockCipher" \
2253 "$P_SRV" \
2254 "$P_CLI request_size=1 force_version=tls1_2 \
2255 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2256 0 \
2257 -s "Read from client: 1 bytes read"
2258
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002259run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2260 "$P_SRV" \
2261 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2262 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2263 0 \
2264 -s "Read from client: 1 bytes read"
2265
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002266run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2267 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002268 "$P_CLI request_size=1 force_version=tls1_2 \
2269 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002270 0 \
2271 -s "Read from client: 1 bytes read"
2272
2273run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2274 "$P_SRV" \
2275 "$P_CLI request_size=1 force_version=tls1_2 \
2276 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2277 trunc_hmac=1" \
2278 0 \
2279 -s "Read from client: 1 bytes read"
2280
2281run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002282 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002283 "$P_CLI request_size=1 force_version=tls1_2 \
2284 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2285 0 \
2286 -s "Read from client: 1 bytes read"
2287
2288run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002289 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002290 "$P_CLI request_size=1 force_version=tls1_2 \
2291 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2292 trunc_hmac=1" \
2293 0 \
2294 -s "Read from client: 1 bytes read"
2295
2296run_test "Small packet TLS 1.2 AEAD" \
2297 "$P_SRV" \
2298 "$P_CLI request_size=1 force_version=tls1_2 \
2299 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2300 0 \
2301 -s "Read from client: 1 bytes read"
2302
2303run_test "Small packet TLS 1.2 AEAD shorter tag" \
2304 "$P_SRV" \
2305 "$P_CLI request_size=1 force_version=tls1_2 \
2306 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2307 0 \
2308 -s "Read from client: 1 bytes read"
2309
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002310# Test for large packets
2311
2312run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002313 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002314 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002315 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2316 0 \
2317 -s "Read from client: 16384 bytes read"
2318
2319run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002320 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002321 "$P_CLI request_size=16384 force_version=ssl3 \
2322 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2323 0 \
2324 -s "Read from client: 16384 bytes read"
2325
2326run_test "Large packet TLS 1.0 BlockCipher" \
2327 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002328 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002329 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2330 0 \
2331 -s "Read from client: 16384 bytes read"
2332
2333run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2334 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002335 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002336 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2337 trunc_hmac=1" \
2338 0 \
2339 -s "Read from client: 16384 bytes read"
2340
2341run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002342 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002343 "$P_CLI request_size=16384 force_version=tls1 \
2344 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2345 trunc_hmac=1" \
2346 0 \
2347 -s "Read from client: 16384 bytes read"
2348
2349run_test "Large packet TLS 1.1 BlockCipher" \
2350 "$P_SRV" \
2351 "$P_CLI request_size=16384 force_version=tls1_1 \
2352 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2353 0 \
2354 -s "Read from client: 16384 bytes read"
2355
2356run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002357 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002358 "$P_CLI request_size=16384 force_version=tls1_1 \
2359 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2360 0 \
2361 -s "Read from client: 16384 bytes read"
2362
2363run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2364 "$P_SRV" \
2365 "$P_CLI request_size=16384 force_version=tls1_1 \
2366 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2367 trunc_hmac=1" \
2368 0 \
2369 -s "Read from client: 16384 bytes read"
2370
2371run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002372 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002373 "$P_CLI request_size=16384 force_version=tls1_1 \
2374 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2375 trunc_hmac=1" \
2376 0 \
2377 -s "Read from client: 16384 bytes read"
2378
2379run_test "Large packet TLS 1.2 BlockCipher" \
2380 "$P_SRV" \
2381 "$P_CLI request_size=16384 force_version=tls1_2 \
2382 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2383 0 \
2384 -s "Read from client: 16384 bytes read"
2385
2386run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2387 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002388 "$P_CLI request_size=16384 force_version=tls1_2 \
2389 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002390 0 \
2391 -s "Read from client: 16384 bytes read"
2392
2393run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2394 "$P_SRV" \
2395 "$P_CLI request_size=16384 force_version=tls1_2 \
2396 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2397 trunc_hmac=1" \
2398 0 \
2399 -s "Read from client: 16384 bytes read"
2400
2401run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002402 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002403 "$P_CLI request_size=16384 force_version=tls1_2 \
2404 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2405 0 \
2406 -s "Read from client: 16384 bytes read"
2407
2408run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002409 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002410 "$P_CLI request_size=16384 force_version=tls1_2 \
2411 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2412 trunc_hmac=1" \
2413 0 \
2414 -s "Read from client: 16384 bytes read"
2415
2416run_test "Large packet TLS 1.2 AEAD" \
2417 "$P_SRV" \
2418 "$P_CLI request_size=16384 force_version=tls1_2 \
2419 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2420 0 \
2421 -s "Read from client: 16384 bytes read"
2422
2423run_test "Large packet TLS 1.2 AEAD shorter tag" \
2424 "$P_SRV" \
2425 "$P_CLI request_size=16384 force_version=tls1_2 \
2426 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2427 0 \
2428 -s "Read from client: 16384 bytes read"
2429
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002430# Final report
2431
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002432echo "------------------------------------------------------------------------"
2433
2434if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002435 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002436else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002437 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002438fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002439PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002440echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002441
2442exit $FAILS