blob: 23f19ea274202f56babd5880b83204b6c56a6480 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
9# Assumes all options are compiled in.
10
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010016: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020017: ${GNUTLS_CLI:=gnutls-cli}
18: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010019
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010020O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
21O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020022G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010023G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010024
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010025TESTS=0
26FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020027SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020029CONFIG_H='../include/polarssl/config.h'
30
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010031MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010032FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020033EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034
35print_usage() {
36 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010037 printf " -h|--help\tPrint this help.\n"
38 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
39 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
40 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010041}
42
43get_options() {
44 while [ $# -gt 0 ]; do
45 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046 -f|--filter)
47 shift; FILTER=$1
48 ;;
49 -e|--exclude)
50 shift; EXCLUDE=$1
51 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052 -m|--memcheck)
53 MEMCHECK=1
54 ;;
55 -h|--help)
56 print_usage
57 exit 0
58 ;;
59 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020060 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061 print_usage
62 exit 1
63 ;;
64 esac
65 shift
66 done
67}
68
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020069# skip next test if OpenSSL can't send SSLv2 ClientHello
70requires_openssl_with_sslv2() {
71 if [ -z "${OPENSSL_HAS_SSL2:-}" ]; then
Manuel Pégourié-Gonnarda4afadf2014-08-30 22:09:36 +020072 if $OPENSSL_CMD ciphers -ssl2 >/dev/null 2>&1; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020073 OPENSSL_HAS_SSL2="YES"
74 else
75 OPENSSL_HAS_SSL2="NO"
76 fi
77 fi
78 if [ "$OPENSSL_HAS_SSL2" = "NO" ]; then
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020083# skip next test if OpenSSL doesn't support FALLBACK_SCSV
84requires_openssl_with_fallback_scsv() {
85 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
86 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
87 then
88 OPENSSL_HAS_FBSCSV="YES"
89 else
90 OPENSSL_HAS_FBSCSV="NO"
91 fi
92 fi
93 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
94 SKIP_NEXT="YES"
95 fi
96}
97
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020098# skip next test if GnuTLS isn't available
99requires_gnutls() {
100 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
101 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null; then
102 GNUTLS_AVAILABLE="YES"
103 else
104 GNUTLS_AVAILABLE="NO"
105 fi
106 fi
107 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
108 SKIP_NEXT="YES"
109 fi
110}
111
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100112# print_name <name>
113print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100114 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200115 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100116 for i in `seq 1 $LEN`; do printf '.'; done
117 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100118
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200119 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100120}
121
122# fail <message>
123fail() {
124 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100125 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100126
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200127 mv $SRV_OUT o-srv-${TESTS}.log
128 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100129 echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100130
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200131 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
132 echo " ! server output:"
133 cat o-srv-${TESTS}.log
134 echo " ! ============================================================"
135 echo " ! client output:"
136 cat o-cli-${TESTS}.log
137 fi
138
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200139 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100140}
141
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100142# is_polar <cmd_line>
143is_polar() {
144 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
145}
146
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100147# has_mem_err <log_file_name>
148has_mem_err() {
149 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
150 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
151 then
152 return 1 # false: does not have errors
153 else
154 return 0 # true: has errors
155 fi
156}
157
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200158# wait for server to start: two versions depending on lsof availability
159wait_server_start() {
160 if which lsof >/dev/null; then
161 # make sure we don't loop forever
162 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
163 WATCHDOG_PID=$!
164
165 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100166 until lsof -nbi TCP:"$PORT" 2>/dev/null | grep LISTEN >/dev/null;
167 do :; done
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200168
169 kill $WATCHDOG_PID
170 wait $WATCHDOG_PID
171 else
172 sleep "$START_DELAY"
173 fi
174}
175
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200176# wait for client to terminate and set CLI_EXIT
177# must be called right after starting the client
178wait_client_done() {
179 CLI_PID=$!
180
181 ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
182 WATCHDOG_PID=$!
183
184 wait $CLI_PID
185 CLI_EXIT=$?
186
187 kill $WATCHDOG_PID
188 wait $WATCHDOG_PID
189
190 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
191}
192
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100193# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100194# Options: -s pattern pattern that must be present in server output
195# -c pattern pattern that must be present in client output
196# -S pattern pattern that must be absent in server output
197# -C pattern pattern that must be absent in client output
198run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100199 NAME="$1"
200 SRV_CMD="$2"
201 CLI_CMD="$3"
202 CLI_EXPECT="$4"
203 shift 4
204
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100205 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
206 else
207 return
208 fi
209
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100210 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100211
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200212 # should we skip?
213 if [ "X$SKIP_NEXT" = "XYES" ]; then
214 SKIP_NEXT="NO"
215 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200216 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200217 return
218 fi
219
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100220 # prepend valgrind to our commands if active
221 if [ "$MEMCHECK" -gt 0 ]; then
222 if is_polar "$SRV_CMD"; then
223 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
224 fi
225 if is_polar "$CLI_CMD"; then
226 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
227 fi
228 fi
229
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100230 # run the commands
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200231 echo "$SRV_CMD" > $SRV_OUT
232 $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100233 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200234 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200235
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200236 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200237 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
238 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100239
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200240 # kill the server
241 kill $SRV_PID
242 wait $SRV_PID
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100243
244 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200245 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100246 # expected client exit to incorrectly succeed in case of catastrophic
247 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100248 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200249 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100250 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100251 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100252 return
253 fi
254 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100255 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200256 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100257 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100258 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100259 return
260 fi
261 fi
262
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100263 # check server exit code
264 if [ $? != 0 ]; then
265 fail "server fail"
266 return
267 fi
268
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100269 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100270 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
271 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100272 then
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +0100273 fail "bad client exit code"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100274 return
275 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100276
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100277 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200278 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100279 while [ $# -gt 0 ]
280 do
281 case $1 in
282 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200283 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100284 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100285 return
286 fi
287 ;;
288
289 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200290 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100291 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100292 return
293 fi
294 ;;
295
296 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200297 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100298 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100299 return
300 fi
301 ;;
302
303 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200304 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100305 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100306 return
307 fi
308 ;;
309
310 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200311 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100312 exit 1
313 esac
314 shift 2
315 done
316
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100317 # check valgrind's results
318 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200319 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100320 fail "Server has memory errors"
321 return
322 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200323 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100324 fail "Client has memory errors"
325 return
326 fi
327 fi
328
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100329 # if we're here, everything is ok
330 echo "PASS"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200331 rm -f $SRV_OUT $CLI_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100332}
333
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100334cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200335 rm -f $CLI_OUT $SRV_OUT $SESSION
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200336 kill $SRV_PID >/dev/null 2>&1
337 kill $WATCHDOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100338 exit 1
339}
340
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100341#
342# MAIN
343#
344
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100345get_options "$@"
346
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100347# sanity checks, avoid an avalanche of errors
348if [ ! -x "$P_SRV" ]; then
349 echo "Command '$P_SRV' is not an executable file"
350 exit 1
351fi
352if [ ! -x "$P_CLI" ]; then
353 echo "Command '$P_CLI' is not an executable file"
354 exit 1
355fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100356if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
357 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100358 exit 1
359fi
360
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200361# used by watchdog
362MAIN_PID="$$"
363
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200364# be more patient with valgrind
365if [ "$MEMCHECK" -gt 0 ]; then
366 START_DELAY=3
367 DOG_DELAY=30
368else
369 START_DELAY=1
370 DOG_DELAY=10
371fi
372
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200373# Pick a "unique" port in the range 10000-19999.
374PORT="0000$$"
Manuel Pégourié-Gonnardfab2a3c2014-06-16 16:54:36 +0200375PORT="1$(echo $PORT | tail -c 5)"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200376
377# fix commands to use this port
378P_SRV="$P_SRV server_port=$PORT"
379P_CLI="$P_CLI server_port=$PORT"
380O_SRV="$O_SRV -accept $PORT"
381O_CLI="$O_CLI -connect localhost:$PORT"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200382G_SRV="$G_SRV -p $PORT"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +0100383G_CLI="$G_CLI -p $PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200384
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200385# Also pick a unique name for intermediate files
386SRV_OUT="srv_out.$$"
387CLI_OUT="cli_out.$$"
388SESSION="session.$$"
389
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200390SKIP_NEXT="NO"
391
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100392trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100393
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200394# Basic test
395
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200396# Checks that:
397# - things work with all ciphersuites active (used with config-full in all.sh)
398# - the expected (highest security) parameters are selected
399# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200400run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200401 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200402 "$P_CLI" \
403 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200404 -s "Protocol is TLSv1.2" \
405 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
406 -s "client hello v3, signature_algorithm ext: 6" \
407 -s "ECDHE curve: secp521r1" \
408 -S "error" \
409 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200410
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100411# Tests for rc4 option
412
413run_test "RC4: server disabled, client enabled" \
414 "$P_SRV" \
415 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
416 1 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100417 -s "SSL - None of the common ciphersuites is usable"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100418
419run_test "RC4: server enabled, client disabled" \
420 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
421 "$P_CLI" \
422 1 \
423 -s "SSL - The server has no ciphersuites in common"
424
425run_test "RC4: both enabled" \
426 "$P_SRV arc4=1" \
427 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
428 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100429 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100430 -S "SSL - The server has no ciphersuites in common"
431
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100432# Test for SSLv2 ClientHello
433
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200434requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200435run_test "SSLv2 ClientHello: reference" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100436 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +0100437 "$O_CLI -no_ssl2" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100438 0 \
439 -S "parse client hello v2" \
440 -S "ssl_handshake returned"
441
442# Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200443requires_openssl_with_sslv2
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200444run_test "SSLv2 ClientHello: actual test" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200445 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100446 "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100447 0 \
448 -s "parse client hello v2" \
449 -S "ssl_handshake returned"
450
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100451# Tests for Truncated HMAC extension
452
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100453run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200454 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100455 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100456 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100457 -s "dumping 'computed mac' (20 bytes)" \
458 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100459
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100460run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200461 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100462 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
463 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100464 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100465 -s "dumping 'computed mac' (20 bytes)" \
466 -S "dumping 'computed mac' (10 bytes)"
467
468run_test "Truncated HMAC: client enabled, server default" \
469 "$P_SRV debug_level=4" \
470 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
471 trunc_hmac=1" \
472 0 \
473 -S "dumping 'computed mac' (20 bytes)" \
474 -s "dumping 'computed mac' (10 bytes)"
475
476run_test "Truncated HMAC: client enabled, server disabled" \
477 "$P_SRV debug_level=4 trunc_hmac=0" \
478 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
479 trunc_hmac=1" \
480 0 \
481 -s "dumping 'computed mac' (20 bytes)" \
482 -S "dumping 'computed mac' (10 bytes)"
483
484run_test "Truncated HMAC: client enabled, server enabled" \
485 "$P_SRV debug_level=4 trunc_hmac=1" \
486 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
487 trunc_hmac=1" \
488 0 \
489 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100490 -s "dumping 'computed mac' (10 bytes)"
491
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100492# Tests for Encrypt-then-MAC extension
493
494run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100495 "$P_SRV debug_level=3 \
496 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100497 "$P_CLI debug_level=3" \
498 0 \
499 -c "client hello, adding encrypt_then_mac extension" \
500 -s "found encrypt then mac extension" \
501 -s "server hello, adding encrypt then mac extension" \
502 -c "found encrypt_then_mac extension" \
503 -c "using encrypt then mac" \
504 -s "using encrypt then mac"
505
506run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100507 "$P_SRV debug_level=3 etm=0 \
508 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100509 "$P_CLI debug_level=3 etm=1" \
510 0 \
511 -c "client hello, adding encrypt_then_mac extension" \
512 -s "found encrypt then mac extension" \
513 -S "server hello, adding encrypt then mac extension" \
514 -C "found encrypt_then_mac extension" \
515 -C "using encrypt then mac" \
516 -S "using encrypt then mac"
517
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100518run_test "Encrypt then MAC: client enabled, aead cipher" \
519 "$P_SRV debug_level=3 etm=1 \
520 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
521 "$P_CLI debug_level=3 etm=1" \
522 0 \
523 -c "client hello, adding encrypt_then_mac extension" \
524 -s "found encrypt then mac extension" \
525 -S "server hello, adding encrypt then mac extension" \
526 -C "found encrypt_then_mac extension" \
527 -C "using encrypt then mac" \
528 -S "using encrypt then mac"
529
530run_test "Encrypt then MAC: client enabled, stream cipher" \
531 "$P_SRV debug_level=3 etm=1 \
532 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100533 "$P_CLI debug_level=3 etm=1 arc4=1" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100534 0 \
535 -c "client hello, adding encrypt_then_mac extension" \
536 -s "found encrypt then mac extension" \
537 -S "server hello, adding encrypt then mac extension" \
538 -C "found encrypt_then_mac extension" \
539 -C "using encrypt then mac" \
540 -S "using encrypt then mac"
541
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100542run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100543 "$P_SRV debug_level=3 etm=1 \
544 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100545 "$P_CLI debug_level=3 etm=0" \
546 0 \
547 -C "client hello, adding encrypt_then_mac extension" \
548 -S "found encrypt then mac extension" \
549 -S "server hello, adding encrypt then mac extension" \
550 -C "found encrypt_then_mac extension" \
551 -C "using encrypt then mac" \
552 -S "using encrypt then mac"
553
554run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100555 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100556 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100557 "$P_CLI debug_level=3 force_version=ssl3" \
558 0 \
559 -C "client hello, adding encrypt_then_mac extension" \
560 -S "found encrypt then mac extension" \
561 -S "server hello, adding encrypt then mac extension" \
562 -C "found encrypt_then_mac extension" \
563 -C "using encrypt then mac" \
564 -S "using encrypt then mac"
565
566run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100567 "$P_SRV debug_level=3 force_version=ssl3 \
568 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100569 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100570 0 \
571 -c "client hello, adding encrypt_then_mac extension" \
572 -s "found encrypt then mac extension" \
573 -S "server hello, adding encrypt then mac extension" \
574 -C "found encrypt_then_mac extension" \
575 -C "using encrypt then mac" \
576 -S "using encrypt then mac"
577
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200578# Tests for Extended Master Secret extension
579
580run_test "Extended Master Secret: default" \
581 "$P_SRV debug_level=3" \
582 "$P_CLI debug_level=3" \
583 0 \
584 -c "client hello, adding extended_master_secret extension" \
585 -s "found extended master secret extension" \
586 -s "server hello, adding extended master secret extension" \
587 -c "found extended_master_secret extension" \
588 -c "using extended master secret" \
589 -s "using extended master secret"
590
591run_test "Extended Master Secret: client enabled, server disabled" \
592 "$P_SRV debug_level=3 extended_ms=0" \
593 "$P_CLI debug_level=3 extended_ms=1" \
594 0 \
595 -c "client hello, adding extended_master_secret extension" \
596 -s "found extended master secret extension" \
597 -S "server hello, adding extended master secret extension" \
598 -C "found extended_master_secret extension" \
599 -C "using extended master secret" \
600 -S "using extended master secret"
601
602run_test "Extended Master Secret: client disabled, server enabled" \
603 "$P_SRV debug_level=3 extended_ms=1" \
604 "$P_CLI debug_level=3 extended_ms=0" \
605 0 \
606 -C "client hello, adding extended_master_secret extension" \
607 -S "found extended master secret extension" \
608 -S "server hello, adding extended master secret extension" \
609 -C "found extended_master_secret extension" \
610 -C "using extended master secret" \
611 -S "using extended master secret"
612
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200613run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100614 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200615 "$P_CLI debug_level=3 force_version=ssl3" \
616 0 \
617 -C "client hello, adding extended_master_secret extension" \
618 -S "found extended master secret extension" \
619 -S "server hello, adding extended master secret extension" \
620 -C "found extended_master_secret extension" \
621 -C "using extended master secret" \
622 -S "using extended master secret"
623
624run_test "Extended Master Secret: client enabled, server SSLv3" \
625 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100626 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200627 0 \
628 -c "client hello, adding extended_master_secret extension" \
629 -s "found extended master secret extension" \
630 -S "server hello, adding extended master secret extension" \
631 -C "found extended_master_secret extension" \
632 -C "using extended master secret" \
633 -S "using extended master secret"
634
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200635# Tests for FALLBACK_SCSV
636
637run_test "Fallback SCSV: default" \
638 "$P_SRV" \
639 "$P_CLI debug_level=3 force_version=tls1_1" \
640 0 \
641 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200642 -S "received FALLBACK_SCSV" \
643 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200644 -C "is a fatal alert message (msg 86)"
645
646run_test "Fallback SCSV: explicitly disabled" \
647 "$P_SRV" \
648 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
649 0 \
650 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200651 -S "received FALLBACK_SCSV" \
652 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200653 -C "is a fatal alert message (msg 86)"
654
655run_test "Fallback SCSV: enabled" \
656 "$P_SRV" \
657 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200658 1 \
659 -c "adding FALLBACK_SCSV" \
660 -s "received FALLBACK_SCSV" \
661 -s "inapropriate fallback" \
662 -c "is a fatal alert message (msg 86)"
663
664run_test "Fallback SCSV: enabled, max version" \
665 "$P_SRV" \
666 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200667 0 \
668 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200669 -s "received FALLBACK_SCSV" \
670 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200671 -C "is a fatal alert message (msg 86)"
672
673requires_openssl_with_fallback_scsv
674run_test "Fallback SCSV: default, openssl server" \
675 "$O_SRV" \
676 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
677 0 \
678 -C "adding FALLBACK_SCSV" \
679 -C "is a fatal alert message (msg 86)"
680
681requires_openssl_with_fallback_scsv
682run_test "Fallback SCSV: enabled, openssl server" \
683 "$O_SRV" \
684 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
685 1 \
686 -c "adding FALLBACK_SCSV" \
687 -c "is a fatal alert message (msg 86)"
688
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200689requires_openssl_with_fallback_scsv
690run_test "Fallback SCSV: disabled, openssl client" \
691 "$P_SRV" \
692 "$O_CLI -tls1_1" \
693 0 \
694 -S "received FALLBACK_SCSV" \
695 -S "inapropriate fallback"
696
697requires_openssl_with_fallback_scsv
698run_test "Fallback SCSV: enabled, openssl client" \
699 "$P_SRV" \
700 "$O_CLI -tls1_1 -fallback_scsv" \
701 1 \
702 -s "received FALLBACK_SCSV" \
703 -s "inapropriate fallback"
704
705requires_openssl_with_fallback_scsv
706run_test "Fallback SCSV: enabled, max version, openssl client" \
707 "$P_SRV" \
708 "$O_CLI -fallback_scsv" \
709 0 \
710 -s "received FALLBACK_SCSV" \
711 -S "inapropriate fallback"
712
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100713# Tests for CBC 1/n-1 record splitting
714
715run_test "CBC Record splitting: TLS 1.2, no splitting" \
716 "$P_SRV" \
717 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
718 request_size=123 force_version=tls1_2" \
719 0 \
720 -s "Read from client: 123 bytes read" \
721 -S "Read from client: 1 bytes read" \
722 -S "122 bytes read"
723
724run_test "CBC Record splitting: TLS 1.1, no splitting" \
725 "$P_SRV" \
726 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
727 request_size=123 force_version=tls1_1" \
728 0 \
729 -s "Read from client: 123 bytes read" \
730 -S "Read from client: 1 bytes read" \
731 -S "122 bytes read"
732
733run_test "CBC Record splitting: TLS 1.0, splitting" \
734 "$P_SRV" \
735 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
736 request_size=123 force_version=tls1" \
737 0 \
738 -S "Read from client: 123 bytes read" \
739 -s "Read from client: 1 bytes read" \
740 -s "122 bytes read"
741
742run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100743 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100744 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
745 request_size=123 force_version=ssl3" \
746 0 \
747 -S "Read from client: 123 bytes read" \
748 -s "Read from client: 1 bytes read" \
749 -s "122 bytes read"
750
751run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100752 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100753 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
754 request_size=123 force_version=tls1" \
755 0 \
756 -s "Read from client: 123 bytes read" \
757 -S "Read from client: 1 bytes read" \
758 -S "122 bytes read"
759
760run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
761 "$P_SRV" \
762 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
763 request_size=123 force_version=tls1 recsplit=0" \
764 0 \
765 -s "Read from client: 123 bytes read" \
766 -S "Read from client: 1 bytes read" \
767 -S "122 bytes read"
768
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100769run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
770 "$P_SRV nbio=2" \
771 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
772 request_size=123 force_version=tls1" \
773 0 \
774 -S "Read from client: 123 bytes read" \
775 -s "Read from client: 1 bytes read" \
776 -s "122 bytes read"
777
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100778# Tests for Session Tickets
779
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200780run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200781 "$P_SRV debug_level=3 tickets=1" \
782 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100783 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100784 -c "client hello, adding session ticket extension" \
785 -s "found session ticket extension" \
786 -s "server hello, adding session ticket extension" \
787 -c "found session_ticket extension" \
788 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100789 -S "session successfully restored from cache" \
790 -s "session successfully restored from ticket" \
791 -s "a session has been resumed" \
792 -c "a session has been resumed"
793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200794run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200795 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
796 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100797 0 \
798 -c "client hello, adding session ticket extension" \
799 -s "found session ticket extension" \
800 -s "server hello, adding session ticket extension" \
801 -c "found session_ticket extension" \
802 -c "parse new session ticket" \
803 -S "session successfully restored from cache" \
804 -s "session successfully restored from ticket" \
805 -s "a session has been resumed" \
806 -c "a session has been resumed"
807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200808run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200809 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
810 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100811 0 \
812 -c "client hello, adding session ticket extension" \
813 -s "found session ticket extension" \
814 -s "server hello, adding session ticket extension" \
815 -c "found session_ticket extension" \
816 -c "parse new session ticket" \
817 -S "session successfully restored from cache" \
818 -S "session successfully restored from ticket" \
819 -S "a session has been resumed" \
820 -C "a session has been resumed"
821
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200822run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100823 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200824 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100825 0 \
826 -c "client hello, adding session ticket extension" \
827 -c "found session_ticket extension" \
828 -c "parse new session ticket" \
829 -c "a session has been resumed"
830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200831run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200832 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200833 "( $O_CLI -sess_out $SESSION; \
834 $O_CLI -sess_in $SESSION; \
835 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100836 0 \
837 -s "found session ticket extension" \
838 -s "server hello, adding session ticket extension" \
839 -S "session successfully restored from cache" \
840 -s "session successfully restored from ticket" \
841 -s "a session has been resumed"
842
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100843# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200845run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200846 "$P_SRV debug_level=3 tickets=0" \
847 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100848 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100849 -c "client hello, adding session ticket extension" \
850 -s "found session ticket extension" \
851 -S "server hello, adding session ticket extension" \
852 -C "found session_ticket extension" \
853 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100854 -s "session successfully restored from cache" \
855 -S "session successfully restored from ticket" \
856 -s "a session has been resumed" \
857 -c "a session has been resumed"
858
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200859run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200860 "$P_SRV debug_level=3 tickets=1" \
861 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100862 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100863 -C "client hello, adding session ticket extension" \
864 -S "found session ticket extension" \
865 -S "server hello, adding session ticket extension" \
866 -C "found session_ticket extension" \
867 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100868 -s "session successfully restored from cache" \
869 -S "session successfully restored from ticket" \
870 -s "a session has been resumed" \
871 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200873run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200874 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
875 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100876 0 \
877 -S "session successfully restored from cache" \
878 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100879 -S "a session has been resumed" \
880 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100881
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200882run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200883 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
884 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100885 0 \
886 -s "session successfully restored from cache" \
887 -S "session successfully restored from ticket" \
888 -s "a session has been resumed" \
889 -c "a session has been resumed"
890
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200891run_test "Session resume using cache: timemout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200892 "$P_SRV debug_level=3 tickets=0" \
893 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100894 0 \
895 -s "session successfully restored from cache" \
896 -S "session successfully restored from ticket" \
897 -s "a session has been resumed" \
898 -c "a session has been resumed"
899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200900run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200901 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
902 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100903 0 \
904 -S "session successfully restored from cache" \
905 -S "session successfully restored from ticket" \
906 -S "a session has been resumed" \
907 -C "a session has been resumed"
908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200909run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200910 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
911 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100912 0 \
913 -s "session successfully restored from cache" \
914 -S "session successfully restored from ticket" \
915 -s "a session has been resumed" \
916 -c "a session has been resumed"
917
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200918run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200919 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200920 "( $O_CLI -sess_out $SESSION; \
921 $O_CLI -sess_in $SESSION; \
922 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100923 0 \
924 -s "found session ticket extension" \
925 -S "server hello, adding session ticket extension" \
926 -s "session successfully restored from cache" \
927 -S "session successfully restored from ticket" \
928 -s "a session has been resumed"
929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200930run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100931 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200932 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +0100933 0 \
934 -C "found session_ticket extension" \
935 -C "parse new session ticket" \
936 -c "a session has been resumed"
937
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100938# Tests for Max Fragment Length extension
939
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200940run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200941 "$P_SRV debug_level=3" \
942 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100943 0 \
944 -C "client hello, adding max_fragment_length extension" \
945 -S "found max fragment length extension" \
946 -S "server hello, max_fragment_length extension" \
947 -C "found max_fragment_length extension"
948
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200949run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200950 "$P_SRV debug_level=3" \
951 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100952 0 \
953 -c "client hello, adding max_fragment_length extension" \
954 -s "found max fragment length extension" \
955 -s "server hello, max_fragment_length extension" \
956 -c "found max_fragment_length extension"
957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200958run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200959 "$P_SRV debug_level=3 max_frag_len=4096" \
960 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100961 0 \
962 -C "client hello, adding max_fragment_length extension" \
963 -S "found max fragment length extension" \
964 -S "server hello, max_fragment_length extension" \
965 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100966
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200967requires_gnutls
968run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200969 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200970 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200971 0 \
972 -c "client hello, adding max_fragment_length extension" \
973 -c "found max_fragment_length extension"
974
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100975# Tests for renegotiation
976
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200977run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200978 "$P_SRV debug_level=3 exchanges=2" \
979 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100980 0 \
981 -C "client hello, adding renegotiation extension" \
982 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
983 -S "found renegotiation extension" \
984 -s "server hello, secure renegotiation extension" \
985 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100986 -C "=> renegotiate" \
987 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100988 -S "write hello request"
989
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200990run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200991 "$P_SRV debug_level=3 exchanges=2 renegotiation=1" \
992 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100993 0 \
994 -c "client hello, adding renegotiation extension" \
995 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
996 -s "found renegotiation extension" \
997 -s "server hello, secure renegotiation extension" \
998 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100999 -c "=> renegotiate" \
1000 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001001 -S "write hello request"
1002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001003run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001004 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1005 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001006 0 \
1007 -c "client hello, adding renegotiation extension" \
1008 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1009 -s "found renegotiation extension" \
1010 -s "server hello, secure renegotiation extension" \
1011 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001012 -c "=> renegotiate" \
1013 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001014 -s "write hello request"
1015
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001016run_test "Renegotiation: double" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001017 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1018 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001019 0 \
1020 -c "client hello, adding renegotiation extension" \
1021 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1022 -s "found renegotiation extension" \
1023 -s "server hello, secure renegotiation extension" \
1024 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001025 -c "=> renegotiate" \
1026 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001027 -s "write hello request"
1028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001029run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001030 "$P_SRV debug_level=3 exchanges=2 renegotiation=0" \
1031 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001032 1 \
1033 -c "client hello, adding renegotiation extension" \
1034 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1035 -S "found renegotiation extension" \
1036 -s "server hello, secure renegotiation extension" \
1037 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001038 -c "=> renegotiate" \
1039 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001040 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001041 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001042 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001044run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001045 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1046 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001047 0 \
1048 -C "client hello, adding renegotiation extension" \
1049 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1050 -S "found renegotiation extension" \
1051 -s "server hello, secure renegotiation extension" \
1052 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001053 -C "=> renegotiate" \
1054 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001055 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001056 -S "SSL - An unexpected message was received from our peer" \
1057 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001059run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001060 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001061 renego_delay=-1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001062 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001063 0 \
1064 -C "client hello, adding renegotiation extension" \
1065 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1066 -S "found renegotiation extension" \
1067 -s "server hello, secure renegotiation extension" \
1068 -c "found renegotiation extension" \
1069 -C "=> renegotiate" \
1070 -S "=> renegotiate" \
1071 -s "write hello request" \
1072 -S "SSL - An unexpected message was received from our peer" \
1073 -S "failed"
1074
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001075# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001076run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001077 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001078 renego_delay=2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001079 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001080 0 \
1081 -C "client hello, adding renegotiation extension" \
1082 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1083 -S "found renegotiation extension" \
1084 -s "server hello, secure renegotiation extension" \
1085 -c "found renegotiation extension" \
1086 -C "=> renegotiate" \
1087 -S "=> renegotiate" \
1088 -s "write hello request" \
1089 -S "SSL - An unexpected message was received from our peer" \
1090 -S "failed"
1091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001092run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001093 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001094 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001095 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001096 0 \
1097 -C "client hello, adding renegotiation extension" \
1098 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1099 -S "found renegotiation extension" \
1100 -s "server hello, secure renegotiation extension" \
1101 -c "found renegotiation extension" \
1102 -C "=> renegotiate" \
1103 -S "=> renegotiate" \
1104 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001105 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001107run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001108 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001109 renego_delay=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001110 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001111 0 \
1112 -c "client hello, adding renegotiation extension" \
1113 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1114 -s "found renegotiation extension" \
1115 -s "server hello, secure renegotiation extension" \
1116 -c "found renegotiation extension" \
1117 -c "=> renegotiate" \
1118 -s "=> renegotiate" \
1119 -s "write hello request" \
1120 -S "SSL - An unexpected message was received from our peer" \
1121 -S "failed"
1122
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001123run_test "Renegotiation: periodic, just below period" \
1124 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
1125 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1126 0 \
1127 -C "client hello, adding renegotiation extension" \
1128 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1129 -S "found renegotiation extension" \
1130 -s "server hello, secure renegotiation extension" \
1131 -c "found renegotiation extension" \
1132 -S "record counter limit reached: renegotiate" \
1133 -C "=> renegotiate" \
1134 -S "=> renegotiate" \
1135 -S "write hello request" \
1136 -S "SSL - An unexpected message was received from our peer" \
1137 -S "failed"
1138
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001139# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001140run_test "Renegotiation: periodic, just above period" \
1141 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001142 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001143 0 \
1144 -c "client hello, adding renegotiation extension" \
1145 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1146 -s "found renegotiation extension" \
1147 -s "server hello, secure renegotiation extension" \
1148 -c "found renegotiation extension" \
1149 -s "record counter limit reached: renegotiate" \
1150 -c "=> renegotiate" \
1151 -s "=> renegotiate" \
1152 -s "write hello request" \
1153 -S "SSL - An unexpected message was received from our peer" \
1154 -S "failed"
1155
1156run_test "Renegotiation: periodic, two times period" \
1157 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001158 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001159 0 \
1160 -c "client hello, adding renegotiation extension" \
1161 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1162 -s "found renegotiation extension" \
1163 -s "server hello, secure renegotiation extension" \
1164 -c "found renegotiation extension" \
1165 -s "record counter limit reached: renegotiate" \
1166 -c "=> renegotiate" \
1167 -s "=> renegotiate" \
1168 -s "write hello request" \
1169 -S "SSL - An unexpected message was received from our peer" \
1170 -S "failed"
1171
1172run_test "Renegotiation: periodic, above period, disabled" \
1173 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3" \
1174 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1175 0 \
1176 -C "client hello, adding renegotiation extension" \
1177 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1178 -S "found renegotiation extension" \
1179 -s "server hello, secure renegotiation extension" \
1180 -c "found renegotiation extension" \
1181 -S "record counter limit reached: renegotiate" \
1182 -C "=> renegotiate" \
1183 -S "=> renegotiate" \
1184 -S "write hello request" \
1185 -S "SSL - An unexpected message was received from our peer" \
1186 -S "failed"
1187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001188run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001189 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
1190 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001191 0 \
1192 -c "client hello, adding renegotiation extension" \
1193 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1194 -s "found renegotiation extension" \
1195 -s "server hello, secure renegotiation extension" \
1196 -c "found renegotiation extension" \
1197 -c "=> renegotiate" \
1198 -s "=> renegotiate" \
1199 -S "write hello request"
1200
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001201run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001202 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
1203 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001204 0 \
1205 -c "client hello, adding renegotiation extension" \
1206 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1207 -s "found renegotiation extension" \
1208 -s "server hello, secure renegotiation extension" \
1209 -c "found renegotiation extension" \
1210 -c "=> renegotiate" \
1211 -s "=> renegotiate" \
1212 -s "write hello request"
1213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001214run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001215 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001216 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001217 0 \
1218 -c "client hello, adding renegotiation extension" \
1219 -c "found renegotiation extension" \
1220 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001221 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001222 -C "error" \
1223 -c "HTTP/1.0 200 [Oo][Kk]"
1224
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001225run_test "Renegotiation: gnutls server strict, client-initiated" \
1226 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001227 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001228 0 \
1229 -c "client hello, adding renegotiation extension" \
1230 -c "found renegotiation extension" \
1231 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001232 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001233 -C "error" \
1234 -c "HTTP/1.0 200 [Oo][Kk]"
1235
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001236run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1237 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1238 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1239 1 \
1240 -c "client hello, adding renegotiation extension" \
1241 -C "found renegotiation extension" \
1242 -c "=> renegotiate" \
1243 -c "ssl_handshake() returned" \
1244 -c "error" \
1245 -C "HTTP/1.0 200 [Oo][Kk]"
1246
1247run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1248 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1249 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1250 allow_legacy=0" \
1251 1 \
1252 -c "client hello, adding renegotiation extension" \
1253 -C "found renegotiation extension" \
1254 -c "=> renegotiate" \
1255 -c "ssl_handshake() returned" \
1256 -c "error" \
1257 -C "HTTP/1.0 200 [Oo][Kk]"
1258
1259run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1260 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1261 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1262 allow_legacy=1" \
1263 0 \
1264 -c "client hello, adding renegotiation extension" \
1265 -C "found renegotiation extension" \
1266 -c "=> renegotiate" \
1267 -C "ssl_hanshake() returned" \
1268 -C "error" \
1269 -c "HTTP/1.0 200 [Oo][Kk]"
1270
1271# Test for the "secure renegotation" extension only (no actual renegotiation)
1272
1273run_test "Renego ext: gnutls server strict, client default" \
1274 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1275 "$P_CLI debug_level=3" \
1276 0 \
1277 -c "found renegotiation extension" \
1278 -C "error" \
1279 -c "HTTP/1.0 200 [Oo][Kk]"
1280
1281run_test "Renego ext: gnutls server unsafe, client default" \
1282 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1283 "$P_CLI debug_level=3" \
1284 0 \
1285 -C "found renegotiation extension" \
1286 -C "error" \
1287 -c "HTTP/1.0 200 [Oo][Kk]"
1288
1289run_test "Renego ext: gnutls server unsafe, client break legacy" \
1290 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1291 "$P_CLI debug_level=3 allow_legacy=-1" \
1292 1 \
1293 -C "found renegotiation extension" \
1294 -c "error" \
1295 -C "HTTP/1.0 200 [Oo][Kk]"
1296
1297run_test "Renego ext: gnutls client strict, server default" \
1298 "$P_SRV debug_level=3" \
1299 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1300 0 \
1301 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1302 -s "server hello, secure renegotiation extension"
1303
1304run_test "Renego ext: gnutls client unsafe, server default" \
1305 "$P_SRV debug_level=3" \
1306 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1307 0 \
1308 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1309 -S "server hello, secure renegotiation extension"
1310
1311run_test "Renego ext: gnutls client unsafe, server break legacy" \
1312 "$P_SRV debug_level=3 allow_legacy=-1" \
1313 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1314 1 \
1315 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1316 -S "server hello, secure renegotiation extension"
1317
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001318# Tests for auth_mode
1319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001320run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001321 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001322 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001323 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001324 1 \
1325 -c "x509_verify_cert() returned" \
1326 -c "! self-signed or not signed by a trusted CA" \
1327 -c "! ssl_handshake returned" \
1328 -c "X509 - Certificate verification failed"
1329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001330run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001331 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001332 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001333 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001334 0 \
1335 -c "x509_verify_cert() returned" \
1336 -c "! self-signed or not signed by a trusted CA" \
1337 -C "! ssl_handshake returned" \
1338 -C "X509 - Certificate verification failed"
1339
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001340run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001341 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001342 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001343 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001344 0 \
1345 -C "x509_verify_cert() returned" \
1346 -C "! self-signed or not signed by a trusted CA" \
1347 -C "! ssl_handshake returned" \
1348 -C "X509 - Certificate verification failed"
1349
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001350run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001351 "$P_SRV debug_level=3 auth_mode=required" \
1352 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001353 key_file=data_files/server5.key" \
1354 1 \
1355 -S "skip write certificate request" \
1356 -C "skip parse certificate request" \
1357 -c "got a certificate request" \
1358 -C "skip write certificate" \
1359 -C "skip write certificate verify" \
1360 -S "skip parse certificate verify" \
1361 -s "x509_verify_cert() returned" \
1362 -S "! self-signed or not signed by a trusted CA" \
1363 -s "! ssl_handshake returned" \
1364 -c "! ssl_handshake returned" \
1365 -s "X509 - Certificate verification failed"
1366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001367run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001368 "$P_SRV debug_level=3 auth_mode=optional" \
1369 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001370 key_file=data_files/server5.key" \
1371 0 \
1372 -S "skip write certificate request" \
1373 -C "skip parse certificate request" \
1374 -c "got a certificate request" \
1375 -C "skip write certificate" \
1376 -C "skip write certificate verify" \
1377 -S "skip parse certificate verify" \
1378 -s "x509_verify_cert() returned" \
1379 -s "! self-signed or not signed by a trusted CA" \
1380 -S "! ssl_handshake returned" \
1381 -C "! ssl_handshake returned" \
1382 -S "X509 - Certificate verification failed"
1383
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001384run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001385 "$P_SRV debug_level=3 auth_mode=none" \
1386 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001387 key_file=data_files/server5.key" \
1388 0 \
1389 -s "skip write certificate request" \
1390 -C "skip parse certificate request" \
1391 -c "got no certificate request" \
1392 -c "skip write certificate" \
1393 -c "skip write certificate verify" \
1394 -s "skip parse certificate verify" \
1395 -S "x509_verify_cert() returned" \
1396 -S "! self-signed or not signed by a trusted CA" \
1397 -S "! ssl_handshake returned" \
1398 -C "! ssl_handshake returned" \
1399 -S "X509 - Certificate verification failed"
1400
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001401run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001402 "$P_SRV debug_level=3 auth_mode=optional" \
1403 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001404 0 \
1405 -S "skip write certificate request" \
1406 -C "skip parse certificate request" \
1407 -c "got a certificate request" \
1408 -C "skip write certificate$" \
1409 -C "got no certificate to send" \
1410 -S "SSLv3 client has no certificate" \
1411 -c "skip write certificate verify" \
1412 -s "skip parse certificate verify" \
1413 -s "! no client certificate sent" \
1414 -S "! ssl_handshake returned" \
1415 -C "! ssl_handshake returned" \
1416 -S "X509 - Certificate verification failed"
1417
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001418run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001419 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001420 "$O_CLI" \
1421 0 \
1422 -S "skip write certificate request" \
1423 -s "skip parse certificate verify" \
1424 -s "! no client certificate sent" \
1425 -S "! ssl_handshake returned" \
1426 -S "X509 - Certificate verification failed"
1427
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001428run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001429 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001430 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001431 0 \
1432 -C "skip parse certificate request" \
1433 -c "got a certificate request" \
1434 -C "skip write certificate$" \
1435 -c "skip write certificate verify" \
1436 -C "! ssl_handshake returned"
1437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001438run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001439 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001440 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001441 0 \
1442 -S "skip write certificate request" \
1443 -C "skip parse certificate request" \
1444 -c "got a certificate request" \
1445 -C "skip write certificate$" \
1446 -c "skip write certificate verify" \
1447 -c "got no certificate to send" \
1448 -s "SSLv3 client has no certificate" \
1449 -s "skip parse certificate verify" \
1450 -s "! no client certificate sent" \
1451 -S "! ssl_handshake returned" \
1452 -C "! ssl_handshake returned" \
1453 -S "X509 - Certificate verification failed"
1454
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001455# Tests for certificate selection based on SHA verson
1456
1457run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1458 "$P_SRV crt_file=data_files/server5.crt \
1459 key_file=data_files/server5.key \
1460 crt_file2=data_files/server5-sha1.crt \
1461 key_file2=data_files/server5.key" \
1462 "$P_CLI force_version=tls1_2" \
1463 0 \
1464 -c "signed using.*ECDSA with SHA256" \
1465 -C "signed using.*ECDSA with SHA1"
1466
1467run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1468 "$P_SRV crt_file=data_files/server5.crt \
1469 key_file=data_files/server5.key \
1470 crt_file2=data_files/server5-sha1.crt \
1471 key_file2=data_files/server5.key" \
1472 "$P_CLI force_version=tls1_1" \
1473 0 \
1474 -C "signed using.*ECDSA with SHA256" \
1475 -c "signed using.*ECDSA with SHA1"
1476
1477run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1478 "$P_SRV crt_file=data_files/server5.crt \
1479 key_file=data_files/server5.key \
1480 crt_file2=data_files/server5-sha1.crt \
1481 key_file2=data_files/server5.key" \
1482 "$P_CLI force_version=tls1" \
1483 0 \
1484 -C "signed using.*ECDSA with SHA256" \
1485 -c "signed using.*ECDSA with SHA1"
1486
1487run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1488 "$P_SRV crt_file=data_files/server5.crt \
1489 key_file=data_files/server5.key \
1490 crt_file2=data_files/server6.crt \
1491 key_file2=data_files/server6.key" \
1492 "$P_CLI force_version=tls1_1" \
1493 0 \
1494 -c "serial number.*09" \
1495 -c "signed using.*ECDSA with SHA256" \
1496 -C "signed using.*ECDSA with SHA1"
1497
1498run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1499 "$P_SRV crt_file=data_files/server6.crt \
1500 key_file=data_files/server6.key \
1501 crt_file2=data_files/server5.crt \
1502 key_file2=data_files/server5.key" \
1503 "$P_CLI force_version=tls1_1" \
1504 0 \
1505 -c "serial number.*0A" \
1506 -c "signed using.*ECDSA with SHA256" \
1507 -C "signed using.*ECDSA with SHA1"
1508
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001509# tests for SNI
1510
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001511run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001512 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001513 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001514 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001515 server_name=localhost" \
1516 0 \
1517 -S "parse ServerName extension" \
1518 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1519 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1520
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001521run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001522 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001523 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001524 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 +01001525 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001526 server_name=localhost" \
1527 0 \
1528 -s "parse ServerName extension" \
1529 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1530 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
1531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001532run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001533 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001534 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001535 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 +01001536 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001537 server_name=polarssl.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001538 0 \
1539 -s "parse ServerName extension" \
1540 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001541 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001542
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001543run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001544 "$P_SRV debug_level=3 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001545 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001546 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 +01001547 "$P_CLI debug_level=0 server_addr=127.0.0.1 \
Manuel Pégourié-Gonnard76b8ab72014-03-26 09:31:35 +01001548 server_name=nonesuch.example" \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001549 1 \
1550 -s "parse ServerName extension" \
1551 -s "ssl_sni_wrapper() returned" \
1552 -s "ssl_handshake returned" \
1553 -c "ssl_handshake returned" \
1554 -c "SSL - A fatal alert message was received from our peer"
1555
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001556# Tests for non-blocking I/O: exercise a variety of handshake flows
1557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001558run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001559 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1560 "$P_CLI nbio=2 tickets=0" \
1561 0 \
1562 -S "ssl_handshake returned" \
1563 -C "ssl_handshake returned" \
1564 -c "Read from server: .* bytes read"
1565
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001566run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001567 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1568 "$P_CLI nbio=2 tickets=0" \
1569 0 \
1570 -S "ssl_handshake returned" \
1571 -C "ssl_handshake returned" \
1572 -c "Read from server: .* bytes read"
1573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001574run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001575 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1576 "$P_CLI nbio=2 tickets=1" \
1577 0 \
1578 -S "ssl_handshake returned" \
1579 -C "ssl_handshake returned" \
1580 -c "Read from server: .* bytes read"
1581
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001582run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001583 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1584 "$P_CLI nbio=2 tickets=1" \
1585 0 \
1586 -S "ssl_handshake returned" \
1587 -C "ssl_handshake returned" \
1588 -c "Read from server: .* bytes read"
1589
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001590run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001591 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1592 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1593 0 \
1594 -S "ssl_handshake returned" \
1595 -C "ssl_handshake returned" \
1596 -c "Read from server: .* bytes read"
1597
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001598run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001599 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1600 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1601 0 \
1602 -S "ssl_handshake returned" \
1603 -C "ssl_handshake returned" \
1604 -c "Read from server: .* bytes read"
1605
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001606run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001607 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1608 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1609 0 \
1610 -S "ssl_handshake returned" \
1611 -C "ssl_handshake returned" \
1612 -c "Read from server: .* bytes read"
1613
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001614# Tests for version negotiation
1615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001616run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001617 "$P_SRV" \
1618 "$P_CLI" \
1619 0 \
1620 -S "ssl_handshake returned" \
1621 -C "ssl_handshake returned" \
1622 -s "Protocol is TLSv1.2" \
1623 -c "Protocol is TLSv1.2"
1624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001625run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001626 "$P_SRV" \
1627 "$P_CLI max_version=tls1_1" \
1628 0 \
1629 -S "ssl_handshake returned" \
1630 -C "ssl_handshake returned" \
1631 -s "Protocol is TLSv1.1" \
1632 -c "Protocol is TLSv1.1"
1633
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001634run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001635 "$P_SRV max_version=tls1_1" \
1636 "$P_CLI" \
1637 0 \
1638 -S "ssl_handshake returned" \
1639 -C "ssl_handshake returned" \
1640 -s "Protocol is TLSv1.1" \
1641 -c "Protocol is TLSv1.1"
1642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001643run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001644 "$P_SRV max_version=tls1_1" \
1645 "$P_CLI max_version=tls1_1" \
1646 0 \
1647 -S "ssl_handshake returned" \
1648 -C "ssl_handshake returned" \
1649 -s "Protocol is TLSv1.1" \
1650 -c "Protocol is TLSv1.1"
1651
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001652run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001653 "$P_SRV min_version=tls1_1" \
1654 "$P_CLI max_version=tls1_1" \
1655 0 \
1656 -S "ssl_handshake returned" \
1657 -C "ssl_handshake returned" \
1658 -s "Protocol is TLSv1.1" \
1659 -c "Protocol is TLSv1.1"
1660
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001661run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001662 "$P_SRV max_version=tls1_1" \
1663 "$P_CLI min_version=tls1_1" \
1664 0 \
1665 -S "ssl_handshake returned" \
1666 -C "ssl_handshake returned" \
1667 -s "Protocol is TLSv1.1" \
1668 -c "Protocol is TLSv1.1"
1669
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001670run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001671 "$P_SRV max_version=tls1_1" \
1672 "$P_CLI min_version=tls1_2" \
1673 1 \
1674 -s "ssl_handshake returned" \
1675 -c "ssl_handshake returned" \
1676 -c "SSL - Handshake protocol not within min/max boundaries"
1677
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001678run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001679 "$P_SRV min_version=tls1_2" \
1680 "$P_CLI max_version=tls1_1" \
1681 1 \
1682 -s "ssl_handshake returned" \
1683 -c "ssl_handshake returned" \
1684 -s "SSL - Handshake protocol not within min/max boundaries"
1685
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001686# Tests for ALPN extension
1687
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001688if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then
1689
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001690run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001691 "$P_SRV debug_level=3" \
1692 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001693 0 \
1694 -C "client hello, adding alpn extension" \
1695 -S "found alpn extension" \
1696 -C "got an alert message, type: \\[2:120]" \
1697 -S "server hello, adding alpn extension" \
1698 -C "found alpn extension " \
1699 -C "Application Layer Protocol is" \
1700 -S "Application Layer Protocol is"
1701
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001702run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001703 "$P_SRV debug_level=3" \
1704 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001705 0 \
1706 -c "client hello, adding alpn extension" \
1707 -s "found alpn extension" \
1708 -C "got an alert message, type: \\[2:120]" \
1709 -S "server hello, adding alpn extension" \
1710 -C "found alpn extension " \
1711 -c "Application Layer Protocol is (none)" \
1712 -S "Application Layer Protocol is"
1713
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001714run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001715 "$P_SRV debug_level=3 alpn=abc,1234" \
1716 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001717 0 \
1718 -C "client hello, adding alpn extension" \
1719 -S "found alpn extension" \
1720 -C "got an alert message, type: \\[2:120]" \
1721 -S "server hello, adding alpn extension" \
1722 -C "found alpn extension " \
1723 -C "Application Layer Protocol is" \
1724 -s "Application Layer Protocol is (none)"
1725
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001726run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001727 "$P_SRV debug_level=3 alpn=abc,1234" \
1728 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001729 0 \
1730 -c "client hello, adding alpn extension" \
1731 -s "found alpn extension" \
1732 -C "got an alert message, type: \\[2:120]" \
1733 -s "server hello, adding alpn extension" \
1734 -c "found alpn extension" \
1735 -c "Application Layer Protocol is abc" \
1736 -s "Application Layer Protocol is abc"
1737
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001738run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001739 "$P_SRV debug_level=3 alpn=abc,1234" \
1740 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001741 0 \
1742 -c "client hello, adding alpn extension" \
1743 -s "found alpn extension" \
1744 -C "got an alert message, type: \\[2:120]" \
1745 -s "server hello, adding alpn extension" \
1746 -c "found alpn extension" \
1747 -c "Application Layer Protocol is abc" \
1748 -s "Application Layer Protocol is abc"
1749
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001750run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001751 "$P_SRV debug_level=3 alpn=abc,1234" \
1752 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001753 0 \
1754 -c "client hello, adding alpn extension" \
1755 -s "found alpn extension" \
1756 -C "got an alert message, type: \\[2:120]" \
1757 -s "server hello, adding alpn extension" \
1758 -c "found alpn extension" \
1759 -c "Application Layer Protocol is 1234" \
1760 -s "Application Layer Protocol is 1234"
1761
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001762run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001763 "$P_SRV debug_level=3 alpn=abc,123" \
1764 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001765 1 \
1766 -c "client hello, adding alpn extension" \
1767 -s "found alpn extension" \
1768 -c "got an alert message, type: \\[2:120]" \
1769 -S "server hello, adding alpn extension" \
1770 -C "found alpn extension" \
1771 -C "Application Layer Protocol is 1234" \
1772 -S "Application Layer Protocol is 1234"
1773
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02001774fi
1775
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001776# Tests for keyUsage in leaf certificates, part 1:
1777# server-side certificate/suite selection
1778
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001779run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001780 "$P_SRV key_file=data_files/server2.key \
1781 crt_file=data_files/server2.ku-ds.crt" \
1782 "$P_CLI" \
1783 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02001784 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001785
1786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001787run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001788 "$P_SRV key_file=data_files/server2.key \
1789 crt_file=data_files/server2.ku-ke.crt" \
1790 "$P_CLI" \
1791 0 \
1792 -c "Ciphersuite is TLS-RSA-WITH-"
1793
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001794run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001795 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001796 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001797 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001798 1 \
1799 -C "Ciphersuite is "
1800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001801run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001802 "$P_SRV key_file=data_files/server5.key \
1803 crt_file=data_files/server5.ku-ds.crt" \
1804 "$P_CLI" \
1805 0 \
1806 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
1807
1808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001809run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001810 "$P_SRV key_file=data_files/server5.key \
1811 crt_file=data_files/server5.ku-ka.crt" \
1812 "$P_CLI" \
1813 0 \
1814 -c "Ciphersuite is TLS-ECDH-"
1815
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001816run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001817 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001818 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02001819 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001820 1 \
1821 -C "Ciphersuite is "
1822
1823# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001824# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001825
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001826run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001827 "$O_SRV -key data_files/server2.key \
1828 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001829 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001830 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1831 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001832 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001833 -C "Processing of the Certificate handshake message failed" \
1834 -c "Ciphersuite is TLS-"
1835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001836run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001837 "$O_SRV -key data_files/server2.key \
1838 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001839 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001840 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1841 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001842 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001843 -C "Processing of the Certificate handshake message failed" \
1844 -c "Ciphersuite is TLS-"
1845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001846run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001847 "$O_SRV -key data_files/server2.key \
1848 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001849 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001850 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1851 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001852 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001853 -C "Processing of the Certificate handshake message failed" \
1854 -c "Ciphersuite is TLS-"
1855
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001856run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001857 "$O_SRV -key data_files/server2.key \
1858 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001859 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001860 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1861 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001862 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001863 -c "Processing of the Certificate handshake message failed" \
1864 -C "Ciphersuite is TLS-"
1865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001866run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001867 "$O_SRV -key data_files/server2.key \
1868 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001869 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001870 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
1871 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001872 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001873 -C "Processing of the Certificate handshake message failed" \
1874 -c "Ciphersuite is TLS-"
1875
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001876run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001877 "$O_SRV -key data_files/server2.key \
1878 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001879 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001880 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1881 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001882 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02001883 -c "Processing of the Certificate handshake message failed" \
1884 -C "Ciphersuite is TLS-"
1885
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001886# Tests for keyUsage in leaf certificates, part 3:
1887# server-side checking of client cert
1888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001889run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001890 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001891 "$O_CLI -key data_files/server2.key \
1892 -cert data_files/server2.ku-ds.crt" \
1893 0 \
1894 -S "bad certificate (usage extensions)" \
1895 -S "Processing of the Certificate handshake message failed"
1896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001897run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001898 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001899 "$O_CLI -key data_files/server2.key \
1900 -cert data_files/server2.ku-ke.crt" \
1901 0 \
1902 -s "bad certificate (usage extensions)" \
1903 -S "Processing of the Certificate handshake message failed"
1904
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001905run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001906 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001907 "$O_CLI -key data_files/server2.key \
1908 -cert data_files/server2.ku-ke.crt" \
1909 1 \
1910 -s "bad certificate (usage extensions)" \
1911 -s "Processing of the Certificate handshake message failed"
1912
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001913run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001914 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001915 "$O_CLI -key data_files/server5.key \
1916 -cert data_files/server5.ku-ds.crt" \
1917 0 \
1918 -S "bad certificate (usage extensions)" \
1919 -S "Processing of the Certificate handshake message failed"
1920
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001921run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001922 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02001923 "$O_CLI -key data_files/server5.key \
1924 -cert data_files/server5.ku-ka.crt" \
1925 0 \
1926 -s "bad certificate (usage extensions)" \
1927 -S "Processing of the Certificate handshake message failed"
1928
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001929# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
1930
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001931run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001932 "$P_SRV key_file=data_files/server5.key \
1933 crt_file=data_files/server5.eku-srv.crt" \
1934 "$P_CLI" \
1935 0
1936
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001937run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001938 "$P_SRV key_file=data_files/server5.key \
1939 crt_file=data_files/server5.eku-srv.crt" \
1940 "$P_CLI" \
1941 0
1942
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001943run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001944 "$P_SRV key_file=data_files/server5.key \
1945 crt_file=data_files/server5.eku-cs_any.crt" \
1946 "$P_CLI" \
1947 0
1948
1949# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001950run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001951 "$P_SRV psk=abc123 key_file=data_files/server5.key \
1952 crt_file=data_files/server5.eku-cli.crt" \
1953 "$P_CLI psk=badbad" \
1954 1
1955
1956# Tests for extendedKeyUsage, part 2: client-side checking of server cert
1957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001958run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001959 "$O_SRV -key data_files/server5.key \
1960 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001961 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001962 0 \
1963 -C "bad certificate (usage extensions)" \
1964 -C "Processing of the Certificate handshake message failed" \
1965 -c "Ciphersuite is TLS-"
1966
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001967run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001968 "$O_SRV -key data_files/server5.key \
1969 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001970 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001971 0 \
1972 -C "bad certificate (usage extensions)" \
1973 -C "Processing of the Certificate handshake message failed" \
1974 -c "Ciphersuite is TLS-"
1975
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001976run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001977 "$O_SRV -key data_files/server5.key \
1978 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001979 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001980 0 \
1981 -C "bad certificate (usage extensions)" \
1982 -C "Processing of the Certificate handshake message failed" \
1983 -c "Ciphersuite is TLS-"
1984
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001985run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001986 "$O_SRV -key data_files/server5.key \
1987 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001988 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001989 1 \
1990 -c "bad certificate (usage extensions)" \
1991 -c "Processing of the Certificate handshake message failed" \
1992 -C "Ciphersuite is TLS-"
1993
1994# Tests for extendedKeyUsage, part 3: server-side checking of client cert
1995
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001996run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001997 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02001998 "$O_CLI -key data_files/server5.key \
1999 -cert data_files/server5.eku-cli.crt" \
2000 0 \
2001 -S "bad certificate (usage extensions)" \
2002 -S "Processing of the Certificate handshake message failed"
2003
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002004run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002005 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002006 "$O_CLI -key data_files/server5.key \
2007 -cert data_files/server5.eku-srv_cli.crt" \
2008 0 \
2009 -S "bad certificate (usage extensions)" \
2010 -S "Processing of the Certificate handshake message failed"
2011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002012run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002013 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002014 "$O_CLI -key data_files/server5.key \
2015 -cert data_files/server5.eku-cs_any.crt" \
2016 0 \
2017 -S "bad certificate (usage extensions)" \
2018 -S "Processing of the Certificate handshake message failed"
2019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002020run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002021 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002022 "$O_CLI -key data_files/server5.key \
2023 -cert data_files/server5.eku-cs.crt" \
2024 0 \
2025 -s "bad certificate (usage extensions)" \
2026 -S "Processing of the Certificate handshake message failed"
2027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002028run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002029 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002030 "$O_CLI -key data_files/server5.key \
2031 -cert data_files/server5.eku-cs.crt" \
2032 1 \
2033 -s "bad certificate (usage extensions)" \
2034 -s "Processing of the Certificate handshake message failed"
2035
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002036# Tests for DHM parameters loading
2037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002038run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002039 "$P_SRV" \
2040 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2041 debug_level=3" \
2042 0 \
2043 -c "value of 'DHM: P ' (2048 bits)" \
2044 -c "value of 'DHM: G ' (2048 bits)"
2045
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002046run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002047 "$P_SRV dhm_file=data_files/dhparams.pem" \
2048 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2049 debug_level=3" \
2050 0 \
2051 -c "value of 'DHM: P ' (1024 bits)" \
2052 -c "value of 'DHM: G ' (2 bits)"
2053
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002054# Tests for PSK callback
2055
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002056run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002057 "$P_SRV psk=abc123 psk_identity=foo" \
2058 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2059 psk_identity=foo psk=abc123" \
2060 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002061 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002062 -S "SSL - Unknown identity received" \
2063 -S "SSL - Verification of the message MAC failed"
2064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002065run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002066 "$P_SRV" \
2067 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2068 psk_identity=foo psk=abc123" \
2069 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002070 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002071 -S "SSL - Unknown identity received" \
2072 -S "SSL - Verification of the message MAC failed"
2073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002074run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002075 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2076 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2077 psk_identity=foo psk=abc123" \
2078 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002079 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002080 -s "SSL - Unknown identity received" \
2081 -S "SSL - Verification of the message MAC failed"
2082
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002083run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002084 "$P_SRV psk_list=abc,dead,def,beef" \
2085 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2086 psk_identity=abc psk=dead" \
2087 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002088 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002089 -S "SSL - Unknown identity received" \
2090 -S "SSL - Verification of the message MAC failed"
2091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002092run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002093 "$P_SRV psk_list=abc,dead,def,beef" \
2094 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2095 psk_identity=def psk=beef" \
2096 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002097 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002098 -S "SSL - Unknown identity received" \
2099 -S "SSL - Verification of the message MAC failed"
2100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002101run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002102 "$P_SRV psk_list=abc,dead,def,beef" \
2103 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2104 psk_identity=ghi psk=beef" \
2105 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002106 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002107 -s "SSL - Unknown identity received" \
2108 -S "SSL - Verification of the message MAC failed"
2109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002110run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002111 "$P_SRV psk_list=abc,dead,def,beef" \
2112 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2113 psk_identity=abc psk=beef" \
2114 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002115 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002116 -S "SSL - Unknown identity received" \
2117 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002118
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002119# Tests for ciphersuites per version
2120
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002121run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002122 "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002123 "$P_CLI force_version=ssl3" \
2124 0 \
2125 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002127run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002128 "$P_SRV arc4=1 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
2129 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002130 0 \
2131 -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA"
2132
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002133run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002134 "$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" \
2135 "$P_CLI force_version=tls1_1" \
2136 0 \
2137 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2138
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002139run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002140 "$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" \
2141 "$P_CLI force_version=tls1_2" \
2142 0 \
2143 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2144
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002145# Tests for ssl_get_bytes_avail()
2146
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002147run_test "ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002148 "$P_SRV" \
2149 "$P_CLI request_size=100" \
2150 0 \
2151 -s "Read from client: 100 bytes read$"
2152
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002153run_test "ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002154 "$P_SRV" \
2155 "$P_CLI request_size=500" \
2156 0 \
2157 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002158
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002159# Tests for small packets
2160
2161run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002162 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002163 "$P_CLI request_size=1 force_version=ssl3 \
2164 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2165 0 \
2166 -s "Read from client: 1 bytes read"
2167
2168run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002169 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002170 "$P_CLI request_size=1 force_version=ssl3 \
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.0 BlockCipher" \
2176 "$P_SRV" \
2177 "$P_CLI request_size=1 force_version=tls1 \
2178 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2179 0 \
2180 -s "Read from client: 1 bytes read"
2181
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002182run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2183 "$P_SRV" \
2184 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2185 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2186 0 \
2187 -s "Read from client: 1 bytes read"
2188
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002189run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2190 "$P_SRV" \
2191 "$P_CLI request_size=1 force_version=tls1 \
2192 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2193 trunc_hmac=1" \
2194 0 \
2195 -s "Read from client: 1 bytes read"
2196
2197run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002198 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002199 "$P_CLI request_size=1 force_version=tls1 \
2200 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2201 trunc_hmac=1" \
2202 0 \
2203 -s "Read from client: 1 bytes read"
2204
2205run_test "Small packet TLS 1.1 BlockCipher" \
2206 "$P_SRV" \
2207 "$P_CLI request_size=1 force_version=tls1_1 \
2208 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2209 0 \
2210 -s "Read from client: 1 bytes read"
2211
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002212run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2213 "$P_SRV" \
2214 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2215 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2216 0 \
2217 -s "Read from client: 1 bytes read"
2218
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002219run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002220 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002221 "$P_CLI request_size=1 force_version=tls1_1 \
2222 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2223 0 \
2224 -s "Read from client: 1 bytes read"
2225
2226run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2227 "$P_SRV" \
2228 "$P_CLI request_size=1 force_version=tls1_1 \
2229 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2230 trunc_hmac=1" \
2231 0 \
2232 -s "Read from client: 1 bytes read"
2233
2234run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002235 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002236 "$P_CLI request_size=1 force_version=tls1_1 \
2237 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2238 trunc_hmac=1" \
2239 0 \
2240 -s "Read from client: 1 bytes read"
2241
2242run_test "Small packet TLS 1.2 BlockCipher" \
2243 "$P_SRV" \
2244 "$P_CLI request_size=1 force_version=tls1_2 \
2245 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2246 0 \
2247 -s "Read from client: 1 bytes read"
2248
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002249run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2250 "$P_SRV" \
2251 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2252 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2253 0 \
2254 -s "Read from client: 1 bytes read"
2255
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002256run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2257 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002258 "$P_CLI request_size=1 force_version=tls1_2 \
2259 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002260 0 \
2261 -s "Read from client: 1 bytes read"
2262
2263run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2264 "$P_SRV" \
2265 "$P_CLI request_size=1 force_version=tls1_2 \
2266 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2267 trunc_hmac=1" \
2268 0 \
2269 -s "Read from client: 1 bytes read"
2270
2271run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002272 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002273 "$P_CLI request_size=1 force_version=tls1_2 \
2274 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2275 0 \
2276 -s "Read from client: 1 bytes read"
2277
2278run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002279 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002280 "$P_CLI request_size=1 force_version=tls1_2 \
2281 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2282 trunc_hmac=1" \
2283 0 \
2284 -s "Read from client: 1 bytes read"
2285
2286run_test "Small packet TLS 1.2 AEAD" \
2287 "$P_SRV" \
2288 "$P_CLI request_size=1 force_version=tls1_2 \
2289 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2290 0 \
2291 -s "Read from client: 1 bytes read"
2292
2293run_test "Small packet TLS 1.2 AEAD shorter tag" \
2294 "$P_SRV" \
2295 "$P_CLI request_size=1 force_version=tls1_2 \
2296 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2297 0 \
2298 -s "Read from client: 1 bytes read"
2299
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002300# Test for large packets
2301
2302run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002303 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002304 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002305 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2306 0 \
2307 -s "Read from client: 16384 bytes read"
2308
2309run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002310 "$P_SRV min_version=ssl3 arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002311 "$P_CLI request_size=16384 force_version=ssl3 \
2312 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2313 0 \
2314 -s "Read from client: 16384 bytes read"
2315
2316run_test "Large packet TLS 1.0 BlockCipher" \
2317 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002318 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002319 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2320 0 \
2321 -s "Read from client: 16384 bytes read"
2322
2323run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2324 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002325 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002326 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2327 trunc_hmac=1" \
2328 0 \
2329 -s "Read from client: 16384 bytes read"
2330
2331run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002332 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002333 "$P_CLI request_size=16384 force_version=tls1 \
2334 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2335 trunc_hmac=1" \
2336 0 \
2337 -s "Read from client: 16384 bytes read"
2338
2339run_test "Large packet TLS 1.1 BlockCipher" \
2340 "$P_SRV" \
2341 "$P_CLI request_size=16384 force_version=tls1_1 \
2342 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2343 0 \
2344 -s "Read from client: 16384 bytes read"
2345
2346run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002347 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002348 "$P_CLI request_size=16384 force_version=tls1_1 \
2349 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2350 0 \
2351 -s "Read from client: 16384 bytes read"
2352
2353run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2354 "$P_SRV" \
2355 "$P_CLI request_size=16384 force_version=tls1_1 \
2356 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2357 trunc_hmac=1" \
2358 0 \
2359 -s "Read from client: 16384 bytes read"
2360
2361run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002362 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002363 "$P_CLI request_size=16384 force_version=tls1_1 \
2364 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2365 trunc_hmac=1" \
2366 0 \
2367 -s "Read from client: 16384 bytes read"
2368
2369run_test "Large packet TLS 1.2 BlockCipher" \
2370 "$P_SRV" \
2371 "$P_CLI request_size=16384 force_version=tls1_2 \
2372 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2373 0 \
2374 -s "Read from client: 16384 bytes read"
2375
2376run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2377 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002378 "$P_CLI request_size=16384 force_version=tls1_2 \
2379 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002380 0 \
2381 -s "Read from client: 16384 bytes read"
2382
2383run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2384 "$P_SRV" \
2385 "$P_CLI request_size=16384 force_version=tls1_2 \
2386 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2387 trunc_hmac=1" \
2388 0 \
2389 -s "Read from client: 16384 bytes read"
2390
2391run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002392 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002393 "$P_CLI request_size=16384 force_version=tls1_2 \
2394 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2395 0 \
2396 -s "Read from client: 16384 bytes read"
2397
2398run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002399 "$P_SRV arc4=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002400 "$P_CLI request_size=16384 force_version=tls1_2 \
2401 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2402 trunc_hmac=1" \
2403 0 \
2404 -s "Read from client: 16384 bytes read"
2405
2406run_test "Large packet TLS 1.2 AEAD" \
2407 "$P_SRV" \
2408 "$P_CLI request_size=16384 force_version=tls1_2 \
2409 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2410 0 \
2411 -s "Read from client: 16384 bytes read"
2412
2413run_test "Large packet TLS 1.2 AEAD shorter tag" \
2414 "$P_SRV" \
2415 "$P_CLI request_size=16384 force_version=tls1_2 \
2416 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2417 0 \
2418 -s "Read from client: 16384 bytes read"
2419
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002420# Final report
2421
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002422echo "------------------------------------------------------------------------"
2423
2424if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002425 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002426else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01002427 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002428fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02002429PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02002430echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002431
2432exit $FAILS