blob: 51c3fd0c6d24e3d3425028e0e2adf05dce04ebe4 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
9# Assumes all options are compiled in.
10
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010016: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020017: ${GNUTLS_CLI:=gnutls-cli}
18: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010019
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010020O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
21O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020022G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010023G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010024
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010025TESTS=0
26FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020027SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020029CONFIG_H='../include/polarssl/config.h'
30
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010031MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010032FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020033EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034
35print_usage() {
36 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010037 printf " -h|--help\tPrint this help.\n"
38 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
39 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
40 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041}
42
43get_options() {
44 while [ $# -gt 0 ]; do
45 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046 -f|--filter)
47 shift; FILTER=$1
48 ;;
49 -e|--exclude)
50 shift; EXCLUDE=$1
51 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052 -m|--memcheck)
53 MEMCHECK=1
54 ;;
55 -h|--help)
56 print_usage
57 exit 0
58 ;;
59 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020060 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061 print_usage
62 exit 1
63 ;;
64 esac
65 shift
66 done
67}
68
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020069# skip next test if OpenSSL can't send SSLv2 ClientHello
70requires_openssl_with_sslv2() {
71 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020072 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020073 OPENSSL_HAS_SSL2="YES"
74 else
75 OPENSSL_HAS_SSL2="NO"
76 fi
77 fi
78 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020083# skip next test if OpenSSL doesn't support FALLBACK_SCSV
84requires_openssl_with_fallback_scsv() {
85 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
86 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
87 then
88 OPENSSL_HAS_FBSCSV="YES"
89 else
90 OPENSSL_HAS_FBSCSV="NO"
91 fi
92 fi
93 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
94 SKIP_NEXT="YES"
95 fi
96}
97
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020098# skip next test if GnuTLS isn't available
99requires_gnutls() {
100 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
101 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
102 GNUTLS_AVAILABLE="YES"
103 else
104 GNUTLS_AVAILABLE="NO"
105 fi
106 fi
107 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
108 SKIP_NEXT="YES"
109 fi
110}
111
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100112# print_name <name>
113print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100114 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200115 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100116 for i in `seq 1 $LEN`; do printf '.'; done
117 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100118
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200119 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100120}
121
122# fail <message>
123fail() {
124 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100125 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100126
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200127 mv $SRV_OUT o-srv-${TESTS}.log
128 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100129 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100130
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200131 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
132 echo " ! server output:"
133 cat o-srv-${TESTS}.log
134 echo " ! ============================================================"
135 echo " ! client output:"
136 cat o-cli-${TESTS}.log
137 fi
138
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200139 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100140}
141
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100142# is_polar <cmd_line>
143is_polar() {
144 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
145}
146
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100147# has_mem_err <log_file_name>
148has_mem_err() {
149 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
150 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
151 then
152 return 1 # false: does not have errors
153 else
154 return 0 # true: has errors
155 fi
156}
157
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200158# wait for server to start: two versions depending on lsof availability
159wait_server_start() {
160 if which lsof >/dev/null; then
161 # make sure we don't loop forever
162 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
163 WATCHDOG_PID=$!
164
165 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100166 until lsof -nbi TCP:"$PORT" 2>/dev/null | grep LISTEN >/dev/null;
167 do :; done
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200168
169 kill $WATCHDOG_PID
170 wait $WATCHDOG_PID
171 else
172 sleep "$START_DELAY"
173 fi
174}
175
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200176# wait for client to terminate and set CLI_EXIT
177# must be called right after starting the client
178wait_client_done() {
179 CLI_PID=$!
180
181 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
182 WATCHDOG_PID=$!
183
184 wait $CLI_PID
185 CLI_EXIT=$?
186
187 kill $WATCHDOG_PID
188 wait $WATCHDOG_PID
189
190 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
191}
192
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100193# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100194# Options: -s pattern pattern that must be present in server output
195# -c pattern pattern that must be present in client output
196# -S pattern pattern that must be absent in server output
197# -C pattern pattern that must be absent in client output
198run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100199 NAME="$1"
200 SRV_CMD="$2"
201 CLI_CMD="$3"
202 CLI_EXPECT="$4"
203 shift 4
204
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100205 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
206 else
207 return
208 fi
209
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100210 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100211
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200212 # should we skip?
213 if [ "X$SKIP_NEXT" = "XYES" ]; then
214 SKIP_NEXT="NO"
215 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200216 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200217 return
218 fi
219
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100220 # prepend valgrind to our commands if active
221 if [ "$MEMCHECK" -gt 0 ]; then
222 if is_polar "$SRV_CMD"; then
223 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
224 fi
225 if is_polar "$CLI_CMD"; then
226 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
227 fi
228 fi
229
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100230 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200231 echo "$SRV_CMD" > $SRV_OUT
232 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100233 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200234 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200235
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200236 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200237 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
238 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100239
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200240 # kill the server
241 kill $SRV_PID
242 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100243
244 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200245 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100246 # expected client exit to incorrectly succeed in case of catastrophic
247 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100248 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200249 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100250 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100251 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100252 return
253 fi
254 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100255 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200256 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100257 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100258 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100259 return
260 fi
261 fi
262
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100263 # check server exit code
264 if [ $? != 0 ]; then
265 fail "server fail"
266 return
267 fi
268
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100269 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100270 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
271 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100272 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100273 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100274 return
275 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100276
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100277 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200278 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100279 while [ $# -gt 0 ]
280 do
281 case $1 in
282 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200283 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100284 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100285 return
286 fi
287 ;;
288
289 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200290 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100291 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100292 return
293 fi
294 ;;
295
296 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200297 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100298 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100299 return
300 fi
301 ;;
302
303 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200304 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100305 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100306 return
307 fi
308 ;;
309
310 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200311 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100312 exit 1
313 esac
314 shift 2
315 done
316
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100317 # check valgrind's results
318 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200319 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100320 fail "Server has memory errors"
321 return
322 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200323 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100324 fail "Client has memory errors"
325 return
326 fi
327 fi
328
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100329 # if we're here, everything is ok
330 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200331 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100332}
333
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100334cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200335 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200336 kill $SRV_PID >/dev/null 2>&1
337 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100338 exit 1
339}
340
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100341#
342# MAIN
343#
344
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100345get_options "$@"
346
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100347# sanity checks, avoid an avalanche of errors
348if [ ! -x "$P_SRV" ]; then
349 echo "Command '$P_SRV' is not an executable file"
350 exit 1
351fi
352if [ ! -x "$P_CLI" ]; then
353 echo "Command '$P_CLI' is not an executable file"
354 exit 1
355fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100356if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
357 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100358 exit 1
359fi
360
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200361# used by watchdog
362MAIN_PID="$$"
363
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200364# be more patient with valgrind
365if [ "$MEMCHECK" -gt 0 ]; then
366 START_DELAY=3
367 DOG_DELAY=30
368else
369 START_DELAY=1
370 DOG_DELAY=10
371fi
372
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200373# Pick a "unique" port in the range 10000-19999.
374PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200375PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200376
377# fix commands to use this port
378P_SRV="$P_SRV server_port=$PORT"
379P_CLI="$P_CLI server_port=$PORT"
380O_SRV="$O_SRV -accept $PORT"
381O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200382G_SRV="$G_SRV -p $PORT"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100383G_CLI="$G_CLI -p $PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200384
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200385# Also pick a unique name for intermediate files
386SRV_OUT="srv_out.$$"
387CLI_OUT="cli_out.$$"
388SESSION="session.$$"
389
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200390SKIP_NEXT="NO"
391
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100392trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100393
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200394# Basic test
395
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200396# Checks that:
397# - things work with all ciphersuites active (used with config-full in all.sh)
398# - the expected (highest security) parameters are selected
399# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200400run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200401 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200402 "$P_CLI" \
403 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200404 -s "Protocol is TLSv1.2" \
405 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
406 -s "client hello v3, signature_algorithm ext: 6" \
407 -s "ECDHE curve: secp521r1" \
408 -S "error" \
409 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200410
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100411# Test for SSLv2 ClientHello
412
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200413requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200414run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100415 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100416 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100417 0 \
418 -S "parse client hello v2" \
419 -S "ssl_handshake returned"
420
421# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200422requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200423run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200424 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100425 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100426 0 \
427 -s "parse client hello v2" \
428 -S "ssl_handshake returned"
429
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100430# Tests for Truncated HMAC extension
431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200432run_test "Truncated HMAC: reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200433 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100434 "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100435 0 \
436 -s "dumping 'computed mac' (20 bytes)"
437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200438run_test "Truncated HMAC: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200439 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100440 "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100441 0 \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100442 -s "dumping 'computed mac' (10 bytes)"
443
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100444# Tests for Encrypt-then-MAC extension
445
446run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100447 "$P_SRV debug_level=3 \
448 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100449 "$P_CLI debug_level=3" \
450 0 \
451 -c "client hello, adding encrypt_then_mac extension" \
452 -s "found encrypt then mac extension" \
453 -s "server hello, adding encrypt then mac extension" \
454 -c "found encrypt_then_mac extension" \
455 -c "using encrypt then mac" \
456 -s "using encrypt then mac"
457
458run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100459 "$P_SRV debug_level=3 etm=0 \
460 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100461 "$P_CLI debug_level=3 etm=1" \
462 0 \
463 -c "client hello, adding encrypt_then_mac extension" \
464 -s "found encrypt then mac extension" \
465 -S "server hello, adding encrypt then mac extension" \
466 -C "found encrypt_then_mac extension" \
467 -C "using encrypt then mac" \
468 -S "using encrypt then mac"
469
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100470run_test "Encrypt then MAC: client enabled, aead cipher" \
471 "$P_SRV debug_level=3 etm=1 \
472 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
473 "$P_CLI debug_level=3 etm=1" \
474 0 \
475 -c "client hello, adding encrypt_then_mac extension" \
476 -s "found encrypt then mac extension" \
477 -S "server hello, adding encrypt then mac extension" \
478 -C "found encrypt_then_mac extension" \
479 -C "using encrypt then mac" \
480 -S "using encrypt then mac"
481
482run_test "Encrypt then MAC: client enabled, stream cipher" \
483 "$P_SRV debug_level=3 etm=1 \
484 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
485 "$P_CLI debug_level=3 etm=1" \
486 0 \
487 -c "client hello, adding encrypt_then_mac extension" \
488 -s "found encrypt then mac extension" \
489 -S "server hello, adding encrypt then mac extension" \
490 -C "found encrypt_then_mac extension" \
491 -C "using encrypt then mac" \
492 -S "using encrypt then mac"
493
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100494run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100495 "$P_SRV debug_level=3 etm=1 \
496 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100497 "$P_CLI debug_level=3 etm=0" \
498 0 \
499 -C "client hello, adding encrypt_then_mac extension" \
500 -S "found encrypt then mac extension" \
501 -S "server hello, adding encrypt then mac extension" \
502 -C "found encrypt_then_mac extension" \
503 -C "using encrypt then mac" \
504 -S "using encrypt then mac"
505
506run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100507 "$P_SRV debug_level=3 \
508 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100509 "$P_CLI debug_level=3 force_version=ssl3" \
510 0 \
511 -C "client hello, adding encrypt_then_mac extension" \
512 -S "found encrypt then mac extension" \
513 -S "server hello, adding encrypt then mac extension" \
514 -C "found encrypt_then_mac extension" \
515 -C "using encrypt then mac" \
516 -S "using encrypt then mac"
517
518run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100519 "$P_SRV debug_level=3 force_version=ssl3 \
520 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100521 "$P_CLI debug_level=3" \
522 0 \
523 -c "client hello, adding encrypt_then_mac extension" \
524 -s "found encrypt then mac extension" \
525 -S "server hello, adding encrypt then mac extension" \
526 -C "found encrypt_then_mac extension" \
527 -C "using encrypt then mac" \
528 -S "using encrypt then mac"
529
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200530# Tests for Extended Master Secret extension
531
532run_test "Extended Master Secret: default" \
533 "$P_SRV debug_level=3" \
534 "$P_CLI debug_level=3" \
535 0 \
536 -c "client hello, adding extended_master_secret extension" \
537 -s "found extended master secret extension" \
538 -s "server hello, adding extended master secret extension" \
539 -c "found extended_master_secret extension" \
540 -c "using extended master secret" \
541 -s "using extended master secret"
542
543run_test "Extended Master Secret: client enabled, server disabled" \
544 "$P_SRV debug_level=3 extended_ms=0" \
545 "$P_CLI debug_level=3 extended_ms=1" \
546 0 \
547 -c "client hello, adding extended_master_secret extension" \
548 -s "found extended master secret extension" \
549 -S "server hello, adding extended master secret extension" \
550 -C "found extended_master_secret extension" \
551 -C "using extended master secret" \
552 -S "using extended master secret"
553
554run_test "Extended Master Secret: client disabled, server enabled" \
555 "$P_SRV debug_level=3 extended_ms=1" \
556 "$P_CLI debug_level=3 extended_ms=0" \
557 0 \
558 -C "client hello, adding extended_master_secret extension" \
559 -S "found extended master secret extension" \
560 -S "server hello, adding extended master secret extension" \
561 -C "found extended_master_secret extension" \
562 -C "using extended master secret" \
563 -S "using extended master secret"
564
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200565run_test "Extended Master Secret: client SSLv3, server enabled" \
566 "$P_SRV debug_level=3" \
567 "$P_CLI debug_level=3 force_version=ssl3" \
568 0 \
569 -C "client hello, adding extended_master_secret extension" \
570 -S "found extended master secret extension" \
571 -S "server hello, adding extended master secret extension" \
572 -C "found extended_master_secret extension" \
573 -C "using extended master secret" \
574 -S "using extended master secret"
575
576run_test "Extended Master Secret: client enabled, server SSLv3" \
577 "$P_SRV debug_level=3 force_version=ssl3" \
578 "$P_CLI debug_level=3" \
579 0 \
580 -c "client hello, adding extended_master_secret extension" \
581 -s "found extended master secret extension" \
582 -S "server hello, adding extended master secret extension" \
583 -C "found extended_master_secret extension" \
584 -C "using extended master secret" \
585 -S "using extended master secret"
586
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200587# Tests for FALLBACK_SCSV
588
589run_test "Fallback SCSV: default" \
590 "$P_SRV" \
591 "$P_CLI debug_level=3 force_version=tls1_1" \
592 0 \
593 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200594 -S "received FALLBACK_SCSV" \
595 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200596 -C "is a fatal alert message (msg 86)"
597
598run_test "Fallback SCSV: explicitly disabled" \
599 "$P_SRV" \
600 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
601 0 \
602 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200603 -S "received FALLBACK_SCSV" \
604 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200605 -C "is a fatal alert message (msg 86)"
606
607run_test "Fallback SCSV: enabled" \
608 "$P_SRV" \
609 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200610 1 \
611 -c "adding FALLBACK_SCSV" \
612 -s "received FALLBACK_SCSV" \
613 -s "inapropriate fallback" \
614 -c "is a fatal alert message (msg 86)"
615
616run_test "Fallback SCSV: enabled, max version" \
617 "$P_SRV" \
618 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200619 0 \
620 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200621 -s "received FALLBACK_SCSV" \
622 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200623 -C "is a fatal alert message (msg 86)"
624
625requires_openssl_with_fallback_scsv
626run_test "Fallback SCSV: default, openssl server" \
627 "$O_SRV" \
628 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
629 0 \
630 -C "adding FALLBACK_SCSV" \
631 -C "is a fatal alert message (msg 86)"
632
633requires_openssl_with_fallback_scsv
634run_test "Fallback SCSV: enabled, openssl server" \
635 "$O_SRV" \
636 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
637 1 \
638 -c "adding FALLBACK_SCSV" \
639 -c "is a fatal alert message (msg 86)"
640
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200641requires_openssl_with_fallback_scsv
642run_test "Fallback SCSV: disabled, openssl client" \
643 "$P_SRV" \
644 "$O_CLI -tls1_1" \
645 0 \
646 -S "received FALLBACK_SCSV" \
647 -S "inapropriate fallback"
648
649requires_openssl_with_fallback_scsv
650run_test "Fallback SCSV: enabled, openssl client" \
651 "$P_SRV" \
652 "$O_CLI -tls1_1 -fallback_scsv" \
653 1 \
654 -s "received FALLBACK_SCSV" \
655 -s "inapropriate fallback"
656
657requires_openssl_with_fallback_scsv
658run_test "Fallback SCSV: enabled, max version, openssl client" \
659 "$P_SRV" \
660 "$O_CLI -fallback_scsv" \
661 0 \
662 -s "received FALLBACK_SCSV" \
663 -S "inapropriate fallback"
664
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100665# Tests for CBC 1/n-1 record splitting
666
667run_test "CBC Record splitting: TLS 1.2, no splitting" \
668 "$P_SRV" \
669 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
670 request_size=123 force_version=tls1_2" \
671 0 \
672 -s "Read from client: 123 bytes read" \
673 -S "Read from client: 1 bytes read" \
674 -S "122 bytes read"
675
676run_test "CBC Record splitting: TLS 1.1, no splitting" \
677 "$P_SRV" \
678 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
679 request_size=123 force_version=tls1_1" \
680 0 \
681 -s "Read from client: 123 bytes read" \
682 -S "Read from client: 1 bytes read" \
683 -S "122 bytes read"
684
685run_test "CBC Record splitting: TLS 1.0, splitting" \
686 "$P_SRV" \
687 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
688 request_size=123 force_version=tls1" \
689 0 \
690 -S "Read from client: 123 bytes read" \
691 -s "Read from client: 1 bytes read" \
692 -s "122 bytes read"
693
694run_test "CBC Record splitting: SSLv3, splitting" \
695 "$P_SRV" \
696 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
697 request_size=123 force_version=ssl3" \
698 0 \
699 -S "Read from client: 123 bytes read" \
700 -s "Read from client: 1 bytes read" \
701 -s "122 bytes read"
702
703run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
704 "$P_SRV" \
705 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
706 request_size=123 force_version=tls1" \
707 0 \
708 -s "Read from client: 123 bytes read" \
709 -S "Read from client: 1 bytes read" \
710 -S "122 bytes read"
711
712run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
713 "$P_SRV" \
714 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
715 request_size=123 force_version=tls1 recsplit=0" \
716 0 \
717 -s "Read from client: 123 bytes read" \
718 -S "Read from client: 1 bytes read" \
719 -S "122 bytes read"
720
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100721run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
722 "$P_SRV nbio=2" \
723 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
724 request_size=123 force_version=tls1" \
725 0 \
726 -S "Read from client: 123 bytes read" \
727 -s "Read from client: 1 bytes read" \
728 -s "122 bytes read"
729
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100730# Tests for Session Tickets
731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200732run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200733 "$P_SRV debug_level=3 tickets=1" \
734 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100735 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100736 -c "client hello, adding session ticket extension" \
737 -s "found session ticket extension" \
738 -s "server hello, adding session ticket extension" \
739 -c "found session_ticket extension" \
740 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100741 -S "session successfully restored from cache" \
742 -s "session successfully restored from ticket" \
743 -s "a session has been resumed" \
744 -c "a session has been resumed"
745
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200746run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200747 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
748 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100749 0 \
750 -c "client hello, adding session ticket extension" \
751 -s "found session ticket extension" \
752 -s "server hello, adding session ticket extension" \
753 -c "found session_ticket extension" \
754 -c "parse new session ticket" \
755 -S "session successfully restored from cache" \
756 -s "session successfully restored from ticket" \
757 -s "a session has been resumed" \
758 -c "a session has been resumed"
759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200760run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200761 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
762 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100763 0 \
764 -c "client hello, adding session ticket extension" \
765 -s "found session ticket extension" \
766 -s "server hello, adding session ticket extension" \
767 -c "found session_ticket extension" \
768 -c "parse new session ticket" \
769 -S "session successfully restored from cache" \
770 -S "session successfully restored from ticket" \
771 -S "a session has been resumed" \
772 -C "a session has been resumed"
773
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200774run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100775 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200776 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100777 0 \
778 -c "client hello, adding session ticket extension" \
779 -c "found session_ticket extension" \
780 -c "parse new session ticket" \
781 -c "a session has been resumed"
782
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200783run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200784 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200785 "( $O_CLI -sess_out $SESSION; \
786 $O_CLI -sess_in $SESSION; \
787 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100788 0 \
789 -s "found session ticket extension" \
790 -s "server hello, adding session ticket extension" \
791 -S "session successfully restored from cache" \
792 -s "session successfully restored from ticket" \
793 -s "a session has been resumed"
794
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100795# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100796
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200797run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200798 "$P_SRV debug_level=3 tickets=0" \
799 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100800 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100801 -c "client hello, adding session ticket extension" \
802 -s "found session ticket extension" \
803 -S "server hello, adding session ticket extension" \
804 -C "found session_ticket extension" \
805 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100806 -s "session successfully restored from cache" \
807 -S "session successfully restored from ticket" \
808 -s "a session has been resumed" \
809 -c "a session has been resumed"
810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200811run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200812 "$P_SRV debug_level=3 tickets=1" \
813 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100814 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100815 -C "client hello, adding session ticket extension" \
816 -S "found session ticket extension" \
817 -S "server hello, adding session ticket extension" \
818 -C "found session_ticket extension" \
819 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100820 -s "session successfully restored from cache" \
821 -S "session successfully restored from ticket" \
822 -s "a session has been resumed" \
823 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200825run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200826 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
827 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100828 0 \
829 -S "session successfully restored from cache" \
830 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100831 -S "a session has been resumed" \
832 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100833
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200834run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200835 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
836 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100837 0 \
838 -s "session successfully restored from cache" \
839 -S "session successfully restored from ticket" \
840 -s "a session has been resumed" \
841 -c "a session has been resumed"
842
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200843run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200844 "$P_SRV debug_level=3 tickets=0" \
845 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100846 0 \
847 -s "session successfully restored from cache" \
848 -S "session successfully restored from ticket" \
849 -s "a session has been resumed" \
850 -c "a session has been resumed"
851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200852run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200853 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
854 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100855 0 \
856 -S "session successfully restored from cache" \
857 -S "session successfully restored from ticket" \
858 -S "a session has been resumed" \
859 -C "a session has been resumed"
860
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200861run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200862 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
863 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100864 0 \
865 -s "session successfully restored from cache" \
866 -S "session successfully restored from ticket" \
867 -s "a session has been resumed" \
868 -c "a session has been resumed"
869
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200870run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200871 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200872 "( $O_CLI -sess_out $SESSION; \
873 $O_CLI -sess_in $SESSION; \
874 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100875 0 \
876 -s "found session ticket extension" \
877 -S "server hello, adding session ticket extension" \
878 -s "session successfully restored from cache" \
879 -S "session successfully restored from ticket" \
880 -s "a session has been resumed"
881
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200882run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100883 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200884 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100885 0 \
886 -C "found session_ticket extension" \
887 -C "parse new session ticket" \
888 -c "a session has been resumed"
889
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100890# Tests for Max Fragment Length extension
891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200892run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200893 "$P_SRV debug_level=3" \
894 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100895 0 \
896 -C "client hello, adding max_fragment_length extension" \
897 -S "found max fragment length extension" \
898 -S "server hello, max_fragment_length extension" \
899 -C "found max_fragment_length extension"
900
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200901run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200902 "$P_SRV debug_level=3" \
903 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100904 0 \
905 -c "client hello, adding max_fragment_length extension" \
906 -s "found max fragment length extension" \
907 -s "server hello, max_fragment_length extension" \
908 -c "found max_fragment_length extension"
909
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200910run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200911 "$P_SRV debug_level=3 max_frag_len=4096" \
912 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100913 0 \
914 -C "client hello, adding max_fragment_length extension" \
915 -S "found max fragment length extension" \
916 -S "server hello, max_fragment_length extension" \
917 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100918
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200919requires_gnutls
920run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200921 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200922 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200923 0 \
924 -c "client hello, adding max_fragment_length extension" \
925 -c "found max_fragment_length extension"
926
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100927# Tests for renegotiation
928
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200929run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200930 "$P_SRV debug_level=3 exchanges=2" \
931 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100932 0 \
933 -C "client hello, adding renegotiation extension" \
934 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
935 -S "found renegotiation extension" \
936 -s "server hello, secure renegotiation extension" \
937 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100938 -C "=> renegotiate" \
939 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100940 -S "write hello request"
941
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200942run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200943 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
944 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100945 0 \
946 -c "client hello, adding renegotiation extension" \
947 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
948 -s "found renegotiation extension" \
949 -s "server hello, secure renegotiation extension" \
950 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100951 -c "=> renegotiate" \
952 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100953 -S "write hello request"
954
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200955run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200956 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
957 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100958 0 \
959 -c "client hello, adding renegotiation extension" \
960 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
961 -s "found renegotiation extension" \
962 -s "server hello, secure renegotiation extension" \
963 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100964 -c "=> renegotiate" \
965 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100966 -s "write hello request"
967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200968run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200969 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
970 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100971 0 \
972 -c "client hello, adding renegotiation extension" \
973 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
974 -s "found renegotiation extension" \
975 -s "server hello, secure renegotiation extension" \
976 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100977 -c "=> renegotiate" \
978 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100979 -s "write hello request"
980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200981run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200982 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
983 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100984 1 \
985 -c "client hello, adding renegotiation extension" \
986 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
987 -S "found renegotiation extension" \
988 -s "server hello, secure renegotiation extension" \
989 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100990 -c "=> renegotiate" \
991 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200992 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +0200993 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +0200994 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100995
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200996run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200997 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
998 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100999 0 \
1000 -C "client hello, adding renegotiation extension" \
1001 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1002 -S "found renegotiation extension" \
1003 -s "server hello, secure renegotiation extension" \
1004 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001005 -C "=> renegotiate" \
1006 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001007 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001008 -S "SSL - An unexpected message was received from our peer" \
1009 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001011run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001012 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001013 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001014 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001015 0 \
1016 -C "client hello, adding renegotiation extension" \
1017 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1018 -S "found renegotiation extension" \
1019 -s "server hello, secure renegotiation extension" \
1020 -c "found renegotiation extension" \
1021 -C "=> renegotiate" \
1022 -S "=> renegotiate" \
1023 -s "write hello request" \
1024 -S "SSL - An unexpected message was received from our peer" \
1025 -S "failed"
1026
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001027# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001028run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001029 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001030 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001031 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001032 0 \
1033 -C "client hello, adding renegotiation extension" \
1034 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1035 -S "found renegotiation extension" \
1036 -s "server hello, secure renegotiation extension" \
1037 -c "found renegotiation extension" \
1038 -C "=> renegotiate" \
1039 -S "=> renegotiate" \
1040 -s "write hello request" \
1041 -S "SSL - An unexpected message was received from our peer" \
1042 -S "failed"
1043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001044run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001045 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001046 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001047 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001048 0 \
1049 -C "client hello, adding renegotiation extension" \
1050 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1051 -S "found renegotiation extension" \
1052 -s "server hello, secure renegotiation extension" \
1053 -c "found renegotiation extension" \
1054 -C "=> renegotiate" \
1055 -S "=> renegotiate" \
1056 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001057 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001059run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001060 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001061 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001062 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001063 0 \
1064 -c "client hello, adding renegotiation extension" \
1065 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1066 -s "found renegotiation extension" \
1067 -s "server hello, secure renegotiation extension" \
1068 -c "found renegotiation extension" \
1069 -c "=> renegotiate" \
1070 -s "=> renegotiate" \
1071 -s "write hello request" \
1072 -S "SSL - An unexpected message was received from our peer" \
1073 -S "failed"
1074
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001075run_test "Renegotiation: periodic, just below period" \
1076 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1077 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1078 0 \
1079 -C "client hello, adding renegotiation extension" \
1080 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1081 -S "found renegotiation extension" \
1082 -s "server hello, secure renegotiation extension" \
1083 -c "found renegotiation extension" \
1084 -S "record counter limit reached: renegotiate" \
1085 -C "=> renegotiate" \
1086 -S "=> renegotiate" \
1087 -S "write hello request" \
1088 -S "SSL - An unexpected message was received from our peer" \
1089 -S "failed"
1090
1091run_test "Renegotiation: periodic, just above period" \
1092 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1093 "$P_CLI debug_level=3 exchanges=3 renegotiation=1" \
1094 0 \
1095 -c "client hello, adding renegotiation extension" \
1096 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1097 -s "found renegotiation extension" \
1098 -s "server hello, secure renegotiation extension" \
1099 -c "found renegotiation extension" \
1100 -s "record counter limit reached: renegotiate" \
1101 -c "=> renegotiate" \
1102 -s "=> renegotiate" \
1103 -s "write hello request" \
1104 -S "SSL - An unexpected message was received from our peer" \
1105 -S "failed"
1106
1107run_test "Renegotiation: periodic, two times period" \
1108 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1109 "$P_CLI debug_level=3 exchanges=6 renegotiation=1" \
1110 0 \
1111 -c "client hello, adding renegotiation extension" \
1112 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1113 -s "found renegotiation extension" \
1114 -s "server hello, secure renegotiation extension" \
1115 -c "found renegotiation extension" \
1116 -s "record counter limit reached: renegotiate" \
1117 -c "=> renegotiate" \
1118 -s "=> renegotiate" \
1119 -s "write hello request" \
1120 -S "SSL - An unexpected message was received from our peer" \
1121 -S "failed"
1122
1123run_test "Renegotiation: periodic, above period, disabled" \
1124 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1125 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1126 0 \
1127 -C "client hello, adding renegotiation extension" \
1128 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1129 -S "found renegotiation extension" \
1130 -s "server hello, secure renegotiation extension" \
1131 -c "found renegotiation extension" \
1132 -S "record counter limit reached: renegotiate" \
1133 -C "=> renegotiate" \
1134 -S "=> renegotiate" \
1135 -S "write hello request" \
1136 -S "SSL - An unexpected message was received from our peer" \
1137 -S "failed"
1138
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001139run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001140 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1141 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001142 0 \
1143 -c "client hello, adding renegotiation extension" \
1144 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1145 -s "found renegotiation extension" \
1146 -s "server hello, secure renegotiation extension" \
1147 -c "found renegotiation extension" \
1148 -c "=> renegotiate" \
1149 -s "=> renegotiate" \
1150 -S "write hello request"
1151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001152run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001153 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1154 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001155 0 \
1156 -c "client hello, adding renegotiation extension" \
1157 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1158 -s "found renegotiation extension" \
1159 -s "server hello, secure renegotiation extension" \
1160 -c "found renegotiation extension" \
1161 -c "=> renegotiate" \
1162 -s "=> renegotiate" \
1163 -s "write hello request"
1164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001165run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001166 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001167 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001168 0 \
1169 -c "client hello, adding renegotiation extension" \
1170 -c "found renegotiation extension" \
1171 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001172 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001173 -C "error" \
1174 -c "HTTP/1.0 200 [Oo][Kk]"
1175
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001176run_test "Renegotiation: gnutls server strict, client-initiated" \
1177 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001178 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001179 0 \
1180 -c "client hello, adding renegotiation extension" \
1181 -c "found renegotiation extension" \
1182 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001183 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001184 -C "error" \
1185 -c "HTTP/1.0 200 [Oo][Kk]"
1186
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001187run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1188 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1189 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1190 1 \
1191 -c "client hello, adding renegotiation extension" \
1192 -C "found renegotiation extension" \
1193 -c "=> renegotiate" \
1194 -c "ssl_handshake() returned" \
1195 -c "error" \
1196 -C "HTTP/1.0 200 [Oo][Kk]"
1197
1198run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1199 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1200 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1201 allow_legacy=0" \
1202 1 \
1203 -c "client hello, adding renegotiation extension" \
1204 -C "found renegotiation extension" \
1205 -c "=> renegotiate" \
1206 -c "ssl_handshake() returned" \
1207 -c "error" \
1208 -C "HTTP/1.0 200 [Oo][Kk]"
1209
1210run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1211 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1212 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1213 allow_legacy=1" \
1214 0 \
1215 -c "client hello, adding renegotiation extension" \
1216 -C "found renegotiation extension" \
1217 -c "=> renegotiate" \
1218 -C "ssl_hanshake() returned" \
1219 -C "error" \
1220 -c "HTTP/1.0 200 [Oo][Kk]"
1221
1222# Test for the "secure renegotation" extension only (no actual renegotiation)
1223
1224run_test "Renego ext: gnutls server strict, client default" \
1225 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1226 "$P_CLI debug_level=3" \
1227 0 \
1228 -c "found renegotiation extension" \
1229 -C "error" \
1230 -c "HTTP/1.0 200 [Oo][Kk]"
1231
1232run_test "Renego ext: gnutls server unsafe, client default" \
1233 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1234 "$P_CLI debug_level=3" \
1235 0 \
1236 -C "found renegotiation extension" \
1237 -C "error" \
1238 -c "HTTP/1.0 200 [Oo][Kk]"
1239
1240run_test "Renego ext: gnutls server unsafe, client break legacy" \
1241 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1242 "$P_CLI debug_level=3 allow_legacy=-1" \
1243 1 \
1244 -C "found renegotiation extension" \
1245 -c "error" \
1246 -C "HTTP/1.0 200 [Oo][Kk]"
1247
1248run_test "Renego ext: gnutls client strict, server default" \
1249 "$P_SRV debug_level=3" \
1250 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1251 0 \
1252 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1253 -s "server hello, secure renegotiation extension"
1254
1255run_test "Renego ext: gnutls client unsafe, server default" \
1256 "$P_SRV debug_level=3" \
1257 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1258 0 \
1259 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1260 -S "server hello, secure renegotiation extension"
1261
1262run_test "Renego ext: gnutls client unsafe, server break legacy" \
1263 "$P_SRV debug_level=3 allow_legacy=-1" \
1264 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1265 1 \
1266 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1267 -S "server hello, secure renegotiation extension"
1268
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001269# Tests for auth_mode
1270
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001271run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001272 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001273 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001274 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001275 1 \
1276 -c "x509_verify_cert() returned" \
1277 -c "! self-signed or not signed by a trusted CA" \
1278 -c "! ssl_handshake returned" \
1279 -c "X509 - Certificate verification failed"
1280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001281run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001282 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001283 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001284 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001285 0 \
1286 -c "x509_verify_cert() returned" \
1287 -c "! self-signed or not signed by a trusted CA" \
1288 -C "! ssl_handshake returned" \
1289 -C "X509 - Certificate verification failed"
1290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001291run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001292 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001293 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001294 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001295 0 \
1296 -C "x509_verify_cert() returned" \
1297 -C "! self-signed or not signed by a trusted CA" \
1298 -C "! ssl_handshake returned" \
1299 -C "X509 - Certificate verification failed"
1300
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001301run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001302 "$P_SRV debug_level=3 auth_mode=required" \
1303 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001304 key_file=data_files/server5.key" \
1305 1 \
1306 -S "skip write certificate request" \
1307 -C "skip parse certificate request" \
1308 -c "got a certificate request" \
1309 -C "skip write certificate" \
1310 -C "skip write certificate verify" \
1311 -S "skip parse certificate verify" \
1312 -s "x509_verify_cert() returned" \
1313 -S "! self-signed or not signed by a trusted CA" \
1314 -s "! ssl_handshake returned" \
1315 -c "! ssl_handshake returned" \
1316 -s "X509 - Certificate verification failed"
1317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001318run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001319 "$P_SRV debug_level=3 auth_mode=optional" \
1320 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001321 key_file=data_files/server5.key" \
1322 0 \
1323 -S "skip write certificate request" \
1324 -C "skip parse certificate request" \
1325 -c "got a certificate request" \
1326 -C "skip write certificate" \
1327 -C "skip write certificate verify" \
1328 -S "skip parse certificate verify" \
1329 -s "x509_verify_cert() returned" \
1330 -s "! self-signed or not signed by a trusted CA" \
1331 -S "! ssl_handshake returned" \
1332 -C "! ssl_handshake returned" \
1333 -S "X509 - Certificate verification failed"
1334
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001335run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001336 "$P_SRV debug_level=3 auth_mode=none" \
1337 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001338 key_file=data_files/server5.key" \
1339 0 \
1340 -s "skip write certificate request" \
1341 -C "skip parse certificate request" \
1342 -c "got no certificate request" \
1343 -c "skip write certificate" \
1344 -c "skip write certificate verify" \
1345 -s "skip parse certificate verify" \
1346 -S "x509_verify_cert() returned" \
1347 -S "! self-signed or not signed by a trusted CA" \
1348 -S "! ssl_handshake returned" \
1349 -C "! ssl_handshake returned" \
1350 -S "X509 - Certificate verification failed"
1351
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001352run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001353 "$P_SRV debug_level=3 auth_mode=optional" \
1354 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001355 0 \
1356 -S "skip write certificate request" \
1357 -C "skip parse certificate request" \
1358 -c "got a certificate request" \
1359 -C "skip write certificate$" \
1360 -C "got no certificate to send" \
1361 -S "SSLv3 client has no certificate" \
1362 -c "skip write certificate verify" \
1363 -s "skip parse certificate verify" \
1364 -s "! no client certificate sent" \
1365 -S "! ssl_handshake returned" \
1366 -C "! ssl_handshake returned" \
1367 -S "X509 - Certificate verification failed"
1368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001369run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001370 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001371 "$O_CLI" \
1372 0 \
1373 -S "skip write certificate request" \
1374 -s "skip parse certificate verify" \
1375 -s "! no client certificate sent" \
1376 -S "! ssl_handshake returned" \
1377 -S "X509 - Certificate verification failed"
1378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001379run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001380 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001381 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001382 0 \
1383 -C "skip parse certificate request" \
1384 -c "got a certificate request" \
1385 -C "skip write certificate$" \
1386 -c "skip write certificate verify" \
1387 -C "! ssl_handshake returned"
1388
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001389run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001390 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
1391 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001392 0 \
1393 -S "skip write certificate request" \
1394 -C "skip parse certificate request" \
1395 -c "got a certificate request" \
1396 -C "skip write certificate$" \
1397 -c "skip write certificate verify" \
1398 -c "got no certificate to send" \
1399 -s "SSLv3 client has no certificate" \
1400 -s "skip parse certificate verify" \
1401 -s "! no client certificate sent" \
1402 -S "! ssl_handshake returned" \
1403 -C "! ssl_handshake returned" \
1404 -S "X509 - Certificate verification failed"
1405
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001406# tests for SNI
1407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001408run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001409 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001410 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001411 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001412 server_name=localhost" \
1413 0 \
1414 -S "parse ServerName extension" \
1415 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1416 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1417
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001418run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001419 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001420 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001421 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 +01001422 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001423 server_name=localhost" \
1424 0 \
1425 -s "parse ServerName extension" \
1426 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1427 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1428
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001429run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001430 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001431 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001432 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 +01001433 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001434 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001435 0 \
1436 -s "parse ServerName extension" \
1437 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001438 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001440run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001441 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001442 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001443 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 +01001444 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001445 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001446 1 \
1447 -s "parse ServerName extension" \
1448 -s "ssl_sni_wrapper() returned" \
1449 -s "ssl_handshake returned" \
1450 -c "ssl_handshake returned" \
1451 -c "SSL - A fatal alert message was received from our peer"
1452
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001453# Tests for non-blocking I/O: exercise a variety of handshake flows
1454
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001455run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001456 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1457 "$P_CLI nbio=2 tickets=0" \
1458 0 \
1459 -S "ssl_handshake returned" \
1460 -C "ssl_handshake returned" \
1461 -c "Read from server: .* bytes read"
1462
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001463run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001464 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1465 "$P_CLI nbio=2 tickets=0" \
1466 0 \
1467 -S "ssl_handshake returned" \
1468 -C "ssl_handshake returned" \
1469 -c "Read from server: .* bytes read"
1470
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001471run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001472 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1473 "$P_CLI nbio=2 tickets=1" \
1474 0 \
1475 -S "ssl_handshake returned" \
1476 -C "ssl_handshake returned" \
1477 -c "Read from server: .* bytes read"
1478
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001479run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001480 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1481 "$P_CLI nbio=2 tickets=1" \
1482 0 \
1483 -S "ssl_handshake returned" \
1484 -C "ssl_handshake returned" \
1485 -c "Read from server: .* bytes read"
1486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001487run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001488 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1489 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1490 0 \
1491 -S "ssl_handshake returned" \
1492 -C "ssl_handshake returned" \
1493 -c "Read from server: .* bytes read"
1494
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001495run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001496 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1497 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1498 0 \
1499 -S "ssl_handshake returned" \
1500 -C "ssl_handshake returned" \
1501 -c "Read from server: .* bytes read"
1502
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001503run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001504 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1505 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1506 0 \
1507 -S "ssl_handshake returned" \
1508 -C "ssl_handshake returned" \
1509 -c "Read from server: .* bytes read"
1510
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001511# Tests for version negotiation
1512
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001513run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001514 "$P_SRV" \
1515 "$P_CLI" \
1516 0 \
1517 -S "ssl_handshake returned" \
1518 -C "ssl_handshake returned" \
1519 -s "Protocol is TLSv1.2" \
1520 -c "Protocol is TLSv1.2"
1521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001522run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001523 "$P_SRV" \
1524 "$P_CLI max_version=tls1_1" \
1525 0 \
1526 -S "ssl_handshake returned" \
1527 -C "ssl_handshake returned" \
1528 -s "Protocol is TLSv1.1" \
1529 -c "Protocol is TLSv1.1"
1530
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001531run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001532 "$P_SRV max_version=tls1_1" \
1533 "$P_CLI" \
1534 0 \
1535 -S "ssl_handshake returned" \
1536 -C "ssl_handshake returned" \
1537 -s "Protocol is TLSv1.1" \
1538 -c "Protocol is TLSv1.1"
1539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001540run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001541 "$P_SRV max_version=tls1_1" \
1542 "$P_CLI max_version=tls1_1" \
1543 0 \
1544 -S "ssl_handshake returned" \
1545 -C "ssl_handshake returned" \
1546 -s "Protocol is TLSv1.1" \
1547 -c "Protocol is TLSv1.1"
1548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001549run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001550 "$P_SRV min_version=tls1_1" \
1551 "$P_CLI max_version=tls1_1" \
1552 0 \
1553 -S "ssl_handshake returned" \
1554 -C "ssl_handshake returned" \
1555 -s "Protocol is TLSv1.1" \
1556 -c "Protocol is TLSv1.1"
1557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001558run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001559 "$P_SRV max_version=tls1_1" \
1560 "$P_CLI min_version=tls1_1" \
1561 0 \
1562 -S "ssl_handshake returned" \
1563 -C "ssl_handshake returned" \
1564 -s "Protocol is TLSv1.1" \
1565 -c "Protocol is TLSv1.1"
1566
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001567run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001568 "$P_SRV max_version=tls1_1" \
1569 "$P_CLI min_version=tls1_2" \
1570 1 \
1571 -s "ssl_handshake returned" \
1572 -c "ssl_handshake returned" \
1573 -c "SSL - Handshake protocol not within min/max boundaries"
1574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001575run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001576 "$P_SRV min_version=tls1_2" \
1577 "$P_CLI max_version=tls1_1" \
1578 1 \
1579 -s "ssl_handshake returned" \
1580 -c "ssl_handshake returned" \
1581 -s "SSL - Handshake protocol not within min/max boundaries"
1582
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001583# Tests for ALPN extension
1584
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001585if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001587run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001588 "$P_SRV debug_level=3" \
1589 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001590 0 \
1591 -C "client hello, adding alpn extension" \
1592 -S "found alpn extension" \
1593 -C "got an alert message, type: \\[2:120]" \
1594 -S "server hello, adding alpn extension" \
1595 -C "found alpn extension " \
1596 -C "Application Layer Protocol is" \
1597 -S "Application Layer Protocol is"
1598
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001599run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001600 "$P_SRV debug_level=3" \
1601 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001602 0 \
1603 -c "client hello, adding alpn extension" \
1604 -s "found alpn extension" \
1605 -C "got an alert message, type: \\[2:120]" \
1606 -S "server hello, adding alpn extension" \
1607 -C "found alpn extension " \
1608 -c "Application Layer Protocol is (none)" \
1609 -S "Application Layer Protocol is"
1610
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001611run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001612 "$P_SRV debug_level=3 alpn=abc,1234" \
1613 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001614 0 \
1615 -C "client hello, adding alpn extension" \
1616 -S "found alpn extension" \
1617 -C "got an alert message, type: \\[2:120]" \
1618 -S "server hello, adding alpn extension" \
1619 -C "found alpn extension " \
1620 -C "Application Layer Protocol is" \
1621 -s "Application Layer Protocol is (none)"
1622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001623run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001624 "$P_SRV debug_level=3 alpn=abc,1234" \
1625 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001626 0 \
1627 -c "client hello, adding alpn extension" \
1628 -s "found alpn extension" \
1629 -C "got an alert message, type: \\[2:120]" \
1630 -s "server hello, adding alpn extension" \
1631 -c "found alpn extension" \
1632 -c "Application Layer Protocol is abc" \
1633 -s "Application Layer Protocol is abc"
1634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001635run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001636 "$P_SRV debug_level=3 alpn=abc,1234" \
1637 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001638 0 \
1639 -c "client hello, adding alpn extension" \
1640 -s "found alpn extension" \
1641 -C "got an alert message, type: \\[2:120]" \
1642 -s "server hello, adding alpn extension" \
1643 -c "found alpn extension" \
1644 -c "Application Layer Protocol is abc" \
1645 -s "Application Layer Protocol is abc"
1646
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001647run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001648 "$P_SRV debug_level=3 alpn=abc,1234" \
1649 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001650 0 \
1651 -c "client hello, adding alpn extension" \
1652 -s "found alpn extension" \
1653 -C "got an alert message, type: \\[2:120]" \
1654 -s "server hello, adding alpn extension" \
1655 -c "found alpn extension" \
1656 -c "Application Layer Protocol is 1234" \
1657 -s "Application Layer Protocol is 1234"
1658
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001659run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001660 "$P_SRV debug_level=3 alpn=abc,123" \
1661 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001662 1 \
1663 -c "client hello, adding alpn extension" \
1664 -s "found alpn extension" \
1665 -c "got an alert message, type: \\[2:120]" \
1666 -S "server hello, adding alpn extension" \
1667 -C "found alpn extension" \
1668 -C "Application Layer Protocol is 1234" \
1669 -S "Application Layer Protocol is 1234"
1670
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001671fi
1672
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001673# Tests for keyUsage in leaf certificates, part 1:
1674# server-side certificate/suite selection
1675
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001676run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001677 "$P_SRV key_file=data_files/server2.key \
1678 crt_file=data_files/server2.ku-ds.crt" \
1679 "$P_CLI" \
1680 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001681 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001682
1683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001684run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001685 "$P_SRV key_file=data_files/server2.key \
1686 crt_file=data_files/server2.ku-ke.crt" \
1687 "$P_CLI" \
1688 0 \
1689 -c "Ciphersuite is TLS-RSA-WITH-"
1690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001691run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001692 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001693 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001694 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001695 1 \
1696 -C "Ciphersuite is "
1697
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001698run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001699 "$P_SRV key_file=data_files/server5.key \
1700 crt_file=data_files/server5.ku-ds.crt" \
1701 "$P_CLI" \
1702 0 \
1703 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1704
1705
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001706run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001707 "$P_SRV key_file=data_files/server5.key \
1708 crt_file=data_files/server5.ku-ka.crt" \
1709 "$P_CLI" \
1710 0 \
1711 -c "Ciphersuite is TLS-ECDH-"
1712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001713run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001714 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001715 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001716 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001717 1 \
1718 -C "Ciphersuite is "
1719
1720# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001721# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001723run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001724 "$O_SRV -key data_files/server2.key \
1725 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001726 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001727 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1728 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001729 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001730 -C "Processing of the Certificate handshake message failed" \
1731 -c "Ciphersuite is TLS-"
1732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001733run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001734 "$O_SRV -key data_files/server2.key \
1735 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001736 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001737 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1738 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001739 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001740 -C "Processing of the Certificate handshake message failed" \
1741 -c "Ciphersuite is TLS-"
1742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001743run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001744 "$O_SRV -key data_files/server2.key \
1745 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001746 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001747 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1748 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001749 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001750 -C "Processing of the Certificate handshake message failed" \
1751 -c "Ciphersuite is TLS-"
1752
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001753run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001754 "$O_SRV -key data_files/server2.key \
1755 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001756 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001757 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1758 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001759 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001760 -c "Processing of the Certificate handshake message failed" \
1761 -C "Ciphersuite is TLS-"
1762
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001763run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001764 "$O_SRV -key data_files/server2.key \
1765 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001766 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001767 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1768 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001769 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001770 -C "Processing of the Certificate handshake message failed" \
1771 -c "Ciphersuite is TLS-"
1772
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001773run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001774 "$O_SRV -key data_files/server2.key \
1775 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001776 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001777 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1778 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001779 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001780 -c "Processing of the Certificate handshake message failed" \
1781 -C "Ciphersuite is TLS-"
1782
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001783# Tests for keyUsage in leaf certificates, part 3:
1784# server-side checking of client cert
1785
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001786run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001787 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001788 "$O_CLI -key data_files/server2.key \
1789 -cert data_files/server2.ku-ds.crt" \
1790 0 \
1791 -S "bad certificate (usage extensions)" \
1792 -S "Processing of the Certificate handshake message failed"
1793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001794run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001795 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001796 "$O_CLI -key data_files/server2.key \
1797 -cert data_files/server2.ku-ke.crt" \
1798 0 \
1799 -s "bad certificate (usage extensions)" \
1800 -S "Processing of the Certificate handshake message failed"
1801
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001802run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001803 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001804 "$O_CLI -key data_files/server2.key \
1805 -cert data_files/server2.ku-ke.crt" \
1806 1 \
1807 -s "bad certificate (usage extensions)" \
1808 -s "Processing of the Certificate handshake message failed"
1809
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001810run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001811 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001812 "$O_CLI -key data_files/server5.key \
1813 -cert data_files/server5.ku-ds.crt" \
1814 0 \
1815 -S "bad certificate (usage extensions)" \
1816 -S "Processing of the Certificate handshake message failed"
1817
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001818run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001819 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001820 "$O_CLI -key data_files/server5.key \
1821 -cert data_files/server5.ku-ka.crt" \
1822 0 \
1823 -s "bad certificate (usage extensions)" \
1824 -S "Processing of the Certificate handshake message failed"
1825
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001826# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1827
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001828run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001829 "$P_SRV key_file=data_files/server5.key \
1830 crt_file=data_files/server5.eku-srv.crt" \
1831 "$P_CLI" \
1832 0
1833
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001834run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001835 "$P_SRV key_file=data_files/server5.key \
1836 crt_file=data_files/server5.eku-srv.crt" \
1837 "$P_CLI" \
1838 0
1839
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001840run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001841 "$P_SRV key_file=data_files/server5.key \
1842 crt_file=data_files/server5.eku-cs_any.crt" \
1843 "$P_CLI" \
1844 0
1845
1846# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001847run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001848 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1849 crt_file=data_files/server5.eku-cli.crt" \
1850 "$P_CLI psk=badbad" \
1851 1
1852
1853# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001855run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001856 "$O_SRV -key data_files/server5.key \
1857 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001858 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001859 0 \
1860 -C "bad certificate (usage extensions)" \
1861 -C "Processing of the Certificate handshake message failed" \
1862 -c "Ciphersuite is TLS-"
1863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001864run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001865 "$O_SRV -key data_files/server5.key \
1866 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001867 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001868 0 \
1869 -C "bad certificate (usage extensions)" \
1870 -C "Processing of the Certificate handshake message failed" \
1871 -c "Ciphersuite is TLS-"
1872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001873run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001874 "$O_SRV -key data_files/server5.key \
1875 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001876 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001877 0 \
1878 -C "bad certificate (usage extensions)" \
1879 -C "Processing of the Certificate handshake message failed" \
1880 -c "Ciphersuite is TLS-"
1881
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001882run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001883 "$O_SRV -key data_files/server5.key \
1884 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001885 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001886 1 \
1887 -c "bad certificate (usage extensions)" \
1888 -c "Processing of the Certificate handshake message failed" \
1889 -C "Ciphersuite is TLS-"
1890
1891# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1892
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001893run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001894 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001895 "$O_CLI -key data_files/server5.key \
1896 -cert data_files/server5.eku-cli.crt" \
1897 0 \
1898 -S "bad certificate (usage extensions)" \
1899 -S "Processing of the Certificate handshake message failed"
1900
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001901run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001902 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001903 "$O_CLI -key data_files/server5.key \
1904 -cert data_files/server5.eku-srv_cli.crt" \
1905 0 \
1906 -S "bad certificate (usage extensions)" \
1907 -S "Processing of the Certificate handshake message failed"
1908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001909run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001910 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001911 "$O_CLI -key data_files/server5.key \
1912 -cert data_files/server5.eku-cs_any.crt" \
1913 0 \
1914 -S "bad certificate (usage extensions)" \
1915 -S "Processing of the Certificate handshake message failed"
1916
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001917run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001918 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001919 "$O_CLI -key data_files/server5.key \
1920 -cert data_files/server5.eku-cs.crt" \
1921 0 \
1922 -s "bad certificate (usage extensions)" \
1923 -S "Processing of the Certificate handshake message failed"
1924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001925run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001926 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001927 "$O_CLI -key data_files/server5.key \
1928 -cert data_files/server5.eku-cs.crt" \
1929 1 \
1930 -s "bad certificate (usage extensions)" \
1931 -s "Processing of the Certificate handshake message failed"
1932
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001933# Tests for DHM parameters loading
1934
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001935run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001936 "$P_SRV" \
1937 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1938 debug_level=3" \
1939 0 \
1940 -c "value of 'DHM: P ' (2048 bits)" \
1941 -c "value of 'DHM: G ' (2048 bits)"
1942
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001943run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02001944 "$P_SRV dhm_file=data_files/dhparams.pem" \
1945 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
1946 debug_level=3" \
1947 0 \
1948 -c "value of 'DHM: P ' (1024 bits)" \
1949 -c "value of 'DHM: G ' (2 bits)"
1950
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001951# Tests for PSK callback
1952
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001953run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001954 "$P_SRV psk=abc123 psk_identity=foo" \
1955 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1956 psk_identity=foo psk=abc123" \
1957 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001958 -S "SSL - The server has no ciphersuites in common" \
1959 -S "SSL - Unknown identity received" \
1960 -S "SSL - Verification of the message MAC failed"
1961
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001962run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001963 "$P_SRV" \
1964 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1965 psk_identity=foo psk=abc123" \
1966 1 \
1967 -s "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001968 -S "SSL - Unknown identity received" \
1969 -S "SSL - Verification of the message MAC failed"
1970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001971run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001972 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
1973 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1974 psk_identity=foo psk=abc123" \
1975 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001976 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001977 -s "SSL - Unknown identity received" \
1978 -S "SSL - Verification of the message MAC failed"
1979
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001980run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001981 "$P_SRV psk_list=abc,dead,def,beef" \
1982 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1983 psk_identity=abc psk=dead" \
1984 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001985 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001986 -S "SSL - Unknown identity received" \
1987 -S "SSL - Verification of the message MAC failed"
1988
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001989run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001990 "$P_SRV psk_list=abc,dead,def,beef" \
1991 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
1992 psk_identity=def psk=beef" \
1993 0 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02001994 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001995 -S "SSL - Unknown identity received" \
1996 -S "SSL - Verification of the message MAC failed"
1997
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001998run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02001999 "$P_SRV psk_list=abc,dead,def,beef" \
2000 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2001 psk_identity=ghi psk=beef" \
2002 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002003 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002004 -s "SSL - Unknown identity received" \
2005 -S "SSL - Verification of the message MAC failed"
2006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002007run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002008 "$P_SRV psk_list=abc,dead,def,beef" \
2009 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2010 psk_identity=abc psk=beef" \
2011 1 \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002012 -S "SSL - The server has no ciphersuites in common" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002013 -S "SSL - Unknown identity received" \
2014 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002015
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002016# Tests for ciphersuites per version
2017
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002018run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002019 "$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" \
2020 "$P_CLI force_version=ssl3" \
2021 0 \
2022 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002024run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002025 "$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" \
2026 "$P_CLI force_version=tls1" \
2027 0 \
2028 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002030run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002031 "$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" \
2032 "$P_CLI force_version=tls1_1" \
2033 0 \
2034 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002036run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002037 "$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" \
2038 "$P_CLI force_version=tls1_2" \
2039 0 \
2040 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2041
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002042# Tests for ssl_get_bytes_avail()
2043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002044run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002045 "$P_SRV" \
2046 "$P_CLI request_size=100" \
2047 0 \
2048 -s "Read from client: 100 bytes read$"
2049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002050run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002051 "$P_SRV" \
2052 "$P_CLI request_size=500" \
2053 0 \
2054 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002055
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002056# Tests for small packets
2057
2058run_test "Small packet SSLv3 BlockCipher" \
2059 "$P_SRV" \
2060 "$P_CLI request_size=1 force_version=ssl3 \
2061 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2062 0 \
2063 -s "Read from client: 1 bytes read"
2064
2065run_test "Small packet SSLv3 StreamCipher" \
2066 "$P_SRV" \
2067 "$P_CLI request_size=1 force_version=ssl3 \
2068 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2069 0 \
2070 -s "Read from client: 1 bytes read"
2071
2072run_test "Small packet TLS 1.0 BlockCipher" \
2073 "$P_SRV" \
2074 "$P_CLI request_size=1 force_version=tls1 \
2075 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2076 0 \
2077 -s "Read from client: 1 bytes read"
2078
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002079run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2080 "$P_SRV" \
2081 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2082 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2083 0 \
2084 -s "Read from client: 1 bytes read"
2085
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002086run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2087 "$P_SRV" \
2088 "$P_CLI request_size=1 force_version=tls1 \
2089 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2090 trunc_hmac=1" \
2091 0 \
2092 -s "Read from client: 1 bytes read"
2093
2094run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
2095 "$P_SRV" \
2096 "$P_CLI request_size=1 force_version=tls1 \
2097 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2098 trunc_hmac=1" \
2099 0 \
2100 -s "Read from client: 1 bytes read"
2101
2102run_test "Small packet TLS 1.1 BlockCipher" \
2103 "$P_SRV" \
2104 "$P_CLI request_size=1 force_version=tls1_1 \
2105 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2106 0 \
2107 -s "Read from client: 1 bytes read"
2108
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002109run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2110 "$P_SRV" \
2111 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2112 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2113 0 \
2114 -s "Read from client: 1 bytes read"
2115
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002116run_test "Small packet TLS 1.1 StreamCipher" \
2117 "$P_SRV" \
2118 "$P_CLI request_size=1 force_version=tls1_1 \
2119 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2120 0 \
2121 -s "Read from client: 1 bytes read"
2122
2123run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2124 "$P_SRV" \
2125 "$P_CLI request_size=1 force_version=tls1_1 \
2126 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2127 trunc_hmac=1" \
2128 0 \
2129 -s "Read from client: 1 bytes read"
2130
2131run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
2132 "$P_SRV" \
2133 "$P_CLI request_size=1 force_version=tls1_1 \
2134 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2135 trunc_hmac=1" \
2136 0 \
2137 -s "Read from client: 1 bytes read"
2138
2139run_test "Small packet TLS 1.2 BlockCipher" \
2140 "$P_SRV" \
2141 "$P_CLI request_size=1 force_version=tls1_2 \
2142 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2143 0 \
2144 -s "Read from client: 1 bytes read"
2145
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002146run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2147 "$P_SRV" \
2148 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2149 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2150 0 \
2151 -s "Read from client: 1 bytes read"
2152
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002153run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2154 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002155 "$P_CLI request_size=1 force_version=tls1_2 \
2156 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002157 0 \
2158 -s "Read from client: 1 bytes read"
2159
2160run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2161 "$P_SRV" \
2162 "$P_CLI request_size=1 force_version=tls1_2 \
2163 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2164 trunc_hmac=1" \
2165 0 \
2166 -s "Read from client: 1 bytes read"
2167
2168run_test "Small packet TLS 1.2 StreamCipher" \
2169 "$P_SRV" \
2170 "$P_CLI request_size=1 force_version=tls1_2 \
2171 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2172 0 \
2173 -s "Read from client: 1 bytes read"
2174
2175run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
2176 "$P_SRV" \
2177 "$P_CLI request_size=1 force_version=tls1_2 \
2178 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2179 trunc_hmac=1" \
2180 0 \
2181 -s "Read from client: 1 bytes read"
2182
2183run_test "Small packet TLS 1.2 AEAD" \
2184 "$P_SRV" \
2185 "$P_CLI request_size=1 force_version=tls1_2 \
2186 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2187 0 \
2188 -s "Read from client: 1 bytes read"
2189
2190run_test "Small packet TLS 1.2 AEAD shorter tag" \
2191 "$P_SRV" \
2192 "$P_CLI request_size=1 force_version=tls1_2 \
2193 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2194 0 \
2195 -s "Read from client: 1 bytes read"
2196
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002197# Test for large packets
2198
2199run_test "Large packet SSLv3 BlockCipher" \
2200 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002201 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002202 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2203 0 \
2204 -s "Read from client: 16384 bytes read"
2205
2206run_test "Large packet SSLv3 StreamCipher" \
2207 "$P_SRV" \
2208 "$P_CLI request_size=16384 force_version=ssl3 \
2209 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2210 0 \
2211 -s "Read from client: 16384 bytes read"
2212
2213run_test "Large packet TLS 1.0 BlockCipher" \
2214 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002215 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002216 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2217 0 \
2218 -s "Read from client: 16384 bytes read"
2219
2220run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2221 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002222 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002223 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2224 trunc_hmac=1" \
2225 0 \
2226 -s "Read from client: 16384 bytes read"
2227
2228run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
2229 "$P_SRV" \
2230 "$P_CLI request_size=16384 force_version=tls1 \
2231 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2232 trunc_hmac=1" \
2233 0 \
2234 -s "Read from client: 16384 bytes read"
2235
2236run_test "Large packet TLS 1.1 BlockCipher" \
2237 "$P_SRV" \
2238 "$P_CLI request_size=16384 force_version=tls1_1 \
2239 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2240 0 \
2241 -s "Read from client: 16384 bytes read"
2242
2243run_test "Large packet TLS 1.1 StreamCipher" \
2244 "$P_SRV" \
2245 "$P_CLI request_size=16384 force_version=tls1_1 \
2246 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2247 0 \
2248 -s "Read from client: 16384 bytes read"
2249
2250run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2251 "$P_SRV" \
2252 "$P_CLI request_size=16384 force_version=tls1_1 \
2253 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2254 trunc_hmac=1" \
2255 0 \
2256 -s "Read from client: 16384 bytes read"
2257
2258run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
2259 "$P_SRV" \
2260 "$P_CLI request_size=16384 force_version=tls1_1 \
2261 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2262 trunc_hmac=1" \
2263 0 \
2264 -s "Read from client: 16384 bytes read"
2265
2266run_test "Large packet TLS 1.2 BlockCipher" \
2267 "$P_SRV" \
2268 "$P_CLI request_size=16384 force_version=tls1_2 \
2269 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2270 0 \
2271 -s "Read from client: 16384 bytes read"
2272
2273run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2274 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002275 "$P_CLI request_size=16384 force_version=tls1_2 \
2276 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002277 0 \
2278 -s "Read from client: 16384 bytes read"
2279
2280run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2281 "$P_SRV" \
2282 "$P_CLI request_size=16384 force_version=tls1_2 \
2283 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2284 trunc_hmac=1" \
2285 0 \
2286 -s "Read from client: 16384 bytes read"
2287
2288run_test "Large packet TLS 1.2 StreamCipher" \
2289 "$P_SRV" \
2290 "$P_CLI request_size=16384 force_version=tls1_2 \
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.2 StreamCipher truncated MAC" \
2296 "$P_SRV" \
2297 "$P_CLI request_size=16384 force_version=tls1_2 \
2298 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2299 trunc_hmac=1" \
2300 0 \
2301 -s "Read from client: 16384 bytes read"
2302
2303run_test "Large packet TLS 1.2 AEAD" \
2304 "$P_SRV" \
2305 "$P_CLI request_size=16384 force_version=tls1_2 \
2306 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2307 0 \
2308 -s "Read from client: 16384 bytes read"
2309
2310run_test "Large packet TLS 1.2 AEAD shorter tag" \
2311 "$P_SRV" \
2312 "$P_CLI request_size=16384 force_version=tls1_2 \
2313 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2314 0 \
2315 -s "Read from client: 16384 bytes read"
2316
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002317# Final report
2318
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002319echo "------------------------------------------------------------------------"
2320
2321if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002322 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002323else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002324 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002325fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002326PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002327echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002328
2329exit $FAILS