blob: d3b7b3fdcd286a344f732e76748d38bbcd6cb7b7 [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#
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02009# Assumes a build with default options.
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010010
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é-Gonnardbe9eb872014-09-05 17:45:19 +020016: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010017: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020018: ${GNUTLS_CLI:=gnutls-cli}
19: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010020
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020021O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010022O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020023G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010024G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010025
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010026TESTS=0
27FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020028SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010029
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000030CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020031
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010032MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010033FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020034EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010035
36print_usage() {
37 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010038 printf " -h|--help\tPrint this help.\n"
39 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
40 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
41 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010042}
43
44get_options() {
45 while [ $# -gt 0 ]; do
46 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010047 -f|--filter)
48 shift; FILTER=$1
49 ;;
50 -e|--exclude)
51 shift; EXCLUDE=$1
52 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010053 -m|--memcheck)
54 MEMCHECK=1
55 ;;
56 -h|--help)
57 print_usage
58 exit 0
59 ;;
60 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020061 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062 print_usage
63 exit 1
64 ;;
65 esac
66 shift
67 done
68}
69
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010070# skip next test if the flag is not enabled in config.h
71requires_config_enabled() {
72 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
73 SKIP_NEXT="YES"
74 fi
75}
76
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020077# skip next test if OpenSSL doesn't support FALLBACK_SCSV
78requires_openssl_with_fallback_scsv() {
79 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
80 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
81 then
82 OPENSSL_HAS_FBSCSV="YES"
83 else
84 OPENSSL_HAS_FBSCSV="NO"
85 fi
86 fi
87 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
88 SKIP_NEXT="YES"
89 fi
90}
91
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020092# skip next test if GnuTLS isn't available
93requires_gnutls() {
94 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +020095 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020096 GNUTLS_AVAILABLE="YES"
97 else
98 GNUTLS_AVAILABLE="NO"
99 fi
100 fi
101 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
102 SKIP_NEXT="YES"
103 fi
104}
105
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200106# skip next test if IPv6 isn't available on this host
107requires_ipv6() {
108 if [ -z "${HAS_IPV6:-}" ]; then
109 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
110 SRV_PID=$!
111 sleep 1
112 kill $SRV_PID >/dev/null 2>&1
113 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
114 HAS_IPV6="NO"
115 else
116 HAS_IPV6="YES"
117 fi
118 rm -r $SRV_OUT
119 fi
120
121 if [ "$HAS_IPV6" = "NO" ]; then
122 SKIP_NEXT="YES"
123 fi
124}
125
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200126# skip the next test if valgrind is in use
127not_with_valgrind() {
128 if [ "$MEMCHECK" -gt 0 ]; then
129 SKIP_NEXT="YES"
130 fi
131}
132
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200133# multiply the client timeout delay by the given factor for the next test
134needs_more_time() {
135 CLI_DELAY_FACTOR=$1
136}
137
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100138# print_name <name>
139print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100140 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200141 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100142 for i in `seq 1 $LEN`; do printf '.'; done
143 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100144
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200145 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100146}
147
148# fail <message>
149fail() {
150 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100151 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100152
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200153 mv $SRV_OUT o-srv-${TESTS}.log
154 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200155 if [ -n "$PXY_CMD" ]; then
156 mv $PXY_OUT o-pxy-${TESTS}.log
157 fi
158 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100159
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200160 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
161 echo " ! server output:"
162 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200163 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200164 echo " ! client output:"
165 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200166 if [ -n "$PXY_CMD" ]; then
167 echo " ! ========================================================"
168 echo " ! proxy output:"
169 cat o-pxy-${TESTS}.log
170 fi
171 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200172 fi
173
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200174 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100175}
176
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100177# is_polar <cmd_line>
178is_polar() {
179 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
180}
181
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200182# openssl s_server doesn't have -www with DTLS
183check_osrv_dtls() {
184 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
185 NEEDS_INPUT=1
186 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
187 else
188 NEEDS_INPUT=0
189 fi
190}
191
192# provide input to commands that need it
193provide_input() {
194 if [ $NEEDS_INPUT -eq 0 ]; then
195 return
196 fi
197
198 while true; do
199 echo "HTTP/1.0 200 OK"
200 sleep 1
201 done
202}
203
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100204# has_mem_err <log_file_name>
205has_mem_err() {
206 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
207 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
208 then
209 return 1 # false: does not have errors
210 else
211 return 0 # true: has errors
212 fi
213}
214
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200215# wait for server to start: two versions depending on lsof availability
216wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200217 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200218 # make sure we don't loop forever
219 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200220 DOG_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200221
222 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200223 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnarda65d5082015-01-12 14:54:55 +0100224 until lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null;
225 do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200226 else
Manuel Pégourié-Gonnarda65d5082015-01-12 14:54:55 +0100227 until lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null;
228 do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200229 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200230
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200231 kill $DOG_PID >/dev/null 2>&1
232 wait $DOG_PID
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200233 else
234 sleep "$START_DELAY"
235 fi
236}
237
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200238# wait for client to terminate and set CLI_EXIT
239# must be called right after starting the client
240wait_client_done() {
241 CLI_PID=$!
242
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200243 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
244 CLI_DELAY_FACTOR=1
245
246 ( sleep $CLI_DELAY; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200247 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200248
249 wait $CLI_PID
250 CLI_EXIT=$?
251
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200252 kill $DOG_PID >/dev/null 2>&1
253 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200254
255 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
256}
257
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200258# check if the given command uses dtls and sets global variable DTLS
259detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200260 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200261 DTLS=1
262 else
263 DTLS=0
264 fi
265}
266
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200267# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100268# Options: -s pattern pattern that must be present in server output
269# -c pattern pattern that must be present in client output
270# -S pattern pattern that must be absent in server output
271# -C pattern pattern that must be absent in client output
272run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100273 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200274 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100275
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100276 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
277 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200278 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100279 return
280 fi
281
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100282 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100283
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200284 # should we skip?
285 if [ "X$SKIP_NEXT" = "XYES" ]; then
286 SKIP_NEXT="NO"
287 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200288 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200289 return
290 fi
291
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200292 # does this test use a proxy?
293 if [ "X$1" = "X-p" ]; then
294 PXY_CMD="$2"
295 shift 2
296 else
297 PXY_CMD=""
298 fi
299
300 # get commands and client output
301 SRV_CMD="$1"
302 CLI_CMD="$2"
303 CLI_EXPECT="$3"
304 shift 3
305
306 # fix client port
307 if [ -n "$PXY_CMD" ]; then
308 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
309 else
310 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
311 fi
312
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200313 # update DTLS variable
314 detect_dtls "$SRV_CMD"
315
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100316 # prepend valgrind to our commands if active
317 if [ "$MEMCHECK" -gt 0 ]; then
318 if is_polar "$SRV_CMD"; then
319 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
320 fi
321 if is_polar "$CLI_CMD"; then
322 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
323 fi
324 fi
325
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100326 # run the commands
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200327 if [ -n "$PXY_CMD" ]; then
328 echo "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200329 $PXY_CMD >> $PXY_OUT 2>&1 &
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200330 PXY_PID=$!
331 # assume proxy starts faster than server
332 fi
333
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200334 check_osrv_dtls
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200335 echo "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200336 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100337 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200338 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200339
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200340 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200341 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
342 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100343
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200344 # terminate the server (and the proxy)
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200345 kill $SRV_PID
346 wait $SRV_PID
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200347 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200348 kill $PXY_PID >/dev/null 2>&1
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200349 wait $PXY_PID
350 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100351
352 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200353 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100354 # expected client exit to incorrectly succeed in case of catastrophic
355 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100356 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200357 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100358 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100359 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100360 return
361 fi
362 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100363 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200364 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100365 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100366 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100367 return
368 fi
369 fi
370
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100371 # check server exit code
372 if [ $? != 0 ]; then
373 fail "server fail"
374 return
375 fi
376
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100377 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100378 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
379 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100380 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200381 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100382 return
383 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100384
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100385 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200386 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100387 while [ $# -gt 0 ]
388 do
389 case $1 in
390 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200391 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100392 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100393 return
394 fi
395 ;;
396
397 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200398 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100399 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100400 return
401 fi
402 ;;
403
404 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200405 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100406 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100407 return
408 fi
409 ;;
410
411 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200412 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100413 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100414 return
415 fi
416 ;;
417
418 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200419 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100420 exit 1
421 esac
422 shift 2
423 done
424
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100425 # check valgrind's results
426 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200427 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100428 fail "Server has memory errors"
429 return
430 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200431 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100432 fail "Client has memory errors"
433 return
434 fi
435 fi
436
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100437 # if we're here, everything is ok
438 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200439 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100440}
441
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100442cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200443 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200444 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
445 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
446 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
447 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100448 exit 1
449}
450
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100451#
452# MAIN
453#
454
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000455if cd $( dirname $0 ); then :; else
456 echo "cd $( dirname $0 ) failed" >&2
457 exit 1
458fi
459
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100460get_options "$@"
461
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100462# sanity checks, avoid an avalanche of errors
463if [ ! -x "$P_SRV" ]; then
464 echo "Command '$P_SRV' is not an executable file"
465 exit 1
466fi
467if [ ! -x "$P_CLI" ]; then
468 echo "Command '$P_CLI' is not an executable file"
469 exit 1
470fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200471if [ ! -x "$P_PXY" ]; then
472 echo "Command '$P_PXY' is not an executable file"
473 exit 1
474fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100475if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
476 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100477 exit 1
478fi
479
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200480# used by watchdog
481MAIN_PID="$$"
482
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200483# be more patient with valgrind
484if [ "$MEMCHECK" -gt 0 ]; then
485 START_DELAY=3
486 DOG_DELAY=30
487else
488 START_DELAY=1
489 DOG_DELAY=10
490fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200491CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200492
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200493# Pick a "unique" server port in the range 10000-19999, and a proxy port
494PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000495PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200496SRV_PORT="1$PORT_BASE"
497PXY_PORT="2$PORT_BASE"
498unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200499
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200500# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000501# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200502P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
503P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
504P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200505O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200506O_CLI="$O_CLI -connect localhost:+SRV_PORT"
507G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000508G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200509
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200510# Also pick a unique name for intermediate files
511SRV_OUT="srv_out.$$"
512CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200513PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200514SESSION="session.$$"
515
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200516SKIP_NEXT="NO"
517
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100518trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100519
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200520# Basic test
521
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200522# Checks that:
523# - things work with all ciphersuites active (used with config-full in all.sh)
524# - the expected (highest security) parameters are selected
525# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200526run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200527 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200528 "$P_CLI" \
529 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200530 -s "Protocol is TLSv1.2" \
531 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
532 -s "client hello v3, signature_algorithm ext: 6" \
533 -s "ECDHE curve: secp521r1" \
534 -S "error" \
535 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200536
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000537run_test "Default, DTLS" \
538 "$P_SRV dtls=1" \
539 "$P_CLI dtls=1" \
540 0 \
541 -s "Protocol is DTLSv1.2" \
542 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
543
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100544# Tests for rc4 option
545
546run_test "RC4: server disabled, client enabled" \
547 "$P_SRV" \
548 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
549 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100550 -s "SSL - The server has no ciphersuites in common"
551
552run_test "RC4: server half, client enabled" \
553 "$P_SRV arc4=1" \
554 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
555 1 \
556 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100557
558run_test "RC4: server enabled, client disabled" \
559 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
560 "$P_CLI" \
561 1 \
562 -s "SSL - The server has no ciphersuites in common"
563
564run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100565 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100566 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
567 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100568 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100569 -S "SSL - The server has no ciphersuites in common"
570
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100571# Tests for Truncated HMAC extension
572
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100573run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200574 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100575 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100576 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100577 -s "dumping 'computed mac' (20 bytes)" \
578 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100579
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100580run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200581 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100582 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
583 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100584 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100585 -s "dumping 'computed mac' (20 bytes)" \
586 -S "dumping 'computed mac' (10 bytes)"
587
588run_test "Truncated HMAC: client enabled, server default" \
589 "$P_SRV debug_level=4" \
590 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
591 trunc_hmac=1" \
592 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100593 -s "dumping 'computed mac' (20 bytes)" \
594 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100595
596run_test "Truncated HMAC: client enabled, server disabled" \
597 "$P_SRV debug_level=4 trunc_hmac=0" \
598 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
599 trunc_hmac=1" \
600 0 \
601 -s "dumping 'computed mac' (20 bytes)" \
602 -S "dumping 'computed mac' (10 bytes)"
603
604run_test "Truncated HMAC: client enabled, server enabled" \
605 "$P_SRV debug_level=4 trunc_hmac=1" \
606 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
607 trunc_hmac=1" \
608 0 \
609 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100610 -s "dumping 'computed mac' (10 bytes)"
611
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100612# Tests for Encrypt-then-MAC extension
613
614run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100615 "$P_SRV debug_level=3 \
616 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100617 "$P_CLI debug_level=3" \
618 0 \
619 -c "client hello, adding encrypt_then_mac extension" \
620 -s "found encrypt then mac extension" \
621 -s "server hello, adding encrypt then mac extension" \
622 -c "found encrypt_then_mac extension" \
623 -c "using encrypt then mac" \
624 -s "using encrypt then mac"
625
626run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100627 "$P_SRV debug_level=3 etm=0 \
628 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100629 "$P_CLI debug_level=3 etm=1" \
630 0 \
631 -c "client hello, adding encrypt_then_mac extension" \
632 -s "found encrypt then mac extension" \
633 -S "server hello, adding encrypt then mac extension" \
634 -C "found encrypt_then_mac extension" \
635 -C "using encrypt then mac" \
636 -S "using encrypt then mac"
637
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100638run_test "Encrypt then MAC: client enabled, aead cipher" \
639 "$P_SRV debug_level=3 etm=1 \
640 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
641 "$P_CLI debug_level=3 etm=1" \
642 0 \
643 -c "client hello, adding encrypt_then_mac extension" \
644 -s "found encrypt then mac extension" \
645 -S "server hello, adding encrypt then mac extension" \
646 -C "found encrypt_then_mac extension" \
647 -C "using encrypt then mac" \
648 -S "using encrypt then mac"
649
650run_test "Encrypt then MAC: client enabled, stream cipher" \
651 "$P_SRV debug_level=3 etm=1 \
652 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100653 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100654 0 \
655 -c "client hello, adding encrypt_then_mac extension" \
656 -s "found encrypt then mac extension" \
657 -S "server hello, adding encrypt then mac extension" \
658 -C "found encrypt_then_mac extension" \
659 -C "using encrypt then mac" \
660 -S "using encrypt then mac"
661
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100662run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100663 "$P_SRV debug_level=3 etm=1 \
664 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100665 "$P_CLI debug_level=3 etm=0" \
666 0 \
667 -C "client hello, adding encrypt_then_mac extension" \
668 -S "found encrypt then mac extension" \
669 -S "server hello, adding encrypt then mac extension" \
670 -C "found encrypt_then_mac extension" \
671 -C "using encrypt then mac" \
672 -S "using encrypt then mac"
673
674run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100675 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100676 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100677 "$P_CLI debug_level=3 force_version=ssl3" \
678 0 \
679 -C "client hello, adding encrypt_then_mac extension" \
680 -S "found encrypt then mac extension" \
681 -S "server hello, adding encrypt then mac extension" \
682 -C "found encrypt_then_mac extension" \
683 -C "using encrypt then mac" \
684 -S "using encrypt then mac"
685
686run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100687 "$P_SRV debug_level=3 force_version=ssl3 \
688 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100689 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100690 0 \
691 -c "client hello, adding encrypt_then_mac extension" \
692 -s "found encrypt then mac extension" \
693 -S "server hello, adding encrypt then mac extension" \
694 -C "found encrypt_then_mac extension" \
695 -C "using encrypt then mac" \
696 -S "using encrypt then mac"
697
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200698# Tests for Extended Master Secret extension
699
700run_test "Extended Master Secret: default" \
701 "$P_SRV debug_level=3" \
702 "$P_CLI debug_level=3" \
703 0 \
704 -c "client hello, adding extended_master_secret extension" \
705 -s "found extended master secret extension" \
706 -s "server hello, adding extended master secret extension" \
707 -c "found extended_master_secret extension" \
708 -c "using extended master secret" \
709 -s "using extended master secret"
710
711run_test "Extended Master Secret: client enabled, server disabled" \
712 "$P_SRV debug_level=3 extended_ms=0" \
713 "$P_CLI debug_level=3 extended_ms=1" \
714 0 \
715 -c "client hello, adding extended_master_secret extension" \
716 -s "found extended master secret extension" \
717 -S "server hello, adding extended master secret extension" \
718 -C "found extended_master_secret extension" \
719 -C "using extended master secret" \
720 -S "using extended master secret"
721
722run_test "Extended Master Secret: client disabled, server enabled" \
723 "$P_SRV debug_level=3 extended_ms=1" \
724 "$P_CLI debug_level=3 extended_ms=0" \
725 0 \
726 -C "client hello, adding extended_master_secret extension" \
727 -S "found extended master secret extension" \
728 -S "server hello, adding extended master secret extension" \
729 -C "found extended_master_secret extension" \
730 -C "using extended master secret" \
731 -S "using extended master secret"
732
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200733run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100734 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200735 "$P_CLI debug_level=3 force_version=ssl3" \
736 0 \
737 -C "client hello, adding extended_master_secret extension" \
738 -S "found extended master secret extension" \
739 -S "server hello, adding extended master secret extension" \
740 -C "found extended_master_secret extension" \
741 -C "using extended master secret" \
742 -S "using extended master secret"
743
744run_test "Extended Master Secret: client enabled, server SSLv3" \
745 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100746 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200747 0 \
748 -c "client hello, adding extended_master_secret extension" \
749 -s "found extended master secret extension" \
750 -S "server hello, adding extended master secret extension" \
751 -C "found extended_master_secret extension" \
752 -C "using extended master secret" \
753 -S "using extended master secret"
754
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200755# Tests for FALLBACK_SCSV
756
757run_test "Fallback SCSV: default" \
758 "$P_SRV" \
759 "$P_CLI debug_level=3 force_version=tls1_1" \
760 0 \
761 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200762 -S "received FALLBACK_SCSV" \
763 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200764 -C "is a fatal alert message (msg 86)"
765
766run_test "Fallback SCSV: explicitly disabled" \
767 "$P_SRV" \
768 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
769 0 \
770 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200771 -S "received FALLBACK_SCSV" \
772 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200773 -C "is a fatal alert message (msg 86)"
774
775run_test "Fallback SCSV: enabled" \
776 "$P_SRV" \
777 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200778 1 \
779 -c "adding FALLBACK_SCSV" \
780 -s "received FALLBACK_SCSV" \
781 -s "inapropriate fallback" \
782 -c "is a fatal alert message (msg 86)"
783
784run_test "Fallback SCSV: enabled, max version" \
785 "$P_SRV" \
786 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200787 0 \
788 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200789 -s "received FALLBACK_SCSV" \
790 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200791 -C "is a fatal alert message (msg 86)"
792
793requires_openssl_with_fallback_scsv
794run_test "Fallback SCSV: default, openssl server" \
795 "$O_SRV" \
796 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
797 0 \
798 -C "adding FALLBACK_SCSV" \
799 -C "is a fatal alert message (msg 86)"
800
801requires_openssl_with_fallback_scsv
802run_test "Fallback SCSV: enabled, openssl server" \
803 "$O_SRV" \
804 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
805 1 \
806 -c "adding FALLBACK_SCSV" \
807 -c "is a fatal alert message (msg 86)"
808
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200809requires_openssl_with_fallback_scsv
810run_test "Fallback SCSV: disabled, openssl client" \
811 "$P_SRV" \
812 "$O_CLI -tls1_1" \
813 0 \
814 -S "received FALLBACK_SCSV" \
815 -S "inapropriate fallback"
816
817requires_openssl_with_fallback_scsv
818run_test "Fallback SCSV: enabled, openssl client" \
819 "$P_SRV" \
820 "$O_CLI -tls1_1 -fallback_scsv" \
821 1 \
822 -s "received FALLBACK_SCSV" \
823 -s "inapropriate fallback"
824
825requires_openssl_with_fallback_scsv
826run_test "Fallback SCSV: enabled, max version, openssl client" \
827 "$P_SRV" \
828 "$O_CLI -fallback_scsv" \
829 0 \
830 -s "received FALLBACK_SCSV" \
831 -S "inapropriate fallback"
832
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100833# Tests for CBC 1/n-1 record splitting
834
835run_test "CBC Record splitting: TLS 1.2, no splitting" \
836 "$P_SRV" \
837 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
838 request_size=123 force_version=tls1_2" \
839 0 \
840 -s "Read from client: 123 bytes read" \
841 -S "Read from client: 1 bytes read" \
842 -S "122 bytes read"
843
844run_test "CBC Record splitting: TLS 1.1, no splitting" \
845 "$P_SRV" \
846 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
847 request_size=123 force_version=tls1_1" \
848 0 \
849 -s "Read from client: 123 bytes read" \
850 -S "Read from client: 1 bytes read" \
851 -S "122 bytes read"
852
853run_test "CBC Record splitting: TLS 1.0, splitting" \
854 "$P_SRV" \
855 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
856 request_size=123 force_version=tls1" \
857 0 \
858 -S "Read from client: 123 bytes read" \
859 -s "Read from client: 1 bytes read" \
860 -s "122 bytes read"
861
862run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100863 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100864 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
865 request_size=123 force_version=ssl3" \
866 0 \
867 -S "Read from client: 123 bytes read" \
868 -s "Read from client: 1 bytes read" \
869 -s "122 bytes read"
870
871run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100872 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100873 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
874 request_size=123 force_version=tls1" \
875 0 \
876 -s "Read from client: 123 bytes read" \
877 -S "Read from client: 1 bytes read" \
878 -S "122 bytes read"
879
880run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
881 "$P_SRV" \
882 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
883 request_size=123 force_version=tls1 recsplit=0" \
884 0 \
885 -s "Read from client: 123 bytes read" \
886 -S "Read from client: 1 bytes read" \
887 -S "122 bytes read"
888
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100889run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
890 "$P_SRV nbio=2" \
891 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
892 request_size=123 force_version=tls1" \
893 0 \
894 -S "Read from client: 123 bytes read" \
895 -s "Read from client: 1 bytes read" \
896 -s "122 bytes read"
897
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100898# Tests for Session Tickets
899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200900run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200901 "$P_SRV debug_level=3 tickets=1" \
902 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100903 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100904 -c "client hello, adding session ticket extension" \
905 -s "found session ticket extension" \
906 -s "server hello, adding session ticket extension" \
907 -c "found session_ticket extension" \
908 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100909 -S "session successfully restored from cache" \
910 -s "session successfully restored from ticket" \
911 -s "a session has been resumed" \
912 -c "a session has been resumed"
913
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200914run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200915 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
916 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100917 0 \
918 -c "client hello, adding session ticket extension" \
919 -s "found session ticket extension" \
920 -s "server hello, adding session ticket extension" \
921 -c "found session_ticket extension" \
922 -c "parse new session ticket" \
923 -S "session successfully restored from cache" \
924 -s "session successfully restored from ticket" \
925 -s "a session has been resumed" \
926 -c "a session has been resumed"
927
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200928run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200929 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
930 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100931 0 \
932 -c "client hello, adding session ticket extension" \
933 -s "found session ticket extension" \
934 -s "server hello, adding session ticket extension" \
935 -c "found session_ticket extension" \
936 -c "parse new session ticket" \
937 -S "session successfully restored from cache" \
938 -S "session successfully restored from ticket" \
939 -S "a session has been resumed" \
940 -C "a session has been resumed"
941
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200942run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100943 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200944 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100945 0 \
946 -c "client hello, adding session ticket extension" \
947 -c "found session_ticket extension" \
948 -c "parse new session ticket" \
949 -c "a session has been resumed"
950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200951run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200952 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200953 "( $O_CLI -sess_out $SESSION; \
954 $O_CLI -sess_in $SESSION; \
955 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100956 0 \
957 -s "found session ticket extension" \
958 -s "server hello, adding session ticket extension" \
959 -S "session successfully restored from cache" \
960 -s "session successfully restored from ticket" \
961 -s "a session has been resumed"
962
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100963# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100964
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200965run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200966 "$P_SRV debug_level=3 tickets=0" \
967 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100968 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100969 -c "client hello, adding session ticket extension" \
970 -s "found session ticket extension" \
971 -S "server hello, adding session ticket extension" \
972 -C "found session_ticket extension" \
973 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100974 -s "session successfully restored from cache" \
975 -S "session successfully restored from ticket" \
976 -s "a session has been resumed" \
977 -c "a session has been resumed"
978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200979run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200980 "$P_SRV debug_level=3 tickets=1" \
981 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100982 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100983 -C "client hello, adding session ticket extension" \
984 -S "found session ticket extension" \
985 -S "server hello, adding session ticket extension" \
986 -C "found session_ticket extension" \
987 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100988 -s "session successfully restored from cache" \
989 -S "session successfully restored from ticket" \
990 -s "a session has been resumed" \
991 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200993run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200994 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
995 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100996 0 \
997 -S "session successfully restored from cache" \
998 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100999 -S "a session has been resumed" \
1000 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001002run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001003 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1004 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001005 0 \
1006 -s "session successfully restored from cache" \
1007 -S "session successfully restored from ticket" \
1008 -s "a session has been resumed" \
1009 -c "a session has been resumed"
1010
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001011run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001012 "$P_SRV debug_level=3 tickets=0" \
1013 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001014 0 \
1015 -s "session successfully restored from cache" \
1016 -S "session successfully restored from ticket" \
1017 -s "a session has been resumed" \
1018 -c "a session has been resumed"
1019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001020run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001021 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1022 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001023 0 \
1024 -S "session successfully restored from cache" \
1025 -S "session successfully restored from ticket" \
1026 -S "a session has been resumed" \
1027 -C "a session has been resumed"
1028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001029run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001030 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1031 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001032 0 \
1033 -s "session successfully restored from cache" \
1034 -S "session successfully restored from ticket" \
1035 -s "a session has been resumed" \
1036 -c "a session has been resumed"
1037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001038run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001039 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001040 "( $O_CLI -sess_out $SESSION; \
1041 $O_CLI -sess_in $SESSION; \
1042 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001043 0 \
1044 -s "found session ticket extension" \
1045 -S "server hello, adding session ticket extension" \
1046 -s "session successfully restored from cache" \
1047 -S "session successfully restored from ticket" \
1048 -s "a session has been resumed"
1049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001050run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001051 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001052 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001053 0 \
1054 -C "found session_ticket extension" \
1055 -C "parse new session ticket" \
1056 -c "a session has been resumed"
1057
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001058# Tests for Max Fragment Length extension
1059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001060run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001061 "$P_SRV debug_level=3" \
1062 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001063 0 \
1064 -C "client hello, adding max_fragment_length extension" \
1065 -S "found max fragment length extension" \
1066 -S "server hello, max_fragment_length extension" \
1067 -C "found max_fragment_length extension"
1068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001069run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001070 "$P_SRV debug_level=3" \
1071 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001072 0 \
1073 -c "client hello, adding max_fragment_length extension" \
1074 -s "found max fragment length extension" \
1075 -s "server hello, max_fragment_length extension" \
1076 -c "found max_fragment_length extension"
1077
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001078run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001079 "$P_SRV debug_level=3 max_frag_len=4096" \
1080 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001081 0 \
1082 -C "client hello, adding max_fragment_length extension" \
1083 -S "found max fragment length extension" \
1084 -S "server hello, max_fragment_length extension" \
1085 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001086
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001087requires_gnutls
1088run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001089 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001090 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001091 0 \
1092 -c "client hello, adding max_fragment_length extension" \
1093 -c "found max_fragment_length extension"
1094
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001095run_test "Max fragment length: client, message just fits" \
1096 "$P_SRV debug_level=3" \
1097 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1098 0 \
1099 -c "client hello, adding max_fragment_length extension" \
1100 -s "found max fragment length extension" \
1101 -s "server hello, max_fragment_length extension" \
1102 -c "found max_fragment_length extension" \
1103 -c "2048 bytes written in 1 fragments" \
1104 -s "2048 bytes read"
1105
1106run_test "Max fragment length: client, larger message" \
1107 "$P_SRV debug_level=3" \
1108 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1109 0 \
1110 -c "client hello, adding max_fragment_length extension" \
1111 -s "found max fragment length extension" \
1112 -s "server hello, max_fragment_length extension" \
1113 -c "found max_fragment_length extension" \
1114 -c "2345 bytes written in 2 fragments" \
1115 -s "2048 bytes read" \
1116 -s "297 bytes read"
1117
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001118run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001119 "$P_SRV debug_level=3 dtls=1" \
1120 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1121 1 \
1122 -c "client hello, adding max_fragment_length extension" \
1123 -s "found max fragment length extension" \
1124 -s "server hello, max_fragment_length extension" \
1125 -c "found max_fragment_length extension" \
1126 -c "fragment larger than.*maximum"
1127
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001128# Tests for renegotiation
1129
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001130run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001131 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001132 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001133 0 \
1134 -C "client hello, adding renegotiation extension" \
1135 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1136 -S "found renegotiation extension" \
1137 -s "server hello, secure renegotiation extension" \
1138 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001139 -C "=> renegotiate" \
1140 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001141 -S "write hello request"
1142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001143run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001144 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001145 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001146 0 \
1147 -c "client hello, adding renegotiation extension" \
1148 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1149 -s "found renegotiation extension" \
1150 -s "server hello, secure renegotiation extension" \
1151 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001152 -c "=> renegotiate" \
1153 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001154 -S "write hello request"
1155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001156run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001157 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001158 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +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" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001165 -c "=> renegotiate" \
1166 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001167 -s "write hello request"
1168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001169run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001170 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001171 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001172 0 \
1173 -c "client hello, adding renegotiation extension" \
1174 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1175 -s "found renegotiation extension" \
1176 -s "server hello, secure renegotiation extension" \
1177 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001178 -c "=> renegotiate" \
1179 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001180 -s "write hello request"
1181
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001182run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001183 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001184 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001185 1 \
1186 -c "client hello, adding renegotiation extension" \
1187 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1188 -S "found renegotiation extension" \
1189 -s "server hello, secure renegotiation extension" \
1190 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001191 -c "=> renegotiate" \
1192 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001193 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001194 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001195 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001196
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001197run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001198 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001199 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001200 0 \
1201 -C "client hello, adding renegotiation extension" \
1202 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1203 -S "found renegotiation extension" \
1204 -s "server hello, secure renegotiation extension" \
1205 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001206 -C "=> renegotiate" \
1207 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001208 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001209 -S "SSL - An unexpected message was received from our peer" \
1210 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001211
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001212run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001213 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001214 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001215 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001216 0 \
1217 -C "client hello, adding renegotiation extension" \
1218 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1219 -S "found renegotiation extension" \
1220 -s "server hello, secure renegotiation extension" \
1221 -c "found renegotiation extension" \
1222 -C "=> renegotiate" \
1223 -S "=> renegotiate" \
1224 -s "write hello request" \
1225 -S "SSL - An unexpected message was received from our peer" \
1226 -S "failed"
1227
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001228# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001229run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001230 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001231 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001232 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001233 0 \
1234 -C "client hello, adding renegotiation extension" \
1235 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1236 -S "found renegotiation extension" \
1237 -s "server hello, secure renegotiation extension" \
1238 -c "found renegotiation extension" \
1239 -C "=> renegotiate" \
1240 -S "=> renegotiate" \
1241 -s "write hello request" \
1242 -S "SSL - An unexpected message was received from our peer" \
1243 -S "failed"
1244
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001245run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001246 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001247 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001248 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001249 0 \
1250 -C "client hello, adding renegotiation extension" \
1251 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1252 -S "found renegotiation extension" \
1253 -s "server hello, secure renegotiation extension" \
1254 -c "found renegotiation extension" \
1255 -C "=> renegotiate" \
1256 -S "=> renegotiate" \
1257 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001258 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001259
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001260run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001261 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001262 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001263 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001264 0 \
1265 -c "client hello, adding renegotiation extension" \
1266 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1267 -s "found renegotiation extension" \
1268 -s "server hello, secure renegotiation extension" \
1269 -c "found renegotiation extension" \
1270 -c "=> renegotiate" \
1271 -s "=> renegotiate" \
1272 -s "write hello request" \
1273 -S "SSL - An unexpected message was received from our peer" \
1274 -S "failed"
1275
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001276run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001277 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001278 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1279 0 \
1280 -C "client hello, adding renegotiation extension" \
1281 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1282 -S "found renegotiation extension" \
1283 -s "server hello, secure renegotiation extension" \
1284 -c "found renegotiation extension" \
1285 -S "record counter limit reached: renegotiate" \
1286 -C "=> renegotiate" \
1287 -S "=> renegotiate" \
1288 -S "write hello request" \
1289 -S "SSL - An unexpected message was received from our peer" \
1290 -S "failed"
1291
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001292# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001293run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001294 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001295 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001296 0 \
1297 -c "client hello, adding renegotiation extension" \
1298 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1299 -s "found renegotiation extension" \
1300 -s "server hello, secure renegotiation extension" \
1301 -c "found renegotiation extension" \
1302 -s "record counter limit reached: renegotiate" \
1303 -c "=> renegotiate" \
1304 -s "=> renegotiate" \
1305 -s "write hello request" \
1306 -S "SSL - An unexpected message was received from our peer" \
1307 -S "failed"
1308
1309run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001310 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001311 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001312 0 \
1313 -c "client hello, adding renegotiation extension" \
1314 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1315 -s "found renegotiation extension" \
1316 -s "server hello, secure renegotiation extension" \
1317 -c "found renegotiation extension" \
1318 -s "record counter limit reached: renegotiate" \
1319 -c "=> renegotiate" \
1320 -s "=> renegotiate" \
1321 -s "write hello request" \
1322 -S "SSL - An unexpected message was received from our peer" \
1323 -S "failed"
1324
1325run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001326 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001327 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1328 0 \
1329 -C "client hello, adding renegotiation extension" \
1330 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1331 -S "found renegotiation extension" \
1332 -s "server hello, secure renegotiation extension" \
1333 -c "found renegotiation extension" \
1334 -S "record counter limit reached: renegotiate" \
1335 -C "=> renegotiate" \
1336 -S "=> renegotiate" \
1337 -S "write hello request" \
1338 -S "SSL - An unexpected message was received from our peer" \
1339 -S "failed"
1340
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001341run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001342 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001343 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001344 0 \
1345 -c "client hello, adding renegotiation extension" \
1346 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1347 -s "found renegotiation extension" \
1348 -s "server hello, secure renegotiation extension" \
1349 -c "found renegotiation extension" \
1350 -c "=> renegotiate" \
1351 -s "=> renegotiate" \
1352 -S "write hello request"
1353
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001354run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001355 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001356 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001357 0 \
1358 -c "client hello, adding renegotiation extension" \
1359 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1360 -s "found renegotiation extension" \
1361 -s "server hello, secure renegotiation extension" \
1362 -c "found renegotiation extension" \
1363 -c "=> renegotiate" \
1364 -s "=> renegotiate" \
1365 -s "write hello request"
1366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001367run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001368 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001369 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001370 0 \
1371 -c "client hello, adding renegotiation extension" \
1372 -c "found renegotiation extension" \
1373 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001374 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001375 -C "error" \
1376 -c "HTTP/1.0 200 [Oo][Kk]"
1377
Paul Bakker539d9722015-02-08 16:18:35 +01001378requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001379run_test "Renegotiation: gnutls server strict, client-initiated" \
1380 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001381 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001382 0 \
1383 -c "client hello, adding renegotiation extension" \
1384 -c "found renegotiation extension" \
1385 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001386 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001387 -C "error" \
1388 -c "HTTP/1.0 200 [Oo][Kk]"
1389
Paul Bakker539d9722015-02-08 16:18:35 +01001390requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001391run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1392 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1393 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1394 1 \
1395 -c "client hello, adding renegotiation extension" \
1396 -C "found renegotiation extension" \
1397 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001398 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001399 -c "error" \
1400 -C "HTTP/1.0 200 [Oo][Kk]"
1401
Paul Bakker539d9722015-02-08 16:18:35 +01001402requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001403run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1404 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1405 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1406 allow_legacy=0" \
1407 1 \
1408 -c "client hello, adding renegotiation extension" \
1409 -C "found renegotiation extension" \
1410 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001411 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001412 -c "error" \
1413 -C "HTTP/1.0 200 [Oo][Kk]"
1414
Paul Bakker539d9722015-02-08 16:18:35 +01001415requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001416run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1417 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1418 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1419 allow_legacy=1" \
1420 0 \
1421 -c "client hello, adding renegotiation extension" \
1422 -C "found renegotiation extension" \
1423 -c "=> renegotiate" \
1424 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001425 -C "error" \
1426 -c "HTTP/1.0 200 [Oo][Kk]"
1427
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001428run_test "Renegotiation: DTLS, client-initiated" \
1429 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1430 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1431 0 \
1432 -c "client hello, adding renegotiation extension" \
1433 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1434 -s "found renegotiation extension" \
1435 -s "server hello, secure renegotiation extension" \
1436 -c "found renegotiation extension" \
1437 -c "=> renegotiate" \
1438 -s "=> renegotiate" \
1439 -S "write hello request"
1440
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001441run_test "Renegotiation: DTLS, server-initiated" \
1442 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001443 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1444 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001445 0 \
1446 -c "client hello, adding renegotiation extension" \
1447 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1448 -s "found renegotiation extension" \
1449 -s "server hello, secure renegotiation extension" \
1450 -c "found renegotiation extension" \
1451 -c "=> renegotiate" \
1452 -s "=> renegotiate" \
1453 -s "write hello request"
1454
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001455requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001456run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1457 "$G_SRV -u --mtu 4096" \
1458 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1459 0 \
1460 -c "client hello, adding renegotiation extension" \
1461 -c "found renegotiation extension" \
1462 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001463 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001464 -C "error" \
1465 -s "Extra-header:"
1466
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001467# Test for the "secure renegotation" extension only (no actual renegotiation)
1468
Paul Bakker539d9722015-02-08 16:18:35 +01001469requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001470run_test "Renego ext: gnutls server strict, client default" \
1471 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1472 "$P_CLI debug_level=3" \
1473 0 \
1474 -c "found renegotiation extension" \
1475 -C "error" \
1476 -c "HTTP/1.0 200 [Oo][Kk]"
1477
Paul Bakker539d9722015-02-08 16:18:35 +01001478requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001479run_test "Renego ext: gnutls server unsafe, client default" \
1480 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1481 "$P_CLI debug_level=3" \
1482 0 \
1483 -C "found renegotiation extension" \
1484 -C "error" \
1485 -c "HTTP/1.0 200 [Oo][Kk]"
1486
Paul Bakker539d9722015-02-08 16:18:35 +01001487requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001488run_test "Renego ext: gnutls server unsafe, client break legacy" \
1489 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1490 "$P_CLI debug_level=3 allow_legacy=-1" \
1491 1 \
1492 -C "found renegotiation extension" \
1493 -c "error" \
1494 -C "HTTP/1.0 200 [Oo][Kk]"
1495
Paul Bakker539d9722015-02-08 16:18:35 +01001496requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001497run_test "Renego ext: gnutls client strict, server default" \
1498 "$P_SRV debug_level=3" \
1499 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1500 0 \
1501 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1502 -s "server hello, secure renegotiation extension"
1503
Paul Bakker539d9722015-02-08 16:18:35 +01001504requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001505run_test "Renego ext: gnutls client unsafe, server default" \
1506 "$P_SRV debug_level=3" \
1507 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1508 0 \
1509 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1510 -S "server hello, secure renegotiation extension"
1511
Paul Bakker539d9722015-02-08 16:18:35 +01001512requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001513run_test "Renego ext: gnutls client unsafe, server break legacy" \
1514 "$P_SRV debug_level=3 allow_legacy=-1" \
1515 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1516 1 \
1517 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1518 -S "server hello, secure renegotiation extension"
1519
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001520# Tests for auth_mode
1521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001522run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001523 "$P_SRV crt_file=data_files/server5-badsign.crt \
1524 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001525 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001526 1 \
1527 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001528 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001529 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001530 -c "X509 - Certificate verification failed"
1531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001532run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001533 "$P_SRV crt_file=data_files/server5-badsign.crt \
1534 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001535 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001536 0 \
1537 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001538 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001539 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001540 -C "X509 - Certificate verification failed"
1541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001542run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001543 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001544 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001545 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001546 0 \
1547 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001548 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001549 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001550 -C "X509 - Certificate verification failed"
1551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001552run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001553 "$P_SRV debug_level=3 auth_mode=required" \
1554 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001555 key_file=data_files/server5.key" \
1556 1 \
1557 -S "skip write certificate request" \
1558 -C "skip parse certificate request" \
1559 -c "got a certificate request" \
1560 -C "skip write certificate" \
1561 -C "skip write certificate verify" \
1562 -S "skip parse certificate verify" \
1563 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001564 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001565 -s "! mbedtls_ssl_handshake returned" \
1566 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001567 -s "X509 - Certificate verification failed"
1568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001569run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001570 "$P_SRV debug_level=3 auth_mode=optional" \
1571 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001572 key_file=data_files/server5.key" \
1573 0 \
1574 -S "skip write certificate request" \
1575 -C "skip parse certificate request" \
1576 -c "got a certificate request" \
1577 -C "skip write certificate" \
1578 -C "skip write certificate verify" \
1579 -S "skip parse certificate verify" \
1580 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001581 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001582 -S "! mbedtls_ssl_handshake returned" \
1583 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001584 -S "X509 - Certificate verification failed"
1585
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001586run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001587 "$P_SRV debug_level=3 auth_mode=none" \
1588 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001589 key_file=data_files/server5.key" \
1590 0 \
1591 -s "skip write certificate request" \
1592 -C "skip parse certificate request" \
1593 -c "got no certificate request" \
1594 -c "skip write certificate" \
1595 -c "skip write certificate verify" \
1596 -s "skip parse certificate verify" \
1597 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001598 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001599 -S "! mbedtls_ssl_handshake returned" \
1600 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001601 -S "X509 - Certificate verification failed"
1602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001603run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001604 "$P_SRV debug_level=3 auth_mode=optional" \
1605 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001606 0 \
1607 -S "skip write certificate request" \
1608 -C "skip parse certificate request" \
1609 -c "got a certificate request" \
1610 -C "skip write certificate$" \
1611 -C "got no certificate to send" \
1612 -S "SSLv3 client has no certificate" \
1613 -c "skip write certificate verify" \
1614 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001615 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001616 -S "! mbedtls_ssl_handshake returned" \
1617 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001618 -S "X509 - Certificate verification failed"
1619
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001620run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001621 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001622 "$O_CLI" \
1623 0 \
1624 -S "skip write certificate request" \
1625 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001626 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001627 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001628 -S "X509 - Certificate verification failed"
1629
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001630run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001631 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001632 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001633 0 \
1634 -C "skip parse certificate request" \
1635 -c "got a certificate request" \
1636 -C "skip write certificate$" \
1637 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001638 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001639
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001640run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001641 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001642 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001643 0 \
1644 -S "skip write certificate request" \
1645 -C "skip parse certificate request" \
1646 -c "got a certificate request" \
1647 -C "skip write certificate$" \
1648 -c "skip write certificate verify" \
1649 -c "got no certificate to send" \
1650 -s "SSLv3 client has no certificate" \
1651 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001652 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001653 -S "! mbedtls_ssl_handshake returned" \
1654 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001655 -S "X509 - Certificate verification failed"
1656
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001657# Tests for certificate selection based on SHA verson
1658
1659run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1660 "$P_SRV crt_file=data_files/server5.crt \
1661 key_file=data_files/server5.key \
1662 crt_file2=data_files/server5-sha1.crt \
1663 key_file2=data_files/server5.key" \
1664 "$P_CLI force_version=tls1_2" \
1665 0 \
1666 -c "signed using.*ECDSA with SHA256" \
1667 -C "signed using.*ECDSA with SHA1"
1668
1669run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1670 "$P_SRV crt_file=data_files/server5.crt \
1671 key_file=data_files/server5.key \
1672 crt_file2=data_files/server5-sha1.crt \
1673 key_file2=data_files/server5.key" \
1674 "$P_CLI force_version=tls1_1" \
1675 0 \
1676 -C "signed using.*ECDSA with SHA256" \
1677 -c "signed using.*ECDSA with SHA1"
1678
1679run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1680 "$P_SRV crt_file=data_files/server5.crt \
1681 key_file=data_files/server5.key \
1682 crt_file2=data_files/server5-sha1.crt \
1683 key_file2=data_files/server5.key" \
1684 "$P_CLI force_version=tls1" \
1685 0 \
1686 -C "signed using.*ECDSA with SHA256" \
1687 -c "signed using.*ECDSA with SHA1"
1688
1689run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1690 "$P_SRV crt_file=data_files/server5.crt \
1691 key_file=data_files/server5.key \
1692 crt_file2=data_files/server6.crt \
1693 key_file2=data_files/server6.key" \
1694 "$P_CLI force_version=tls1_1" \
1695 0 \
1696 -c "serial number.*09" \
1697 -c "signed using.*ECDSA with SHA256" \
1698 -C "signed using.*ECDSA with SHA1"
1699
1700run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1701 "$P_SRV crt_file=data_files/server6.crt \
1702 key_file=data_files/server6.key \
1703 crt_file2=data_files/server5.crt \
1704 key_file2=data_files/server5.key" \
1705 "$P_CLI force_version=tls1_1" \
1706 0 \
1707 -c "serial number.*0A" \
1708 -c "signed using.*ECDSA with SHA256" \
1709 -C "signed using.*ECDSA with SHA1"
1710
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001711# tests for SNI
1712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001713run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001714 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001715 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001716 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001717 0 \
1718 -S "parse ServerName extension" \
1719 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1720 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001721
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001722run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001723 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001724 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001725 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001726 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001727 0 \
1728 -s "parse ServerName extension" \
1729 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1730 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001732run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001733 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001734 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001735 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001736 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001737 0 \
1738 -s "parse ServerName extension" \
1739 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1740 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001741
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001742run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001743 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001744 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001745 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001746 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001747 1 \
1748 -s "parse ServerName extension" \
1749 -s "ssl_sni_wrapper() returned" \
1750 -s "mbedtls_ssl_handshake returned" \
1751 -c "mbedtls_ssl_handshake returned" \
1752 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001753
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001754run_test "SNI: client auth no override: optional" \
1755 "$P_SRV debug_level=3 auth_mode=optional \
1756 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1757 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1758 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001759 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001760 -S "skip write certificate request" \
1761 -C "skip parse certificate request" \
1762 -c "got a certificate request" \
1763 -C "skip write certificate" \
1764 -C "skip write certificate verify" \
1765 -S "skip parse certificate verify"
1766
1767run_test "SNI: client auth override: none -> optional" \
1768 "$P_SRV debug_level=3 auth_mode=none \
1769 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1770 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1771 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001772 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001773 -S "skip write certificate request" \
1774 -C "skip parse certificate request" \
1775 -c "got a certificate request" \
1776 -C "skip write certificate" \
1777 -C "skip write certificate verify" \
1778 -S "skip parse certificate verify"
1779
1780run_test "SNI: client auth override: optional -> none" \
1781 "$P_SRV debug_level=3 auth_mode=optional \
1782 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1783 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1784 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001785 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001786 -s "skip write certificate request" \
1787 -C "skip parse certificate request" \
1788 -c "got no certificate request" \
1789 -c "skip write certificate" \
1790 -c "skip write certificate verify" \
1791 -s "skip parse certificate verify"
1792
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001793run_test "SNI: CA no override" \
1794 "$P_SRV debug_level=3 auth_mode=optional \
1795 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1796 ca_file=data_files/test-ca.crt \
1797 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1798 "$P_CLI debug_level=3 server_name=localhost \
1799 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1800 1 \
1801 -S "skip write certificate request" \
1802 -C "skip parse certificate request" \
1803 -c "got a certificate request" \
1804 -C "skip write certificate" \
1805 -C "skip write certificate verify" \
1806 -S "skip parse certificate verify" \
1807 -s "x509_verify_cert() returned" \
1808 -s "! The certificate is not correctly signed by the trusted CA" \
1809 -S "The certificate has been revoked (is on a CRL)"
1810
1811run_test "SNI: CA override" \
1812 "$P_SRV debug_level=3 auth_mode=optional \
1813 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1814 ca_file=data_files/test-ca.crt \
1815 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1816 "$P_CLI debug_level=3 server_name=localhost \
1817 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1818 0 \
1819 -S "skip write certificate request" \
1820 -C "skip parse certificate request" \
1821 -c "got a certificate request" \
1822 -C "skip write certificate" \
1823 -C "skip write certificate verify" \
1824 -S "skip parse certificate verify" \
1825 -S "x509_verify_cert() returned" \
1826 -S "! The certificate is not correctly signed by the trusted CA" \
1827 -S "The certificate has been revoked (is on a CRL)"
1828
1829run_test "SNI: CA override with CRL" \
1830 "$P_SRV debug_level=3 auth_mode=optional \
1831 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1832 ca_file=data_files/test-ca.crt \
1833 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1834 "$P_CLI debug_level=3 server_name=localhost \
1835 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1836 1 \
1837 -S "skip write certificate request" \
1838 -C "skip parse certificate request" \
1839 -c "got a certificate request" \
1840 -C "skip write certificate" \
1841 -C "skip write certificate verify" \
1842 -S "skip parse certificate verify" \
1843 -s "x509_verify_cert() returned" \
1844 -S "! The certificate is not correctly signed by the trusted CA" \
1845 -s "The certificate has been revoked (is on a CRL)"
1846
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001847# Tests for non-blocking I/O: exercise a variety of handshake flows
1848
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001849run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001850 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1851 "$P_CLI nbio=2 tickets=0" \
1852 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001853 -S "mbedtls_ssl_handshake returned" \
1854 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001855 -c "Read from server: .* bytes read"
1856
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001857run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001858 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1859 "$P_CLI nbio=2 tickets=0" \
1860 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001861 -S "mbedtls_ssl_handshake returned" \
1862 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001863 -c "Read from server: .* bytes read"
1864
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001865run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001866 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1867 "$P_CLI nbio=2 tickets=1" \
1868 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001869 -S "mbedtls_ssl_handshake returned" \
1870 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001871 -c "Read from server: .* bytes read"
1872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001873run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001874 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1875 "$P_CLI nbio=2 tickets=1" \
1876 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001877 -S "mbedtls_ssl_handshake returned" \
1878 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001879 -c "Read from server: .* bytes read"
1880
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001881run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001882 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1883 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1884 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001885 -S "mbedtls_ssl_handshake returned" \
1886 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001887 -c "Read from server: .* bytes read"
1888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001889run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001890 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1891 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1892 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001893 -S "mbedtls_ssl_handshake returned" \
1894 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001895 -c "Read from server: .* bytes read"
1896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001897run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001898 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1899 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1900 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001901 -S "mbedtls_ssl_handshake returned" \
1902 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001903 -c "Read from server: .* bytes read"
1904
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001905# Tests for version negotiation
1906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001907run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001908 "$P_SRV" \
1909 "$P_CLI" \
1910 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001911 -S "mbedtls_ssl_handshake returned" \
1912 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001913 -s "Protocol is TLSv1.2" \
1914 -c "Protocol is TLSv1.2"
1915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001916run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001917 "$P_SRV" \
1918 "$P_CLI max_version=tls1_1" \
1919 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001920 -S "mbedtls_ssl_handshake returned" \
1921 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001922 -s "Protocol is TLSv1.1" \
1923 -c "Protocol is TLSv1.1"
1924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001925run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001926 "$P_SRV max_version=tls1_1" \
1927 "$P_CLI" \
1928 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001929 -S "mbedtls_ssl_handshake returned" \
1930 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001931 -s "Protocol is TLSv1.1" \
1932 -c "Protocol is TLSv1.1"
1933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001934run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001935 "$P_SRV max_version=tls1_1" \
1936 "$P_CLI max_version=tls1_1" \
1937 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001938 -S "mbedtls_ssl_handshake returned" \
1939 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001940 -s "Protocol is TLSv1.1" \
1941 -c "Protocol is TLSv1.1"
1942
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001943run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001944 "$P_SRV min_version=tls1_1" \
1945 "$P_CLI max_version=tls1_1" \
1946 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001947 -S "mbedtls_ssl_handshake returned" \
1948 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001949 -s "Protocol is TLSv1.1" \
1950 -c "Protocol is TLSv1.1"
1951
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001952run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001953 "$P_SRV max_version=tls1_1" \
1954 "$P_CLI min_version=tls1_1" \
1955 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001956 -S "mbedtls_ssl_handshake returned" \
1957 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001958 -s "Protocol is TLSv1.1" \
1959 -c "Protocol is TLSv1.1"
1960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001961run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001962 "$P_SRV max_version=tls1_1" \
1963 "$P_CLI min_version=tls1_2" \
1964 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001965 -s "mbedtls_ssl_handshake returned" \
1966 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001967 -c "SSL - Handshake protocol not within min/max boundaries"
1968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001969run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001970 "$P_SRV min_version=tls1_2" \
1971 "$P_CLI max_version=tls1_1" \
1972 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001973 -s "mbedtls_ssl_handshake returned" \
1974 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001975 -s "SSL - Handshake protocol not within min/max boundaries"
1976
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001977# Tests for ALPN extension
1978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001979run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001980 "$P_SRV debug_level=3" \
1981 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001982 0 \
1983 -C "client hello, adding alpn extension" \
1984 -S "found alpn extension" \
1985 -C "got an alert message, type: \\[2:120]" \
1986 -S "server hello, adding alpn extension" \
1987 -C "found alpn extension " \
1988 -C "Application Layer Protocol is" \
1989 -S "Application Layer Protocol is"
1990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001991run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001992 "$P_SRV debug_level=3" \
1993 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001994 0 \
1995 -c "client hello, adding alpn extension" \
1996 -s "found alpn extension" \
1997 -C "got an alert message, type: \\[2:120]" \
1998 -S "server hello, adding alpn extension" \
1999 -C "found alpn extension " \
2000 -c "Application Layer Protocol is (none)" \
2001 -S "Application Layer Protocol is"
2002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002003run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002004 "$P_SRV debug_level=3 alpn=abc,1234" \
2005 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002006 0 \
2007 -C "client hello, adding alpn extension" \
2008 -S "found alpn extension" \
2009 -C "got an alert message, type: \\[2:120]" \
2010 -S "server hello, adding alpn extension" \
2011 -C "found alpn extension " \
2012 -C "Application Layer Protocol is" \
2013 -s "Application Layer Protocol is (none)"
2014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002015run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002016 "$P_SRV debug_level=3 alpn=abc,1234" \
2017 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002018 0 \
2019 -c "client hello, adding alpn extension" \
2020 -s "found alpn extension" \
2021 -C "got an alert message, type: \\[2:120]" \
2022 -s "server hello, adding alpn extension" \
2023 -c "found alpn extension" \
2024 -c "Application Layer Protocol is abc" \
2025 -s "Application Layer Protocol is abc"
2026
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002027run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002028 "$P_SRV debug_level=3 alpn=abc,1234" \
2029 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002030 0 \
2031 -c "client hello, adding alpn extension" \
2032 -s "found alpn extension" \
2033 -C "got an alert message, type: \\[2:120]" \
2034 -s "server hello, adding alpn extension" \
2035 -c "found alpn extension" \
2036 -c "Application Layer Protocol is abc" \
2037 -s "Application Layer Protocol is abc"
2038
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002039run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002040 "$P_SRV debug_level=3 alpn=abc,1234" \
2041 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002042 0 \
2043 -c "client hello, adding alpn extension" \
2044 -s "found alpn extension" \
2045 -C "got an alert message, type: \\[2:120]" \
2046 -s "server hello, adding alpn extension" \
2047 -c "found alpn extension" \
2048 -c "Application Layer Protocol is 1234" \
2049 -s "Application Layer Protocol is 1234"
2050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002051run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002052 "$P_SRV debug_level=3 alpn=abc,123" \
2053 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002054 1 \
2055 -c "client hello, adding alpn extension" \
2056 -s "found alpn extension" \
2057 -c "got an alert message, type: \\[2:120]" \
2058 -S "server hello, adding alpn extension" \
2059 -C "found alpn extension" \
2060 -C "Application Layer Protocol is 1234" \
2061 -S "Application Layer Protocol is 1234"
2062
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002063
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002064# Tests for keyUsage in leaf certificates, part 1:
2065# server-side certificate/suite selection
2066
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002067run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002068 "$P_SRV key_file=data_files/server2.key \
2069 crt_file=data_files/server2.ku-ds.crt" \
2070 "$P_CLI" \
2071 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002072 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002073
2074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002075run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002076 "$P_SRV key_file=data_files/server2.key \
2077 crt_file=data_files/server2.ku-ke.crt" \
2078 "$P_CLI" \
2079 0 \
2080 -c "Ciphersuite is TLS-RSA-WITH-"
2081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002082run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002083 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002084 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002085 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002086 1 \
2087 -C "Ciphersuite is "
2088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002089run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002090 "$P_SRV key_file=data_files/server5.key \
2091 crt_file=data_files/server5.ku-ds.crt" \
2092 "$P_CLI" \
2093 0 \
2094 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2095
2096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002097run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002098 "$P_SRV key_file=data_files/server5.key \
2099 crt_file=data_files/server5.ku-ka.crt" \
2100 "$P_CLI" \
2101 0 \
2102 -c "Ciphersuite is TLS-ECDH-"
2103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002104run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002105 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002106 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002107 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002108 1 \
2109 -C "Ciphersuite is "
2110
2111# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002112# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002114run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002115 "$O_SRV -key data_files/server2.key \
2116 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002117 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002118 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2119 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002120 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002121 -C "Processing of the Certificate handshake message failed" \
2122 -c "Ciphersuite is TLS-"
2123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002124run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002125 "$O_SRV -key data_files/server2.key \
2126 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002127 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002128 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2129 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002130 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002131 -C "Processing of the Certificate handshake message failed" \
2132 -c "Ciphersuite is TLS-"
2133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002134run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002135 "$O_SRV -key data_files/server2.key \
2136 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002137 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002138 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2139 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002140 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002141 -C "Processing of the Certificate handshake message failed" \
2142 -c "Ciphersuite is TLS-"
2143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002144run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002145 "$O_SRV -key data_files/server2.key \
2146 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002147 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002148 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2149 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002150 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002151 -c "Processing of the Certificate handshake message failed" \
2152 -C "Ciphersuite is TLS-"
2153
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002154run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2155 "$O_SRV -key data_files/server2.key \
2156 -cert data_files/server2.ku-ke.crt" \
2157 "$P_CLI debug_level=1 auth_mode=optional \
2158 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2159 0 \
2160 -c "bad certificate (usage extensions)" \
2161 -C "Processing of the Certificate handshake message failed" \
2162 -c "Ciphersuite is TLS-" \
2163 -c "! Usage does not match the keyUsage extension"
2164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002165run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002166 "$O_SRV -key data_files/server2.key \
2167 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002168 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002169 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2170 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002171 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002172 -C "Processing of the Certificate handshake message failed" \
2173 -c "Ciphersuite is TLS-"
2174
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002175run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002176 "$O_SRV -key data_files/server2.key \
2177 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002178 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002179 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2180 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002181 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002182 -c "Processing of the Certificate handshake message failed" \
2183 -C "Ciphersuite is TLS-"
2184
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002185run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2186 "$O_SRV -key data_files/server2.key \
2187 -cert data_files/server2.ku-ds.crt" \
2188 "$P_CLI debug_level=1 auth_mode=optional \
2189 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2190 0 \
2191 -c "bad certificate (usage extensions)" \
2192 -C "Processing of the Certificate handshake message failed" \
2193 -c "Ciphersuite is TLS-" \
2194 -c "! Usage does not match the keyUsage extension"
2195
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002196# Tests for keyUsage in leaf certificates, part 3:
2197# server-side checking of client cert
2198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002199run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002200 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002201 "$O_CLI -key data_files/server2.key \
2202 -cert data_files/server2.ku-ds.crt" \
2203 0 \
2204 -S "bad certificate (usage extensions)" \
2205 -S "Processing of the Certificate handshake message failed"
2206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002207run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002208 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002209 "$O_CLI -key data_files/server2.key \
2210 -cert data_files/server2.ku-ke.crt" \
2211 0 \
2212 -s "bad certificate (usage extensions)" \
2213 -S "Processing of the Certificate handshake message failed"
2214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002215run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002216 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002217 "$O_CLI -key data_files/server2.key \
2218 -cert data_files/server2.ku-ke.crt" \
2219 1 \
2220 -s "bad certificate (usage extensions)" \
2221 -s "Processing of the Certificate handshake message failed"
2222
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002223run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002224 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002225 "$O_CLI -key data_files/server5.key \
2226 -cert data_files/server5.ku-ds.crt" \
2227 0 \
2228 -S "bad certificate (usage extensions)" \
2229 -S "Processing of the Certificate handshake message failed"
2230
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002231run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002232 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002233 "$O_CLI -key data_files/server5.key \
2234 -cert data_files/server5.ku-ka.crt" \
2235 0 \
2236 -s "bad certificate (usage extensions)" \
2237 -S "Processing of the Certificate handshake message failed"
2238
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002239# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2240
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002241run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002242 "$P_SRV key_file=data_files/server5.key \
2243 crt_file=data_files/server5.eku-srv.crt" \
2244 "$P_CLI" \
2245 0
2246
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002247run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002248 "$P_SRV key_file=data_files/server5.key \
2249 crt_file=data_files/server5.eku-srv.crt" \
2250 "$P_CLI" \
2251 0
2252
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002253run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002254 "$P_SRV key_file=data_files/server5.key \
2255 crt_file=data_files/server5.eku-cs_any.crt" \
2256 "$P_CLI" \
2257 0
2258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002259run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002260 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002261 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002262 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002263 1
2264
2265# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002267run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002268 "$O_SRV -key data_files/server5.key \
2269 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002270 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002271 0 \
2272 -C "bad certificate (usage extensions)" \
2273 -C "Processing of the Certificate handshake message failed" \
2274 -c "Ciphersuite is TLS-"
2275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002276run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002277 "$O_SRV -key data_files/server5.key \
2278 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002279 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002280 0 \
2281 -C "bad certificate (usage extensions)" \
2282 -C "Processing of the Certificate handshake message failed" \
2283 -c "Ciphersuite is TLS-"
2284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002285run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002286 "$O_SRV -key data_files/server5.key \
2287 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002288 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002289 0 \
2290 -C "bad certificate (usage extensions)" \
2291 -C "Processing of the Certificate handshake message failed" \
2292 -c "Ciphersuite is TLS-"
2293
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002294run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002295 "$O_SRV -key data_files/server5.key \
2296 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002297 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002298 1 \
2299 -c "bad certificate (usage extensions)" \
2300 -c "Processing of the Certificate handshake message failed" \
2301 -C "Ciphersuite is TLS-"
2302
2303# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2304
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002305run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002306 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002307 "$O_CLI -key data_files/server5.key \
2308 -cert data_files/server5.eku-cli.crt" \
2309 0 \
2310 -S "bad certificate (usage extensions)" \
2311 -S "Processing of the Certificate handshake message failed"
2312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002313run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002314 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002315 "$O_CLI -key data_files/server5.key \
2316 -cert data_files/server5.eku-srv_cli.crt" \
2317 0 \
2318 -S "bad certificate (usage extensions)" \
2319 -S "Processing of the Certificate handshake message failed"
2320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002321run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002322 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002323 "$O_CLI -key data_files/server5.key \
2324 -cert data_files/server5.eku-cs_any.crt" \
2325 0 \
2326 -S "bad certificate (usage extensions)" \
2327 -S "Processing of the Certificate handshake message failed"
2328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002329run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002330 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002331 "$O_CLI -key data_files/server5.key \
2332 -cert data_files/server5.eku-cs.crt" \
2333 0 \
2334 -s "bad certificate (usage extensions)" \
2335 -S "Processing of the Certificate handshake message failed"
2336
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002337run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002338 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002339 "$O_CLI -key data_files/server5.key \
2340 -cert data_files/server5.eku-cs.crt" \
2341 1 \
2342 -s "bad certificate (usage extensions)" \
2343 -s "Processing of the Certificate handshake message failed"
2344
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002345# Tests for DHM parameters loading
2346
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002347run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002348 "$P_SRV" \
2349 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2350 debug_level=3" \
2351 0 \
2352 -c "value of 'DHM: P ' (2048 bits)" \
2353 -c "value of 'DHM: G ' (2048 bits)"
2354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002355run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002356 "$P_SRV dhm_file=data_files/dhparams.pem" \
2357 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2358 debug_level=3" \
2359 0 \
2360 -c "value of 'DHM: P ' (1024 bits)" \
2361 -c "value of 'DHM: G ' (2 bits)"
2362
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002363# Tests for DHM client-side size checking
2364
2365run_test "DHM size: server default, client default, OK" \
2366 "$P_SRV" \
2367 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2368 debug_level=1" \
2369 0 \
2370 -C "DHM prime too short:"
2371
2372run_test "DHM size: server default, client 2048, OK" \
2373 "$P_SRV" \
2374 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2375 debug_level=1 dhmlen=2048" \
2376 0 \
2377 -C "DHM prime too short:"
2378
2379run_test "DHM size: server 1024, client default, OK" \
2380 "$P_SRV dhm_file=data_files/dhparams.pem" \
2381 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2382 debug_level=1" \
2383 0 \
2384 -C "DHM prime too short:"
2385
2386run_test "DHM size: server 1000, client default, rejected" \
2387 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2388 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2389 debug_level=1" \
2390 1 \
2391 -c "DHM prime too short:"
2392
2393run_test "DHM size: server default, client 2049, rejected" \
2394 "$P_SRV" \
2395 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2396 debug_level=1 dhmlen=2049" \
2397 1 \
2398 -c "DHM prime too short:"
2399
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002400# Tests for PSK callback
2401
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002402run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002403 "$P_SRV psk=abc123 psk_identity=foo" \
2404 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2405 psk_identity=foo psk=abc123" \
2406 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002407 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002408 -S "SSL - Unknown identity received" \
2409 -S "SSL - Verification of the message MAC failed"
2410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002411run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002412 "$P_SRV" \
2413 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2414 psk_identity=foo psk=abc123" \
2415 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002416 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002417 -S "SSL - Unknown identity received" \
2418 -S "SSL - Verification of the message MAC failed"
2419
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002420run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002421 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2422 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2423 psk_identity=foo psk=abc123" \
2424 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002425 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002426 -s "SSL - Unknown identity received" \
2427 -S "SSL - Verification of the message MAC failed"
2428
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002429run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002430 "$P_SRV psk_list=abc,dead,def,beef" \
2431 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2432 psk_identity=abc psk=dead" \
2433 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002434 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002435 -S "SSL - Unknown identity received" \
2436 -S "SSL - Verification of the message MAC failed"
2437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002438run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002439 "$P_SRV psk_list=abc,dead,def,beef" \
2440 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2441 psk_identity=def psk=beef" \
2442 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002443 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002444 -S "SSL - Unknown identity received" \
2445 -S "SSL - Verification of the message MAC failed"
2446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002447run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002448 "$P_SRV psk_list=abc,dead,def,beef" \
2449 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2450 psk_identity=ghi psk=beef" \
2451 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002452 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002453 -s "SSL - Unknown identity received" \
2454 -S "SSL - Verification of the message MAC failed"
2455
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002456run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002457 "$P_SRV psk_list=abc,dead,def,beef" \
2458 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2459 psk_identity=abc psk=beef" \
2460 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002461 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002462 -S "SSL - Unknown identity received" \
2463 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002464
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002465# Tests for ciphersuites per version
2466
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002467run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002468 "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002469 "$P_CLI force_version=ssl3" \
2470 0 \
2471 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2472
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002473run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002474 "$P_SRV arc4=1 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01002475 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002476 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002477 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002478
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002479run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002480 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002481 "$P_CLI force_version=tls1_1" \
2482 0 \
2483 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002485run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002486 "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002487 "$P_CLI force_version=tls1_2" \
2488 0 \
2489 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2490
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002491# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002492
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002493run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002494 "$P_SRV" \
2495 "$P_CLI request_size=100" \
2496 0 \
2497 -s "Read from client: 100 bytes read$"
2498
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002499run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002500 "$P_SRV" \
2501 "$P_CLI request_size=500" \
2502 0 \
2503 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002504
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002505# Tests for small packets
2506
2507run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002508 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002509 "$P_CLI request_size=1 force_version=ssl3 \
2510 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2511 0 \
2512 -s "Read from client: 1 bytes read"
2513
2514run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002515 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002516 "$P_CLI request_size=1 force_version=ssl3 \
2517 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2518 0 \
2519 -s "Read from client: 1 bytes read"
2520
2521run_test "Small packet TLS 1.0 BlockCipher" \
2522 "$P_SRV" \
2523 "$P_CLI request_size=1 force_version=tls1 \
2524 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2525 0 \
2526 -s "Read from client: 1 bytes read"
2527
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002528run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2529 "$P_SRV" \
2530 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2531 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2532 0 \
2533 -s "Read from client: 1 bytes read"
2534
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002535run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2536 "$P_SRV" \
2537 "$P_CLI request_size=1 force_version=tls1 \
2538 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2539 trunc_hmac=1" \
2540 0 \
2541 -s "Read from client: 1 bytes read"
2542
2543run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002544 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002545 "$P_CLI request_size=1 force_version=tls1 \
2546 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2547 trunc_hmac=1" \
2548 0 \
2549 -s "Read from client: 1 bytes read"
2550
2551run_test "Small packet TLS 1.1 BlockCipher" \
2552 "$P_SRV" \
2553 "$P_CLI request_size=1 force_version=tls1_1 \
2554 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2555 0 \
2556 -s "Read from client: 1 bytes read"
2557
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002558run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2559 "$P_SRV" \
2560 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2561 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2562 0 \
2563 -s "Read from client: 1 bytes read"
2564
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002565run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002566 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002567 "$P_CLI request_size=1 force_version=tls1_1 \
2568 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2569 0 \
2570 -s "Read from client: 1 bytes read"
2571
2572run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2573 "$P_SRV" \
2574 "$P_CLI request_size=1 force_version=tls1_1 \
2575 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2576 trunc_hmac=1" \
2577 0 \
2578 -s "Read from client: 1 bytes read"
2579
2580run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002581 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002582 "$P_CLI request_size=1 force_version=tls1_1 \
2583 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2584 trunc_hmac=1" \
2585 0 \
2586 -s "Read from client: 1 bytes read"
2587
2588run_test "Small packet TLS 1.2 BlockCipher" \
2589 "$P_SRV" \
2590 "$P_CLI request_size=1 force_version=tls1_2 \
2591 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2592 0 \
2593 -s "Read from client: 1 bytes read"
2594
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002595run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2596 "$P_SRV" \
2597 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2598 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2599 0 \
2600 -s "Read from client: 1 bytes read"
2601
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002602run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2603 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002604 "$P_CLI request_size=1 force_version=tls1_2 \
2605 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002606 0 \
2607 -s "Read from client: 1 bytes read"
2608
2609run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2610 "$P_SRV" \
2611 "$P_CLI request_size=1 force_version=tls1_2 \
2612 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2613 trunc_hmac=1" \
2614 0 \
2615 -s "Read from client: 1 bytes read"
2616
2617run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002618 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002619 "$P_CLI request_size=1 force_version=tls1_2 \
2620 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2621 0 \
2622 -s "Read from client: 1 bytes read"
2623
2624run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002625 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002626 "$P_CLI request_size=1 force_version=tls1_2 \
2627 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2628 trunc_hmac=1" \
2629 0 \
2630 -s "Read from client: 1 bytes read"
2631
2632run_test "Small packet TLS 1.2 AEAD" \
2633 "$P_SRV" \
2634 "$P_CLI request_size=1 force_version=tls1_2 \
2635 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2636 0 \
2637 -s "Read from client: 1 bytes read"
2638
2639run_test "Small packet TLS 1.2 AEAD shorter tag" \
2640 "$P_SRV" \
2641 "$P_CLI request_size=1 force_version=tls1_2 \
2642 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2643 0 \
2644 -s "Read from client: 1 bytes read"
2645
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002646# Test for large packets
2647
2648run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002649 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002650 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002651 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2652 0 \
2653 -s "Read from client: 16384 bytes read"
2654
2655run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002656 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002657 "$P_CLI request_size=16384 force_version=ssl3 \
2658 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2659 0 \
2660 -s "Read from client: 16384 bytes read"
2661
2662run_test "Large packet TLS 1.0 BlockCipher" \
2663 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002664 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002665 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2666 0 \
2667 -s "Read from client: 16384 bytes read"
2668
2669run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2670 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002671 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002672 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2673 trunc_hmac=1" \
2674 0 \
2675 -s "Read from client: 16384 bytes read"
2676
2677run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002678 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002679 "$P_CLI request_size=16384 force_version=tls1 \
2680 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2681 trunc_hmac=1" \
2682 0 \
2683 -s "Read from client: 16384 bytes read"
2684
2685run_test "Large packet TLS 1.1 BlockCipher" \
2686 "$P_SRV" \
2687 "$P_CLI request_size=16384 force_version=tls1_1 \
2688 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2689 0 \
2690 -s "Read from client: 16384 bytes read"
2691
2692run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002693 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002694 "$P_CLI request_size=16384 force_version=tls1_1 \
2695 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2696 0 \
2697 -s "Read from client: 16384 bytes read"
2698
2699run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2700 "$P_SRV" \
2701 "$P_CLI request_size=16384 force_version=tls1_1 \
2702 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2703 trunc_hmac=1" \
2704 0 \
2705 -s "Read from client: 16384 bytes read"
2706
2707run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002708 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002709 "$P_CLI request_size=16384 force_version=tls1_1 \
2710 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2711 trunc_hmac=1" \
2712 0 \
2713 -s "Read from client: 16384 bytes read"
2714
2715run_test "Large packet TLS 1.2 BlockCipher" \
2716 "$P_SRV" \
2717 "$P_CLI request_size=16384 force_version=tls1_2 \
2718 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2719 0 \
2720 -s "Read from client: 16384 bytes read"
2721
2722run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2723 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002724 "$P_CLI request_size=16384 force_version=tls1_2 \
2725 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002726 0 \
2727 -s "Read from client: 16384 bytes read"
2728
2729run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2730 "$P_SRV" \
2731 "$P_CLI request_size=16384 force_version=tls1_2 \
2732 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2733 trunc_hmac=1" \
2734 0 \
2735 -s "Read from client: 16384 bytes read"
2736
2737run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002738 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002739 "$P_CLI request_size=16384 force_version=tls1_2 \
2740 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2741 0 \
2742 -s "Read from client: 16384 bytes read"
2743
2744run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002745 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002746 "$P_CLI request_size=16384 force_version=tls1_2 \
2747 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2748 trunc_hmac=1" \
2749 0 \
2750 -s "Read from client: 16384 bytes read"
2751
2752run_test "Large packet TLS 1.2 AEAD" \
2753 "$P_SRV" \
2754 "$P_CLI request_size=16384 force_version=tls1_2 \
2755 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2756 0 \
2757 -s "Read from client: 16384 bytes read"
2758
2759run_test "Large packet TLS 1.2 AEAD shorter tag" \
2760 "$P_SRV" \
2761 "$P_CLI request_size=16384 force_version=tls1_2 \
2762 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2763 0 \
2764 -s "Read from client: 16384 bytes read"
2765
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002766# Tests for DTLS HelloVerifyRequest
2767
2768run_test "DTLS cookie: enabled" \
2769 "$P_SRV dtls=1 debug_level=2" \
2770 "$P_CLI dtls=1 debug_level=2" \
2771 0 \
2772 -s "cookie verification failed" \
2773 -s "cookie verification passed" \
2774 -S "cookie verification skipped" \
2775 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002776 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002777 -S "SSL - The requested feature is not available"
2778
2779run_test "DTLS cookie: disabled" \
2780 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2781 "$P_CLI dtls=1 debug_level=2" \
2782 0 \
2783 -S "cookie verification failed" \
2784 -S "cookie verification passed" \
2785 -s "cookie verification skipped" \
2786 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002787 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002788 -S "SSL - The requested feature is not available"
2789
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002790run_test "DTLS cookie: default (failing)" \
2791 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2792 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2793 1 \
2794 -s "cookie verification failed" \
2795 -S "cookie verification passed" \
2796 -S "cookie verification skipped" \
2797 -C "received hello verify request" \
2798 -S "hello verification requested" \
2799 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002800
2801requires_ipv6
2802run_test "DTLS cookie: enabled, IPv6" \
2803 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2804 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2805 0 \
2806 -s "cookie verification failed" \
2807 -s "cookie verification passed" \
2808 -S "cookie verification skipped" \
2809 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002810 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002811 -S "SSL - The requested feature is not available"
2812
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002813run_test "DTLS cookie: enabled, nbio" \
2814 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2815 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2816 0 \
2817 -s "cookie verification failed" \
2818 -s "cookie verification passed" \
2819 -S "cookie verification skipped" \
2820 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002821 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002822 -S "SSL - The requested feature is not available"
2823
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002824# Tests for various cases of client authentication with DTLS
2825# (focused on handshake flows and message parsing)
2826
2827run_test "DTLS client auth: required" \
2828 "$P_SRV dtls=1 auth_mode=required" \
2829 "$P_CLI dtls=1" \
2830 0 \
2831 -s "Verifying peer X.509 certificate... ok"
2832
2833run_test "DTLS client auth: optional, client has no cert" \
2834 "$P_SRV dtls=1 auth_mode=optional" \
2835 "$P_CLI dtls=1 crt_file=none key_file=none" \
2836 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002837 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002838
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002839run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002840 "$P_SRV dtls=1 auth_mode=none" \
2841 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
2842 0 \
2843 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002844 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002845
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02002846# Tests for receiving fragmented handshake messages with DTLS
2847
2848requires_gnutls
2849run_test "DTLS reassembly: no fragmentation (gnutls server)" \
2850 "$G_SRV -u --mtu 2048 -a" \
2851 "$P_CLI dtls=1 debug_level=2" \
2852 0 \
2853 -C "found fragmented DTLS handshake message" \
2854 -C "error"
2855
2856requires_gnutls
2857run_test "DTLS reassembly: some fragmentation (gnutls server)" \
2858 "$G_SRV -u --mtu 512" \
2859 "$P_CLI dtls=1 debug_level=2" \
2860 0 \
2861 -c "found fragmented DTLS handshake message" \
2862 -C "error"
2863
2864requires_gnutls
2865run_test "DTLS reassembly: more fragmentation (gnutls server)" \
2866 "$G_SRV -u --mtu 128" \
2867 "$P_CLI dtls=1 debug_level=2" \
2868 0 \
2869 -c "found fragmented DTLS handshake message" \
2870 -C "error"
2871
2872requires_gnutls
2873run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
2874 "$G_SRV -u --mtu 128" \
2875 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2876 0 \
2877 -c "found fragmented DTLS handshake message" \
2878 -C "error"
2879
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002880requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002881run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
2882 "$G_SRV -u --mtu 256" \
2883 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
2884 0 \
2885 -c "found fragmented DTLS handshake message" \
2886 -c "client hello, adding renegotiation extension" \
2887 -c "found renegotiation extension" \
2888 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002889 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002890 -C "error" \
2891 -s "Extra-header:"
2892
2893requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002894run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
2895 "$G_SRV -u --mtu 256" \
2896 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
2897 0 \
2898 -c "found fragmented DTLS handshake message" \
2899 -c "client hello, adding renegotiation extension" \
2900 -c "found renegotiation extension" \
2901 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002902 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002903 -C "error" \
2904 -s "Extra-header:"
2905
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002906run_test "DTLS reassembly: no fragmentation (openssl server)" \
2907 "$O_SRV -dtls1 -mtu 2048" \
2908 "$P_CLI dtls=1 debug_level=2" \
2909 0 \
2910 -C "found fragmented DTLS handshake message" \
2911 -C "error"
2912
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002913run_test "DTLS reassembly: some fragmentation (openssl server)" \
2914 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002915 "$P_CLI dtls=1 debug_level=2" \
2916 0 \
2917 -c "found fragmented DTLS handshake message" \
2918 -C "error"
2919
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002920run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002921 "$O_SRV -dtls1 -mtu 256" \
2922 "$P_CLI dtls=1 debug_level=2" \
2923 0 \
2924 -c "found fragmented DTLS handshake message" \
2925 -C "error"
2926
2927run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2928 "$O_SRV -dtls1 -mtu 256" \
2929 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2930 0 \
2931 -c "found fragmented DTLS handshake message" \
2932 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002933
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002934# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002935
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002936not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002937run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002938 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002939 "$P_SRV dtls=1 debug_level=2" \
2940 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002941 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002942 -C "replayed record" \
2943 -S "replayed record" \
2944 -C "record from another epoch" \
2945 -S "record from another epoch" \
2946 -C "discarding invalid record" \
2947 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002948 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002949 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002950 -c "HTTP/1.0 200 OK"
2951
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002952not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002953run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002954 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002955 "$P_SRV dtls=1 debug_level=2" \
2956 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002957 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002958 -c "replayed record" \
2959 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002960 -c "discarding invalid record" \
2961 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002962 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002963 -s "Extra-header:" \
2964 -c "HTTP/1.0 200 OK"
2965
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002966run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
2967 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002968 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
2969 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002970 0 \
2971 -c "replayed record" \
2972 -S "replayed record" \
2973 -c "discarding invalid record" \
2974 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002975 -c "resend" \
2976 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002977 -s "Extra-header:" \
2978 -c "HTTP/1.0 200 OK"
2979
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002980run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002981 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002982 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002983 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002984 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002985 -c "discarding invalid record (mac)" \
2986 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002987 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002988 -c "HTTP/1.0 200 OK" \
2989 -S "too many records with bad MAC" \
2990 -S "Verification of the message MAC failed"
2991
2992run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
2993 -p "$P_PXY bad_ad=1" \
2994 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
2995 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2996 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002997 -C "discarding invalid record (mac)" \
2998 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002999 -S "Extra-header:" \
3000 -C "HTTP/1.0 200 OK" \
3001 -s "too many records with bad MAC" \
3002 -s "Verification of the message MAC failed"
3003
3004run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3005 -p "$P_PXY bad_ad=1" \
3006 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3007 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3008 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003009 -c "discarding invalid record (mac)" \
3010 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003011 -s "Extra-header:" \
3012 -c "HTTP/1.0 200 OK" \
3013 -S "too many records with bad MAC" \
3014 -S "Verification of the message MAC failed"
3015
3016run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3017 -p "$P_PXY bad_ad=1" \
3018 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3019 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3020 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003021 -c "discarding invalid record (mac)" \
3022 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003023 -s "Extra-header:" \
3024 -c "HTTP/1.0 200 OK" \
3025 -s "too many records with bad MAC" \
3026 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003027
3028run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003029 -p "$P_PXY delay_ccs=1" \
3030 "$P_SRV dtls=1 debug_level=1" \
3031 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003032 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003033 -c "record from another epoch" \
3034 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003035 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003036 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003037 -s "Extra-header:" \
3038 -c "HTTP/1.0 200 OK"
3039
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003040# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003041
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003042needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003043run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003044 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003045 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3046 psk=abc123" \
3047 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003048 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3049 0 \
3050 -s "Extra-header:" \
3051 -c "HTTP/1.0 200 OK"
3052
3053needs_more_time 2
3054run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3055 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003056 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3057 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003058 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3059 0 \
3060 -s "Extra-header:" \
3061 -c "HTTP/1.0 200 OK"
3062
3063needs_more_time 2
3064run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3065 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003066 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3067 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003068 0 \
3069 -s "Extra-header:" \
3070 -c "HTTP/1.0 200 OK"
3071
3072needs_more_time 2
3073run_test "DTLS proxy: 3d, FS, client auth" \
3074 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003075 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3076 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003077 0 \
3078 -s "Extra-header:" \
3079 -c "HTTP/1.0 200 OK"
3080
3081needs_more_time 2
3082run_test "DTLS proxy: 3d, FS, ticket" \
3083 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003084 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3085 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003086 0 \
3087 -s "Extra-header:" \
3088 -c "HTTP/1.0 200 OK"
3089
3090needs_more_time 2
3091run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3092 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003093 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3094 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003095 0 \
3096 -s "Extra-header:" \
3097 -c "HTTP/1.0 200 OK"
3098
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003099needs_more_time 2
3100run_test "DTLS proxy: 3d, max handshake, nbio" \
3101 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003102 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3103 auth_mode=required" \
3104 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003105 0 \
3106 -s "Extra-header:" \
3107 -c "HTTP/1.0 200 OK"
3108
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003109needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003110run_test "DTLS proxy: 3d, min handshake, resumption" \
3111 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3112 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3113 psk=abc123 debug_level=3" \
3114 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3115 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3116 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3117 0 \
3118 -s "a session has been resumed" \
3119 -c "a session has been resumed" \
3120 -s "Extra-header:" \
3121 -c "HTTP/1.0 200 OK"
3122
3123needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003124run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3125 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3126 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3127 psk=abc123 debug_level=3 nbio=2" \
3128 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3129 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3130 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3131 0 \
3132 -s "a session has been resumed" \
3133 -c "a session has been resumed" \
3134 -s "Extra-header:" \
3135 -c "HTTP/1.0 200 OK"
3136
3137needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003138run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003139 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003140 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3141 psk=abc123 renegotiation=1 debug_level=2" \
3142 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3143 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003144 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3145 0 \
3146 -c "=> renegotiate" \
3147 -s "=> renegotiate" \
3148 -s "Extra-header:" \
3149 -c "HTTP/1.0 200 OK"
3150
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003151needs_more_time 4
3152run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3153 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003154 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3155 psk=abc123 renegotiation=1 debug_level=2" \
3156 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3157 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003158 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3159 0 \
3160 -c "=> renegotiate" \
3161 -s "=> renegotiate" \
3162 -s "Extra-header:" \
3163 -c "HTTP/1.0 200 OK"
3164
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003165needs_more_time 4
3166run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003167 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003168 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003169 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003170 debug_level=2" \
3171 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003172 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003173 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3174 0 \
3175 -c "=> renegotiate" \
3176 -s "=> renegotiate" \
3177 -s "Extra-header:" \
3178 -c "HTTP/1.0 200 OK"
3179
3180needs_more_time 4
3181run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003182 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003183 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003184 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003185 debug_level=2 nbio=2" \
3186 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003187 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003188 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3189 0 \
3190 -c "=> renegotiate" \
3191 -s "=> renegotiate" \
3192 -s "Extra-header:" \
3193 -c "HTTP/1.0 200 OK"
3194
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003195needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003196run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003197 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3198 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003199 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003200 0 \
3201 -s "Extra-header:" \
3202 -c "HTTP/1.0 200 OK"
3203
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003204needs_more_time 8
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003205run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3206 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3207 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003208 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003209 0 \
3210 -s "Extra-header:" \
3211 -c "HTTP/1.0 200 OK"
3212
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003213needs_more_time 8
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003214run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3215 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3216 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003217 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003218 0 \
3219 -s "Extra-header:" \
3220 -c "HTTP/1.0 200 OK"
3221
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003222requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003223needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003224run_test "DTLS proxy: 3d, gnutls server" \
3225 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3226 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003227 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003228 0 \
3229 -s "Extra-header:" \
3230 -c "Extra-header:"
3231
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003232requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003233needs_more_time 8
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003234run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3235 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3236 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003237 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003238 0 \
3239 -s "Extra-header:" \
3240 -c "Extra-header:"
3241
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003242requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003243needs_more_time 8
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003244run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3245 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3246 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003247 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003248 0 \
3249 -s "Extra-header:" \
3250 -c "Extra-header:"
3251
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003252# Final report
3253
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003254echo "------------------------------------------------------------------------"
3255
3256if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003257 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003258else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003259 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003260fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003261PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003262echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003263
3264exit $FAILS