blob: 9d5b50f272e93386fb5ec2de79eacc08cf48d17f [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
9# Assumes all options are compiled in.
10
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010016: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020017: ${GNUTLS_CLI:=gnutls-cli}
18: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010019
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010020O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
21O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020022G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010023G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010024
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010025TESTS=0
26FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020027SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020029CONFIG_H='../include/polarssl/config.h'
30
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010031MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010032FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020033EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034
35print_usage() {
36 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010037 printf " -h|--help\tPrint this help.\n"
38 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
39 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
40 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041}
42
43get_options() {
44 while [ $# -gt 0 ]; do
45 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046 -f|--filter)
47 shift; FILTER=$1
48 ;;
49 -e|--exclude)
50 shift; EXCLUDE=$1
51 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052 -m|--memcheck)
53 MEMCHECK=1
54 ;;
55 -h|--help)
56 print_usage
57 exit 0
58 ;;
59 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020060 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061 print_usage
62 exit 1
63 ;;
64 esac
65 shift
66 done
67}
68
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020069# skip next test if OpenSSL can't send SSLv2 ClientHello
70requires_openssl_with_sslv2() {
71 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020072 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020073 OPENSSL_HAS_SSL2="YES"
74 else
75 OPENSSL_HAS_SSL2="NO"
76 fi
77 fi
78 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020083# skip next test if OpenSSL doesn't support FALLBACK_SCSV
84requires_openssl_with_fallback_scsv() {
85 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
86 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
87 then
88 OPENSSL_HAS_FBSCSV="YES"
89 else
90 OPENSSL_HAS_FBSCSV="NO"
91 fi
92 fi
93 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
94 SKIP_NEXT="YES"
95 fi
96}
97
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020098# skip next test if GnuTLS isn't available
99requires_gnutls() {
100 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
101 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
102 GNUTLS_AVAILABLE="YES"
103 else
104 GNUTLS_AVAILABLE="NO"
105 fi
106 fi
107 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
108 SKIP_NEXT="YES"
109 fi
110}
111
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100112# print_name <name>
113print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100114 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200115 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100116 for i in `seq 1 $LEN`; do printf '.'; done
117 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100118
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200119 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100120}
121
122# fail <message>
123fail() {
124 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100125 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100126
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200127 mv $SRV_OUT o-srv-${TESTS}.log
128 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100129 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100130
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200131 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
132 echo " ! server output:"
133 cat o-srv-${TESTS}.log
134 echo " ! ============================================================"
135 echo " ! client output:"
136 cat o-cli-${TESTS}.log
137 fi
138
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200139 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100140}
141
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100142# is_polar <cmd_line>
143is_polar() {
144 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
145}
146
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100147# has_mem_err <log_file_name>
148has_mem_err() {
149 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
150 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
151 then
152 return 1 # false: does not have errors
153 else
154 return 0 # true: has errors
155 fi
156}
157
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200158# wait for server to start: two versions depending on lsof availability
159wait_server_start() {
160 if which lsof >/dev/null; then
161 # make sure we don't loop forever
162 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
163 WATCHDOG_PID=$!
164
165 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100166 until lsof -nbi TCP:"$PORT" 2>/dev/null | grep LISTEN >/dev/null;
167 do :; done
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200168
169 kill $WATCHDOG_PID
170 wait $WATCHDOG_PID
171 else
172 sleep "$START_DELAY"
173 fi
174}
175
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200176# wait for client to terminate and set CLI_EXIT
177# must be called right after starting the client
178wait_client_done() {
179 CLI_PID=$!
180
181 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
182 WATCHDOG_PID=$!
183
184 wait $CLI_PID
185 CLI_EXIT=$?
186
187 kill $WATCHDOG_PID
188 wait $WATCHDOG_PID
189
190 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
191}
192
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100193# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100194# Options: -s pattern pattern that must be present in server output
195# -c pattern pattern that must be present in client output
196# -S pattern pattern that must be absent in server output
197# -C pattern pattern that must be absent in client output
198run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100199 NAME="$1"
200 SRV_CMD="$2"
201 CLI_CMD="$3"
202 CLI_EXPECT="$4"
203 shift 4
204
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100205 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
206 else
207 return
208 fi
209
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100210 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100211
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200212 # should we skip?
213 if [ "X$SKIP_NEXT" = "XYES" ]; then
214 SKIP_NEXT="NO"
215 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200216 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200217 return
218 fi
219
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100220 # prepend valgrind to our commands if active
221 if [ "$MEMCHECK" -gt 0 ]; then
222 if is_polar "$SRV_CMD"; then
223 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
224 fi
225 if is_polar "$CLI_CMD"; then
226 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
227 fi
228 fi
229
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100230 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200231 echo "$SRV_CMD" > $SRV_OUT
232 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100233 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200234 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200235
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200236 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200237 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
238 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100239
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200240 # kill the server
241 kill $SRV_PID
242 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100243
244 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200245 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100246 # expected client exit to incorrectly succeed in case of catastrophic
247 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100248 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200249 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100250 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100251 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100252 return
253 fi
254 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100255 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200256 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100257 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100258 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100259 return
260 fi
261 fi
262
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100263 # check server exit code
264 if [ $? != 0 ]; then
265 fail "server fail"
266 return
267 fi
268
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100269 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100270 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
271 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100272 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100273 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100274 return
275 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100276
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100277 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200278 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100279 while [ $# -gt 0 ]
280 do
281 case $1 in
282 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200283 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100284 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100285 return
286 fi
287 ;;
288
289 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200290 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100291 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100292 return
293 fi
294 ;;
295
296 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200297 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100298 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100299 return
300 fi
301 ;;
302
303 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200304 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100305 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100306 return
307 fi
308 ;;
309
310 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200311 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100312 exit 1
313 esac
314 shift 2
315 done
316
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100317 # check valgrind's results
318 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200319 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100320 fail "Server has memory errors"
321 return
322 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200323 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100324 fail "Client has memory errors"
325 return
326 fi
327 fi
328
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100329 # if we're here, everything is ok
330 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200331 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100332}
333
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100334cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200335 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200336 kill $SRV_PID >/dev/null 2>&1
337 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100338 exit 1
339}
340
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100341#
342# MAIN
343#
344
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100345get_options "$@"
346
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100347# sanity checks, avoid an avalanche of errors
348if [ ! -x "$P_SRV" ]; then
349 echo "Command '$P_SRV' is not an executable file"
350 exit 1
351fi
352if [ ! -x "$P_CLI" ]; then
353 echo "Command '$P_CLI' is not an executable file"
354 exit 1
355fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100356if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
357 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100358 exit 1
359fi
360
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200361# used by watchdog
362MAIN_PID="$$"
363
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200364# be more patient with valgrind
365if [ "$MEMCHECK" -gt 0 ]; then
366 START_DELAY=3
367 DOG_DELAY=30
368else
369 START_DELAY=1
370 DOG_DELAY=10
371fi
372
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200373# Pick a "unique" port in the range 10000-19999.
374PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200375PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200376
377# fix commands to use this port
378P_SRV="$P_SRV server_port=$PORT"
379P_CLI="$P_CLI server_port=$PORT"
380O_SRV="$O_SRV -accept $PORT"
381O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200382G_SRV="$G_SRV -p $PORT"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100383G_CLI="$G_CLI -p $PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200384
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200385# Also pick a unique name for intermediate files
386SRV_OUT="srv_out.$$"
387CLI_OUT="cli_out.$$"
388SESSION="session.$$"
389
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200390SKIP_NEXT="NO"
391
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100392trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100393
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200394# Basic test
395
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200396# Checks that:
397# - things work with all ciphersuites active (used with config-full in all.sh)
398# - the expected (highest security) parameters are selected
399# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200400run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200401 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200402 "$P_CLI" \
403 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200404 -s "Protocol is TLSv1.2" \
405 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
406 -s "client hello v3, signature_algorithm ext: 6" \
407 -s "ECDHE curve: secp521r1" \
408 -S "error" \
409 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200410
Manuel Pégourié-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 \
417 -s "SSL - The server has no ciphersuites in common"
418
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 \
429 -S "SSL - The server has no ciphersuites in common"
430
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100431# Test for SSLv2 ClientHello
432
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200433requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200434run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100435 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100436 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100437 0 \
438 -S "parse client hello v2" \
439 -S "ssl_handshake returned"
440
441# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200442requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200443run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200444 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100445 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100446 0 \
447 -s "parse client hello v2" \
448 -S "ssl_handshake returned"
449
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100450# Tests for Truncated HMAC extension
451
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100452run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200453 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100454 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100455 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100456 -s "dumping 'computed mac' (20 bytes)" \
457 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100458
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100459run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200460 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100461 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
462 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100463 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100464 -s "dumping 'computed mac' (20 bytes)" \
465 -S "dumping 'computed mac' (10 bytes)"
466
467run_test "Truncated HMAC: client enabled, server default" \
468 "$P_SRV debug_level=4" \
469 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
470 trunc_hmac=1" \
471 0 \
472 -S "dumping 'computed mac' (20 bytes)" \
473 -s "dumping 'computed mac' (10 bytes)"
474
475run_test "Truncated HMAC: client enabled, server disabled" \
476 "$P_SRV debug_level=4 trunc_hmac=0" \
477 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
478 trunc_hmac=1" \
479 0 \
480 -s "dumping 'computed mac' (20 bytes)" \
481 -S "dumping 'computed mac' (10 bytes)"
482
483run_test "Truncated HMAC: client enabled, server enabled" \
484 "$P_SRV debug_level=4 trunc_hmac=1" \
485 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
486 trunc_hmac=1" \
487 0 \
488 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100489 -s "dumping 'computed mac' (10 bytes)"
490
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100491# Tests for Encrypt-then-MAC extension
492
493run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100494 "$P_SRV debug_level=3 \
495 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100496 "$P_CLI debug_level=3" \
497 0 \
498 -c "client hello, adding encrypt_then_mac extension" \
499 -s "found encrypt then mac extension" \
500 -s "server hello, adding encrypt then mac extension" \
501 -c "found encrypt_then_mac extension" \
502 -c "using encrypt then mac" \
503 -s "using encrypt then mac"
504
505run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100506 "$P_SRV debug_level=3 etm=0 \
507 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100508 "$P_CLI debug_level=3 etm=1" \
509 0 \
510 -c "client hello, adding encrypt_then_mac extension" \
511 -s "found encrypt then mac extension" \
512 -S "server hello, adding encrypt then mac extension" \
513 -C "found encrypt_then_mac extension" \
514 -C "using encrypt then mac" \
515 -S "using encrypt then mac"
516
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100517run_test "Encrypt then MAC: client enabled, aead cipher" \
518 "$P_SRV debug_level=3 etm=1 \
519 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
520 "$P_CLI debug_level=3 etm=1" \
521 0 \
522 -c "client hello, adding encrypt_then_mac extension" \
523 -s "found encrypt then mac extension" \
524 -S "server hello, adding encrypt then mac extension" \
525 -C "found encrypt_then_mac extension" \
526 -C "using encrypt then mac" \
527 -S "using encrypt then mac"
528
529run_test "Encrypt then MAC: client enabled, stream cipher" \
530 "$P_SRV debug_level=3 etm=1 \
531 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
532 "$P_CLI debug_level=3 etm=1" \
533 0 \
534 -c "client hello, adding encrypt_then_mac extension" \
535 -s "found encrypt then mac extension" \
536 -S "server hello, adding encrypt then mac extension" \
537 -C "found encrypt_then_mac extension" \
538 -C "using encrypt then mac" \
539 -S "using encrypt then mac"
540
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100541run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100542 "$P_SRV debug_level=3 etm=1 \
543 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100544 "$P_CLI debug_level=3 etm=0" \
545 0 \
546 -C "client hello, adding encrypt_then_mac extension" \
547 -S "found encrypt then mac extension" \
548 -S "server hello, adding encrypt then mac extension" \
549 -C "found encrypt_then_mac extension" \
550 -C "using encrypt then mac" \
551 -S "using encrypt then mac"
552
553run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100554 "$P_SRV debug_level=3 \
555 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100556 "$P_CLI debug_level=3 force_version=ssl3" \
557 0 \
558 -C "client hello, adding encrypt_then_mac extension" \
559 -S "found encrypt then mac extension" \
560 -S "server hello, adding encrypt then mac extension" \
561 -C "found encrypt_then_mac extension" \
562 -C "using encrypt then mac" \
563 -S "using encrypt then mac"
564
565run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100566 "$P_SRV debug_level=3 force_version=ssl3 \
567 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100568 "$P_CLI debug_level=3" \
569 0 \
570 -c "client hello, adding encrypt_then_mac extension" \
571 -s "found encrypt then mac extension" \
572 -S "server hello, adding encrypt then mac extension" \
573 -C "found encrypt_then_mac extension" \
574 -C "using encrypt then mac" \
575 -S "using encrypt then mac"
576
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200577# Tests for Extended Master Secret extension
578
579run_test "Extended Master Secret: default" \
580 "$P_SRV debug_level=3" \
581 "$P_CLI debug_level=3" \
582 0 \
583 -c "client hello, adding extended_master_secret extension" \
584 -s "found extended master secret extension" \
585 -s "server hello, adding extended master secret extension" \
586 -c "found extended_master_secret extension" \
587 -c "using extended master secret" \
588 -s "using extended master secret"
589
590run_test "Extended Master Secret: client enabled, server disabled" \
591 "$P_SRV debug_level=3 extended_ms=0" \
592 "$P_CLI debug_level=3 extended_ms=1" \
593 0 \
594 -c "client hello, adding extended_master_secret extension" \
595 -s "found extended master secret extension" \
596 -S "server hello, adding extended master secret extension" \
597 -C "found extended_master_secret extension" \
598 -C "using extended master secret" \
599 -S "using extended master secret"
600
601run_test "Extended Master Secret: client disabled, server enabled" \
602 "$P_SRV debug_level=3 extended_ms=1" \
603 "$P_CLI debug_level=3 extended_ms=0" \
604 0 \
605 -C "client hello, adding extended_master_secret extension" \
606 -S "found extended master secret extension" \
607 -S "server hello, adding extended master secret extension" \
608 -C "found extended_master_secret extension" \
609 -C "using extended master secret" \
610 -S "using extended master secret"
611
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200612run_test "Extended Master Secret: client SSLv3, server enabled" \
613 "$P_SRV debug_level=3" \
614 "$P_CLI debug_level=3 force_version=ssl3" \
615 0 \
616 -C "client hello, adding extended_master_secret extension" \
617 -S "found extended master secret extension" \
618 -S "server hello, adding extended master secret extension" \
619 -C "found extended_master_secret extension" \
620 -C "using extended master secret" \
621 -S "using extended master secret"
622
623run_test "Extended Master Secret: client enabled, server SSLv3" \
624 "$P_SRV debug_level=3 force_version=ssl3" \
625 "$P_CLI debug_level=3" \
626 0 \
627 -c "client hello, adding extended_master_secret extension" \
628 -s "found extended master secret extension" \
629 -S "server hello, adding extended master secret extension" \
630 -C "found extended_master_secret extension" \
631 -C "using extended master secret" \
632 -S "using extended master secret"
633
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200634# Tests for FALLBACK_SCSV
635
636run_test "Fallback SCSV: default" \
637 "$P_SRV" \
638 "$P_CLI debug_level=3 force_version=tls1_1" \
639 0 \
640 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200641 -S "received FALLBACK_SCSV" \
642 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200643 -C "is a fatal alert message (msg 86)"
644
645run_test "Fallback SCSV: explicitly disabled" \
646 "$P_SRV" \
647 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
648 0 \
649 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200650 -S "received FALLBACK_SCSV" \
651 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200652 -C "is a fatal alert message (msg 86)"
653
654run_test "Fallback SCSV: enabled" \
655 "$P_SRV" \
656 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200657 1 \
658 -c "adding FALLBACK_SCSV" \
659 -s "received FALLBACK_SCSV" \
660 -s "inapropriate fallback" \
661 -c "is a fatal alert message (msg 86)"
662
663run_test "Fallback SCSV: enabled, max version" \
664 "$P_SRV" \
665 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200666 0 \
667 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200668 -s "received FALLBACK_SCSV" \
669 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200670 -C "is a fatal alert message (msg 86)"
671
672requires_openssl_with_fallback_scsv
673run_test "Fallback SCSV: default, openssl server" \
674 "$O_SRV" \
675 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
676 0 \
677 -C "adding FALLBACK_SCSV" \
678 -C "is a fatal alert message (msg 86)"
679
680requires_openssl_with_fallback_scsv
681run_test "Fallback SCSV: enabled, openssl server" \
682 "$O_SRV" \
683 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
684 1 \
685 -c "adding FALLBACK_SCSV" \
686 -c "is a fatal alert message (msg 86)"
687
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200688requires_openssl_with_fallback_scsv
689run_test "Fallback SCSV: disabled, openssl client" \
690 "$P_SRV" \
691 "$O_CLI -tls1_1" \
692 0 \
693 -S "received FALLBACK_SCSV" \
694 -S "inapropriate fallback"
695
696requires_openssl_with_fallback_scsv
697run_test "Fallback SCSV: enabled, openssl client" \
698 "$P_SRV" \
699 "$O_CLI -tls1_1 -fallback_scsv" \
700 1 \
701 -s "received FALLBACK_SCSV" \
702 -s "inapropriate fallback"
703
704requires_openssl_with_fallback_scsv
705run_test "Fallback SCSV: enabled, max version, openssl client" \
706 "$P_SRV" \
707 "$O_CLI -fallback_scsv" \
708 0 \
709 -s "received FALLBACK_SCSV" \
710 -S "inapropriate fallback"
711
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100712# Tests for CBC 1/n-1 record splitting
713
714run_test "CBC Record splitting: TLS 1.2, no splitting" \
715 "$P_SRV" \
716 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
717 request_size=123 force_version=tls1_2" \
718 0 \
719 -s "Read from client: 123 bytes read" \
720 -S "Read from client: 1 bytes read" \
721 -S "122 bytes read"
722
723run_test "CBC Record splitting: TLS 1.1, no splitting" \
724 "$P_SRV" \
725 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
726 request_size=123 force_version=tls1_1" \
727 0 \
728 -s "Read from client: 123 bytes read" \
729 -S "Read from client: 1 bytes read" \
730 -S "122 bytes read"
731
732run_test "CBC Record splitting: TLS 1.0, splitting" \
733 "$P_SRV" \
734 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
735 request_size=123 force_version=tls1" \
736 0 \
737 -S "Read from client: 123 bytes read" \
738 -s "Read from client: 1 bytes read" \
739 -s "122 bytes read"
740
741run_test "CBC Record splitting: SSLv3, splitting" \
742 "$P_SRV" \
743 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
744 request_size=123 force_version=ssl3" \
745 0 \
746 -S "Read from client: 123 bytes read" \
747 -s "Read from client: 1 bytes read" \
748 -s "122 bytes read"
749
750run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
751 "$P_SRV" \
752 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
753 request_size=123 force_version=tls1" \
754 0 \
755 -s "Read from client: 123 bytes read" \
756 -S "Read from client: 1 bytes read" \
757 -S "122 bytes read"
758
759run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
760 "$P_SRV" \
761 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
762 request_size=123 force_version=tls1 recsplit=0" \
763 0 \
764 -s "Read from client: 123 bytes read" \
765 -S "Read from client: 1 bytes read" \
766 -S "122 bytes read"
767
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100768run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
769 "$P_SRV nbio=2" \
770 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
771 request_size=123 force_version=tls1" \
772 0 \
773 -S "Read from client: 123 bytes read" \
774 -s "Read from client: 1 bytes read" \
775 -s "122 bytes read"
776
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100777# Tests for Session Tickets
778
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200779run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200780 "$P_SRV debug_level=3 tickets=1" \
781 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100782 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100783 -c "client hello, adding session ticket extension" \
784 -s "found session ticket extension" \
785 -s "server hello, adding session ticket extension" \
786 -c "found session_ticket extension" \
787 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100788 -S "session successfully restored from cache" \
789 -s "session successfully restored from ticket" \
790 -s "a session has been resumed" \
791 -c "a session has been resumed"
792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200793run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200794 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
795 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100796 0 \
797 -c "client hello, adding session ticket extension" \
798 -s "found session ticket extension" \
799 -s "server hello, adding session ticket extension" \
800 -c "found session_ticket extension" \
801 -c "parse new session ticket" \
802 -S "session successfully restored from cache" \
803 -s "session successfully restored from ticket" \
804 -s "a session has been resumed" \
805 -c "a session has been resumed"
806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200807run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200808 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
809 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100810 0 \
811 -c "client hello, adding session ticket extension" \
812 -s "found session ticket extension" \
813 -s "server hello, adding session ticket extension" \
814 -c "found session_ticket extension" \
815 -c "parse new session ticket" \
816 -S "session successfully restored from cache" \
817 -S "session successfully restored from ticket" \
818 -S "a session has been resumed" \
819 -C "a session has been resumed"
820
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200821run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100822 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200823 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100824 0 \
825 -c "client hello, adding session ticket extension" \
826 -c "found session_ticket extension" \
827 -c "parse new session ticket" \
828 -c "a session has been resumed"
829
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200830run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200831 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200832 "( $O_CLI -sess_out $SESSION; \
833 $O_CLI -sess_in $SESSION; \
834 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100835 0 \
836 -s "found session ticket extension" \
837 -s "server hello, adding session ticket extension" \
838 -S "session successfully restored from cache" \
839 -s "session successfully restored from ticket" \
840 -s "a session has been resumed"
841
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100842# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200844run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200845 "$P_SRV debug_level=3 tickets=0" \
846 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100847 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100848 -c "client hello, adding session ticket extension" \
849 -s "found session ticket extension" \
850 -S "server hello, adding session ticket extension" \
851 -C "found session_ticket extension" \
852 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100853 -s "session successfully restored from cache" \
854 -S "session successfully restored from ticket" \
855 -s "a session has been resumed" \
856 -c "a session has been resumed"
857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200858run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200859 "$P_SRV debug_level=3 tickets=1" \
860 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100861 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100862 -C "client hello, adding session ticket extension" \
863 -S "found session ticket extension" \
864 -S "server hello, adding session ticket extension" \
865 -C "found session_ticket extension" \
866 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100867 -s "session successfully restored from cache" \
868 -S "session successfully restored from ticket" \
869 -s "a session has been resumed" \
870 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100871
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200872run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200873 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
874 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100875 0 \
876 -S "session successfully restored from cache" \
877 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100878 -S "a session has been resumed" \
879 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100880
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200881run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200882 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
883 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100884 0 \
885 -s "session successfully restored from cache" \
886 -S "session successfully restored from ticket" \
887 -s "a session has been resumed" \
888 -c "a session has been resumed"
889
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200890run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200891 "$P_SRV debug_level=3 tickets=0" \
892 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100893 0 \
894 -s "session successfully restored from cache" \
895 -S "session successfully restored from ticket" \
896 -s "a session has been resumed" \
897 -c "a session has been resumed"
898
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200899run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200900 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
901 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100902 0 \
903 -S "session successfully restored from cache" \
904 -S "session successfully restored from ticket" \
905 -S "a session has been resumed" \
906 -C "a session has been resumed"
907
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200908run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200909 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
910 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100911 0 \
912 -s "session successfully restored from cache" \
913 -S "session successfully restored from ticket" \
914 -s "a session has been resumed" \
915 -c "a session has been resumed"
916
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200917run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200918 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200919 "( $O_CLI -sess_out $SESSION; \
920 $O_CLI -sess_in $SESSION; \
921 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100922 0 \
923 -s "found session ticket extension" \
924 -S "server hello, adding session ticket extension" \
925 -s "session successfully restored from cache" \
926 -S "session successfully restored from ticket" \
927 -s "a session has been resumed"
928
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200929run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100930 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200931 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100932 0 \
933 -C "found session_ticket extension" \
934 -C "parse new session ticket" \
935 -c "a session has been resumed"
936
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100937# Tests for Max Fragment Length extension
938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200939run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200940 "$P_SRV debug_level=3" \
941 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100942 0 \
943 -C "client hello, adding max_fragment_length extension" \
944 -S "found max fragment length extension" \
945 -S "server hello, max_fragment_length extension" \
946 -C "found max_fragment_length extension"
947
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200948run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200949 "$P_SRV debug_level=3" \
950 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100951 0 \
952 -c "client hello, adding max_fragment_length extension" \
953 -s "found max fragment length extension" \
954 -s "server hello, max_fragment_length extension" \
955 -c "found max_fragment_length extension"
956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200957run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200958 "$P_SRV debug_level=3 max_frag_len=4096" \
959 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100960 0 \
961 -C "client hello, adding max_fragment_length extension" \
962 -S "found max fragment length extension" \
963 -S "server hello, max_fragment_length extension" \
964 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100965
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200966requires_gnutls
967run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200968 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200969 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200970 0 \
971 -c "client hello, adding max_fragment_length extension" \
972 -c "found max_fragment_length extension"
973
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100974# Tests for renegotiation
975
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200976run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200977 "$P_SRV debug_level=3 exchanges=2" \
978 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100979 0 \
980 -C "client hello, adding renegotiation extension" \
981 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
982 -S "found renegotiation extension" \
983 -s "server hello, secure renegotiation extension" \
984 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100985 -C "=> renegotiate" \
986 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100987 -S "write hello request"
988
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200989run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200990 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
991 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100992 0 \
993 -c "client hello, adding renegotiation extension" \
994 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
995 -s "found renegotiation extension" \
996 -s "server hello, secure renegotiation extension" \
997 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100998 -c "=> renegotiate" \
999 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001000 -S "write hello request"
1001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001002run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001003 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1004 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001005 0 \
1006 -c "client hello, adding renegotiation extension" \
1007 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1008 -s "found renegotiation extension" \
1009 -s "server hello, secure renegotiation extension" \
1010 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001011 -c "=> renegotiate" \
1012 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001013 -s "write hello request"
1014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001015run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001016 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1017 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001018 0 \
1019 -c "client hello, adding renegotiation extension" \
1020 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1021 -s "found renegotiation extension" \
1022 -s "server hello, secure renegotiation extension" \
1023 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001024 -c "=> renegotiate" \
1025 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001026 -s "write hello request"
1027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001028run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001029 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1030 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001031 1 \
1032 -c "client hello, adding renegotiation extension" \
1033 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1034 -S "found renegotiation extension" \
1035 -s "server hello, secure renegotiation extension" \
1036 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001037 -c "=> renegotiate" \
1038 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001039 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001040 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001041 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001042
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001043run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001044 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1045 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001046 0 \
1047 -C "client hello, adding renegotiation extension" \
1048 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1049 -S "found renegotiation extension" \
1050 -s "server hello, secure renegotiation extension" \
1051 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001052 -C "=> renegotiate" \
1053 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001054 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001055 -S "SSL - An unexpected message was received from our peer" \
1056 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001057
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001058run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001059 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001060 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001061 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001062 0 \
1063 -C "client hello, adding renegotiation extension" \
1064 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1065 -S "found renegotiation extension" \
1066 -s "server hello, secure renegotiation extension" \
1067 -c "found renegotiation extension" \
1068 -C "=> renegotiate" \
1069 -S "=> renegotiate" \
1070 -s "write hello request" \
1071 -S "SSL - An unexpected message was received from our peer" \
1072 -S "failed"
1073
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001074# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001075run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001076 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001077 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001078 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001079 0 \
1080 -C "client hello, adding renegotiation extension" \
1081 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1082 -S "found renegotiation extension" \
1083 -s "server hello, secure renegotiation extension" \
1084 -c "found renegotiation extension" \
1085 -C "=> renegotiate" \
1086 -S "=> renegotiate" \
1087 -s "write hello request" \
1088 -S "SSL - An unexpected message was received from our peer" \
1089 -S "failed"
1090
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001091run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001092 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001093 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001094 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001095 0 \
1096 -C "client hello, adding renegotiation extension" \
1097 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1098 -S "found renegotiation extension" \
1099 -s "server hello, secure renegotiation extension" \
1100 -c "found renegotiation extension" \
1101 -C "=> renegotiate" \
1102 -S "=> renegotiate" \
1103 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001104 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001106run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001107 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001108 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001109 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001110 0 \
1111 -c "client hello, adding renegotiation extension" \
1112 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1113 -s "found renegotiation extension" \
1114 -s "server hello, secure renegotiation extension" \
1115 -c "found renegotiation extension" \
1116 -c "=> renegotiate" \
1117 -s "=> renegotiate" \
1118 -s "write hello request" \
1119 -S "SSL - An unexpected message was received from our peer" \
1120 -S "failed"
1121
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001122run_test "Renegotiation: periodic, just below period" \
1123 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1124 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1125 0 \
1126 -C "client hello, adding renegotiation extension" \
1127 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1128 -S "found renegotiation extension" \
1129 -s "server hello, secure renegotiation extension" \
1130 -c "found renegotiation extension" \
1131 -S "record counter limit reached: renegotiate" \
1132 -C "=> renegotiate" \
1133 -S "=> renegotiate" \
1134 -S "write hello request" \
1135 -S "SSL - An unexpected message was received from our peer" \
1136 -S "failed"
1137
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001138# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001139run_test "Renegotiation: periodic, just above period" \
1140 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001141 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001142 0 \
1143 -c "client hello, adding renegotiation extension" \
1144 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1145 -s "found renegotiation extension" \
1146 -s "server hello, secure renegotiation extension" \
1147 -c "found renegotiation extension" \
1148 -s "record counter limit reached: renegotiate" \
1149 -c "=> renegotiate" \
1150 -s "=> renegotiate" \
1151 -s "write hello request" \
1152 -S "SSL - An unexpected message was received from our peer" \
1153 -S "failed"
1154
1155run_test "Renegotiation: periodic, two times period" \
1156 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001157 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001158 0 \
1159 -c "client hello, adding renegotiation extension" \
1160 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1161 -s "found renegotiation extension" \
1162 -s "server hello, secure renegotiation extension" \
1163 -c "found renegotiation extension" \
1164 -s "record counter limit reached: renegotiate" \
1165 -c "=> renegotiate" \
1166 -s "=> renegotiate" \
1167 -s "write hello request" \
1168 -S "SSL - An unexpected message was received from our peer" \
1169 -S "failed"
1170
1171run_test "Renegotiation: periodic, above period, disabled" \
1172 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1173 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1174 0 \
1175 -C "client hello, adding renegotiation extension" \
1176 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1177 -S "found renegotiation extension" \
1178 -s "server hello, secure renegotiation extension" \
1179 -c "found renegotiation extension" \
1180 -S "record counter limit reached: renegotiate" \
1181 -C "=> renegotiate" \
1182 -S "=> renegotiate" \
1183 -S "write hello request" \
1184 -S "SSL - An unexpected message was received from our peer" \
1185 -S "failed"
1186
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001187run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001188 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1189 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001190 0 \
1191 -c "client hello, adding renegotiation extension" \
1192 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1193 -s "found renegotiation extension" \
1194 -s "server hello, secure renegotiation extension" \
1195 -c "found renegotiation extension" \
1196 -c "=> renegotiate" \
1197 -s "=> renegotiate" \
1198 -S "write hello request"
1199
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001200run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001201 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1202 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001203 0 \
1204 -c "client hello, adding renegotiation extension" \
1205 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1206 -s "found renegotiation extension" \
1207 -s "server hello, secure renegotiation extension" \
1208 -c "found renegotiation extension" \
1209 -c "=> renegotiate" \
1210 -s "=> renegotiate" \
1211 -s "write hello request"
1212
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001213run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001214 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001215 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001216 0 \
1217 -c "client hello, adding renegotiation extension" \
1218 -c "found renegotiation extension" \
1219 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001220 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001221 -C "error" \
1222 -c "HTTP/1.0 200 [Oo][Kk]"
1223
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001224run_test "Renegotiation: gnutls server strict, client-initiated" \
1225 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001226 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001227 0 \
1228 -c "client hello, adding renegotiation extension" \
1229 -c "found renegotiation extension" \
1230 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001231 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001232 -C "error" \
1233 -c "HTTP/1.0 200 [Oo][Kk]"
1234
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001235run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1236 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1237 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1238 1 \
1239 -c "client hello, adding renegotiation extension" \
1240 -C "found renegotiation extension" \
1241 -c "=> renegotiate" \
1242 -c "ssl_handshake() returned" \
1243 -c "error" \
1244 -C "HTTP/1.0 200 [Oo][Kk]"
1245
1246run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1247 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1248 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1249 allow_legacy=0" \
1250 1 \
1251 -c "client hello, adding renegotiation extension" \
1252 -C "found renegotiation extension" \
1253 -c "=> renegotiate" \
1254 -c "ssl_handshake() returned" \
1255 -c "error" \
1256 -C "HTTP/1.0 200 [Oo][Kk]"
1257
1258run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1259 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1260 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1261 allow_legacy=1" \
1262 0 \
1263 -c "client hello, adding renegotiation extension" \
1264 -C "found renegotiation extension" \
1265 -c "=> renegotiate" \
1266 -C "ssl_hanshake() returned" \
1267 -C "error" \
1268 -c "HTTP/1.0 200 [Oo][Kk]"
1269
1270# Test for the "secure renegotation" extension only (no actual renegotiation)
1271
1272run_test "Renego ext: gnutls server strict, client default" \
1273 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1274 "$P_CLI debug_level=3" \
1275 0 \
1276 -c "found renegotiation extension" \
1277 -C "error" \
1278 -c "HTTP/1.0 200 [Oo][Kk]"
1279
1280run_test "Renego ext: gnutls server unsafe, client default" \
1281 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1282 "$P_CLI debug_level=3" \
1283 0 \
1284 -C "found renegotiation extension" \
1285 -C "error" \
1286 -c "HTTP/1.0 200 [Oo][Kk]"
1287
1288run_test "Renego ext: gnutls server unsafe, client break legacy" \
1289 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1290 "$P_CLI debug_level=3 allow_legacy=-1" \
1291 1 \
1292 -C "found renegotiation extension" \
1293 -c "error" \
1294 -C "HTTP/1.0 200 [Oo][Kk]"
1295
1296run_test "Renego ext: gnutls client strict, server default" \
1297 "$P_SRV debug_level=3" \
1298 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1299 0 \
1300 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1301 -s "server hello, secure renegotiation extension"
1302
1303run_test "Renego ext: gnutls client unsafe, server default" \
1304 "$P_SRV debug_level=3" \
1305 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1306 0 \
1307 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1308 -S "server hello, secure renegotiation extension"
1309
1310run_test "Renego ext: gnutls client unsafe, server break legacy" \
1311 "$P_SRV debug_level=3 allow_legacy=-1" \
1312 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1313 1 \
1314 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1315 -S "server hello, secure renegotiation extension"
1316
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001317# Tests for auth_mode
1318
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001319run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001320 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001321 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001322 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001323 1 \
1324 -c "x509_verify_cert() returned" \
1325 -c "! self-signed or not signed by a trusted CA" \
1326 -c "! ssl_handshake returned" \
1327 -c "X509 - Certificate verification failed"
1328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001329run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001330 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001331 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001332 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001333 0 \
1334 -c "x509_verify_cert() returned" \
1335 -c "! self-signed or not signed by a trusted CA" \
1336 -C "! ssl_handshake returned" \
1337 -C "X509 - Certificate verification failed"
1338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001339run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001340 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001341 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001342 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001343 0 \
1344 -C "x509_verify_cert() returned" \
1345 -C "! self-signed or not signed by a trusted CA" \
1346 -C "! ssl_handshake returned" \
1347 -C "X509 - Certificate verification failed"
1348
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001349run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001350 "$P_SRV debug_level=3 auth_mode=required" \
1351 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001352 key_file=data_files/server5.key" \
1353 1 \
1354 -S "skip write certificate request" \
1355 -C "skip parse certificate request" \
1356 -c "got a certificate request" \
1357 -C "skip write certificate" \
1358 -C "skip write certificate verify" \
1359 -S "skip parse certificate verify" \
1360 -s "x509_verify_cert() returned" \
1361 -S "! self-signed or not signed by a trusted CA" \
1362 -s "! ssl_handshake returned" \
1363 -c "! ssl_handshake returned" \
1364 -s "X509 - Certificate verification failed"
1365
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001366run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001367 "$P_SRV debug_level=3 auth_mode=optional" \
1368 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001369 key_file=data_files/server5.key" \
1370 0 \
1371 -S "skip write certificate request" \
1372 -C "skip parse certificate request" \
1373 -c "got a certificate request" \
1374 -C "skip write certificate" \
1375 -C "skip write certificate verify" \
1376 -S "skip parse certificate verify" \
1377 -s "x509_verify_cert() returned" \
1378 -s "! self-signed or not signed by a trusted CA" \
1379 -S "! ssl_handshake returned" \
1380 -C "! ssl_handshake returned" \
1381 -S "X509 - Certificate verification failed"
1382
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001383run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001384 "$P_SRV debug_level=3 auth_mode=none" \
1385 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001386 key_file=data_files/server5.key" \
1387 0 \
1388 -s "skip write certificate request" \
1389 -C "skip parse certificate request" \
1390 -c "got no certificate request" \
1391 -c "skip write certificate" \
1392 -c "skip write certificate verify" \
1393 -s "skip parse certificate verify" \
1394 -S "x509_verify_cert() returned" \
1395 -S "! self-signed or not signed by a trusted CA" \
1396 -S "! ssl_handshake returned" \
1397 -C "! ssl_handshake returned" \
1398 -S "X509 - Certificate verification failed"
1399
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001400run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001401 "$P_SRV debug_level=3 auth_mode=optional" \
1402 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001403 0 \
1404 -S "skip write certificate request" \
1405 -C "skip parse certificate request" \
1406 -c "got a certificate request" \
1407 -C "skip write certificate$" \
1408 -C "got no certificate to send" \
1409 -S "SSLv3 client has no certificate" \
1410 -c "skip write certificate verify" \
1411 -s "skip parse certificate verify" \
1412 -s "! no client certificate sent" \
1413 -S "! ssl_handshake returned" \
1414 -C "! ssl_handshake returned" \
1415 -S "X509 - Certificate verification failed"
1416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001417run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001418 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001419 "$O_CLI" \
1420 0 \
1421 -S "skip write certificate request" \
1422 -s "skip parse certificate verify" \
1423 -s "! no client certificate sent" \
1424 -S "! ssl_handshake returned" \
1425 -S "X509 - Certificate verification failed"
1426
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001427run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001428 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001429 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001430 0 \
1431 -C "skip parse certificate request" \
1432 -c "got a certificate request" \
1433 -C "skip write certificate$" \
1434 -c "skip write certificate verify" \
1435 -C "! ssl_handshake returned"
1436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001437run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001438 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001439 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001440 0 \
1441 -S "skip write certificate request" \
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 "got no certificate to send" \
1447 -s "SSLv3 client has no certificate" \
1448 -s "skip parse certificate verify" \
1449 -s "! no client certificate sent" \
1450 -S "! ssl_handshake returned" \
1451 -C "! ssl_handshake returned" \
1452 -S "X509 - Certificate verification failed"
1453
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001454# Tests for certificate selection based on SHA verson
1455
1456run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1457 "$P_SRV crt_file=data_files/server5.crt \
1458 key_file=data_files/server5.key \
1459 crt_file2=data_files/server5-sha1.crt \
1460 key_file2=data_files/server5.key" \
1461 "$P_CLI force_version=tls1_2" \
1462 0 \
1463 -c "signed using.*ECDSA with SHA256" \
1464 -C "signed using.*ECDSA with SHA1"
1465
1466run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1467 "$P_SRV crt_file=data_files/server5.crt \
1468 key_file=data_files/server5.key \
1469 crt_file2=data_files/server5-sha1.crt \
1470 key_file2=data_files/server5.key" \
1471 "$P_CLI force_version=tls1_1" \
1472 0 \
1473 -C "signed using.*ECDSA with SHA256" \
1474 -c "signed using.*ECDSA with SHA1"
1475
1476run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1477 "$P_SRV crt_file=data_files/server5.crt \
1478 key_file=data_files/server5.key \
1479 crt_file2=data_files/server5-sha1.crt \
1480 key_file2=data_files/server5.key" \
1481 "$P_CLI force_version=tls1" \
1482 0 \
1483 -C "signed using.*ECDSA with SHA256" \
1484 -c "signed using.*ECDSA with SHA1"
1485
1486run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1487 "$P_SRV crt_file=data_files/server5.crt \
1488 key_file=data_files/server5.key \
1489 crt_file2=data_files/server6.crt \
1490 key_file2=data_files/server6.key" \
1491 "$P_CLI force_version=tls1_1" \
1492 0 \
1493 -c "serial number.*09" \
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 2)" \
1498 "$P_SRV crt_file=data_files/server6.crt \
1499 key_file=data_files/server6.key \
1500 crt_file2=data_files/server5.crt \
1501 key_file2=data_files/server5.key" \
1502 "$P_CLI force_version=tls1_1" \
1503 0 \
1504 -c "serial number.*0A" \
1505 -c "signed using.*ECDSA with SHA256" \
1506 -C "signed using.*ECDSA with SHA1"
1507
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001508# tests for SNI
1509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001510run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001511 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001512 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001513 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001514 server_name=localhost" \
1515 0 \
1516 -S "parse ServerName extension" \
1517 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1518 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001520run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001521 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001522 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001523 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 +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 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 2" \
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é-Gonnard76b8ab72014-03-26 09:31:35 +01001536 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001537 0 \
1538 -s "parse ServerName extension" \
1539 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001540 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001542run_test "SNI: no matching cert" \
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=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001548 1 \
1549 -s "parse ServerName extension" \
1550 -s "ssl_sni_wrapper() returned" \
1551 -s "ssl_handshake returned" \
1552 -c "ssl_handshake returned" \
1553 -c "SSL - A fatal alert message was received from our peer"
1554
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001555# Tests for non-blocking I/O: exercise a variety of handshake flows
1556
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001557run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001558 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1559 "$P_CLI nbio=2 tickets=0" \
1560 0 \
1561 -S "ssl_handshake returned" \
1562 -C "ssl_handshake returned" \
1563 -c "Read from server: .* bytes read"
1564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001565run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001566 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1567 "$P_CLI nbio=2 tickets=0" \
1568 0 \
1569 -S "ssl_handshake returned" \
1570 -C "ssl_handshake returned" \
1571 -c "Read from server: .* bytes read"
1572
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001573run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001574 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1575 "$P_CLI nbio=2 tickets=1" \
1576 0 \
1577 -S "ssl_handshake returned" \
1578 -C "ssl_handshake returned" \
1579 -c "Read from server: .* bytes read"
1580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001581run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001582 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1583 "$P_CLI nbio=2 tickets=1" \
1584 0 \
1585 -S "ssl_handshake returned" \
1586 -C "ssl_handshake returned" \
1587 -c "Read from server: .* bytes read"
1588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001589run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001590 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1591 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1592 0 \
1593 -S "ssl_handshake returned" \
1594 -C "ssl_handshake returned" \
1595 -c "Read from server: .* bytes read"
1596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001597run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001598 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1599 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1600 0 \
1601 -S "ssl_handshake returned" \
1602 -C "ssl_handshake returned" \
1603 -c "Read from server: .* bytes read"
1604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001605run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001606 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1607 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1608 0 \
1609 -S "ssl_handshake returned" \
1610 -C "ssl_handshake returned" \
1611 -c "Read from server: .* bytes read"
1612
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001613# Tests for version negotiation
1614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001615run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001616 "$P_SRV" \
1617 "$P_CLI" \
1618 0 \
1619 -S "ssl_handshake returned" \
1620 -C "ssl_handshake returned" \
1621 -s "Protocol is TLSv1.2" \
1622 -c "Protocol is TLSv1.2"
1623
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001624run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001625 "$P_SRV" \
1626 "$P_CLI max_version=tls1_1" \
1627 0 \
1628 -S "ssl_handshake returned" \
1629 -C "ssl_handshake returned" \
1630 -s "Protocol is TLSv1.1" \
1631 -c "Protocol is TLSv1.1"
1632
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001633run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001634 "$P_SRV max_version=tls1_1" \
1635 "$P_CLI" \
1636 0 \
1637 -S "ssl_handshake returned" \
1638 -C "ssl_handshake returned" \
1639 -s "Protocol is TLSv1.1" \
1640 -c "Protocol is TLSv1.1"
1641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001642run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001643 "$P_SRV max_version=tls1_1" \
1644 "$P_CLI max_version=tls1_1" \
1645 0 \
1646 -S "ssl_handshake returned" \
1647 -C "ssl_handshake returned" \
1648 -s "Protocol is TLSv1.1" \
1649 -c "Protocol is TLSv1.1"
1650
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001651run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001652 "$P_SRV min_version=tls1_1" \
1653 "$P_CLI max_version=tls1_1" \
1654 0 \
1655 -S "ssl_handshake returned" \
1656 -C "ssl_handshake returned" \
1657 -s "Protocol is TLSv1.1" \
1658 -c "Protocol is TLSv1.1"
1659
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001660run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001661 "$P_SRV max_version=tls1_1" \
1662 "$P_CLI min_version=tls1_1" \
1663 0 \
1664 -S "ssl_handshake returned" \
1665 -C "ssl_handshake returned" \
1666 -s "Protocol is TLSv1.1" \
1667 -c "Protocol is TLSv1.1"
1668
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001669run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001670 "$P_SRV max_version=tls1_1" \
1671 "$P_CLI min_version=tls1_2" \
1672 1 \
1673 -s "ssl_handshake returned" \
1674 -c "ssl_handshake returned" \
1675 -c "SSL - Handshake protocol not within min/max boundaries"
1676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001677run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001678 "$P_SRV min_version=tls1_2" \
1679 "$P_CLI max_version=tls1_1" \
1680 1 \
1681 -s "ssl_handshake returned" \
1682 -c "ssl_handshake returned" \
1683 -s "SSL - Handshake protocol not within min/max boundaries"
1684
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001685# Tests for ALPN extension
1686
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001687if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1688
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001689run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001690 "$P_SRV debug_level=3" \
1691 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001692 0 \
1693 -C "client hello, adding alpn extension" \
1694 -S "found alpn extension" \
1695 -C "got an alert message, type: \\[2:120]" \
1696 -S "server hello, adding alpn extension" \
1697 -C "found alpn extension " \
1698 -C "Application Layer Protocol is" \
1699 -S "Application Layer Protocol is"
1700
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001701run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001702 "$P_SRV debug_level=3" \
1703 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001704 0 \
1705 -c "client hello, adding alpn extension" \
1706 -s "found alpn extension" \
1707 -C "got an alert message, type: \\[2:120]" \
1708 -S "server hello, adding alpn extension" \
1709 -C "found alpn extension " \
1710 -c "Application Layer Protocol is (none)" \
1711 -S "Application Layer Protocol is"
1712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001713run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001714 "$P_SRV debug_level=3 alpn=abc,1234" \
1715 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001716 0 \
1717 -C "client hello, adding alpn extension" \
1718 -S "found alpn extension" \
1719 -C "got an alert message, type: \\[2:120]" \
1720 -S "server hello, adding alpn extension" \
1721 -C "found alpn extension " \
1722 -C "Application Layer Protocol is" \
1723 -s "Application Layer Protocol is (none)"
1724
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001725run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001726 "$P_SRV debug_level=3 alpn=abc,1234" \
1727 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001728 0 \
1729 -c "client hello, adding alpn extension" \
1730 -s "found alpn extension" \
1731 -C "got an alert message, type: \\[2:120]" \
1732 -s "server hello, adding alpn extension" \
1733 -c "found alpn extension" \
1734 -c "Application Layer Protocol is abc" \
1735 -s "Application Layer Protocol is abc"
1736
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001737run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001738 "$P_SRV debug_level=3 alpn=abc,1234" \
1739 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001740 0 \
1741 -c "client hello, adding alpn extension" \
1742 -s "found alpn extension" \
1743 -C "got an alert message, type: \\[2:120]" \
1744 -s "server hello, adding alpn extension" \
1745 -c "found alpn extension" \
1746 -c "Application Layer Protocol is abc" \
1747 -s "Application Layer Protocol is abc"
1748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001749run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001750 "$P_SRV debug_level=3 alpn=abc,1234" \
1751 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001752 0 \
1753 -c "client hello, adding alpn extension" \
1754 -s "found alpn extension" \
1755 -C "got an alert message, type: \\[2:120]" \
1756 -s "server hello, adding alpn extension" \
1757 -c "found alpn extension" \
1758 -c "Application Layer Protocol is 1234" \
1759 -s "Application Layer Protocol is 1234"
1760
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001761run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001762 "$P_SRV debug_level=3 alpn=abc,123" \
1763 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001764 1 \
1765 -c "client hello, adding alpn extension" \
1766 -s "found alpn extension" \
1767 -c "got an alert message, type: \\[2:120]" \
1768 -S "server hello, adding alpn extension" \
1769 -C "found alpn extension" \
1770 -C "Application Layer Protocol is 1234" \
1771 -S "Application Layer Protocol is 1234"
1772
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001773fi
1774
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001775# Tests for keyUsage in leaf certificates, part 1:
1776# server-side certificate/suite selection
1777
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001778run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001779 "$P_SRV key_file=data_files/server2.key \
1780 crt_file=data_files/server2.ku-ds.crt" \
1781 "$P_CLI" \
1782 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001783 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001784
1785
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001786run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001787 "$P_SRV key_file=data_files/server2.key \
1788 crt_file=data_files/server2.ku-ke.crt" \
1789 "$P_CLI" \
1790 0 \
1791 -c "Ciphersuite is TLS-RSA-WITH-"
1792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001793run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001794 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001795 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001796 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001797 1 \
1798 -C "Ciphersuite is "
1799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001800run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001801 "$P_SRV key_file=data_files/server5.key \
1802 crt_file=data_files/server5.ku-ds.crt" \
1803 "$P_CLI" \
1804 0 \
1805 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1806
1807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001808run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001809 "$P_SRV key_file=data_files/server5.key \
1810 crt_file=data_files/server5.ku-ka.crt" \
1811 "$P_CLI" \
1812 0 \
1813 -c "Ciphersuite is TLS-ECDH-"
1814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001815run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001816 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001817 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001818 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001819 1 \
1820 -C "Ciphersuite is "
1821
1822# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001823# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001825run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001826 "$O_SRV -key data_files/server2.key \
1827 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001828 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001829 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1830 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001831 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001832 -C "Processing of the Certificate handshake message failed" \
1833 -c "Ciphersuite is TLS-"
1834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001835run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001836 "$O_SRV -key data_files/server2.key \
1837 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001838 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001839 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1840 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001841 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001842 -C "Processing of the Certificate handshake message failed" \
1843 -c "Ciphersuite is TLS-"
1844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001845run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001846 "$O_SRV -key data_files/server2.key \
1847 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001848 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001849 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1850 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001851 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001852 -C "Processing of the Certificate handshake message failed" \
1853 -c "Ciphersuite is TLS-"
1854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001855run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001856 "$O_SRV -key data_files/server2.key \
1857 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001858 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001859 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1860 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001861 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001862 -c "Processing of the Certificate handshake message failed" \
1863 -C "Ciphersuite is TLS-"
1864
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001865run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001866 "$O_SRV -key data_files/server2.key \
1867 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001868 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001869 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1870 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001871 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001872 -C "Processing of the Certificate handshake message failed" \
1873 -c "Ciphersuite is TLS-"
1874
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001875run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001876 "$O_SRV -key data_files/server2.key \
1877 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001878 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001879 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1880 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001881 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001882 -c "Processing of the Certificate handshake message failed" \
1883 -C "Ciphersuite is TLS-"
1884
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001885# Tests for keyUsage in leaf certificates, part 3:
1886# server-side checking of client cert
1887
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001888run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001889 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001890 "$O_CLI -key data_files/server2.key \
1891 -cert data_files/server2.ku-ds.crt" \
1892 0 \
1893 -S "bad certificate (usage extensions)" \
1894 -S "Processing of the Certificate handshake message failed"
1895
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001896run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001897 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001898 "$O_CLI -key data_files/server2.key \
1899 -cert data_files/server2.ku-ke.crt" \
1900 0 \
1901 -s "bad certificate (usage extensions)" \
1902 -S "Processing of the Certificate handshake message failed"
1903
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001904run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001905 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001906 "$O_CLI -key data_files/server2.key \
1907 -cert data_files/server2.ku-ke.crt" \
1908 1 \
1909 -s "bad certificate (usage extensions)" \
1910 -s "Processing of the Certificate handshake message failed"
1911
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001912run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001913 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001914 "$O_CLI -key data_files/server5.key \
1915 -cert data_files/server5.ku-ds.crt" \
1916 0 \
1917 -S "bad certificate (usage extensions)" \
1918 -S "Processing of the Certificate handshake message failed"
1919
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001920run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001921 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001922 "$O_CLI -key data_files/server5.key \
1923 -cert data_files/server5.ku-ka.crt" \
1924 0 \
1925 -s "bad certificate (usage extensions)" \
1926 -S "Processing of the Certificate handshake message failed"
1927
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001928# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001930run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001931 "$P_SRV key_file=data_files/server5.key \
1932 crt_file=data_files/server5.eku-srv.crt" \
1933 "$P_CLI" \
1934 0
1935
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001936run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001937 "$P_SRV key_file=data_files/server5.key \
1938 crt_file=data_files/server5.eku-srv.crt" \
1939 "$P_CLI" \
1940 0
1941
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001942run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001943 "$P_SRV key_file=data_files/server5.key \
1944 crt_file=data_files/server5.eku-cs_any.crt" \
1945 "$P_CLI" \
1946 0
1947
1948# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001949run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001950 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1951 crt_file=data_files/server5.eku-cli.crt" \
1952 "$P_CLI psk=badbad" \
1953 1
1954
1955# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001957run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001958 "$O_SRV -key data_files/server5.key \
1959 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001960 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001961 0 \
1962 -C "bad certificate (usage extensions)" \
1963 -C "Processing of the Certificate handshake message failed" \
1964 -c "Ciphersuite is TLS-"
1965
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001966run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001967 "$O_SRV -key data_files/server5.key \
1968 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001969 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001970 0 \
1971 -C "bad certificate (usage extensions)" \
1972 -C "Processing of the Certificate handshake message failed" \
1973 -c "Ciphersuite is TLS-"
1974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001975run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001976 "$O_SRV -key data_files/server5.key \
1977 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001978 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001979 0 \
1980 -C "bad certificate (usage extensions)" \
1981 -C "Processing of the Certificate handshake message failed" \
1982 -c "Ciphersuite is TLS-"
1983
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001984run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001985 "$O_SRV -key data_files/server5.key \
1986 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001987 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001988 1 \
1989 -c "bad certificate (usage extensions)" \
1990 -c "Processing of the Certificate handshake message failed" \
1991 -C "Ciphersuite is TLS-"
1992
1993# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001995run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001996 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001997 "$O_CLI -key data_files/server5.key \
1998 -cert data_files/server5.eku-cli.crt" \
1999 0 \
2000 -S "bad certificate (usage extensions)" \
2001 -S "Processing of the Certificate handshake message failed"
2002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002003run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002004 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002005 "$O_CLI -key data_files/server5.key \
2006 -cert data_files/server5.eku-srv_cli.crt" \
2007 0 \
2008 -S "bad certificate (usage extensions)" \
2009 -S "Processing of the Certificate handshake message failed"
2010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002011run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002012 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002013 "$O_CLI -key data_files/server5.key \
2014 -cert data_files/server5.eku-cs_any.crt" \
2015 0 \
2016 -S "bad certificate (usage extensions)" \
2017 -S "Processing of the Certificate handshake message failed"
2018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002019run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002020 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002021 "$O_CLI -key data_files/server5.key \
2022 -cert data_files/server5.eku-cs.crt" \
2023 0 \
2024 -s "bad certificate (usage extensions)" \
2025 -S "Processing of the Certificate handshake message failed"
2026
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002027run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002028 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002029 "$O_CLI -key data_files/server5.key \
2030 -cert data_files/server5.eku-cs.crt" \
2031 1 \
2032 -s "bad certificate (usage extensions)" \
2033 -s "Processing of the Certificate handshake message failed"
2034
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002035# Tests for DHM parameters loading
2036
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002037run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002038 "$P_SRV" \
2039 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2040 debug_level=3" \
2041 0 \
2042 -c "value of 'DHM: P ' (2048 bits)" \
2043 -c "value of 'DHM: G ' (2048 bits)"
2044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002045run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002046 "$P_SRV dhm_file=data_files/dhparams.pem" \
2047 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2048 debug_level=3" \
2049 0 \
2050 -c "value of 'DHM: P ' (1024 bits)" \
2051 -c "value of 'DHM: G ' (2 bits)"
2052
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002053# Tests for PSK callback
2054
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002055run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002056 "$P_SRV psk=abc123 psk_identity=foo" \
2057 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2058 psk_identity=foo psk=abc123" \
2059 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002060 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002061 -S "SSL - Unknown identity received" \
2062 -S "SSL - Verification of the message MAC failed"
2063
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002064run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002065 "$P_SRV" \
2066 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2067 psk_identity=foo psk=abc123" \
2068 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002069 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002070 -S "SSL - Unknown identity received" \
2071 -S "SSL - Verification of the message MAC failed"
2072
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002073run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002074 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2075 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2076 psk_identity=foo psk=abc123" \
2077 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002078 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002079 -s "SSL - Unknown identity received" \
2080 -S "SSL - Verification of the message MAC failed"
2081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002082run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002083 "$P_SRV psk_list=abc,dead,def,beef" \
2084 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2085 psk_identity=abc psk=dead" \
2086 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002087 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002088 -S "SSL - Unknown identity received" \
2089 -S "SSL - Verification of the message MAC failed"
2090
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002091run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002092 "$P_SRV psk_list=abc,dead,def,beef" \
2093 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2094 psk_identity=def psk=beef" \
2095 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002096 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002097 -S "SSL - Unknown identity received" \
2098 -S "SSL - Verification of the message MAC failed"
2099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002100run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002101 "$P_SRV psk_list=abc,dead,def,beef" \
2102 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2103 psk_identity=ghi psk=beef" \
2104 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002105 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002106 -s "SSL - Unknown identity received" \
2107 -S "SSL - Verification of the message MAC failed"
2108
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002109run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002110 "$P_SRV psk_list=abc,dead,def,beef" \
2111 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2112 psk_identity=abc psk=beef" \
2113 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002114 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002115 -S "SSL - Unknown identity received" \
2116 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002117
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002118# Tests for ciphersuites per version
2119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002120run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002121 "$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 +02002122 "$P_CLI force_version=ssl3" \
2123 0 \
2124 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2125
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002126run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002127 "$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" \
2128 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002129 0 \
2130 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002132run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002133 "$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" \
2134 "$P_CLI force_version=tls1_1" \
2135 0 \
2136 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002138run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002139 "$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" \
2140 "$P_CLI force_version=tls1_2" \
2141 0 \
2142 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2143
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002144# Tests for ssl_get_bytes_avail()
2145
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002146run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002147 "$P_SRV" \
2148 "$P_CLI request_size=100" \
2149 0 \
2150 -s "Read from client: 100 bytes read$"
2151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002152run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002153 "$P_SRV" \
2154 "$P_CLI request_size=500" \
2155 0 \
2156 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002157
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002158# Tests for small packets
2159
2160run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002161 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002162 "$P_CLI request_size=1 force_version=ssl3 \
2163 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2164 0 \
2165 -s "Read from client: 1 bytes read"
2166
2167run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002168 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002169 "$P_CLI request_size=1 force_version=ssl3 \
2170 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2171 0 \
2172 -s "Read from client: 1 bytes read"
2173
2174run_test "Small packet TLS 1.0 BlockCipher" \
2175 "$P_SRV" \
2176 "$P_CLI request_size=1 force_version=tls1 \
2177 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2178 0 \
2179 -s "Read from client: 1 bytes read"
2180
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002181run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2182 "$P_SRV" \
2183 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2184 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2185 0 \
2186 -s "Read from client: 1 bytes read"
2187
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002188run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2189 "$P_SRV" \
2190 "$P_CLI request_size=1 force_version=tls1 \
2191 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2192 trunc_hmac=1" \
2193 0 \
2194 -s "Read from client: 1 bytes read"
2195
2196run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002197 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002198 "$P_CLI request_size=1 force_version=tls1 \
2199 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2200 trunc_hmac=1" \
2201 0 \
2202 -s "Read from client: 1 bytes read"
2203
2204run_test "Small packet TLS 1.1 BlockCipher" \
2205 "$P_SRV" \
2206 "$P_CLI request_size=1 force_version=tls1_1 \
2207 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2208 0 \
2209 -s "Read from client: 1 bytes read"
2210
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002211run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2212 "$P_SRV" \
2213 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2214 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2215 0 \
2216 -s "Read from client: 1 bytes read"
2217
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002218run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002219 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002220 "$P_CLI request_size=1 force_version=tls1_1 \
2221 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2222 0 \
2223 -s "Read from client: 1 bytes read"
2224
2225run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2226 "$P_SRV" \
2227 "$P_CLI request_size=1 force_version=tls1_1 \
2228 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2229 trunc_hmac=1" \
2230 0 \
2231 -s "Read from client: 1 bytes read"
2232
2233run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002234 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002235 "$P_CLI request_size=1 force_version=tls1_1 \
2236 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2237 trunc_hmac=1" \
2238 0 \
2239 -s "Read from client: 1 bytes read"
2240
2241run_test "Small packet TLS 1.2 BlockCipher" \
2242 "$P_SRV" \
2243 "$P_CLI request_size=1 force_version=tls1_2 \
2244 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2245 0 \
2246 -s "Read from client: 1 bytes read"
2247
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002248run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2249 "$P_SRV" \
2250 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2251 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2252 0 \
2253 -s "Read from client: 1 bytes read"
2254
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002255run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2256 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002257 "$P_CLI request_size=1 force_version=tls1_2 \
2258 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002259 0 \
2260 -s "Read from client: 1 bytes read"
2261
2262run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2263 "$P_SRV" \
2264 "$P_CLI request_size=1 force_version=tls1_2 \
2265 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2266 trunc_hmac=1" \
2267 0 \
2268 -s "Read from client: 1 bytes read"
2269
2270run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002271 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002272 "$P_CLI request_size=1 force_version=tls1_2 \
2273 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2274 0 \
2275 -s "Read from client: 1 bytes read"
2276
2277run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002278 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002279 "$P_CLI request_size=1 force_version=tls1_2 \
2280 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2281 trunc_hmac=1" \
2282 0 \
2283 -s "Read from client: 1 bytes read"
2284
2285run_test "Small packet TLS 1.2 AEAD" \
2286 "$P_SRV" \
2287 "$P_CLI request_size=1 force_version=tls1_2 \
2288 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2289 0 \
2290 -s "Read from client: 1 bytes read"
2291
2292run_test "Small packet TLS 1.2 AEAD shorter tag" \
2293 "$P_SRV" \
2294 "$P_CLI request_size=1 force_version=tls1_2 \
2295 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2296 0 \
2297 -s "Read from client: 1 bytes read"
2298
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002299# Test for large packets
2300
2301run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002302 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002303 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002304 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2305 0 \
2306 -s "Read from client: 16384 bytes read"
2307
2308run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002309 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002310 "$P_CLI request_size=16384 force_version=ssl3 \
2311 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2312 0 \
2313 -s "Read from client: 16384 bytes read"
2314
2315run_test "Large packet TLS 1.0 BlockCipher" \
2316 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002317 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002318 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2319 0 \
2320 -s "Read from client: 16384 bytes read"
2321
2322run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2323 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002324 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002325 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2326 trunc_hmac=1" \
2327 0 \
2328 -s "Read from client: 16384 bytes read"
2329
2330run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002331 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002332 "$P_CLI request_size=16384 force_version=tls1 \
2333 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2334 trunc_hmac=1" \
2335 0 \
2336 -s "Read from client: 16384 bytes read"
2337
2338run_test "Large packet TLS 1.1 BlockCipher" \
2339 "$P_SRV" \
2340 "$P_CLI request_size=16384 force_version=tls1_1 \
2341 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2342 0 \
2343 -s "Read from client: 16384 bytes read"
2344
2345run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002346 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002347 "$P_CLI request_size=16384 force_version=tls1_1 \
2348 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2349 0 \
2350 -s "Read from client: 16384 bytes read"
2351
2352run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2353 "$P_SRV" \
2354 "$P_CLI request_size=16384 force_version=tls1_1 \
2355 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2356 trunc_hmac=1" \
2357 0 \
2358 -s "Read from client: 16384 bytes read"
2359
2360run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002361 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002362 "$P_CLI request_size=16384 force_version=tls1_1 \
2363 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2364 trunc_hmac=1" \
2365 0 \
2366 -s "Read from client: 16384 bytes read"
2367
2368run_test "Large packet TLS 1.2 BlockCipher" \
2369 "$P_SRV" \
2370 "$P_CLI request_size=16384 force_version=tls1_2 \
2371 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2372 0 \
2373 -s "Read from client: 16384 bytes read"
2374
2375run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2376 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002377 "$P_CLI request_size=16384 force_version=tls1_2 \
2378 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002379 0 \
2380 -s "Read from client: 16384 bytes read"
2381
2382run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2383 "$P_SRV" \
2384 "$P_CLI request_size=16384 force_version=tls1_2 \
2385 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2386 trunc_hmac=1" \
2387 0 \
2388 -s "Read from client: 16384 bytes read"
2389
2390run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002391 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002392 "$P_CLI request_size=16384 force_version=tls1_2 \
2393 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2394 0 \
2395 -s "Read from client: 16384 bytes read"
2396
2397run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002398 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002399 "$P_CLI request_size=16384 force_version=tls1_2 \
2400 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2401 trunc_hmac=1" \
2402 0 \
2403 -s "Read from client: 16384 bytes read"
2404
2405run_test "Large packet TLS 1.2 AEAD" \
2406 "$P_SRV" \
2407 "$P_CLI request_size=16384 force_version=tls1_2 \
2408 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2409 0 \
2410 -s "Read from client: 16384 bytes read"
2411
2412run_test "Large packet TLS 1.2 AEAD shorter tag" \
2413 "$P_SRV" \
2414 "$P_CLI request_size=16384 force_version=tls1_2 \
2415 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2416 0 \
2417 -s "Read from client: 16384 bytes read"
2418
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002419# Final report
2420
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002421echo "------------------------------------------------------------------------"
2422
2423if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002424 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002425else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002426 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002427fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002428PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002429echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002430
2431exit $FAILS