blob: 2874c819ab7c83f55437bdf9f1e9ba3c689565bc [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
9# Assumes all options are compiled in.
10
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010016: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020017: ${GNUTLS_CLI:=gnutls-cli}
18: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010019
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010020O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
21O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020022G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010023G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010024
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010025TESTS=0
26FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020027SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020029CONFIG_H='../include/polarssl/config.h'
30
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010031MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010032FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020033EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034
35print_usage() {
36 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010037 printf " -h|--help\tPrint this help.\n"
38 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
39 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
40 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041}
42
43get_options() {
44 while [ $# -gt 0 ]; do
45 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046 -f|--filter)
47 shift; FILTER=$1
48 ;;
49 -e|--exclude)
50 shift; EXCLUDE=$1
51 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052 -m|--memcheck)
53 MEMCHECK=1
54 ;;
55 -h|--help)
56 print_usage
57 exit 0
58 ;;
59 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020060 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061 print_usage
62 exit 1
63 ;;
64 esac
65 shift
66 done
67}
68
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020069# skip next test if OpenSSL can't send SSLv2 ClientHello
70requires_openssl_with_sslv2() {
71 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020072 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020073 OPENSSL_HAS_SSL2="YES"
74 else
75 OPENSSL_HAS_SSL2="NO"
76 fi
77 fi
78 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020083# skip next test if OpenSSL doesn't support FALLBACK_SCSV
84requires_openssl_with_fallback_scsv() {
85 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
86 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
87 then
88 OPENSSL_HAS_FBSCSV="YES"
89 else
90 OPENSSL_HAS_FBSCSV="NO"
91 fi
92 fi
93 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
94 SKIP_NEXT="YES"
95 fi
96}
97
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020098# skip next test if GnuTLS isn't available
99requires_gnutls() {
100 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
101 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
102 GNUTLS_AVAILABLE="YES"
103 else
104 GNUTLS_AVAILABLE="NO"
105 fi
106 fi
107 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
108 SKIP_NEXT="YES"
109 fi
110}
111
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100112# print_name <name>
113print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100114 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200115 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100116 for i in `seq 1 $LEN`; do printf '.'; done
117 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100118
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200119 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100120}
121
122# fail <message>
123fail() {
124 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100125 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100126
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200127 mv $SRV_OUT o-srv-${TESTS}.log
128 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100129 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100130
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200131 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
132 echo " ! server output:"
133 cat o-srv-${TESTS}.log
134 echo " ! ============================================================"
135 echo " ! client output:"
136 cat o-cli-${TESTS}.log
137 fi
138
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200139 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100140}
141
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100142# is_polar <cmd_line>
143is_polar() {
144 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
145}
146
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100147# has_mem_err <log_file_name>
148has_mem_err() {
149 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
150 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
151 then
152 return 1 # false: does not have errors
153 else
154 return 0 # true: has errors
155 fi
156}
157
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200158# wait for server to start: two versions depending on lsof availability
159wait_server_start() {
160 if which lsof >/dev/null; then
161 # make sure we don't loop forever
162 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
163 WATCHDOG_PID=$!
164
165 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100166 until lsof -nbi TCP:"$PORT" 2>/dev/null | grep LISTEN >/dev/null;
167 do :; done
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200168
169 kill $WATCHDOG_PID
170 wait $WATCHDOG_PID
171 else
172 sleep "$START_DELAY"
173 fi
174}
175
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200176# wait for client to terminate and set CLI_EXIT
177# must be called right after starting the client
178wait_client_done() {
179 CLI_PID=$!
180
181 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
182 WATCHDOG_PID=$!
183
184 wait $CLI_PID
185 CLI_EXIT=$?
186
187 kill $WATCHDOG_PID
188 wait $WATCHDOG_PID
189
190 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
191}
192
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100193# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100194# Options: -s pattern pattern that must be present in server output
195# -c pattern pattern that must be present in client output
196# -S pattern pattern that must be absent in server output
197# -C pattern pattern that must be absent in client output
198run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100199 NAME="$1"
200 SRV_CMD="$2"
201 CLI_CMD="$3"
202 CLI_EXPECT="$4"
203 shift 4
204
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100205 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
206 else
207 return
208 fi
209
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100210 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100211
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200212 # should we skip?
213 if [ "X$SKIP_NEXT" = "XYES" ]; then
214 SKIP_NEXT="NO"
215 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200216 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200217 return
218 fi
219
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100220 # prepend valgrind to our commands if active
221 if [ "$MEMCHECK" -gt 0 ]; then
222 if is_polar "$SRV_CMD"; then
223 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
224 fi
225 if is_polar "$CLI_CMD"; then
226 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
227 fi
228 fi
229
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100230 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200231 echo "$SRV_CMD" > $SRV_OUT
232 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100233 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200234 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200235
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200236 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200237 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
238 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100239
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200240 # kill the server
241 kill $SRV_PID
242 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100243
244 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200245 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100246 # expected client exit to incorrectly succeed in case of catastrophic
247 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100248 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200249 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100250 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100251 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100252 return
253 fi
254 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100255 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200256 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100257 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100258 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100259 return
260 fi
261 fi
262
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100263 # check server exit code
264 if [ $? != 0 ]; then
265 fail "server fail"
266 return
267 fi
268
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100269 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100270 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
271 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100272 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100273 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100274 return
275 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100276
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100277 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200278 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100279 while [ $# -gt 0 ]
280 do
281 case $1 in
282 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200283 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100284 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100285 return
286 fi
287 ;;
288
289 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200290 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100291 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100292 return
293 fi
294 ;;
295
296 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200297 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100298 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100299 return
300 fi
301 ;;
302
303 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200304 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100305 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100306 return
307 fi
308 ;;
309
310 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200311 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100312 exit 1
313 esac
314 shift 2
315 done
316
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100317 # check valgrind's results
318 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200319 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100320 fail "Server has memory errors"
321 return
322 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200323 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100324 fail "Client has memory errors"
325 return
326 fi
327 fi
328
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100329 # if we're here, everything is ok
330 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200331 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100332}
333
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100334cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200335 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200336 kill $SRV_PID >/dev/null 2>&1
337 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100338 exit 1
339}
340
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100341#
342# MAIN
343#
344
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100345get_options "$@"
346
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100347# sanity checks, avoid an avalanche of errors
348if [ ! -x "$P_SRV" ]; then
349 echo "Command '$P_SRV' is not an executable file"
350 exit 1
351fi
352if [ ! -x "$P_CLI" ]; then
353 echo "Command '$P_CLI' is not an executable file"
354 exit 1
355fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100356if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
357 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100358 exit 1
359fi
360
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200361# used by watchdog
362MAIN_PID="$$"
363
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200364# be more patient with valgrind
365if [ "$MEMCHECK" -gt 0 ]; then
366 START_DELAY=3
367 DOG_DELAY=30
368else
369 START_DELAY=1
370 DOG_DELAY=10
371fi
372
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200373# Pick a "unique" port in the range 10000-19999.
374PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200375PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200376
377# fix commands to use this port
378P_SRV="$P_SRV server_port=$PORT"
379P_CLI="$P_CLI server_port=$PORT"
380O_SRV="$O_SRV -accept $PORT"
381O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200382G_SRV="$G_SRV -p $PORT"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100383G_CLI="$G_CLI -p $PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200384
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200385# Also pick a unique name for intermediate files
386SRV_OUT="srv_out.$$"
387CLI_OUT="cli_out.$$"
388SESSION="session.$$"
389
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200390SKIP_NEXT="NO"
391
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100392trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100393
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200394# Basic test
395
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200396# Checks that:
397# - things work with all ciphersuites active (used with config-full in all.sh)
398# - the expected (highest security) parameters are selected
399# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200400run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200401 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200402 "$P_CLI" \
403 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200404 -s "Protocol is TLSv1.2" \
405 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
406 -s "client hello v3, signature_algorithm ext: 6" \
407 -s "ECDHE curve: secp521r1" \
408 -S "error" \
409 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200410
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100411# Test for SSLv2 ClientHello
412
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200413requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200414run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100415 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100416 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100417 0 \
418 -S "parse client hello v2" \
419 -S "ssl_handshake returned"
420
421# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200422requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200423run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200424 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100425 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100426 0 \
427 -s "parse client hello v2" \
428 -S "ssl_handshake returned"
429
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100430# Tests for Truncated HMAC extension
431
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100432run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200433 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100434 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100435 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100436 -s "dumping 'computed mac' (20 bytes)" \
437 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100438
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100439run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200440 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100441 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
442 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100443 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100444 -s "dumping 'computed mac' (20 bytes)" \
445 -S "dumping 'computed mac' (10 bytes)"
446
447run_test "Truncated HMAC: client enabled, server default" \
448 "$P_SRV debug_level=4" \
449 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
450 trunc_hmac=1" \
451 0 \
452 -S "dumping 'computed mac' (20 bytes)" \
453 -s "dumping 'computed mac' (10 bytes)"
454
455run_test "Truncated HMAC: client enabled, server disabled" \
456 "$P_SRV debug_level=4 trunc_hmac=0" \
457 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
458 trunc_hmac=1" \
459 0 \
460 -s "dumping 'computed mac' (20 bytes)" \
461 -S "dumping 'computed mac' (10 bytes)"
462
463run_test "Truncated HMAC: client enabled, server enabled" \
464 "$P_SRV debug_level=4 trunc_hmac=1" \
465 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
466 trunc_hmac=1" \
467 0 \
468 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100469 -s "dumping 'computed mac' (10 bytes)"
470
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100471# Tests for Encrypt-then-MAC extension
472
473run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100474 "$P_SRV debug_level=3 \
475 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100476 "$P_CLI debug_level=3" \
477 0 \
478 -c "client hello, adding encrypt_then_mac extension" \
479 -s "found encrypt then mac extension" \
480 -s "server hello, adding encrypt then mac extension" \
481 -c "found encrypt_then_mac extension" \
482 -c "using encrypt then mac" \
483 -s "using encrypt then mac"
484
485run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100486 "$P_SRV debug_level=3 etm=0 \
487 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100488 "$P_CLI debug_level=3 etm=1" \
489 0 \
490 -c "client hello, adding encrypt_then_mac extension" \
491 -s "found encrypt then mac extension" \
492 -S "server hello, adding encrypt then mac extension" \
493 -C "found encrypt_then_mac extension" \
494 -C "using encrypt then mac" \
495 -S "using encrypt then mac"
496
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100497run_test "Encrypt then MAC: client enabled, aead cipher" \
498 "$P_SRV debug_level=3 etm=1 \
499 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
500 "$P_CLI debug_level=3 etm=1" \
501 0 \
502 -c "client hello, adding encrypt_then_mac extension" \
503 -s "found encrypt then mac extension" \
504 -S "server hello, adding encrypt then mac extension" \
505 -C "found encrypt_then_mac extension" \
506 -C "using encrypt then mac" \
507 -S "using encrypt then mac"
508
509run_test "Encrypt then MAC: client enabled, stream cipher" \
510 "$P_SRV debug_level=3 etm=1 \
511 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
512 "$P_CLI debug_level=3 etm=1" \
513 0 \
514 -c "client hello, adding encrypt_then_mac extension" \
515 -s "found encrypt then mac extension" \
516 -S "server hello, adding encrypt then mac extension" \
517 -C "found encrypt_then_mac extension" \
518 -C "using encrypt then mac" \
519 -S "using encrypt then mac"
520
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100521run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100522 "$P_SRV debug_level=3 etm=1 \
523 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100524 "$P_CLI debug_level=3 etm=0" \
525 0 \
526 -C "client hello, adding encrypt_then_mac extension" \
527 -S "found encrypt then mac extension" \
528 -S "server hello, adding encrypt then mac extension" \
529 -C "found encrypt_then_mac extension" \
530 -C "using encrypt then mac" \
531 -S "using encrypt then mac"
532
533run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100534 "$P_SRV debug_level=3 \
535 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100536 "$P_CLI debug_level=3 force_version=ssl3" \
537 0 \
538 -C "client hello, adding encrypt_then_mac extension" \
539 -S "found encrypt then mac extension" \
540 -S "server hello, adding encrypt then mac extension" \
541 -C "found encrypt_then_mac extension" \
542 -C "using encrypt then mac" \
543 -S "using encrypt then mac"
544
545run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100546 "$P_SRV debug_level=3 force_version=ssl3 \
547 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100548 "$P_CLI debug_level=3" \
549 0 \
550 -c "client hello, adding encrypt_then_mac extension" \
551 -s "found encrypt then mac extension" \
552 -S "server hello, adding encrypt then mac extension" \
553 -C "found encrypt_then_mac extension" \
554 -C "using encrypt then mac" \
555 -S "using encrypt then mac"
556
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200557# Tests for Extended Master Secret extension
558
559run_test "Extended Master Secret: default" \
560 "$P_SRV debug_level=3" \
561 "$P_CLI debug_level=3" \
562 0 \
563 -c "client hello, adding extended_master_secret extension" \
564 -s "found extended master secret extension" \
565 -s "server hello, adding extended master secret extension" \
566 -c "found extended_master_secret extension" \
567 -c "using extended master secret" \
568 -s "using extended master secret"
569
570run_test "Extended Master Secret: client enabled, server disabled" \
571 "$P_SRV debug_level=3 extended_ms=0" \
572 "$P_CLI debug_level=3 extended_ms=1" \
573 0 \
574 -c "client hello, adding extended_master_secret extension" \
575 -s "found extended master secret extension" \
576 -S "server hello, adding extended master secret extension" \
577 -C "found extended_master_secret extension" \
578 -C "using extended master secret" \
579 -S "using extended master secret"
580
581run_test "Extended Master Secret: client disabled, server enabled" \
582 "$P_SRV debug_level=3 extended_ms=1" \
583 "$P_CLI debug_level=3 extended_ms=0" \
584 0 \
585 -C "client hello, adding extended_master_secret extension" \
586 -S "found extended master secret extension" \
587 -S "server hello, adding extended master secret extension" \
588 -C "found extended_master_secret extension" \
589 -C "using extended master secret" \
590 -S "using extended master secret"
591
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200592run_test "Extended Master Secret: client SSLv3, server enabled" \
593 "$P_SRV debug_level=3" \
594 "$P_CLI debug_level=3 force_version=ssl3" \
595 0 \
596 -C "client hello, adding extended_master_secret extension" \
597 -S "found extended master secret extension" \
598 -S "server hello, adding extended master secret extension" \
599 -C "found extended_master_secret extension" \
600 -C "using extended master secret" \
601 -S "using extended master secret"
602
603run_test "Extended Master Secret: client enabled, server SSLv3" \
604 "$P_SRV debug_level=3 force_version=ssl3" \
605 "$P_CLI debug_level=3" \
606 0 \
607 -c "client hello, adding extended_master_secret extension" \
608 -s "found extended master secret extension" \
609 -S "server hello, adding extended master secret extension" \
610 -C "found extended_master_secret extension" \
611 -C "using extended master secret" \
612 -S "using extended master secret"
613
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200614# Tests for FALLBACK_SCSV
615
616run_test "Fallback SCSV: default" \
617 "$P_SRV" \
618 "$P_CLI debug_level=3 force_version=tls1_1" \
619 0 \
620 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200621 -S "received FALLBACK_SCSV" \
622 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200623 -C "is a fatal alert message (msg 86)"
624
625run_test "Fallback SCSV: explicitly disabled" \
626 "$P_SRV" \
627 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
628 0 \
629 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200630 -S "received FALLBACK_SCSV" \
631 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200632 -C "is a fatal alert message (msg 86)"
633
634run_test "Fallback SCSV: enabled" \
635 "$P_SRV" \
636 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200637 1 \
638 -c "adding FALLBACK_SCSV" \
639 -s "received FALLBACK_SCSV" \
640 -s "inapropriate fallback" \
641 -c "is a fatal alert message (msg 86)"
642
643run_test "Fallback SCSV: enabled, max version" \
644 "$P_SRV" \
645 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200646 0 \
647 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200648 -s "received FALLBACK_SCSV" \
649 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200650 -C "is a fatal alert message (msg 86)"
651
652requires_openssl_with_fallback_scsv
653run_test "Fallback SCSV: default, openssl server" \
654 "$O_SRV" \
655 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
656 0 \
657 -C "adding FALLBACK_SCSV" \
658 -C "is a fatal alert message (msg 86)"
659
660requires_openssl_with_fallback_scsv
661run_test "Fallback SCSV: enabled, openssl server" \
662 "$O_SRV" \
663 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
664 1 \
665 -c "adding FALLBACK_SCSV" \
666 -c "is a fatal alert message (msg 86)"
667
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200668requires_openssl_with_fallback_scsv
669run_test "Fallback SCSV: disabled, openssl client" \
670 "$P_SRV" \
671 "$O_CLI -tls1_1" \
672 0 \
673 -S "received FALLBACK_SCSV" \
674 -S "inapropriate fallback"
675
676requires_openssl_with_fallback_scsv
677run_test "Fallback SCSV: enabled, openssl client" \
678 "$P_SRV" \
679 "$O_CLI -tls1_1 -fallback_scsv" \
680 1 \
681 -s "received FALLBACK_SCSV" \
682 -s "inapropriate fallback"
683
684requires_openssl_with_fallback_scsv
685run_test "Fallback SCSV: enabled, max version, openssl client" \
686 "$P_SRV" \
687 "$O_CLI -fallback_scsv" \
688 0 \
689 -s "received FALLBACK_SCSV" \
690 -S "inapropriate fallback"
691
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100692# Tests for CBC 1/n-1 record splitting
693
694run_test "CBC Record splitting: TLS 1.2, no splitting" \
695 "$P_SRV" \
696 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
697 request_size=123 force_version=tls1_2" \
698 0 \
699 -s "Read from client: 123 bytes read" \
700 -S "Read from client: 1 bytes read" \
701 -S "122 bytes read"
702
703run_test "CBC Record splitting: TLS 1.1, no splitting" \
704 "$P_SRV" \
705 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
706 request_size=123 force_version=tls1_1" \
707 0 \
708 -s "Read from client: 123 bytes read" \
709 -S "Read from client: 1 bytes read" \
710 -S "122 bytes read"
711
712run_test "CBC Record splitting: TLS 1.0, splitting" \
713 "$P_SRV" \
714 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
715 request_size=123 force_version=tls1" \
716 0 \
717 -S "Read from client: 123 bytes read" \
718 -s "Read from client: 1 bytes read" \
719 -s "122 bytes read"
720
721run_test "CBC Record splitting: SSLv3, splitting" \
722 "$P_SRV" \
723 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
724 request_size=123 force_version=ssl3" \
725 0 \
726 -S "Read from client: 123 bytes read" \
727 -s "Read from client: 1 bytes read" \
728 -s "122 bytes read"
729
730run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
731 "$P_SRV" \
732 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
733 request_size=123 force_version=tls1" \
734 0 \
735 -s "Read from client: 123 bytes read" \
736 -S "Read from client: 1 bytes read" \
737 -S "122 bytes read"
738
739run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
740 "$P_SRV" \
741 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
742 request_size=123 force_version=tls1 recsplit=0" \
743 0 \
744 -s "Read from client: 123 bytes read" \
745 -S "Read from client: 1 bytes read" \
746 -S "122 bytes read"
747
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100748run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
749 "$P_SRV nbio=2" \
750 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
751 request_size=123 force_version=tls1" \
752 0 \
753 -S "Read from client: 123 bytes read" \
754 -s "Read from client: 1 bytes read" \
755 -s "122 bytes read"
756
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100757# Tests for Session Tickets
758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200759run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200760 "$P_SRV debug_level=3 tickets=1" \
761 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100762 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100763 -c "client hello, adding session ticket extension" \
764 -s "found session ticket extension" \
765 -s "server hello, adding session ticket extension" \
766 -c "found session_ticket extension" \
767 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100768 -S "session successfully restored from cache" \
769 -s "session successfully restored from ticket" \
770 -s "a session has been resumed" \
771 -c "a session has been resumed"
772
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200773run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200774 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
775 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100776 0 \
777 -c "client hello, adding session ticket extension" \
778 -s "found session ticket extension" \
779 -s "server hello, adding session ticket extension" \
780 -c "found session_ticket extension" \
781 -c "parse new session ticket" \
782 -S "session successfully restored from cache" \
783 -s "session successfully restored from ticket" \
784 -s "a session has been resumed" \
785 -c "a session has been resumed"
786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200787run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200788 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
789 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100790 0 \
791 -c "client hello, adding session ticket extension" \
792 -s "found session ticket extension" \
793 -s "server hello, adding session ticket extension" \
794 -c "found session_ticket extension" \
795 -c "parse new session ticket" \
796 -S "session successfully restored from cache" \
797 -S "session successfully restored from ticket" \
798 -S "a session has been resumed" \
799 -C "a session has been resumed"
800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200801run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100802 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200803 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100804 0 \
805 -c "client hello, adding session ticket extension" \
806 -c "found session_ticket extension" \
807 -c "parse new session ticket" \
808 -c "a session has been resumed"
809
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200810run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200811 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200812 "( $O_CLI -sess_out $SESSION; \
813 $O_CLI -sess_in $SESSION; \
814 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100815 0 \
816 -s "found session ticket extension" \
817 -s "server hello, adding session ticket extension" \
818 -S "session successfully restored from cache" \
819 -s "session successfully restored from ticket" \
820 -s "a session has been resumed"
821
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100822# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200824run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200825 "$P_SRV debug_level=3 tickets=0" \
826 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100827 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100828 -c "client hello, adding session ticket extension" \
829 -s "found session ticket extension" \
830 -S "server hello, adding session ticket extension" \
831 -C "found session_ticket extension" \
832 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100833 -s "session successfully restored from cache" \
834 -S "session successfully restored from ticket" \
835 -s "a session has been resumed" \
836 -c "a session has been resumed"
837
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200838run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200839 "$P_SRV debug_level=3 tickets=1" \
840 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100841 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100842 -C "client hello, adding session ticket extension" \
843 -S "found session ticket extension" \
844 -S "server hello, adding session ticket extension" \
845 -C "found session_ticket extension" \
846 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100847 -s "session successfully restored from cache" \
848 -S "session successfully restored from ticket" \
849 -s "a session has been resumed" \
850 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200852run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200853 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
854 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100855 0 \
856 -S "session successfully restored from cache" \
857 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100858 -S "a session has been resumed" \
859 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100860
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200861run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200862 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
863 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100864 0 \
865 -s "session successfully restored from cache" \
866 -S "session successfully restored from ticket" \
867 -s "a session has been resumed" \
868 -c "a session has been resumed"
869
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200870run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200871 "$P_SRV debug_level=3 tickets=0" \
872 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100873 0 \
874 -s "session successfully restored from cache" \
875 -S "session successfully restored from ticket" \
876 -s "a session has been resumed" \
877 -c "a session has been resumed"
878
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200879run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200880 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
881 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100882 0 \
883 -S "session successfully restored from cache" \
884 -S "session successfully restored from ticket" \
885 -S "a session has been resumed" \
886 -C "a session has been resumed"
887
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200888run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200889 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
890 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100891 0 \
892 -s "session successfully restored from cache" \
893 -S "session successfully restored from ticket" \
894 -s "a session has been resumed" \
895 -c "a session has been resumed"
896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200897run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200898 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200899 "( $O_CLI -sess_out $SESSION; \
900 $O_CLI -sess_in $SESSION; \
901 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100902 0 \
903 -s "found session ticket extension" \
904 -S "server hello, adding session ticket extension" \
905 -s "session successfully restored from cache" \
906 -S "session successfully restored from ticket" \
907 -s "a session has been resumed"
908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200909run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100910 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200911 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100912 0 \
913 -C "found session_ticket extension" \
914 -C "parse new session ticket" \
915 -c "a session has been resumed"
916
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100917# Tests for Max Fragment Length extension
918
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200919run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200920 "$P_SRV debug_level=3" \
921 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100922 0 \
923 -C "client hello, adding max_fragment_length extension" \
924 -S "found max fragment length extension" \
925 -S "server hello, max_fragment_length extension" \
926 -C "found max_fragment_length extension"
927
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200928run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200929 "$P_SRV debug_level=3" \
930 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100931 0 \
932 -c "client hello, adding max_fragment_length extension" \
933 -s "found max fragment length extension" \
934 -s "server hello, max_fragment_length extension" \
935 -c "found max_fragment_length extension"
936
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200937run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200938 "$P_SRV debug_level=3 max_frag_len=4096" \
939 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100940 0 \
941 -C "client hello, adding max_fragment_length extension" \
942 -S "found max fragment length extension" \
943 -S "server hello, max_fragment_length extension" \
944 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200946requires_gnutls
947run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200948 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200949 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200950 0 \
951 -c "client hello, adding max_fragment_length extension" \
952 -c "found max_fragment_length extension"
953
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100954# Tests for renegotiation
955
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200956run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200957 "$P_SRV debug_level=3 exchanges=2" \
958 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100959 0 \
960 -C "client hello, adding renegotiation extension" \
961 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
962 -S "found renegotiation extension" \
963 -s "server hello, secure renegotiation extension" \
964 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100965 -C "=> renegotiate" \
966 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100967 -S "write hello request"
968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200969run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200970 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
971 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100972 0 \
973 -c "client hello, adding renegotiation extension" \
974 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
975 -s "found renegotiation extension" \
976 -s "server hello, secure renegotiation extension" \
977 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100978 -c "=> renegotiate" \
979 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100980 -S "write hello request"
981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200982run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200983 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
984 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100985 0 \
986 -c "client hello, adding renegotiation extension" \
987 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
988 -s "found renegotiation extension" \
989 -s "server hello, secure renegotiation extension" \
990 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100991 -c "=> renegotiate" \
992 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100993 -s "write hello request"
994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200995run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200996 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
997 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100998 0 \
999 -c "client hello, adding renegotiation extension" \
1000 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1001 -s "found renegotiation extension" \
1002 -s "server hello, secure renegotiation extension" \
1003 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001004 -c "=> renegotiate" \
1005 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001006 -s "write hello request"
1007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001008run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001009 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1010 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001011 1 \
1012 -c "client hello, adding renegotiation extension" \
1013 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1014 -S "found renegotiation extension" \
1015 -s "server hello, secure renegotiation extension" \
1016 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001017 -c "=> renegotiate" \
1018 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001019 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001020 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001021 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001023run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001024 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1025 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001026 0 \
1027 -C "client hello, adding renegotiation extension" \
1028 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1029 -S "found renegotiation extension" \
1030 -s "server hello, secure renegotiation extension" \
1031 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001032 -C "=> renegotiate" \
1033 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001034 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001035 -S "SSL - An unexpected message was received from our peer" \
1036 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001038run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001039 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001040 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001041 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001042 0 \
1043 -C "client hello, adding renegotiation extension" \
1044 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1045 -S "found renegotiation extension" \
1046 -s "server hello, secure renegotiation extension" \
1047 -c "found renegotiation extension" \
1048 -C "=> renegotiate" \
1049 -S "=> renegotiate" \
1050 -s "write hello request" \
1051 -S "SSL - An unexpected message was received from our peer" \
1052 -S "failed"
1053
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001054# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001055run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001056 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001057 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001058 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001059 0 \
1060 -C "client hello, adding renegotiation extension" \
1061 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1062 -S "found renegotiation extension" \
1063 -s "server hello, secure renegotiation extension" \
1064 -c "found renegotiation extension" \
1065 -C "=> renegotiate" \
1066 -S "=> renegotiate" \
1067 -s "write hello request" \
1068 -S "SSL - An unexpected message was received from our peer" \
1069 -S "failed"
1070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001071run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001072 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001073 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001074 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001075 0 \
1076 -C "client hello, adding renegotiation extension" \
1077 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1078 -S "found renegotiation extension" \
1079 -s "server hello, secure renegotiation extension" \
1080 -c "found renegotiation extension" \
1081 -C "=> renegotiate" \
1082 -S "=> renegotiate" \
1083 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001084 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001085
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001086run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001087 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001088 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001089 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001090 0 \
1091 -c "client hello, adding renegotiation extension" \
1092 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1093 -s "found renegotiation extension" \
1094 -s "server hello, secure renegotiation extension" \
1095 -c "found renegotiation extension" \
1096 -c "=> renegotiate" \
1097 -s "=> renegotiate" \
1098 -s "write hello request" \
1099 -S "SSL - An unexpected message was received from our peer" \
1100 -S "failed"
1101
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001102run_test "Renegotiation: periodic, just below period" \
1103 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1104 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1105 0 \
1106 -C "client hello, adding renegotiation extension" \
1107 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1108 -S "found renegotiation extension" \
1109 -s "server hello, secure renegotiation extension" \
1110 -c "found renegotiation extension" \
1111 -S "record counter limit reached: renegotiate" \
1112 -C "=> renegotiate" \
1113 -S "=> renegotiate" \
1114 -S "write hello request" \
1115 -S "SSL - An unexpected message was received from our peer" \
1116 -S "failed"
1117
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001118# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001119run_test "Renegotiation: periodic, just above period" \
1120 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001121 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001122 0 \
1123 -c "client hello, adding renegotiation extension" \
1124 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1125 -s "found renegotiation extension" \
1126 -s "server hello, secure renegotiation extension" \
1127 -c "found renegotiation extension" \
1128 -s "record counter limit reached: renegotiate" \
1129 -c "=> renegotiate" \
1130 -s "=> renegotiate" \
1131 -s "write hello request" \
1132 -S "SSL - An unexpected message was received from our peer" \
1133 -S "failed"
1134
1135run_test "Renegotiation: periodic, two times period" \
1136 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001137 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001138 0 \
1139 -c "client hello, adding renegotiation extension" \
1140 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1141 -s "found renegotiation extension" \
1142 -s "server hello, secure renegotiation extension" \
1143 -c "found renegotiation extension" \
1144 -s "record counter limit reached: renegotiate" \
1145 -c "=> renegotiate" \
1146 -s "=> renegotiate" \
1147 -s "write hello request" \
1148 -S "SSL - An unexpected message was received from our peer" \
1149 -S "failed"
1150
1151run_test "Renegotiation: periodic, above period, disabled" \
1152 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1153 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1154 0 \
1155 -C "client hello, adding renegotiation extension" \
1156 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1157 -S "found renegotiation extension" \
1158 -s "server hello, secure renegotiation extension" \
1159 -c "found renegotiation extension" \
1160 -S "record counter limit reached: renegotiate" \
1161 -C "=> renegotiate" \
1162 -S "=> renegotiate" \
1163 -S "write hello request" \
1164 -S "SSL - An unexpected message was received from our peer" \
1165 -S "failed"
1166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001167run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001168 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1169 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001170 0 \
1171 -c "client hello, adding renegotiation extension" \
1172 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1173 -s "found renegotiation extension" \
1174 -s "server hello, secure renegotiation extension" \
1175 -c "found renegotiation extension" \
1176 -c "=> renegotiate" \
1177 -s "=> renegotiate" \
1178 -S "write hello request"
1179
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001180run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001181 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1182 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001183 0 \
1184 -c "client hello, adding renegotiation extension" \
1185 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1186 -s "found renegotiation extension" \
1187 -s "server hello, secure renegotiation extension" \
1188 -c "found renegotiation extension" \
1189 -c "=> renegotiate" \
1190 -s "=> renegotiate" \
1191 -s "write hello request"
1192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001193run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001194 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001195 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001196 0 \
1197 -c "client hello, adding renegotiation extension" \
1198 -c "found renegotiation extension" \
1199 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001200 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001201 -C "error" \
1202 -c "HTTP/1.0 200 [Oo][Kk]"
1203
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001204run_test "Renegotiation: gnutls server strict, client-initiated" \
1205 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001206 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001207 0 \
1208 -c "client hello, adding renegotiation extension" \
1209 -c "found renegotiation extension" \
1210 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001211 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001212 -C "error" \
1213 -c "HTTP/1.0 200 [Oo][Kk]"
1214
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001215run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1216 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1217 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1218 1 \
1219 -c "client hello, adding renegotiation extension" \
1220 -C "found renegotiation extension" \
1221 -c "=> renegotiate" \
1222 -c "ssl_handshake() returned" \
1223 -c "error" \
1224 -C "HTTP/1.0 200 [Oo][Kk]"
1225
1226run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1227 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1228 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1229 allow_legacy=0" \
1230 1 \
1231 -c "client hello, adding renegotiation extension" \
1232 -C "found renegotiation extension" \
1233 -c "=> renegotiate" \
1234 -c "ssl_handshake() returned" \
1235 -c "error" \
1236 -C "HTTP/1.0 200 [Oo][Kk]"
1237
1238run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1239 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1240 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1241 allow_legacy=1" \
1242 0 \
1243 -c "client hello, adding renegotiation extension" \
1244 -C "found renegotiation extension" \
1245 -c "=> renegotiate" \
1246 -C "ssl_hanshake() returned" \
1247 -C "error" \
1248 -c "HTTP/1.0 200 [Oo][Kk]"
1249
1250# Test for the "secure renegotation" extension only (no actual renegotiation)
1251
1252run_test "Renego ext: gnutls server strict, client default" \
1253 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1254 "$P_CLI debug_level=3" \
1255 0 \
1256 -c "found renegotiation extension" \
1257 -C "error" \
1258 -c "HTTP/1.0 200 [Oo][Kk]"
1259
1260run_test "Renego ext: gnutls server unsafe, client default" \
1261 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1262 "$P_CLI debug_level=3" \
1263 0 \
1264 -C "found renegotiation extension" \
1265 -C "error" \
1266 -c "HTTP/1.0 200 [Oo][Kk]"
1267
1268run_test "Renego ext: gnutls server unsafe, client break legacy" \
1269 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1270 "$P_CLI debug_level=3 allow_legacy=-1" \
1271 1 \
1272 -C "found renegotiation extension" \
1273 -c "error" \
1274 -C "HTTP/1.0 200 [Oo][Kk]"
1275
1276run_test "Renego ext: gnutls client strict, server default" \
1277 "$P_SRV debug_level=3" \
1278 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1279 0 \
1280 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1281 -s "server hello, secure renegotiation extension"
1282
1283run_test "Renego ext: gnutls client unsafe, server default" \
1284 "$P_SRV debug_level=3" \
1285 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1286 0 \
1287 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1288 -S "server hello, secure renegotiation extension"
1289
1290run_test "Renego ext: gnutls client unsafe, server break legacy" \
1291 "$P_SRV debug_level=3 allow_legacy=-1" \
1292 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1293 1 \
1294 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1295 -S "server hello, secure renegotiation extension"
1296
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001297# Tests for auth_mode
1298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001299run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001300 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001301 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001302 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001303 1 \
1304 -c "x509_verify_cert() returned" \
1305 -c "! self-signed or not signed by a trusted CA" \
1306 -c "! ssl_handshake returned" \
1307 -c "X509 - Certificate verification failed"
1308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001309run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001310 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001311 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001312 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001313 0 \
1314 -c "x509_verify_cert() returned" \
1315 -c "! self-signed or not signed by a trusted CA" \
1316 -C "! ssl_handshake returned" \
1317 -C "X509 - Certificate verification failed"
1318
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001319run_test "Authentication: server badcert, client none" \
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=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001323 0 \
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: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001330 "$P_SRV debug_level=3 auth_mode=required" \
1331 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001332 key_file=data_files/server5.key" \
1333 1 \
1334 -S "skip write certificate request" \
1335 -C "skip parse certificate request" \
1336 -c "got a certificate request" \
1337 -C "skip write certificate" \
1338 -C "skip write certificate verify" \
1339 -S "skip parse certificate verify" \
1340 -s "x509_verify_cert() returned" \
1341 -S "! self-signed or not signed by a trusted CA" \
1342 -s "! ssl_handshake returned" \
1343 -c "! ssl_handshake returned" \
1344 -s "X509 - Certificate verification failed"
1345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001346run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001347 "$P_SRV debug_level=3 auth_mode=optional" \
1348 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001349 key_file=data_files/server5.key" \
1350 0 \
1351 -S "skip write certificate request" \
1352 -C "skip parse certificate request" \
1353 -c "got a certificate request" \
1354 -C "skip write certificate" \
1355 -C "skip write certificate verify" \
1356 -S "skip parse certificate verify" \
1357 -s "x509_verify_cert() returned" \
1358 -s "! self-signed or not signed by a trusted CA" \
1359 -S "! ssl_handshake returned" \
1360 -C "! ssl_handshake returned" \
1361 -S "X509 - Certificate verification failed"
1362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001363run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001364 "$P_SRV debug_level=3 auth_mode=none" \
1365 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001366 key_file=data_files/server5.key" \
1367 0 \
1368 -s "skip write certificate request" \
1369 -C "skip parse certificate request" \
1370 -c "got no certificate request" \
1371 -c "skip write certificate" \
1372 -c "skip write certificate verify" \
1373 -s "skip parse certificate verify" \
1374 -S "x509_verify_cert() returned" \
1375 -S "! self-signed or not signed by a trusted CA" \
1376 -S "! ssl_handshake returned" \
1377 -C "! ssl_handshake returned" \
1378 -S "X509 - Certificate verification failed"
1379
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001380run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001381 "$P_SRV debug_level=3 auth_mode=optional" \
1382 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001383 0 \
1384 -S "skip write certificate request" \
1385 -C "skip parse certificate request" \
1386 -c "got a certificate request" \
1387 -C "skip write certificate$" \
1388 -C "got no certificate to send" \
1389 -S "SSLv3 client has no certificate" \
1390 -c "skip write certificate verify" \
1391 -s "skip parse certificate verify" \
1392 -s "! no client certificate sent" \
1393 -S "! ssl_handshake returned" \
1394 -C "! ssl_handshake returned" \
1395 -S "X509 - Certificate verification failed"
1396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001397run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001398 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001399 "$O_CLI" \
1400 0 \
1401 -S "skip write certificate request" \
1402 -s "skip parse certificate verify" \
1403 -s "! no client certificate sent" \
1404 -S "! ssl_handshake returned" \
1405 -S "X509 - Certificate verification failed"
1406
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001407run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001408 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001409 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001410 0 \
1411 -C "skip parse certificate request" \
1412 -c "got a certificate request" \
1413 -C "skip write certificate$" \
1414 -c "skip write certificate verify" \
1415 -C "! ssl_handshake returned"
1416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001417run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001418 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1419 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001420 0 \
1421 -S "skip write certificate request" \
1422 -C "skip parse certificate request" \
1423 -c "got a certificate request" \
1424 -C "skip write certificate$" \
1425 -c "skip write certificate verify" \
1426 -c "got no certificate to send" \
1427 -s "SSLv3 client has no certificate" \
1428 -s "skip parse certificate verify" \
1429 -s "! no client certificate sent" \
1430 -S "! ssl_handshake returned" \
1431 -C "! ssl_handshake returned" \
1432 -S "X509 - Certificate verification failed"
1433
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001434# Tests for certificate selection based on SHA verson
1435
1436run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1437 "$P_SRV crt_file=data_files/server5.crt \
1438 key_file=data_files/server5.key \
1439 crt_file2=data_files/server5-sha1.crt \
1440 key_file2=data_files/server5.key" \
1441 "$P_CLI force_version=tls1_2" \
1442 0 \
1443 -c "signed using.*ECDSA with SHA256" \
1444 -C "signed using.*ECDSA with SHA1"
1445
1446run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1447 "$P_SRV crt_file=data_files/server5.crt \
1448 key_file=data_files/server5.key \
1449 crt_file2=data_files/server5-sha1.crt \
1450 key_file2=data_files/server5.key" \
1451 "$P_CLI force_version=tls1_1" \
1452 0 \
1453 -C "signed using.*ECDSA with SHA256" \
1454 -c "signed using.*ECDSA with SHA1"
1455
1456run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
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" \
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, no SHA-1 -> SHA-2 (order 1)" \
1467 "$P_SRV crt_file=data_files/server5.crt \
1468 key_file=data_files/server5.key \
1469 crt_file2=data_files/server6.crt \
1470 key_file2=data_files/server6.key" \
1471 "$P_CLI force_version=tls1_1" \
1472 0 \
1473 -c "serial number.*09" \
1474 -c "signed using.*ECDSA with SHA256" \
1475 -C "signed using.*ECDSA with SHA1"
1476
1477run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1478 "$P_SRV crt_file=data_files/server6.crt \
1479 key_file=data_files/server6.key \
1480 crt_file2=data_files/server5.crt \
1481 key_file2=data_files/server5.key" \
1482 "$P_CLI force_version=tls1_1" \
1483 0 \
1484 -c "serial number.*0A" \
1485 -c "signed using.*ECDSA with SHA256" \
1486 -C "signed using.*ECDSA with SHA1"
1487
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001488# tests for SNI
1489
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001490run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001491 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001492 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001493 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001494 server_name=localhost" \
1495 0 \
1496 -S "parse ServerName extension" \
1497 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1498 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1499
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001500run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001501 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001502 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001503 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 +01001504 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001505 server_name=localhost" \
1506 0 \
1507 -s "parse ServerName extension" \
1508 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1509 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1510
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001511run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001512 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001513 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001514 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 +01001515 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001516 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001517 0 \
1518 -s "parse ServerName extension" \
1519 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001520 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001522run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001523 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001524 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001525 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 +01001526 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001527 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001528 1 \
1529 -s "parse ServerName extension" \
1530 -s "ssl_sni_wrapper() returned" \
1531 -s "ssl_handshake returned" \
1532 -c "ssl_handshake returned" \
1533 -c "SSL - A fatal alert message was received from our peer"
1534
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001535# Tests for non-blocking I/O: exercise a variety of handshake flows
1536
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001537run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001538 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1539 "$P_CLI nbio=2 tickets=0" \
1540 0 \
1541 -S "ssl_handshake returned" \
1542 -C "ssl_handshake returned" \
1543 -c "Read from server: .* bytes read"
1544
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001545run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001546 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1547 "$P_CLI nbio=2 tickets=0" \
1548 0 \
1549 -S "ssl_handshake returned" \
1550 -C "ssl_handshake returned" \
1551 -c "Read from server: .* bytes read"
1552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001553run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001554 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1555 "$P_CLI nbio=2 tickets=1" \
1556 0 \
1557 -S "ssl_handshake returned" \
1558 -C "ssl_handshake returned" \
1559 -c "Read from server: .* bytes read"
1560
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001561run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001562 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1563 "$P_CLI nbio=2 tickets=1" \
1564 0 \
1565 -S "ssl_handshake returned" \
1566 -C "ssl_handshake returned" \
1567 -c "Read from server: .* bytes read"
1568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001569run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001570 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1571 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1572 0 \
1573 -S "ssl_handshake returned" \
1574 -C "ssl_handshake returned" \
1575 -c "Read from server: .* bytes read"
1576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001577run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001578 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1579 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1580 0 \
1581 -S "ssl_handshake returned" \
1582 -C "ssl_handshake returned" \
1583 -c "Read from server: .* bytes read"
1584
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001585run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001586 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1587 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1588 0 \
1589 -S "ssl_handshake returned" \
1590 -C "ssl_handshake returned" \
1591 -c "Read from server: .* bytes read"
1592
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001593# Tests for version negotiation
1594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001595run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001596 "$P_SRV" \
1597 "$P_CLI" \
1598 0 \
1599 -S "ssl_handshake returned" \
1600 -C "ssl_handshake returned" \
1601 -s "Protocol is TLSv1.2" \
1602 -c "Protocol is TLSv1.2"
1603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001604run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001605 "$P_SRV" \
1606 "$P_CLI max_version=tls1_1" \
1607 0 \
1608 -S "ssl_handshake returned" \
1609 -C "ssl_handshake returned" \
1610 -s "Protocol is TLSv1.1" \
1611 -c "Protocol is TLSv1.1"
1612
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001613run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001614 "$P_SRV max_version=tls1_1" \
1615 "$P_CLI" \
1616 0 \
1617 -S "ssl_handshake returned" \
1618 -C "ssl_handshake returned" \
1619 -s "Protocol is TLSv1.1" \
1620 -c "Protocol is TLSv1.1"
1621
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001622run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001623 "$P_SRV max_version=tls1_1" \
1624 "$P_CLI max_version=tls1_1" \
1625 0 \
1626 -S "ssl_handshake returned" \
1627 -C "ssl_handshake returned" \
1628 -s "Protocol is TLSv1.1" \
1629 -c "Protocol is TLSv1.1"
1630
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001631run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001632 "$P_SRV min_version=tls1_1" \
1633 "$P_CLI max_version=tls1_1" \
1634 0 \
1635 -S "ssl_handshake returned" \
1636 -C "ssl_handshake returned" \
1637 -s "Protocol is TLSv1.1" \
1638 -c "Protocol is TLSv1.1"
1639
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001640run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001641 "$P_SRV max_version=tls1_1" \
1642 "$P_CLI min_version=tls1_1" \
1643 0 \
1644 -S "ssl_handshake returned" \
1645 -C "ssl_handshake returned" \
1646 -s "Protocol is TLSv1.1" \
1647 -c "Protocol is TLSv1.1"
1648
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001649run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001650 "$P_SRV max_version=tls1_1" \
1651 "$P_CLI min_version=tls1_2" \
1652 1 \
1653 -s "ssl_handshake returned" \
1654 -c "ssl_handshake returned" \
1655 -c "SSL - Handshake protocol not within min/max boundaries"
1656
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001657run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001658 "$P_SRV min_version=tls1_2" \
1659 "$P_CLI max_version=tls1_1" \
1660 1 \
1661 -s "ssl_handshake returned" \
1662 -c "ssl_handshake returned" \
1663 -s "SSL - Handshake protocol not within min/max boundaries"
1664
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001665# Tests for ALPN extension
1666
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001667if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1668
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001669run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001670 "$P_SRV debug_level=3" \
1671 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001672 0 \
1673 -C "client hello, adding alpn extension" \
1674 -S "found alpn extension" \
1675 -C "got an alert message, type: \\[2:120]" \
1676 -S "server hello, adding alpn extension" \
1677 -C "found alpn extension " \
1678 -C "Application Layer Protocol is" \
1679 -S "Application Layer Protocol is"
1680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001681run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001682 "$P_SRV debug_level=3" \
1683 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001684 0 \
1685 -c "client hello, adding alpn extension" \
1686 -s "found alpn extension" \
1687 -C "got an alert message, type: \\[2:120]" \
1688 -S "server hello, adding alpn extension" \
1689 -C "found alpn extension " \
1690 -c "Application Layer Protocol is (none)" \
1691 -S "Application Layer Protocol is"
1692
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001693run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001694 "$P_SRV debug_level=3 alpn=abc,1234" \
1695 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001696 0 \
1697 -C "client hello, adding alpn extension" \
1698 -S "found alpn extension" \
1699 -C "got an alert message, type: \\[2:120]" \
1700 -S "server hello, adding alpn extension" \
1701 -C "found alpn extension " \
1702 -C "Application Layer Protocol is" \
1703 -s "Application Layer Protocol is (none)"
1704
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001705run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001706 "$P_SRV debug_level=3 alpn=abc,1234" \
1707 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001708 0 \
1709 -c "client hello, adding alpn extension" \
1710 -s "found alpn extension" \
1711 -C "got an alert message, type: \\[2:120]" \
1712 -s "server hello, adding alpn extension" \
1713 -c "found alpn extension" \
1714 -c "Application Layer Protocol is abc" \
1715 -s "Application Layer Protocol is abc"
1716
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001717run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001718 "$P_SRV debug_level=3 alpn=abc,1234" \
1719 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001720 0 \
1721 -c "client hello, adding alpn extension" \
1722 -s "found alpn extension" \
1723 -C "got an alert message, type: \\[2:120]" \
1724 -s "server hello, adding alpn extension" \
1725 -c "found alpn extension" \
1726 -c "Application Layer Protocol is abc" \
1727 -s "Application Layer Protocol is abc"
1728
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001729run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001730 "$P_SRV debug_level=3 alpn=abc,1234" \
1731 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001732 0 \
1733 -c "client hello, adding alpn extension" \
1734 -s "found alpn extension" \
1735 -C "got an alert message, type: \\[2:120]" \
1736 -s "server hello, adding alpn extension" \
1737 -c "found alpn extension" \
1738 -c "Application Layer Protocol is 1234" \
1739 -s "Application Layer Protocol is 1234"
1740
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001741run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001742 "$P_SRV debug_level=3 alpn=abc,123" \
1743 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001744 1 \
1745 -c "client hello, adding alpn extension" \
1746 -s "found alpn extension" \
1747 -c "got an alert message, type: \\[2:120]" \
1748 -S "server hello, adding alpn extension" \
1749 -C "found alpn extension" \
1750 -C "Application Layer Protocol is 1234" \
1751 -S "Application Layer Protocol is 1234"
1752
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001753fi
1754
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001755# Tests for keyUsage in leaf certificates, part 1:
1756# server-side certificate/suite selection
1757
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001758run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001759 "$P_SRV key_file=data_files/server2.key \
1760 crt_file=data_files/server2.ku-ds.crt" \
1761 "$P_CLI" \
1762 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001763 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001764
1765
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001766run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001767 "$P_SRV key_file=data_files/server2.key \
1768 crt_file=data_files/server2.ku-ke.crt" \
1769 "$P_CLI" \
1770 0 \
1771 -c "Ciphersuite is TLS-RSA-WITH-"
1772
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001773run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001774 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001775 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001776 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001777 1 \
1778 -C "Ciphersuite is "
1779
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001780run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001781 "$P_SRV key_file=data_files/server5.key \
1782 crt_file=data_files/server5.ku-ds.crt" \
1783 "$P_CLI" \
1784 0 \
1785 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1786
1787
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001788run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001789 "$P_SRV key_file=data_files/server5.key \
1790 crt_file=data_files/server5.ku-ka.crt" \
1791 "$P_CLI" \
1792 0 \
1793 -c "Ciphersuite is TLS-ECDH-"
1794
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001795run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001796 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001797 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001798 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001799 1 \
1800 -C "Ciphersuite is "
1801
1802# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001803# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001804
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001805run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001806 "$O_SRV -key data_files/server2.key \
1807 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001808 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001809 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1810 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001811 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001812 -C "Processing of the Certificate handshake message failed" \
1813 -c "Ciphersuite is TLS-"
1814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001815run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001816 "$O_SRV -key data_files/server2.key \
1817 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001818 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001819 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1820 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001821 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001822 -C "Processing of the Certificate handshake message failed" \
1823 -c "Ciphersuite is TLS-"
1824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001825run_test "keyUsage cli: 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-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: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001836 "$O_SRV -key data_files/server2.key \
1837 -cert data_files/server2.ku-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 1 \
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: DigitalSignature, DHE-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-ds.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-DHE-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: DigitalSignature, 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-ds.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-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é-Gonnarda9db85d2014-04-09 14:53:05 +02001865# Tests for keyUsage in leaf certificates, part 3:
1866# server-side checking of client cert
1867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001868run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001869 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001870 "$O_CLI -key data_files/server2.key \
1871 -cert data_files/server2.ku-ds.crt" \
1872 0 \
1873 -S "bad certificate (usage extensions)" \
1874 -S "Processing of the Certificate handshake message failed"
1875
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001876run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001877 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001878 "$O_CLI -key data_files/server2.key \
1879 -cert data_files/server2.ku-ke.crt" \
1880 0 \
1881 -s "bad certificate (usage extensions)" \
1882 -S "Processing of the Certificate handshake message failed"
1883
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001884run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001885 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001886 "$O_CLI -key data_files/server2.key \
1887 -cert data_files/server2.ku-ke.crt" \
1888 1 \
1889 -s "bad certificate (usage extensions)" \
1890 -s "Processing of the Certificate handshake message failed"
1891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001892run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001893 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001894 "$O_CLI -key data_files/server5.key \
1895 -cert data_files/server5.ku-ds.crt" \
1896 0 \
1897 -S "bad certificate (usage extensions)" \
1898 -S "Processing of the Certificate handshake message failed"
1899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001900run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001901 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001902 "$O_CLI -key data_files/server5.key \
1903 -cert data_files/server5.ku-ka.crt" \
1904 0 \
1905 -s "bad certificate (usage extensions)" \
1906 -S "Processing of the Certificate handshake message failed"
1907
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001908# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1909
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001910run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001911 "$P_SRV key_file=data_files/server5.key \
1912 crt_file=data_files/server5.eku-srv.crt" \
1913 "$P_CLI" \
1914 0
1915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001916run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001917 "$P_SRV key_file=data_files/server5.key \
1918 crt_file=data_files/server5.eku-srv.crt" \
1919 "$P_CLI" \
1920 0
1921
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001922run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001923 "$P_SRV key_file=data_files/server5.key \
1924 crt_file=data_files/server5.eku-cs_any.crt" \
1925 "$P_CLI" \
1926 0
1927
1928# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001929run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001930 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1931 crt_file=data_files/server5.eku-cli.crt" \
1932 "$P_CLI psk=badbad" \
1933 1
1934
1935# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1936
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001937run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001938 "$O_SRV -key data_files/server5.key \
1939 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001940 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001941 0 \
1942 -C "bad certificate (usage extensions)" \
1943 -C "Processing of the Certificate handshake message failed" \
1944 -c "Ciphersuite is TLS-"
1945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001946run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001947 "$O_SRV -key data_files/server5.key \
1948 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001949 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001950 0 \
1951 -C "bad certificate (usage extensions)" \
1952 -C "Processing of the Certificate handshake message failed" \
1953 -c "Ciphersuite is TLS-"
1954
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001955run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001956 "$O_SRV -key data_files/server5.key \
1957 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001958 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001959 0 \
1960 -C "bad certificate (usage extensions)" \
1961 -C "Processing of the Certificate handshake message failed" \
1962 -c "Ciphersuite is TLS-"
1963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001964run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001965 "$O_SRV -key data_files/server5.key \
1966 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001967 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001968 1 \
1969 -c "bad certificate (usage extensions)" \
1970 -c "Processing of the Certificate handshake message failed" \
1971 -C "Ciphersuite is TLS-"
1972
1973# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001975run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001976 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001977 "$O_CLI -key data_files/server5.key \
1978 -cert data_files/server5.eku-cli.crt" \
1979 0 \
1980 -S "bad certificate (usage extensions)" \
1981 -S "Processing of the Certificate handshake message failed"
1982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001983run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001984 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001985 "$O_CLI -key data_files/server5.key \
1986 -cert data_files/server5.eku-srv_cli.crt" \
1987 0 \
1988 -S "bad certificate (usage extensions)" \
1989 -S "Processing of the Certificate handshake message failed"
1990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001991run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001992 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001993 "$O_CLI -key data_files/server5.key \
1994 -cert data_files/server5.eku-cs_any.crt" \
1995 0 \
1996 -S "bad certificate (usage extensions)" \
1997 -S "Processing of the Certificate handshake message failed"
1998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001999run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002000 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002001 "$O_CLI -key data_files/server5.key \
2002 -cert data_files/server5.eku-cs.crt" \
2003 0 \
2004 -s "bad certificate (usage extensions)" \
2005 -S "Processing of the Certificate handshake message failed"
2006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002007run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002008 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002009 "$O_CLI -key data_files/server5.key \
2010 -cert data_files/server5.eku-cs.crt" \
2011 1 \
2012 -s "bad certificate (usage extensions)" \
2013 -s "Processing of the Certificate handshake message failed"
2014
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002015# Tests for DHM parameters loading
2016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002017run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002018 "$P_SRV" \
2019 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2020 debug_level=3" \
2021 0 \
2022 -c "value of 'DHM: P ' (2048 bits)" \
2023 -c "value of 'DHM: G ' (2048 bits)"
2024
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002025run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002026 "$P_SRV dhm_file=data_files/dhparams.pem" \
2027 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2028 debug_level=3" \
2029 0 \
2030 -c "value of 'DHM: P ' (1024 bits)" \
2031 -c "value of 'DHM: G ' (2 bits)"
2032
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002033# Tests for PSK callback
2034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002035run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002036 "$P_SRV psk=abc123 psk_identity=foo" \
2037 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2038 psk_identity=foo psk=abc123" \
2039 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002040 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002041 -S "SSL - Unknown identity received" \
2042 -S "SSL - Verification of the message MAC failed"
2043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002044run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002045 "$P_SRV" \
2046 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2047 psk_identity=foo psk=abc123" \
2048 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002049 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002050 -S "SSL - Unknown identity received" \
2051 -S "SSL - Verification of the message MAC failed"
2052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002053run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002054 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2055 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2056 psk_identity=foo psk=abc123" \
2057 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002058 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002059 -s "SSL - Unknown identity received" \
2060 -S "SSL - Verification of the message MAC failed"
2061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002062run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002063 "$P_SRV psk_list=abc,dead,def,beef" \
2064 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2065 psk_identity=abc psk=dead" \
2066 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002067 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002068 -S "SSL - Unknown identity received" \
2069 -S "SSL - Verification of the message MAC failed"
2070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002071run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002072 "$P_SRV psk_list=abc,dead,def,beef" \
2073 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2074 psk_identity=def psk=beef" \
2075 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002076 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002077 -S "SSL - Unknown identity received" \
2078 -S "SSL - Verification of the message MAC failed"
2079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002080run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002081 "$P_SRV psk_list=abc,dead,def,beef" \
2082 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2083 psk_identity=ghi psk=beef" \
2084 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002085 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002086 -s "SSL - Unknown identity received" \
2087 -S "SSL - Verification of the message MAC failed"
2088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002089run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002090 "$P_SRV psk_list=abc,dead,def,beef" \
2091 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2092 psk_identity=abc psk=beef" \
2093 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002094 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002095 -S "SSL - Unknown identity received" \
2096 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002097
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002098# Tests for ciphersuites per version
2099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002100run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002101 "$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" \
2102 "$P_CLI force_version=ssl3" \
2103 0 \
2104 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002106run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002107 "$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" \
2108 "$P_CLI force_version=tls1" \
2109 0 \
2110 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2111
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002112run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002113 "$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" \
2114 "$P_CLI force_version=tls1_1" \
2115 0 \
2116 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2117
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002118run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002119 "$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" \
2120 "$P_CLI force_version=tls1_2" \
2121 0 \
2122 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2123
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002124# Tests for ssl_get_bytes_avail()
2125
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002126run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002127 "$P_SRV" \
2128 "$P_CLI request_size=100" \
2129 0 \
2130 -s "Read from client: 100 bytes read$"
2131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002132run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002133 "$P_SRV" \
2134 "$P_CLI request_size=500" \
2135 0 \
2136 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002137
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002138# Tests for small packets
2139
2140run_test "Small packet SSLv3 BlockCipher" \
2141 "$P_SRV" \
2142 "$P_CLI request_size=1 force_version=ssl3 \
2143 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2144 0 \
2145 -s "Read from client: 1 bytes read"
2146
2147run_test "Small packet SSLv3 StreamCipher" \
2148 "$P_SRV" \
2149 "$P_CLI request_size=1 force_version=ssl3 \
2150 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2151 0 \
2152 -s "Read from client: 1 bytes read"
2153
2154run_test "Small packet TLS 1.0 BlockCipher" \
2155 "$P_SRV" \
2156 "$P_CLI request_size=1 force_version=tls1 \
2157 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2158 0 \
2159 -s "Read from client: 1 bytes read"
2160
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002161run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2162 "$P_SRV" \
2163 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2164 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2165 0 \
2166 -s "Read from client: 1 bytes read"
2167
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002168run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2169 "$P_SRV" \
2170 "$P_CLI request_size=1 force_version=tls1 \
2171 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2172 trunc_hmac=1" \
2173 0 \
2174 -s "Read from client: 1 bytes read"
2175
2176run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
2177 "$P_SRV" \
2178 "$P_CLI request_size=1 force_version=tls1 \
2179 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2180 trunc_hmac=1" \
2181 0 \
2182 -s "Read from client: 1 bytes read"
2183
2184run_test "Small packet TLS 1.1 BlockCipher" \
2185 "$P_SRV" \
2186 "$P_CLI request_size=1 force_version=tls1_1 \
2187 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2188 0 \
2189 -s "Read from client: 1 bytes read"
2190
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002191run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2192 "$P_SRV" \
2193 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2194 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2195 0 \
2196 -s "Read from client: 1 bytes read"
2197
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002198run_test "Small packet TLS 1.1 StreamCipher" \
2199 "$P_SRV" \
2200 "$P_CLI request_size=1 force_version=tls1_1 \
2201 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2202 0 \
2203 -s "Read from client: 1 bytes read"
2204
2205run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2206 "$P_SRV" \
2207 "$P_CLI request_size=1 force_version=tls1_1 \
2208 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2209 trunc_hmac=1" \
2210 0 \
2211 -s "Read from client: 1 bytes read"
2212
2213run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
2214 "$P_SRV" \
2215 "$P_CLI request_size=1 force_version=tls1_1 \
2216 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2217 trunc_hmac=1" \
2218 0 \
2219 -s "Read from client: 1 bytes read"
2220
2221run_test "Small packet TLS 1.2 BlockCipher" \
2222 "$P_SRV" \
2223 "$P_CLI request_size=1 force_version=tls1_2 \
2224 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2225 0 \
2226 -s "Read from client: 1 bytes read"
2227
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002228run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2229 "$P_SRV" \
2230 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2231 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2232 0 \
2233 -s "Read from client: 1 bytes read"
2234
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002235run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2236 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002237 "$P_CLI request_size=1 force_version=tls1_2 \
2238 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002239 0 \
2240 -s "Read from client: 1 bytes read"
2241
2242run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2243 "$P_SRV" \
2244 "$P_CLI request_size=1 force_version=tls1_2 \
2245 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2246 trunc_hmac=1" \
2247 0 \
2248 -s "Read from client: 1 bytes read"
2249
2250run_test "Small packet TLS 1.2 StreamCipher" \
2251 "$P_SRV" \
2252 "$P_CLI request_size=1 force_version=tls1_2 \
2253 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2254 0 \
2255 -s "Read from client: 1 bytes read"
2256
2257run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
2258 "$P_SRV" \
2259 "$P_CLI request_size=1 force_version=tls1_2 \
2260 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2261 trunc_hmac=1" \
2262 0 \
2263 -s "Read from client: 1 bytes read"
2264
2265run_test "Small packet TLS 1.2 AEAD" \
2266 "$P_SRV" \
2267 "$P_CLI request_size=1 force_version=tls1_2 \
2268 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2269 0 \
2270 -s "Read from client: 1 bytes read"
2271
2272run_test "Small packet TLS 1.2 AEAD shorter tag" \
2273 "$P_SRV" \
2274 "$P_CLI request_size=1 force_version=tls1_2 \
2275 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2276 0 \
2277 -s "Read from client: 1 bytes read"
2278
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002279# Test for large packets
2280
2281run_test "Large packet SSLv3 BlockCipher" \
2282 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002283 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002284 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2285 0 \
2286 -s "Read from client: 16384 bytes read"
2287
2288run_test "Large packet SSLv3 StreamCipher" \
2289 "$P_SRV" \
2290 "$P_CLI request_size=16384 force_version=ssl3 \
2291 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2292 0 \
2293 -s "Read from client: 16384 bytes read"
2294
2295run_test "Large packet TLS 1.0 BlockCipher" \
2296 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002297 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002298 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2299 0 \
2300 -s "Read from client: 16384 bytes read"
2301
2302run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2303 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002304 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002305 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2306 trunc_hmac=1" \
2307 0 \
2308 -s "Read from client: 16384 bytes read"
2309
2310run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
2311 "$P_SRV" \
2312 "$P_CLI request_size=16384 force_version=tls1 \
2313 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2314 trunc_hmac=1" \
2315 0 \
2316 -s "Read from client: 16384 bytes read"
2317
2318run_test "Large packet TLS 1.1 BlockCipher" \
2319 "$P_SRV" \
2320 "$P_CLI request_size=16384 force_version=tls1_1 \
2321 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2322 0 \
2323 -s "Read from client: 16384 bytes read"
2324
2325run_test "Large packet TLS 1.1 StreamCipher" \
2326 "$P_SRV" \
2327 "$P_CLI request_size=16384 force_version=tls1_1 \
2328 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2329 0 \
2330 -s "Read from client: 16384 bytes read"
2331
2332run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2333 "$P_SRV" \
2334 "$P_CLI request_size=16384 force_version=tls1_1 \
2335 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2336 trunc_hmac=1" \
2337 0 \
2338 -s "Read from client: 16384 bytes read"
2339
2340run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
2341 "$P_SRV" \
2342 "$P_CLI request_size=16384 force_version=tls1_1 \
2343 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2344 trunc_hmac=1" \
2345 0 \
2346 -s "Read from client: 16384 bytes read"
2347
2348run_test "Large packet TLS 1.2 BlockCipher" \
2349 "$P_SRV" \
2350 "$P_CLI request_size=16384 force_version=tls1_2 \
2351 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2352 0 \
2353 -s "Read from client: 16384 bytes read"
2354
2355run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2356 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002357 "$P_CLI request_size=16384 force_version=tls1_2 \
2358 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002359 0 \
2360 -s "Read from client: 16384 bytes read"
2361
2362run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2363 "$P_SRV" \
2364 "$P_CLI request_size=16384 force_version=tls1_2 \
2365 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2366 trunc_hmac=1" \
2367 0 \
2368 -s "Read from client: 16384 bytes read"
2369
2370run_test "Large packet TLS 1.2 StreamCipher" \
2371 "$P_SRV" \
2372 "$P_CLI request_size=16384 force_version=tls1_2 \
2373 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2374 0 \
2375 -s "Read from client: 16384 bytes read"
2376
2377run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
2378 "$P_SRV" \
2379 "$P_CLI request_size=16384 force_version=tls1_2 \
2380 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2381 trunc_hmac=1" \
2382 0 \
2383 -s "Read from client: 16384 bytes read"
2384
2385run_test "Large packet TLS 1.2 AEAD" \
2386 "$P_SRV" \
2387 "$P_CLI request_size=16384 force_version=tls1_2 \
2388 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2389 0 \
2390 -s "Read from client: 16384 bytes read"
2391
2392run_test "Large packet TLS 1.2 AEAD shorter tag" \
2393 "$P_SRV" \
2394 "$P_CLI request_size=16384 force_version=tls1_2 \
2395 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2396 0 \
2397 -s "Read from client: 16384 bytes read"
2398
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002399# Final report
2400
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002401echo "------------------------------------------------------------------------"
2402
2403if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002404 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002405else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002406 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002407fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002408PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002409echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002410
2411exit $FAILS