blob: 13068281f0330a876499846bb60272fc6b61819f [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é-Gonnard74681fa2015-08-04 20:34:39 +0200218 START_TIME=$( date +%s )
219 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200220
221 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200222 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200223 while [ $DONE -eq 0 ]; do
224 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
225 then
226 DONE=1
227 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
228 echo "SERVERSTART TIMEOUT"
229 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
230 DONE=1
231 fi
232 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200233 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200234 while [ $DONE -eq 0 ]; do
235 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
236 then
237 DONE=1
238 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
239 echo "SERVERSTART TIMEOUT"
240 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
241 DONE=1
242 fi
243 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200244 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200245 else
246 sleep "$START_DELAY"
247 fi
248}
249
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200250# wait for client to terminate and set CLI_EXIT
251# must be called right after starting the client
252wait_client_done() {
253 CLI_PID=$!
254
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200255 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
256 CLI_DELAY_FACTOR=1
257
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200258 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200259 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200260
261 wait $CLI_PID
262 CLI_EXIT=$?
263
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200264 kill $DOG_PID >/dev/null 2>&1
265 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200266
267 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
268}
269
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200270# check if the given command uses dtls and sets global variable DTLS
271detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200272 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200273 DTLS=1
274 else
275 DTLS=0
276 fi
277}
278
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200279# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100280# Options: -s pattern pattern that must be present in server output
281# -c pattern pattern that must be present in client output
282# -S pattern pattern that must be absent in server output
283# -C pattern pattern that must be absent in client output
284run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100285 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200286 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100287
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100288 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
289 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200290 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100291 return
292 fi
293
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100294 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100295
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200296 # should we skip?
297 if [ "X$SKIP_NEXT" = "XYES" ]; then
298 SKIP_NEXT="NO"
299 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200300 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200301 return
302 fi
303
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200304 # does this test use a proxy?
305 if [ "X$1" = "X-p" ]; then
306 PXY_CMD="$2"
307 shift 2
308 else
309 PXY_CMD=""
310 fi
311
312 # get commands and client output
313 SRV_CMD="$1"
314 CLI_CMD="$2"
315 CLI_EXPECT="$3"
316 shift 3
317
318 # fix client port
319 if [ -n "$PXY_CMD" ]; then
320 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
321 else
322 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
323 fi
324
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200325 # update DTLS variable
326 detect_dtls "$SRV_CMD"
327
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100328 # prepend valgrind to our commands if active
329 if [ "$MEMCHECK" -gt 0 ]; then
330 if is_polar "$SRV_CMD"; then
331 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
332 fi
333 if is_polar "$CLI_CMD"; then
334 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
335 fi
336 fi
337
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200338 TIMES_LEFT=2
339 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200340 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200341
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200342 # run the commands
343 if [ -n "$PXY_CMD" ]; then
344 echo "$PXY_CMD" > $PXY_OUT
345 $PXY_CMD >> $PXY_OUT 2>&1 &
346 PXY_PID=$!
347 # assume proxy starts faster than server
348 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200349
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200350 check_osrv_dtls
351 echo "$SRV_CMD" > $SRV_OUT
352 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
353 SRV_PID=$!
354 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200355
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200356 echo "$CLI_CMD" > $CLI_OUT
357 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
358 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100359
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200360 # terminate the server (and the proxy)
361 kill $SRV_PID
362 wait $SRV_PID
363 if [ -n "$PXY_CMD" ]; then
364 kill $PXY_PID >/dev/null 2>&1
365 wait $PXY_PID
366 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100367
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200368 # retry only on timeouts
369 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
370 printf "RETRY "
371 else
372 TIMES_LEFT=0
373 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200374 done
375
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100376 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200377 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100378 # expected client exit to incorrectly succeed in case of catastrophic
379 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100380 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200381 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100382 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100383 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100384 return
385 fi
386 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100387 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200388 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100389 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100390 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100391 return
392 fi
393 fi
394
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100395 # check server exit code
396 if [ $? != 0 ]; then
397 fail "server fail"
398 return
399 fi
400
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100401 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100402 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
403 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100404 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200405 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100406 return
407 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100408
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100409 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200410 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100411 while [ $# -gt 0 ]
412 do
413 case $1 in
414 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200415 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100416 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100417 return
418 fi
419 ;;
420
421 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200422 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100423 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100424 return
425 fi
426 ;;
427
428 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200429 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100430 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100431 return
432 fi
433 ;;
434
435 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200436 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100437 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100438 return
439 fi
440 ;;
441
442 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200443 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100444 exit 1
445 esac
446 shift 2
447 done
448
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100449 # check valgrind's results
450 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200451 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100452 fail "Server has memory errors"
453 return
454 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200455 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100456 fail "Client has memory errors"
457 return
458 fi
459 fi
460
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100461 # if we're here, everything is ok
462 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200463 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100464}
465
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100466cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200467 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200468 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
469 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
470 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
471 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100472 exit 1
473}
474
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100475#
476# MAIN
477#
478
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000479if cd $( dirname $0 ); then :; else
480 echo "cd $( dirname $0 ) failed" >&2
481 exit 1
482fi
483
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100484get_options "$@"
485
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100486# sanity checks, avoid an avalanche of errors
487if [ ! -x "$P_SRV" ]; then
488 echo "Command '$P_SRV' is not an executable file"
489 exit 1
490fi
491if [ ! -x "$P_CLI" ]; then
492 echo "Command '$P_CLI' is not an executable file"
493 exit 1
494fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200495if [ ! -x "$P_PXY" ]; then
496 echo "Command '$P_PXY' is not an executable file"
497 exit 1
498fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100499if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
500 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100501 exit 1
502fi
503
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200504# used by watchdog
505MAIN_PID="$$"
506
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200507# be more patient with valgrind
508if [ "$MEMCHECK" -gt 0 ]; then
509 START_DELAY=3
510 DOG_DELAY=30
511else
512 START_DELAY=1
513 DOG_DELAY=10
514fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200515CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200516
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200517# Pick a "unique" server port in the range 10000-19999, and a proxy port
518PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000519PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200520SRV_PORT="1$PORT_BASE"
521PXY_PORT="2$PORT_BASE"
522unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200523
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200524# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000525# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200526P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
527P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
528P_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 +0200529O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200530O_CLI="$O_CLI -connect localhost:+SRV_PORT"
531G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000532G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200533
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200534# Also pick a unique name for intermediate files
535SRV_OUT="srv_out.$$"
536CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200537PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200538SESSION="session.$$"
539
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200540SKIP_NEXT="NO"
541
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100542trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100543
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200544# Basic test
545
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200546# Checks that:
547# - things work with all ciphersuites active (used with config-full in all.sh)
548# - the expected (highest security) parameters are selected
549# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200550run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200551 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200552 "$P_CLI" \
553 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200554 -s "Protocol is TLSv1.2" \
555 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
556 -s "client hello v3, signature_algorithm ext: 6" \
557 -s "ECDHE curve: secp521r1" \
558 -S "error" \
559 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200560
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000561run_test "Default, DTLS" \
562 "$P_SRV dtls=1" \
563 "$P_CLI dtls=1" \
564 0 \
565 -s "Protocol is DTLSv1.2" \
566 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
567
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100568# Tests for rc4 option
569
570run_test "RC4: server disabled, client enabled" \
571 "$P_SRV" \
572 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
573 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100574 -s "SSL - The server has no ciphersuites in common"
575
576run_test "RC4: server half, client enabled" \
577 "$P_SRV arc4=1" \
578 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
579 1 \
580 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100581
582run_test "RC4: server enabled, client disabled" \
583 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
584 "$P_CLI" \
585 1 \
586 -s "SSL - The server has no ciphersuites in common"
587
588run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100589 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100590 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
591 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100592 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100593 -S "SSL - The server has no ciphersuites in common"
594
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100595# Tests for Truncated HMAC extension
596
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100597run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200598 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100599 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100600 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100601 -s "dumping 'computed mac' (20 bytes)" \
602 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100603
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100604run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200605 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100606 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
607 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100608 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100609 -s "dumping 'computed mac' (20 bytes)" \
610 -S "dumping 'computed mac' (10 bytes)"
611
612run_test "Truncated HMAC: client enabled, server default" \
613 "$P_SRV debug_level=4" \
614 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
615 trunc_hmac=1" \
616 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100617 -s "dumping 'computed mac' (20 bytes)" \
618 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100619
620run_test "Truncated HMAC: client enabled, server disabled" \
621 "$P_SRV debug_level=4 trunc_hmac=0" \
622 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
623 trunc_hmac=1" \
624 0 \
625 -s "dumping 'computed mac' (20 bytes)" \
626 -S "dumping 'computed mac' (10 bytes)"
627
628run_test "Truncated HMAC: client enabled, server enabled" \
629 "$P_SRV debug_level=4 trunc_hmac=1" \
630 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
631 trunc_hmac=1" \
632 0 \
633 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100634 -s "dumping 'computed mac' (10 bytes)"
635
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100636# Tests for Encrypt-then-MAC extension
637
638run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100639 "$P_SRV debug_level=3 \
640 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100641 "$P_CLI debug_level=3" \
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, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100651 "$P_SRV debug_level=3 etm=0 \
652 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100653 "$P_CLI debug_level=3 etm=1" \
654 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é-Gonnard78e745f2014-11-04 15:44:06 +0100662run_test "Encrypt then MAC: client enabled, aead cipher" \
663 "$P_SRV debug_level=3 etm=1 \
664 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
665 "$P_CLI debug_level=3 etm=1" \
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 enabled, stream cipher" \
675 "$P_SRV debug_level=3 etm=1 \
676 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100677 "$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 +0100678 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
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100686run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100687 "$P_SRV debug_level=3 etm=1 \
688 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100689 "$P_CLI debug_level=3 etm=0" \
690 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
698run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100699 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100700 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100701 "$P_CLI debug_level=3 force_version=ssl3" \
702 0 \
703 -C "client hello, adding encrypt_then_mac extension" \
704 -S "found encrypt then mac extension" \
705 -S "server hello, adding encrypt then mac extension" \
706 -C "found encrypt_then_mac extension" \
707 -C "using encrypt then mac" \
708 -S "using encrypt then mac"
709
710run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100711 "$P_SRV debug_level=3 force_version=ssl3 \
712 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100713 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100714 0 \
715 -c "client hello, adding encrypt_then_mac extension" \
716 -s "found encrypt then mac extension" \
717 -S "server hello, adding encrypt then mac extension" \
718 -C "found encrypt_then_mac extension" \
719 -C "using encrypt then mac" \
720 -S "using encrypt then mac"
721
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200722# Tests for Extended Master Secret extension
723
724run_test "Extended Master Secret: default" \
725 "$P_SRV debug_level=3" \
726 "$P_CLI debug_level=3" \
727 0 \
728 -c "client hello, adding extended_master_secret extension" \
729 -s "found extended master secret extension" \
730 -s "server hello, adding extended master secret extension" \
731 -c "found extended_master_secret extension" \
732 -c "using extended master secret" \
733 -s "using extended master secret"
734
735run_test "Extended Master Secret: client enabled, server disabled" \
736 "$P_SRV debug_level=3 extended_ms=0" \
737 "$P_CLI debug_level=3 extended_ms=1" \
738 0 \
739 -c "client hello, adding extended_master_secret extension" \
740 -s "found extended master secret extension" \
741 -S "server hello, adding extended master secret extension" \
742 -C "found extended_master_secret extension" \
743 -C "using extended master secret" \
744 -S "using extended master secret"
745
746run_test "Extended Master Secret: client disabled, server enabled" \
747 "$P_SRV debug_level=3 extended_ms=1" \
748 "$P_CLI debug_level=3 extended_ms=0" \
749 0 \
750 -C "client hello, adding extended_master_secret extension" \
751 -S "found extended master secret extension" \
752 -S "server hello, adding extended master secret extension" \
753 -C "found extended_master_secret extension" \
754 -C "using extended master secret" \
755 -S "using extended master secret"
756
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200757run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100758 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200759 "$P_CLI debug_level=3 force_version=ssl3" \
760 0 \
761 -C "client hello, adding extended_master_secret extension" \
762 -S "found extended master secret extension" \
763 -S "server hello, adding extended master secret extension" \
764 -C "found extended_master_secret extension" \
765 -C "using extended master secret" \
766 -S "using extended master secret"
767
768run_test "Extended Master Secret: client enabled, server SSLv3" \
769 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100770 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200771 0 \
772 -c "client hello, adding extended_master_secret extension" \
773 -s "found extended master secret extension" \
774 -S "server hello, adding extended master secret extension" \
775 -C "found extended_master_secret extension" \
776 -C "using extended master secret" \
777 -S "using extended master secret"
778
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200779# Tests for FALLBACK_SCSV
780
781run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200782 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200783 "$P_CLI debug_level=3 force_version=tls1_1" \
784 0 \
785 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200786 -S "received FALLBACK_SCSV" \
787 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200788 -C "is a fatal alert message (msg 86)"
789
790run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200791 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200792 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
793 0 \
794 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200795 -S "received FALLBACK_SCSV" \
796 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200797 -C "is a fatal alert message (msg 86)"
798
799run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200800 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200801 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200802 1 \
803 -c "adding FALLBACK_SCSV" \
804 -s "received FALLBACK_SCSV" \
805 -s "inapropriate fallback" \
806 -c "is a fatal alert message (msg 86)"
807
808run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200809 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200810 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200811 0 \
812 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200813 -s "received FALLBACK_SCSV" \
814 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200815 -C "is a fatal alert message (msg 86)"
816
817requires_openssl_with_fallback_scsv
818run_test "Fallback SCSV: default, openssl server" \
819 "$O_SRV" \
820 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
821 0 \
822 -C "adding FALLBACK_SCSV" \
823 -C "is a fatal alert message (msg 86)"
824
825requires_openssl_with_fallback_scsv
826run_test "Fallback SCSV: enabled, openssl server" \
827 "$O_SRV" \
828 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
829 1 \
830 -c "adding FALLBACK_SCSV" \
831 -c "is a fatal alert message (msg 86)"
832
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200833requires_openssl_with_fallback_scsv
834run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200835 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200836 "$O_CLI -tls1_1" \
837 0 \
838 -S "received FALLBACK_SCSV" \
839 -S "inapropriate fallback"
840
841requires_openssl_with_fallback_scsv
842run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200843 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200844 "$O_CLI -tls1_1 -fallback_scsv" \
845 1 \
846 -s "received FALLBACK_SCSV" \
847 -s "inapropriate fallback"
848
849requires_openssl_with_fallback_scsv
850run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200851 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200852 "$O_CLI -fallback_scsv" \
853 0 \
854 -s "received FALLBACK_SCSV" \
855 -S "inapropriate fallback"
856
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100857# Tests for CBC 1/n-1 record splitting
858
859run_test "CBC Record splitting: TLS 1.2, no splitting" \
860 "$P_SRV" \
861 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
862 request_size=123 force_version=tls1_2" \
863 0 \
864 -s "Read from client: 123 bytes read" \
865 -S "Read from client: 1 bytes read" \
866 -S "122 bytes read"
867
868run_test "CBC Record splitting: TLS 1.1, no splitting" \
869 "$P_SRV" \
870 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
871 request_size=123 force_version=tls1_1" \
872 0 \
873 -s "Read from client: 123 bytes read" \
874 -S "Read from client: 1 bytes read" \
875 -S "122 bytes read"
876
877run_test "CBC Record splitting: TLS 1.0, splitting" \
878 "$P_SRV" \
879 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
880 request_size=123 force_version=tls1" \
881 0 \
882 -S "Read from client: 123 bytes read" \
883 -s "Read from client: 1 bytes read" \
884 -s "122 bytes read"
885
886run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100887 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100888 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
889 request_size=123 force_version=ssl3" \
890 0 \
891 -S "Read from client: 123 bytes read" \
892 -s "Read from client: 1 bytes read" \
893 -s "122 bytes read"
894
895run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100896 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100897 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
898 request_size=123 force_version=tls1" \
899 0 \
900 -s "Read from client: 123 bytes read" \
901 -S "Read from client: 1 bytes read" \
902 -S "122 bytes read"
903
904run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
905 "$P_SRV" \
906 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
907 request_size=123 force_version=tls1 recsplit=0" \
908 0 \
909 -s "Read from client: 123 bytes read" \
910 -S "Read from client: 1 bytes read" \
911 -S "122 bytes read"
912
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100913run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
914 "$P_SRV nbio=2" \
915 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
916 request_size=123 force_version=tls1" \
917 0 \
918 -S "Read from client: 123 bytes read" \
919 -s "Read from client: 1 bytes read" \
920 -s "122 bytes read"
921
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100922# Tests for Session Tickets
923
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200924run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200925 "$P_SRV debug_level=3 tickets=1" \
926 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100927 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100928 -c "client hello, adding session ticket extension" \
929 -s "found session ticket extension" \
930 -s "server hello, adding session ticket extension" \
931 -c "found session_ticket extension" \
932 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100933 -S "session successfully restored from cache" \
934 -s "session successfully restored from ticket" \
935 -s "a session has been resumed" \
936 -c "a session has been resumed"
937
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200938run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200939 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
940 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100941 0 \
942 -c "client hello, adding session ticket extension" \
943 -s "found session ticket extension" \
944 -s "server hello, adding session ticket extension" \
945 -c "found session_ticket extension" \
946 -c "parse new session ticket" \
947 -S "session successfully restored from cache" \
948 -s "session successfully restored from ticket" \
949 -s "a session has been resumed" \
950 -c "a session has been resumed"
951
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200952run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200953 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
954 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100955 0 \
956 -c "client hello, adding session ticket extension" \
957 -s "found session ticket extension" \
958 -s "server hello, adding session ticket extension" \
959 -c "found session_ticket extension" \
960 -c "parse new session ticket" \
961 -S "session successfully restored from cache" \
962 -S "session successfully restored from ticket" \
963 -S "a session has been resumed" \
964 -C "a session has been resumed"
965
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200966run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100967 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200968 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100969 0 \
970 -c "client hello, adding session ticket extension" \
971 -c "found session_ticket extension" \
972 -c "parse new session ticket" \
973 -c "a session has been resumed"
974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200975run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200976 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200977 "( $O_CLI -sess_out $SESSION; \
978 $O_CLI -sess_in $SESSION; \
979 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100980 0 \
981 -s "found session ticket extension" \
982 -s "server hello, adding session ticket extension" \
983 -S "session successfully restored from cache" \
984 -s "session successfully restored from ticket" \
985 -s "a session has been resumed"
986
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100987# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100988
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200989run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200990 "$P_SRV debug_level=3 tickets=0" \
991 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100992 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100993 -c "client hello, adding session ticket extension" \
994 -s "found session ticket extension" \
995 -S "server hello, adding session ticket extension" \
996 -C "found session_ticket extension" \
997 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100998 -s "session successfully restored from cache" \
999 -S "session successfully restored from ticket" \
1000 -s "a session has been resumed" \
1001 -c "a session has been resumed"
1002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001003run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001004 "$P_SRV debug_level=3 tickets=1" \
1005 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001006 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001007 -C "client hello, adding session ticket extension" \
1008 -S "found session ticket extension" \
1009 -S "server hello, adding session ticket extension" \
1010 -C "found session_ticket extension" \
1011 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001012 -s "session successfully restored from cache" \
1013 -S "session successfully restored from ticket" \
1014 -s "a session has been resumed" \
1015 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001017run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001018 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1019 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001020 0 \
1021 -S "session successfully restored from cache" \
1022 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001023 -S "a session has been resumed" \
1024 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001026run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001027 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1028 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001029 0 \
1030 -s "session successfully restored from cache" \
1031 -S "session successfully restored from ticket" \
1032 -s "a session has been resumed" \
1033 -c "a session has been resumed"
1034
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001035run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001036 "$P_SRV debug_level=3 tickets=0" \
1037 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001038 0 \
1039 -s "session successfully restored from cache" \
1040 -S "session successfully restored from ticket" \
1041 -s "a session has been resumed" \
1042 -c "a session has been resumed"
1043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001044run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001045 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1046 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001047 0 \
1048 -S "session successfully restored from cache" \
1049 -S "session successfully restored from ticket" \
1050 -S "a session has been resumed" \
1051 -C "a session has been resumed"
1052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001053run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001054 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1055 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001056 0 \
1057 -s "session successfully restored from cache" \
1058 -S "session successfully restored from ticket" \
1059 -s "a session has been resumed" \
1060 -c "a session has been resumed"
1061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001062run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001063 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001064 "( $O_CLI -sess_out $SESSION; \
1065 $O_CLI -sess_in $SESSION; \
1066 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001067 0 \
1068 -s "found session ticket extension" \
1069 -S "server hello, adding session ticket extension" \
1070 -s "session successfully restored from cache" \
1071 -S "session successfully restored from ticket" \
1072 -s "a session has been resumed"
1073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001074run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001075 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001076 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001077 0 \
1078 -C "found session_ticket extension" \
1079 -C "parse new session ticket" \
1080 -c "a session has been resumed"
1081
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001082# Tests for Max Fragment Length extension
1083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001084run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001085 "$P_SRV debug_level=3" \
1086 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001087 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001088 -c "Maximum fragment length is 16384" \
1089 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001090 -C "client hello, adding max_fragment_length extension" \
1091 -S "found max fragment length extension" \
1092 -S "server hello, max_fragment_length extension" \
1093 -C "found max_fragment_length extension"
1094
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001095run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001096 "$P_SRV debug_level=3" \
1097 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001098 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001099 -c "Maximum fragment length is 4096" \
1100 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001101 -c "client hello, adding max_fragment_length extension" \
1102 -s "found max fragment length extension" \
1103 -s "server hello, max_fragment_length extension" \
1104 -c "found max_fragment_length extension"
1105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001106run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001107 "$P_SRV debug_level=3 max_frag_len=4096" \
1108 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001109 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001110 -c "Maximum fragment length is 16384" \
1111 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001112 -C "client hello, adding max_fragment_length extension" \
1113 -S "found max fragment length extension" \
1114 -S "server hello, max_fragment_length extension" \
1115 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001116
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001117requires_gnutls
1118run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001119 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001120 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001121 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001122 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001123 -c "client hello, adding max_fragment_length extension" \
1124 -c "found max_fragment_length extension"
1125
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001126run_test "Max fragment length: client, message just fits" \
1127 "$P_SRV debug_level=3" \
1128 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1129 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001130 -c "Maximum fragment length is 2048" \
1131 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001132 -c "client hello, adding max_fragment_length extension" \
1133 -s "found max fragment length extension" \
1134 -s "server hello, max_fragment_length extension" \
1135 -c "found max_fragment_length extension" \
1136 -c "2048 bytes written in 1 fragments" \
1137 -s "2048 bytes read"
1138
1139run_test "Max fragment length: client, larger message" \
1140 "$P_SRV debug_level=3" \
1141 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1142 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001143 -c "Maximum fragment length is 2048" \
1144 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001145 -c "client hello, adding max_fragment_length extension" \
1146 -s "found max fragment length extension" \
1147 -s "server hello, max_fragment_length extension" \
1148 -c "found max_fragment_length extension" \
1149 -c "2345 bytes written in 2 fragments" \
1150 -s "2048 bytes read" \
1151 -s "297 bytes read"
1152
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001153run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001154 "$P_SRV debug_level=3 dtls=1" \
1155 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1156 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001157 -c "Maximum fragment length is 2048" \
1158 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001159 -c "client hello, adding max_fragment_length extension" \
1160 -s "found max fragment length extension" \
1161 -s "server hello, max_fragment_length extension" \
1162 -c "found max_fragment_length extension" \
1163 -c "fragment larger than.*maximum"
1164
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001165# Tests for renegotiation
1166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001167run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001168 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001169 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001170 0 \
1171 -C "client hello, adding renegotiation extension" \
1172 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1173 -S "found renegotiation extension" \
1174 -s "server hello, secure renegotiation extension" \
1175 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001176 -C "=> renegotiate" \
1177 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001178 -S "write hello request"
1179
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001180run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001181 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001182 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001183 0 \
1184 -c "client hello, adding renegotiation extension" \
1185 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1186 -s "found renegotiation extension" \
1187 -s "server hello, secure renegotiation extension" \
1188 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001189 -c "=> renegotiate" \
1190 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001191 -S "write hello request"
1192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001193run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001194 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001195 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001196 0 \
1197 -c "client hello, adding renegotiation extension" \
1198 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1199 -s "found renegotiation extension" \
1200 -s "server hello, secure renegotiation extension" \
1201 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001202 -c "=> renegotiate" \
1203 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001204 -s "write hello request"
1205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001206run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001207 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001208 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001209 0 \
1210 -c "client hello, adding renegotiation extension" \
1211 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1212 -s "found renegotiation extension" \
1213 -s "server hello, secure renegotiation extension" \
1214 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001215 -c "=> renegotiate" \
1216 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001217 -s "write hello request"
1218
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001219run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001220 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001221 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001222 1 \
1223 -c "client hello, adding renegotiation extension" \
1224 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1225 -S "found renegotiation extension" \
1226 -s "server hello, secure renegotiation extension" \
1227 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001228 -c "=> renegotiate" \
1229 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001230 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001231 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001232 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001234run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001235 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001236 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001237 0 \
1238 -C "client hello, adding renegotiation extension" \
1239 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1240 -S "found renegotiation extension" \
1241 -s "server hello, secure renegotiation extension" \
1242 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001243 -C "=> renegotiate" \
1244 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001245 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001246 -S "SSL - An unexpected message was received from our peer" \
1247 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001248
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001249run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001250 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001251 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001252 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001253 0 \
1254 -C "client hello, adding renegotiation extension" \
1255 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1256 -S "found renegotiation extension" \
1257 -s "server hello, secure renegotiation extension" \
1258 -c "found renegotiation extension" \
1259 -C "=> renegotiate" \
1260 -S "=> renegotiate" \
1261 -s "write hello request" \
1262 -S "SSL - An unexpected message was received from our peer" \
1263 -S "failed"
1264
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001265# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001266run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001267 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001268 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001269 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001270 0 \
1271 -C "client hello, adding renegotiation extension" \
1272 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1273 -S "found renegotiation extension" \
1274 -s "server hello, secure renegotiation extension" \
1275 -c "found renegotiation extension" \
1276 -C "=> renegotiate" \
1277 -S "=> renegotiate" \
1278 -s "write hello request" \
1279 -S "SSL - An unexpected message was received from our peer" \
1280 -S "failed"
1281
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001282run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001283 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001284 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001285 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001286 0 \
1287 -C "client hello, adding renegotiation extension" \
1288 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1289 -S "found renegotiation extension" \
1290 -s "server hello, secure renegotiation extension" \
1291 -c "found renegotiation extension" \
1292 -C "=> renegotiate" \
1293 -S "=> renegotiate" \
1294 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001295 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001297run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001298 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001299 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001300 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001301 0 \
1302 -c "client hello, adding renegotiation extension" \
1303 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1304 -s "found renegotiation extension" \
1305 -s "server hello, secure renegotiation extension" \
1306 -c "found renegotiation extension" \
1307 -c "=> renegotiate" \
1308 -s "=> renegotiate" \
1309 -s "write hello request" \
1310 -S "SSL - An unexpected message was received from our peer" \
1311 -S "failed"
1312
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001313run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001314 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001315 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1316 0 \
1317 -C "client hello, adding renegotiation extension" \
1318 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1319 -S "found renegotiation extension" \
1320 -s "server hello, secure renegotiation extension" \
1321 -c "found renegotiation extension" \
1322 -S "record counter limit reached: renegotiate" \
1323 -C "=> renegotiate" \
1324 -S "=> renegotiate" \
1325 -S "write hello request" \
1326 -S "SSL - An unexpected message was received from our peer" \
1327 -S "failed"
1328
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001329# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001330run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001331 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001332 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001333 0 \
1334 -c "client hello, adding renegotiation extension" \
1335 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1336 -s "found renegotiation extension" \
1337 -s "server hello, secure renegotiation extension" \
1338 -c "found renegotiation extension" \
1339 -s "record counter limit reached: renegotiate" \
1340 -c "=> renegotiate" \
1341 -s "=> renegotiate" \
1342 -s "write hello request" \
1343 -S "SSL - An unexpected message was received from our peer" \
1344 -S "failed"
1345
1346run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001347 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001348 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001349 0 \
1350 -c "client hello, adding renegotiation extension" \
1351 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1352 -s "found renegotiation extension" \
1353 -s "server hello, secure renegotiation extension" \
1354 -c "found renegotiation extension" \
1355 -s "record counter limit reached: renegotiate" \
1356 -c "=> renegotiate" \
1357 -s "=> renegotiate" \
1358 -s "write hello request" \
1359 -S "SSL - An unexpected message was received from our peer" \
1360 -S "failed"
1361
1362run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001363 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001364 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1365 0 \
1366 -C "client hello, adding renegotiation extension" \
1367 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1368 -S "found renegotiation extension" \
1369 -s "server hello, secure renegotiation extension" \
1370 -c "found renegotiation extension" \
1371 -S "record counter limit reached: renegotiate" \
1372 -C "=> renegotiate" \
1373 -S "=> renegotiate" \
1374 -S "write hello request" \
1375 -S "SSL - An unexpected message was received from our peer" \
1376 -S "failed"
1377
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001378run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001379 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001380 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001381 0 \
1382 -c "client hello, adding renegotiation extension" \
1383 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1384 -s "found renegotiation extension" \
1385 -s "server hello, secure renegotiation extension" \
1386 -c "found renegotiation extension" \
1387 -c "=> renegotiate" \
1388 -s "=> renegotiate" \
1389 -S "write hello request"
1390
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001391run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001392 "$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 +02001393 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001394 0 \
1395 -c "client hello, adding renegotiation extension" \
1396 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1397 -s "found renegotiation extension" \
1398 -s "server hello, secure renegotiation extension" \
1399 -c "found renegotiation extension" \
1400 -c "=> renegotiate" \
1401 -s "=> renegotiate" \
1402 -s "write hello request"
1403
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001404run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001405 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001406 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001407 0 \
1408 -c "client hello, adding renegotiation extension" \
1409 -c "found renegotiation extension" \
1410 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001411 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001412 -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 strict, client-initiated" \
1417 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001418 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001419 0 \
1420 -c "client hello, adding renegotiation extension" \
1421 -c "found renegotiation extension" \
1422 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001423 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001424 -C "error" \
1425 -c "HTTP/1.0 200 [Oo][Kk]"
1426
Paul Bakker539d9722015-02-08 16:18:35 +01001427requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001428run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1429 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1430 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1431 1 \
1432 -c "client hello, adding renegotiation extension" \
1433 -C "found renegotiation extension" \
1434 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001435 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001436 -c "error" \
1437 -C "HTTP/1.0 200 [Oo][Kk]"
1438
Paul Bakker539d9722015-02-08 16:18:35 +01001439requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001440run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1441 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1442 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1443 allow_legacy=0" \
1444 1 \
1445 -c "client hello, adding renegotiation extension" \
1446 -C "found renegotiation extension" \
1447 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001448 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001449 -c "error" \
1450 -C "HTTP/1.0 200 [Oo][Kk]"
1451
Paul Bakker539d9722015-02-08 16:18:35 +01001452requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001453run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1454 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1455 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1456 allow_legacy=1" \
1457 0 \
1458 -c "client hello, adding renegotiation extension" \
1459 -C "found renegotiation extension" \
1460 -c "=> renegotiate" \
1461 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001462 -C "error" \
1463 -c "HTTP/1.0 200 [Oo][Kk]"
1464
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001465run_test "Renegotiation: DTLS, client-initiated" \
1466 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1467 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1468 0 \
1469 -c "client hello, adding renegotiation extension" \
1470 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1471 -s "found renegotiation extension" \
1472 -s "server hello, secure renegotiation extension" \
1473 -c "found renegotiation extension" \
1474 -c "=> renegotiate" \
1475 -s "=> renegotiate" \
1476 -S "write hello request"
1477
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001478run_test "Renegotiation: DTLS, server-initiated" \
1479 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001480 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1481 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001482 0 \
1483 -c "client hello, adding renegotiation extension" \
1484 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1485 -s "found renegotiation extension" \
1486 -s "server hello, secure renegotiation extension" \
1487 -c "found renegotiation extension" \
1488 -c "=> renegotiate" \
1489 -s "=> renegotiate" \
1490 -s "write hello request"
1491
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001492requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001493run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1494 "$G_SRV -u --mtu 4096" \
1495 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1496 0 \
1497 -c "client hello, adding renegotiation extension" \
1498 -c "found renegotiation extension" \
1499 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001500 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001501 -C "error" \
1502 -s "Extra-header:"
1503
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001504# Test for the "secure renegotation" extension only (no actual renegotiation)
1505
Paul Bakker539d9722015-02-08 16:18:35 +01001506requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001507run_test "Renego ext: gnutls server strict, client default" \
1508 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1509 "$P_CLI debug_level=3" \
1510 0 \
1511 -c "found renegotiation extension" \
1512 -C "error" \
1513 -c "HTTP/1.0 200 [Oo][Kk]"
1514
Paul Bakker539d9722015-02-08 16:18:35 +01001515requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001516run_test "Renego ext: gnutls server unsafe, client default" \
1517 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1518 "$P_CLI debug_level=3" \
1519 0 \
1520 -C "found renegotiation extension" \
1521 -C "error" \
1522 -c "HTTP/1.0 200 [Oo][Kk]"
1523
Paul Bakker539d9722015-02-08 16:18:35 +01001524requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001525run_test "Renego ext: gnutls server unsafe, client break legacy" \
1526 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1527 "$P_CLI debug_level=3 allow_legacy=-1" \
1528 1 \
1529 -C "found renegotiation extension" \
1530 -c "error" \
1531 -C "HTTP/1.0 200 [Oo][Kk]"
1532
Paul Bakker539d9722015-02-08 16:18:35 +01001533requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001534run_test "Renego ext: gnutls client strict, server default" \
1535 "$P_SRV debug_level=3" \
1536 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1537 0 \
1538 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1539 -s "server hello, secure renegotiation extension"
1540
Paul Bakker539d9722015-02-08 16:18:35 +01001541requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001542run_test "Renego ext: gnutls client unsafe, server default" \
1543 "$P_SRV debug_level=3" \
1544 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1545 0 \
1546 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1547 -S "server hello, secure renegotiation extension"
1548
Paul Bakker539d9722015-02-08 16:18:35 +01001549requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001550run_test "Renego ext: gnutls client unsafe, server break legacy" \
1551 "$P_SRV debug_level=3 allow_legacy=-1" \
1552 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1553 1 \
1554 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1555 -S "server hello, secure renegotiation extension"
1556
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001557# Tests for auth_mode
1558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001559run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001560 "$P_SRV crt_file=data_files/server5-badsign.crt \
1561 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001562 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001563 1 \
1564 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001565 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001566 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001567 -c "X509 - Certificate verification failed"
1568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001569run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001570 "$P_SRV crt_file=data_files/server5-badsign.crt \
1571 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001572 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001573 0 \
1574 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001575 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001576 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001577 -C "X509 - Certificate verification failed"
1578
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001579run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001580 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001581 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001582 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001583 0 \
1584 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001585 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001586 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001587 -C "X509 - Certificate verification failed"
1588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001589run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001590 "$P_SRV debug_level=3 auth_mode=required" \
1591 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001592 key_file=data_files/server5.key" \
1593 1 \
1594 -S "skip write certificate request" \
1595 -C "skip parse certificate request" \
1596 -c "got a certificate request" \
1597 -C "skip write certificate" \
1598 -C "skip write certificate verify" \
1599 -S "skip parse certificate verify" \
1600 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001601 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001602 -s "! mbedtls_ssl_handshake returned" \
1603 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001604 -s "X509 - Certificate verification failed"
1605
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001606run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001607 "$P_SRV debug_level=3 auth_mode=optional" \
1608 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001609 key_file=data_files/server5.key" \
1610 0 \
1611 -S "skip write certificate request" \
1612 -C "skip parse certificate request" \
1613 -c "got a certificate request" \
1614 -C "skip write certificate" \
1615 -C "skip write certificate verify" \
1616 -S "skip parse certificate verify" \
1617 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001618 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001619 -S "! mbedtls_ssl_handshake returned" \
1620 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001621 -S "X509 - Certificate verification failed"
1622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001623run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001624 "$P_SRV debug_level=3 auth_mode=none" \
1625 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001626 key_file=data_files/server5.key" \
1627 0 \
1628 -s "skip write certificate request" \
1629 -C "skip parse certificate request" \
1630 -c "got no certificate request" \
1631 -c "skip write certificate" \
1632 -c "skip write certificate verify" \
1633 -s "skip parse certificate verify" \
1634 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001635 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001636 -S "! mbedtls_ssl_handshake returned" \
1637 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001638 -S "X509 - Certificate verification failed"
1639
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001640run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001641 "$P_SRV debug_level=3 auth_mode=optional" \
1642 "$P_CLI debug_level=3 crt_file=none key_file=none" \
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 "got no certificate to send" \
1649 -S "SSLv3 client has no certificate" \
1650 -c "skip write certificate verify" \
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é-Gonnard8e03c712014-08-30 21:42:40 +02001657run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001658 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001659 "$O_CLI" \
1660 0 \
1661 -S "skip write certificate request" \
1662 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001663 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001664 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001665 -S "X509 - Certificate verification failed"
1666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001667run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001668 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001669 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001670 0 \
1671 -C "skip parse certificate request" \
1672 -c "got a certificate request" \
1673 -C "skip write certificate$" \
1674 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001675 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001677run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001678 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001679 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001680 0 \
1681 -S "skip write certificate request" \
1682 -C "skip parse certificate request" \
1683 -c "got a certificate request" \
1684 -C "skip write certificate$" \
1685 -c "skip write certificate verify" \
1686 -c "got no certificate to send" \
1687 -s "SSLv3 client has no certificate" \
1688 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001689 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001690 -S "! mbedtls_ssl_handshake returned" \
1691 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001692 -S "X509 - Certificate verification failed"
1693
Manuel Pégourié-Gonnarda9f12432016-01-29 14:47:09 +01001694# tests for IP adresses in subjectAlternativeName
1695
1696requires_config_enabled MBEDTLS_X509_SAN_IP_ADDRESS_SUPPORT
1697run_test "IP address in SAN: IPv4, good" \
1698 "$P_SRV crt_file=data_files/server5-san-ip.crt \
1699 key_file=data_files/server5.key" \
1700 "$P_CLI debug_level=1 auth_mode=required server_name=IP:127.0.0.1" \
1701 0 \
1702 -C "x509_verify_cert() returned" \
1703 -C "! The certificate Common Name (CN) or subjectAltName (SAN) does not match with the expected name" \
1704 -C "! mbedtls_ssl_handshake returned" \
1705 -C "X509 - Certificate verification failed"
1706
1707requires_config_enabled MBEDTLS_X509_SAN_IP_ADDRESS_SUPPORT
1708run_test "IP address in SAN: IPv4, bad" \
1709 "$P_SRV crt_file=data_files/server5-san-ip.crt \
1710 key_file=data_files/server5.key" \
1711 "$P_CLI debug_level=1 auth_mode=required server_name=IP:127.0.0.2" \
1712 1 \
1713 -c "x509_verify_cert() returned" \
1714 -c "! The certificate Common Name (CN) or subjectAltName (SAN) does not match with the expected name" \
1715 -c "! mbedtls_ssl_handshake returned" \
1716 -c "X509 - Certificate verification failed"
1717
1718requires_config_enabled MBEDTLS_X509_SAN_IP_ADDRESS_SUPPORT
1719run_test "IP address in SAN: IPv6, good" \
1720 "$P_SRV crt_file=data_files/server5-san-ip.crt \
1721 key_file=data_files/server5.key" \
1722 "$P_CLI debug_level=1 auth_mode=required server_name=IP:fe80:0000:0000:0000:0000:0000:0000:0001" \
1723 0 \
1724 -C "x509_verify_cert() returned" \
1725 -C "! The certificate Common Name (CN) or subjectAltName (SAN) does not match with the expected name" \
1726 -C "! mbedtls_ssl_handshake returned" \
1727 -C "X509 - Certificate verification failed"
1728
1729requires_config_enabled MBEDTLS_X509_SAN_IP_ADDRESS_SUPPORT
1730run_test "IP address in SAN: IPv6, bad" \
1731 "$P_SRV crt_file=data_files/server5-san-ip.crt \
1732 key_file=data_files/server5.key" \
1733 "$P_CLI debug_level=1 auth_mode=required server_name=IP:fe80:0000:0000:0000:0000:0000:0000:0002" \
1734 1 \
1735 -c "x509_verify_cert() returned" \
1736 -c "! The certificate Common Name (CN) or subjectAltName (SAN) does not match with the expected name" \
1737 -c "! mbedtls_ssl_handshake returned" \
1738 -c "X509 - Certificate verification failed"
1739
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001740# Tests for certificate selection based on SHA verson
1741
1742run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1743 "$P_SRV crt_file=data_files/server5.crt \
1744 key_file=data_files/server5.key \
1745 crt_file2=data_files/server5-sha1.crt \
1746 key_file2=data_files/server5.key" \
1747 "$P_CLI force_version=tls1_2" \
1748 0 \
1749 -c "signed using.*ECDSA with SHA256" \
1750 -C "signed using.*ECDSA with SHA1"
1751
1752run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1753 "$P_SRV crt_file=data_files/server5.crt \
1754 key_file=data_files/server5.key \
1755 crt_file2=data_files/server5-sha1.crt \
1756 key_file2=data_files/server5.key" \
1757 "$P_CLI force_version=tls1_1" \
1758 0 \
1759 -C "signed using.*ECDSA with SHA256" \
1760 -c "signed using.*ECDSA with SHA1"
1761
1762run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1763 "$P_SRV crt_file=data_files/server5.crt \
1764 key_file=data_files/server5.key \
1765 crt_file2=data_files/server5-sha1.crt \
1766 key_file2=data_files/server5.key" \
1767 "$P_CLI force_version=tls1" \
1768 0 \
1769 -C "signed using.*ECDSA with SHA256" \
1770 -c "signed using.*ECDSA with SHA1"
1771
1772run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1773 "$P_SRV crt_file=data_files/server5.crt \
1774 key_file=data_files/server5.key \
1775 crt_file2=data_files/server6.crt \
1776 key_file2=data_files/server6.key" \
1777 "$P_CLI force_version=tls1_1" \
1778 0 \
1779 -c "serial number.*09" \
1780 -c "signed using.*ECDSA with SHA256" \
1781 -C "signed using.*ECDSA with SHA1"
1782
1783run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1784 "$P_SRV crt_file=data_files/server6.crt \
1785 key_file=data_files/server6.key \
1786 crt_file2=data_files/server5.crt \
1787 key_file2=data_files/server5.key" \
1788 "$P_CLI force_version=tls1_1" \
1789 0 \
1790 -c "serial number.*0A" \
1791 -c "signed using.*ECDSA with SHA256" \
1792 -C "signed using.*ECDSA with SHA1"
1793
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001794# tests for SNI
1795
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001796run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001797 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001798 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001799 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001800 0 \
1801 -S "parse ServerName extension" \
1802 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1803 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001804
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001805run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001806 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001807 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001808 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 +02001809 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001810 0 \
1811 -s "parse ServerName extension" \
1812 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1813 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001815run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001816 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001817 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001818 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 +02001819 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001820 0 \
1821 -s "parse ServerName extension" \
1822 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1823 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001825run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001826 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001827 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001828 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 +02001829 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001830 1 \
1831 -s "parse ServerName extension" \
1832 -s "ssl_sni_wrapper() returned" \
1833 -s "mbedtls_ssl_handshake returned" \
1834 -c "mbedtls_ssl_handshake returned" \
1835 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001836
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001837run_test "SNI: client auth no override: optional" \
1838 "$P_SRV debug_level=3 auth_mode=optional \
1839 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1840 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1841 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001842 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001843 -S "skip write certificate request" \
1844 -C "skip parse certificate request" \
1845 -c "got a certificate request" \
1846 -C "skip write certificate" \
1847 -C "skip write certificate verify" \
1848 -S "skip parse certificate verify"
1849
1850run_test "SNI: client auth override: none -> optional" \
1851 "$P_SRV debug_level=3 auth_mode=none \
1852 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1853 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1854 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001855 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001856 -S "skip write certificate request" \
1857 -C "skip parse certificate request" \
1858 -c "got a certificate request" \
1859 -C "skip write certificate" \
1860 -C "skip write certificate verify" \
1861 -S "skip parse certificate verify"
1862
1863run_test "SNI: client auth override: optional -> none" \
1864 "$P_SRV debug_level=3 auth_mode=optional \
1865 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1866 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1867 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001868 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001869 -s "skip write certificate request" \
1870 -C "skip parse certificate request" \
1871 -c "got no certificate request" \
1872 -c "skip write certificate" \
1873 -c "skip write certificate verify" \
1874 -s "skip parse certificate verify"
1875
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001876run_test "SNI: CA no override" \
1877 "$P_SRV debug_level=3 auth_mode=optional \
1878 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1879 ca_file=data_files/test-ca.crt \
1880 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1881 "$P_CLI debug_level=3 server_name=localhost \
1882 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1883 1 \
1884 -S "skip write certificate request" \
1885 -C "skip parse certificate request" \
1886 -c "got a certificate request" \
1887 -C "skip write certificate" \
1888 -C "skip write certificate verify" \
1889 -S "skip parse certificate verify" \
1890 -s "x509_verify_cert() returned" \
1891 -s "! The certificate is not correctly signed by the trusted CA" \
1892 -S "The certificate has been revoked (is on a CRL)"
1893
1894run_test "SNI: CA override" \
1895 "$P_SRV debug_level=3 auth_mode=optional \
1896 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1897 ca_file=data_files/test-ca.crt \
1898 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1899 "$P_CLI debug_level=3 server_name=localhost \
1900 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1901 0 \
1902 -S "skip write certificate request" \
1903 -C "skip parse certificate request" \
1904 -c "got a certificate request" \
1905 -C "skip write certificate" \
1906 -C "skip write certificate verify" \
1907 -S "skip parse certificate verify" \
1908 -S "x509_verify_cert() returned" \
1909 -S "! The certificate is not correctly signed by the trusted CA" \
1910 -S "The certificate has been revoked (is on a CRL)"
1911
1912run_test "SNI: CA override with CRL" \
1913 "$P_SRV debug_level=3 auth_mode=optional \
1914 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1915 ca_file=data_files/test-ca.crt \
1916 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1917 "$P_CLI debug_level=3 server_name=localhost \
1918 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1919 1 \
1920 -S "skip write certificate request" \
1921 -C "skip parse certificate request" \
1922 -c "got a certificate request" \
1923 -C "skip write certificate" \
1924 -C "skip write certificate verify" \
1925 -S "skip parse certificate verify" \
1926 -s "x509_verify_cert() returned" \
1927 -S "! The certificate is not correctly signed by the trusted CA" \
1928 -s "The certificate has been revoked (is on a CRL)"
1929
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001930# Tests for non-blocking I/O: exercise a variety of handshake flows
1931
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001932run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001933 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1934 "$P_CLI nbio=2 tickets=0" \
1935 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001936 -S "mbedtls_ssl_handshake returned" \
1937 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001938 -c "Read from server: .* bytes read"
1939
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001940run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001941 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1942 "$P_CLI nbio=2 tickets=0" \
1943 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001944 -S "mbedtls_ssl_handshake returned" \
1945 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001946 -c "Read from server: .* bytes read"
1947
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001948run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001949 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1950 "$P_CLI nbio=2 tickets=1" \
1951 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001952 -S "mbedtls_ssl_handshake returned" \
1953 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001954 -c "Read from server: .* bytes read"
1955
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001956run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001957 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1958 "$P_CLI nbio=2 tickets=1" \
1959 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001960 -S "mbedtls_ssl_handshake returned" \
1961 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001962 -c "Read from server: .* bytes read"
1963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001964run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001965 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1966 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1967 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001968 -S "mbedtls_ssl_handshake returned" \
1969 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001970 -c "Read from server: .* bytes read"
1971
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001972run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001973 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1974 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1975 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001976 -S "mbedtls_ssl_handshake returned" \
1977 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001978 -c "Read from server: .* bytes read"
1979
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001980run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001981 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1982 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1983 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001984 -S "mbedtls_ssl_handshake returned" \
1985 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001986 -c "Read from server: .* bytes read"
1987
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001988# Tests for version negotiation
1989
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001990run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001991 "$P_SRV" \
1992 "$P_CLI" \
1993 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001994 -S "mbedtls_ssl_handshake returned" \
1995 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001996 -s "Protocol is TLSv1.2" \
1997 -c "Protocol is TLSv1.2"
1998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001999run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002000 "$P_SRV" \
2001 "$P_CLI max_version=tls1_1" \
2002 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002003 -S "mbedtls_ssl_handshake returned" \
2004 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002005 -s "Protocol is TLSv1.1" \
2006 -c "Protocol is TLSv1.1"
2007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002008run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002009 "$P_SRV max_version=tls1_1" \
2010 "$P_CLI" \
2011 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002012 -S "mbedtls_ssl_handshake returned" \
2013 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002014 -s "Protocol is TLSv1.1" \
2015 -c "Protocol is TLSv1.1"
2016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002017run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002018 "$P_SRV max_version=tls1_1" \
2019 "$P_CLI max_version=tls1_1" \
2020 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002021 -S "mbedtls_ssl_handshake returned" \
2022 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002023 -s "Protocol is TLSv1.1" \
2024 -c "Protocol is TLSv1.1"
2025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002026run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002027 "$P_SRV min_version=tls1_1" \
2028 "$P_CLI max_version=tls1_1" \
2029 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002030 -S "mbedtls_ssl_handshake returned" \
2031 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002032 -s "Protocol is TLSv1.1" \
2033 -c "Protocol is TLSv1.1"
2034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002035run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002036 "$P_SRV max_version=tls1_1" \
2037 "$P_CLI min_version=tls1_1" \
2038 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002039 -S "mbedtls_ssl_handshake returned" \
2040 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002041 -s "Protocol is TLSv1.1" \
2042 -c "Protocol is TLSv1.1"
2043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002044run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002045 "$P_SRV max_version=tls1_1" \
2046 "$P_CLI min_version=tls1_2" \
2047 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002048 -s "mbedtls_ssl_handshake returned" \
2049 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002050 -c "SSL - Handshake protocol not within min/max boundaries"
2051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002052run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002053 "$P_SRV min_version=tls1_2" \
2054 "$P_CLI max_version=tls1_1" \
2055 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002056 -s "mbedtls_ssl_handshake returned" \
2057 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002058 -s "SSL - Handshake protocol not within min/max boundaries"
2059
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002060# Tests for ALPN extension
2061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002062run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002063 "$P_SRV debug_level=3" \
2064 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002065 0 \
2066 -C "client hello, adding alpn extension" \
2067 -S "found alpn extension" \
2068 -C "got an alert message, type: \\[2:120]" \
2069 -S "server hello, adding alpn extension" \
2070 -C "found alpn extension " \
2071 -C "Application Layer Protocol is" \
2072 -S "Application Layer Protocol is"
2073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002074run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002075 "$P_SRV debug_level=3" \
2076 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002077 0 \
2078 -c "client hello, adding alpn extension" \
2079 -s "found alpn extension" \
2080 -C "got an alert message, type: \\[2:120]" \
2081 -S "server hello, adding alpn extension" \
2082 -C "found alpn extension " \
2083 -c "Application Layer Protocol is (none)" \
2084 -S "Application Layer Protocol is"
2085
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002086run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002087 "$P_SRV debug_level=3 alpn=abc,1234" \
2088 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002089 0 \
2090 -C "client hello, adding alpn extension" \
2091 -S "found alpn extension" \
2092 -C "got an alert message, type: \\[2:120]" \
2093 -S "server hello, adding alpn extension" \
2094 -C "found alpn extension " \
2095 -C "Application Layer Protocol is" \
2096 -s "Application Layer Protocol is (none)"
2097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002098run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002099 "$P_SRV debug_level=3 alpn=abc,1234" \
2100 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002101 0 \
2102 -c "client hello, adding alpn extension" \
2103 -s "found alpn extension" \
2104 -C "got an alert message, type: \\[2:120]" \
2105 -s "server hello, adding alpn extension" \
2106 -c "found alpn extension" \
2107 -c "Application Layer Protocol is abc" \
2108 -s "Application Layer Protocol is abc"
2109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002110run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002111 "$P_SRV debug_level=3 alpn=abc,1234" \
2112 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002113 0 \
2114 -c "client hello, adding alpn extension" \
2115 -s "found alpn extension" \
2116 -C "got an alert message, type: \\[2:120]" \
2117 -s "server hello, adding alpn extension" \
2118 -c "found alpn extension" \
2119 -c "Application Layer Protocol is abc" \
2120 -s "Application Layer Protocol is abc"
2121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002122run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002123 "$P_SRV debug_level=3 alpn=abc,1234" \
2124 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002125 0 \
2126 -c "client hello, adding alpn extension" \
2127 -s "found alpn extension" \
2128 -C "got an alert message, type: \\[2:120]" \
2129 -s "server hello, adding alpn extension" \
2130 -c "found alpn extension" \
2131 -c "Application Layer Protocol is 1234" \
2132 -s "Application Layer Protocol is 1234"
2133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002134run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002135 "$P_SRV debug_level=3 alpn=abc,123" \
2136 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002137 1 \
2138 -c "client hello, adding alpn extension" \
2139 -s "found alpn extension" \
2140 -c "got an alert message, type: \\[2:120]" \
2141 -S "server hello, adding alpn extension" \
2142 -C "found alpn extension" \
2143 -C "Application Layer Protocol is 1234" \
2144 -S "Application Layer Protocol is 1234"
2145
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002146
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002147# Tests for keyUsage in leaf certificates, part 1:
2148# server-side certificate/suite selection
2149
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002150run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002151 "$P_SRV key_file=data_files/server2.key \
2152 crt_file=data_files/server2.ku-ds.crt" \
2153 "$P_CLI" \
2154 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002155 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002156
2157
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002158run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002159 "$P_SRV key_file=data_files/server2.key \
2160 crt_file=data_files/server2.ku-ke.crt" \
2161 "$P_CLI" \
2162 0 \
2163 -c "Ciphersuite is TLS-RSA-WITH-"
2164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002165run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002166 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002167 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002168 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002169 1 \
2170 -C "Ciphersuite is "
2171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002172run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002173 "$P_SRV key_file=data_files/server5.key \
2174 crt_file=data_files/server5.ku-ds.crt" \
2175 "$P_CLI" \
2176 0 \
2177 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2178
2179
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002180run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002181 "$P_SRV key_file=data_files/server5.key \
2182 crt_file=data_files/server5.ku-ka.crt" \
2183 "$P_CLI" \
2184 0 \
2185 -c "Ciphersuite is TLS-ECDH-"
2186
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002187run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002188 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002189 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002190 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002191 1 \
2192 -C "Ciphersuite is "
2193
2194# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002195# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002196
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002197run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002198 "$O_SRV -key data_files/server2.key \
2199 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002200 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002201 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2202 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002203 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002204 -C "Processing of the Certificate handshake message failed" \
2205 -c "Ciphersuite is TLS-"
2206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002207run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002208 "$O_SRV -key data_files/server2.key \
2209 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002210 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002211 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2212 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002213 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002214 -C "Processing of the Certificate handshake message failed" \
2215 -c "Ciphersuite is TLS-"
2216
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002217run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002218 "$O_SRV -key data_files/server2.key \
2219 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002220 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002221 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2222 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002223 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002224 -C "Processing of the Certificate handshake message failed" \
2225 -c "Ciphersuite is TLS-"
2226
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002227run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002228 "$O_SRV -key data_files/server2.key \
2229 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002230 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002231 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2232 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002233 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002234 -c "Processing of the Certificate handshake message failed" \
2235 -C "Ciphersuite is TLS-"
2236
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002237run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2238 "$O_SRV -key data_files/server2.key \
2239 -cert data_files/server2.ku-ke.crt" \
2240 "$P_CLI debug_level=1 auth_mode=optional \
2241 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2242 0 \
2243 -c "bad certificate (usage extensions)" \
2244 -C "Processing of the Certificate handshake message failed" \
2245 -c "Ciphersuite is TLS-" \
2246 -c "! Usage does not match the keyUsage extension"
2247
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002248run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002249 "$O_SRV -key data_files/server2.key \
2250 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002251 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002252 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2253 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002254 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002255 -C "Processing of the Certificate handshake message failed" \
2256 -c "Ciphersuite is TLS-"
2257
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002258run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002259 "$O_SRV -key data_files/server2.key \
2260 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002261 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002262 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2263 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002264 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002265 -c "Processing of the Certificate handshake message failed" \
2266 -C "Ciphersuite is TLS-"
2267
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002268run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2269 "$O_SRV -key data_files/server2.key \
2270 -cert data_files/server2.ku-ds.crt" \
2271 "$P_CLI debug_level=1 auth_mode=optional \
2272 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2273 0 \
2274 -c "bad certificate (usage extensions)" \
2275 -C "Processing of the Certificate handshake message failed" \
2276 -c "Ciphersuite is TLS-" \
2277 -c "! Usage does not match the keyUsage extension"
2278
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002279# Tests for keyUsage in leaf certificates, part 3:
2280# server-side checking of client cert
2281
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002282run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002283 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002284 "$O_CLI -key data_files/server2.key \
2285 -cert data_files/server2.ku-ds.crt" \
2286 0 \
2287 -S "bad certificate (usage extensions)" \
2288 -S "Processing of the Certificate handshake message failed"
2289
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002290run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002291 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002292 "$O_CLI -key data_files/server2.key \
2293 -cert data_files/server2.ku-ke.crt" \
2294 0 \
2295 -s "bad certificate (usage extensions)" \
2296 -S "Processing of the Certificate handshake message failed"
2297
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002298run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002299 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002300 "$O_CLI -key data_files/server2.key \
2301 -cert data_files/server2.ku-ke.crt" \
2302 1 \
2303 -s "bad certificate (usage extensions)" \
2304 -s "Processing of the Certificate handshake message failed"
2305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002306run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002307 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002308 "$O_CLI -key data_files/server5.key \
2309 -cert data_files/server5.ku-ds.crt" \
2310 0 \
2311 -S "bad certificate (usage extensions)" \
2312 -S "Processing of the Certificate handshake message failed"
2313
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002314run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002315 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002316 "$O_CLI -key data_files/server5.key \
2317 -cert data_files/server5.ku-ka.crt" \
2318 0 \
2319 -s "bad certificate (usage extensions)" \
2320 -S "Processing of the Certificate handshake message failed"
2321
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002322# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002324run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002325 "$P_SRV key_file=data_files/server5.key \
2326 crt_file=data_files/server5.eku-srv.crt" \
2327 "$P_CLI" \
2328 0
2329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002330run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002331 "$P_SRV key_file=data_files/server5.key \
2332 crt_file=data_files/server5.eku-srv.crt" \
2333 "$P_CLI" \
2334 0
2335
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002336run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002337 "$P_SRV key_file=data_files/server5.key \
2338 crt_file=data_files/server5.eku-cs_any.crt" \
2339 "$P_CLI" \
2340 0
2341
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002342run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002343 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002344 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002345 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002346 1
2347
2348# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2349
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002350run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002351 "$O_SRV -key data_files/server5.key \
2352 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002353 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002354 0 \
2355 -C "bad certificate (usage extensions)" \
2356 -C "Processing of the Certificate handshake message failed" \
2357 -c "Ciphersuite is TLS-"
2358
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002359run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002360 "$O_SRV -key data_files/server5.key \
2361 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002362 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002363 0 \
2364 -C "bad certificate (usage extensions)" \
2365 -C "Processing of the Certificate handshake message failed" \
2366 -c "Ciphersuite is TLS-"
2367
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002368run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002369 "$O_SRV -key data_files/server5.key \
2370 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002371 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002372 0 \
2373 -C "bad certificate (usage extensions)" \
2374 -C "Processing of the Certificate handshake message failed" \
2375 -c "Ciphersuite is TLS-"
2376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002377run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002378 "$O_SRV -key data_files/server5.key \
2379 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002380 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002381 1 \
2382 -c "bad certificate (usage extensions)" \
2383 -c "Processing of the Certificate handshake message failed" \
2384 -C "Ciphersuite is TLS-"
2385
2386# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2387
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002388run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002389 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002390 "$O_CLI -key data_files/server5.key \
2391 -cert data_files/server5.eku-cli.crt" \
2392 0 \
2393 -S "bad certificate (usage extensions)" \
2394 -S "Processing of the Certificate handshake message failed"
2395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002396run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002397 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002398 "$O_CLI -key data_files/server5.key \
2399 -cert data_files/server5.eku-srv_cli.crt" \
2400 0 \
2401 -S "bad certificate (usage extensions)" \
2402 -S "Processing of the Certificate handshake message failed"
2403
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002404run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002405 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002406 "$O_CLI -key data_files/server5.key \
2407 -cert data_files/server5.eku-cs_any.crt" \
2408 0 \
2409 -S "bad certificate (usage extensions)" \
2410 -S "Processing of the Certificate handshake message failed"
2411
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002412run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002413 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002414 "$O_CLI -key data_files/server5.key \
2415 -cert data_files/server5.eku-cs.crt" \
2416 0 \
2417 -s "bad certificate (usage extensions)" \
2418 -S "Processing of the Certificate handshake message failed"
2419
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002420run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002421 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002422 "$O_CLI -key data_files/server5.key \
2423 -cert data_files/server5.eku-cs.crt" \
2424 1 \
2425 -s "bad certificate (usage extensions)" \
2426 -s "Processing of the Certificate handshake message failed"
2427
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002428# Tests for DHM parameters loading
2429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002430run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002431 "$P_SRV" \
2432 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2433 debug_level=3" \
2434 0 \
2435 -c "value of 'DHM: P ' (2048 bits)" \
2436 -c "value of 'DHM: G ' (2048 bits)"
2437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002438run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002439 "$P_SRV dhm_file=data_files/dhparams.pem" \
2440 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2441 debug_level=3" \
2442 0 \
2443 -c "value of 'DHM: P ' (1024 bits)" \
2444 -c "value of 'DHM: G ' (2 bits)"
2445
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002446# Tests for DHM client-side size checking
2447
2448run_test "DHM size: server default, client default, OK" \
2449 "$P_SRV" \
2450 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2451 debug_level=1" \
2452 0 \
2453 -C "DHM prime too short:"
2454
2455run_test "DHM size: server default, client 2048, OK" \
2456 "$P_SRV" \
2457 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2458 debug_level=1 dhmlen=2048" \
2459 0 \
2460 -C "DHM prime too short:"
2461
2462run_test "DHM size: server 1024, client default, OK" \
2463 "$P_SRV dhm_file=data_files/dhparams.pem" \
2464 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2465 debug_level=1" \
2466 0 \
2467 -C "DHM prime too short:"
2468
2469run_test "DHM size: server 1000, client default, rejected" \
2470 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2471 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2472 debug_level=1" \
2473 1 \
2474 -c "DHM prime too short:"
2475
2476run_test "DHM size: server default, client 2049, rejected" \
2477 "$P_SRV" \
2478 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2479 debug_level=1 dhmlen=2049" \
2480 1 \
2481 -c "DHM prime too short:"
2482
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002483# Tests for PSK callback
2484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002485run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002486 "$P_SRV psk=abc123 psk_identity=foo" \
2487 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2488 psk_identity=foo psk=abc123" \
2489 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002490 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002491 -S "SSL - Unknown identity received" \
2492 -S "SSL - Verification of the message MAC failed"
2493
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002494run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002495 "$P_SRV" \
2496 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2497 psk_identity=foo psk=abc123" \
2498 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002499 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002500 -S "SSL - Unknown identity received" \
2501 -S "SSL - Verification of the message MAC failed"
2502
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002503run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002504 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2505 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2506 psk_identity=foo psk=abc123" \
2507 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002508 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002509 -s "SSL - Unknown identity received" \
2510 -S "SSL - Verification of the message MAC failed"
2511
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002512run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002513 "$P_SRV psk_list=abc,dead,def,beef" \
2514 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2515 psk_identity=abc psk=dead" \
2516 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002517 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002518 -S "SSL - Unknown identity received" \
2519 -S "SSL - Verification of the message MAC failed"
2520
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002521run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002522 "$P_SRV psk_list=abc,dead,def,beef" \
2523 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2524 psk_identity=def psk=beef" \
2525 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002526 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002527 -S "SSL - Unknown identity received" \
2528 -S "SSL - Verification of the message MAC failed"
2529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002530run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002531 "$P_SRV psk_list=abc,dead,def,beef" \
2532 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2533 psk_identity=ghi psk=beef" \
2534 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002535 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002536 -s "SSL - Unknown identity received" \
2537 -S "SSL - Verification of the message MAC failed"
2538
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002539run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002540 "$P_SRV psk_list=abc,dead,def,beef" \
2541 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2542 psk_identity=abc psk=beef" \
2543 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002544 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002545 -S "SSL - Unknown identity received" \
2546 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002547
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002548# Tests for EC J-PAKE
2549
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002550requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002551run_test "ECJPAKE: client not configured" \
2552 "$P_SRV debug_level=3" \
2553 "$P_CLI debug_level=3" \
2554 0 \
2555 -C "add ciphersuite: c0ff" \
2556 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002557 -S "found ecjpake kkpp extension" \
2558 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002559 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002560 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002561 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002562 -S "None of the common ciphersuites is usable"
2563
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002564requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002565run_test "ECJPAKE: server not configured" \
2566 "$P_SRV debug_level=3" \
2567 "$P_CLI debug_level=3 ecjpake_pw=bla \
2568 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2569 1 \
2570 -c "add ciphersuite: c0ff" \
2571 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002572 -s "found ecjpake kkpp extension" \
2573 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002574 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002575 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002576 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002577 -s "None of the common ciphersuites is usable"
2578
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002579requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002580run_test "ECJPAKE: working, TLS" \
2581 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2582 "$P_CLI debug_level=3 ecjpake_pw=bla \
2583 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002584 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002585 -c "add ciphersuite: c0ff" \
2586 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002587 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002588 -s "found ecjpake kkpp extension" \
2589 -S "skip ecjpake kkpp extension" \
2590 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002591 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002592 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002593 -S "None of the common ciphersuites is usable" \
2594 -S "SSL - Verification of the message MAC failed"
2595
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002596requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002597run_test "ECJPAKE: password mismatch, TLS" \
2598 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2599 "$P_CLI debug_level=3 ecjpake_pw=bad \
2600 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2601 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002602 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002603 -s "SSL - Verification of the message MAC failed"
2604
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002605requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002606run_test "ECJPAKE: working, DTLS" \
2607 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2608 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2609 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2610 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002611 -c "re-using cached ecjpake parameters" \
2612 -S "SSL - Verification of the message MAC failed"
2613
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002614requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002615run_test "ECJPAKE: working, DTLS, no cookie" \
2616 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2617 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2618 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2619 0 \
2620 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002621 -S "SSL - Verification of the message MAC failed"
2622
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002623requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002624run_test "ECJPAKE: password mismatch, DTLS" \
2625 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2626 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2627 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2628 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002629 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002630 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002631
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002632# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002633requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002634run_test "ECJPAKE: working, DTLS, nolog" \
2635 "$P_SRV dtls=1 ecjpake_pw=bla" \
2636 "$P_CLI dtls=1 ecjpake_pw=bla \
2637 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2638 0
2639
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002640# Tests for ciphersuites per version
2641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002642run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002643 "$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 +02002644 "$P_CLI force_version=ssl3" \
2645 0 \
2646 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2647
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002648run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002649 "$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 +01002650 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002651 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002652 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002653
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002654run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002655 "$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 +02002656 "$P_CLI force_version=tls1_1" \
2657 0 \
2658 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2659
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002660run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002661 "$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 +02002662 "$P_CLI force_version=tls1_2" \
2663 0 \
2664 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2665
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002666# Test for ClientHello without extensions
2667
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002668requires_gnutls
2669run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002670 "$P_SRV debug_level=3" \
2671 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2672 0 \
2673 -s "dumping 'client hello extensions' (0 bytes)"
2674
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002675# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002676
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002677run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002678 "$P_SRV" \
2679 "$P_CLI request_size=100" \
2680 0 \
2681 -s "Read from client: 100 bytes read$"
2682
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002683run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002684 "$P_SRV" \
2685 "$P_CLI request_size=500" \
2686 0 \
2687 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002688
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002689# Tests for small packets
2690
2691run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002692 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002693 "$P_CLI request_size=1 force_version=ssl3 \
2694 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2695 0 \
2696 -s "Read from client: 1 bytes read"
2697
2698run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002699 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002700 "$P_CLI request_size=1 force_version=ssl3 \
2701 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2702 0 \
2703 -s "Read from client: 1 bytes read"
2704
2705run_test "Small packet TLS 1.0 BlockCipher" \
2706 "$P_SRV" \
2707 "$P_CLI request_size=1 force_version=tls1 \
2708 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2709 0 \
2710 -s "Read from client: 1 bytes read"
2711
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002712run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2713 "$P_SRV" \
2714 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2715 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2716 0 \
2717 -s "Read from client: 1 bytes read"
2718
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002719run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2720 "$P_SRV" \
2721 "$P_CLI request_size=1 force_version=tls1 \
2722 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2723 trunc_hmac=1" \
2724 0 \
2725 -s "Read from client: 1 bytes read"
2726
2727run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002728 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002729 "$P_CLI request_size=1 force_version=tls1 \
2730 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2731 trunc_hmac=1" \
2732 0 \
2733 -s "Read from client: 1 bytes read"
2734
2735run_test "Small packet TLS 1.1 BlockCipher" \
2736 "$P_SRV" \
2737 "$P_CLI request_size=1 force_version=tls1_1 \
2738 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2739 0 \
2740 -s "Read from client: 1 bytes read"
2741
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002742run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2743 "$P_SRV" \
2744 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2745 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2746 0 \
2747 -s "Read from client: 1 bytes read"
2748
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002749run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002750 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002751 "$P_CLI request_size=1 force_version=tls1_1 \
2752 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2753 0 \
2754 -s "Read from client: 1 bytes read"
2755
2756run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2757 "$P_SRV" \
2758 "$P_CLI request_size=1 force_version=tls1_1 \
2759 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2760 trunc_hmac=1" \
2761 0 \
2762 -s "Read from client: 1 bytes read"
2763
2764run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002765 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002766 "$P_CLI request_size=1 force_version=tls1_1 \
2767 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2768 trunc_hmac=1" \
2769 0 \
2770 -s "Read from client: 1 bytes read"
2771
2772run_test "Small packet TLS 1.2 BlockCipher" \
2773 "$P_SRV" \
2774 "$P_CLI request_size=1 force_version=tls1_2 \
2775 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2776 0 \
2777 -s "Read from client: 1 bytes read"
2778
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002779run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2780 "$P_SRV" \
2781 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2782 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2783 0 \
2784 -s "Read from client: 1 bytes read"
2785
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002786run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2787 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002788 "$P_CLI request_size=1 force_version=tls1_2 \
2789 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002790 0 \
2791 -s "Read from client: 1 bytes read"
2792
2793run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2794 "$P_SRV" \
2795 "$P_CLI request_size=1 force_version=tls1_2 \
2796 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2797 trunc_hmac=1" \
2798 0 \
2799 -s "Read from client: 1 bytes read"
2800
2801run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002802 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002803 "$P_CLI request_size=1 force_version=tls1_2 \
2804 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2805 0 \
2806 -s "Read from client: 1 bytes read"
2807
2808run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002809 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002810 "$P_CLI request_size=1 force_version=tls1_2 \
2811 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2812 trunc_hmac=1" \
2813 0 \
2814 -s "Read from client: 1 bytes read"
2815
2816run_test "Small packet TLS 1.2 AEAD" \
2817 "$P_SRV" \
2818 "$P_CLI request_size=1 force_version=tls1_2 \
2819 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2820 0 \
2821 -s "Read from client: 1 bytes read"
2822
2823run_test "Small packet TLS 1.2 AEAD shorter tag" \
2824 "$P_SRV" \
2825 "$P_CLI request_size=1 force_version=tls1_2 \
2826 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2827 0 \
2828 -s "Read from client: 1 bytes read"
2829
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002830# Test for large packets
2831
2832run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002833 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002834 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002835 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2836 0 \
2837 -s "Read from client: 16384 bytes read"
2838
2839run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002840 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002841 "$P_CLI request_size=16384 force_version=ssl3 \
2842 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2843 0 \
2844 -s "Read from client: 16384 bytes read"
2845
2846run_test "Large packet TLS 1.0 BlockCipher" \
2847 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002848 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002849 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2850 0 \
2851 -s "Read from client: 16384 bytes read"
2852
2853run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2854 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002855 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002856 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2857 trunc_hmac=1" \
2858 0 \
2859 -s "Read from client: 16384 bytes read"
2860
2861run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002862 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002863 "$P_CLI request_size=16384 force_version=tls1 \
2864 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2865 trunc_hmac=1" \
2866 0 \
2867 -s "Read from client: 16384 bytes read"
2868
2869run_test "Large packet TLS 1.1 BlockCipher" \
2870 "$P_SRV" \
2871 "$P_CLI request_size=16384 force_version=tls1_1 \
2872 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2873 0 \
2874 -s "Read from client: 16384 bytes read"
2875
2876run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002877 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002878 "$P_CLI request_size=16384 force_version=tls1_1 \
2879 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2880 0 \
2881 -s "Read from client: 16384 bytes read"
2882
2883run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2884 "$P_SRV" \
2885 "$P_CLI request_size=16384 force_version=tls1_1 \
2886 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2887 trunc_hmac=1" \
2888 0 \
2889 -s "Read from client: 16384 bytes read"
2890
2891run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002892 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002893 "$P_CLI request_size=16384 force_version=tls1_1 \
2894 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2895 trunc_hmac=1" \
2896 0 \
2897 -s "Read from client: 16384 bytes read"
2898
2899run_test "Large packet TLS 1.2 BlockCipher" \
2900 "$P_SRV" \
2901 "$P_CLI request_size=16384 force_version=tls1_2 \
2902 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2903 0 \
2904 -s "Read from client: 16384 bytes read"
2905
2906run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2907 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002908 "$P_CLI request_size=16384 force_version=tls1_2 \
2909 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002910 0 \
2911 -s "Read from client: 16384 bytes read"
2912
2913run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2914 "$P_SRV" \
2915 "$P_CLI request_size=16384 force_version=tls1_2 \
2916 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2917 trunc_hmac=1" \
2918 0 \
2919 -s "Read from client: 16384 bytes read"
2920
2921run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002922 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002923 "$P_CLI request_size=16384 force_version=tls1_2 \
2924 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2925 0 \
2926 -s "Read from client: 16384 bytes read"
2927
2928run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002929 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002930 "$P_CLI request_size=16384 force_version=tls1_2 \
2931 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2932 trunc_hmac=1" \
2933 0 \
2934 -s "Read from client: 16384 bytes read"
2935
2936run_test "Large packet TLS 1.2 AEAD" \
2937 "$P_SRV" \
2938 "$P_CLI request_size=16384 force_version=tls1_2 \
2939 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2940 0 \
2941 -s "Read from client: 16384 bytes read"
2942
2943run_test "Large packet TLS 1.2 AEAD shorter tag" \
2944 "$P_SRV" \
2945 "$P_CLI request_size=16384 force_version=tls1_2 \
2946 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2947 0 \
2948 -s "Read from client: 16384 bytes read"
2949
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002950# Tests for DTLS HelloVerifyRequest
2951
2952run_test "DTLS cookie: enabled" \
2953 "$P_SRV dtls=1 debug_level=2" \
2954 "$P_CLI dtls=1 debug_level=2" \
2955 0 \
2956 -s "cookie verification failed" \
2957 -s "cookie verification passed" \
2958 -S "cookie verification skipped" \
2959 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002960 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002961 -S "SSL - The requested feature is not available"
2962
2963run_test "DTLS cookie: disabled" \
2964 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2965 "$P_CLI dtls=1 debug_level=2" \
2966 0 \
2967 -S "cookie verification failed" \
2968 -S "cookie verification passed" \
2969 -s "cookie verification skipped" \
2970 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002971 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002972 -S "SSL - The requested feature is not available"
2973
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002974run_test "DTLS cookie: default (failing)" \
2975 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2976 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2977 1 \
2978 -s "cookie verification failed" \
2979 -S "cookie verification passed" \
2980 -S "cookie verification skipped" \
2981 -C "received hello verify request" \
2982 -S "hello verification requested" \
2983 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002984
2985requires_ipv6
2986run_test "DTLS cookie: enabled, IPv6" \
2987 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2988 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2989 0 \
2990 -s "cookie verification failed" \
2991 -s "cookie verification passed" \
2992 -S "cookie verification skipped" \
2993 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002994 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002995 -S "SSL - The requested feature is not available"
2996
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002997run_test "DTLS cookie: enabled, nbio" \
2998 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2999 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3000 0 \
3001 -s "cookie verification failed" \
3002 -s "cookie verification passed" \
3003 -S "cookie verification skipped" \
3004 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003005 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003006 -S "SSL - The requested feature is not available"
3007
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003008# Tests for client reconnecting from the same port with DTLS
3009
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003010not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003011run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003012 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3013 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003014 0 \
3015 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003016 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003017 -S "Client initiated reconnection from same port"
3018
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003019not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003020run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003021 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3022 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003023 0 \
3024 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003025 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003026 -s "Client initiated reconnection from same port"
3027
3028run_test "DTLS client reconnect from same port: reconnect, nbio" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003029 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3030 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003031 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003032 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003033 -s "Client initiated reconnection from same port"
3034
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003035run_test "DTLS client reconnect from same port: no cookies" \
3036 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003037 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3038 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003039 -s "The operation timed out" \
3040 -S "Client initiated reconnection from same port"
3041
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003042# Tests for various cases of client authentication with DTLS
3043# (focused on handshake flows and message parsing)
3044
3045run_test "DTLS client auth: required" \
3046 "$P_SRV dtls=1 auth_mode=required" \
3047 "$P_CLI dtls=1" \
3048 0 \
3049 -s "Verifying peer X.509 certificate... ok"
3050
3051run_test "DTLS client auth: optional, client has no cert" \
3052 "$P_SRV dtls=1 auth_mode=optional" \
3053 "$P_CLI dtls=1 crt_file=none key_file=none" \
3054 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003055 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003056
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003057run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003058 "$P_SRV dtls=1 auth_mode=none" \
3059 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3060 0 \
3061 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003062 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003063
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003064run_test "DTLS wrong PSK: badmac alert" \
3065 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3066 "$P_CLI dtls=1 psk=abc124" \
3067 1 \
3068 -s "SSL - Verification of the message MAC failed" \
3069 -c "SSL - A fatal alert message was received from our peer"
3070
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003071# Tests for receiving fragmented handshake messages with DTLS
3072
3073requires_gnutls
3074run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3075 "$G_SRV -u --mtu 2048 -a" \
3076 "$P_CLI dtls=1 debug_level=2" \
3077 0 \
3078 -C "found fragmented DTLS handshake message" \
3079 -C "error"
3080
3081requires_gnutls
3082run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3083 "$G_SRV -u --mtu 512" \
3084 "$P_CLI dtls=1 debug_level=2" \
3085 0 \
3086 -c "found fragmented DTLS handshake message" \
3087 -C "error"
3088
3089requires_gnutls
3090run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3091 "$G_SRV -u --mtu 128" \
3092 "$P_CLI dtls=1 debug_level=2" \
3093 0 \
3094 -c "found fragmented DTLS handshake message" \
3095 -C "error"
3096
3097requires_gnutls
3098run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3099 "$G_SRV -u --mtu 128" \
3100 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3101 0 \
3102 -c "found fragmented DTLS handshake message" \
3103 -C "error"
3104
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003105requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003106run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3107 "$G_SRV -u --mtu 256" \
3108 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3109 0 \
3110 -c "found fragmented DTLS handshake message" \
3111 -c "client hello, adding renegotiation extension" \
3112 -c "found renegotiation extension" \
3113 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003114 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003115 -C "error" \
3116 -s "Extra-header:"
3117
3118requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003119run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3120 "$G_SRV -u --mtu 256" \
3121 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3122 0 \
3123 -c "found fragmented DTLS handshake message" \
3124 -c "client hello, adding renegotiation extension" \
3125 -c "found renegotiation extension" \
3126 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003127 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003128 -C "error" \
3129 -s "Extra-header:"
3130
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003131run_test "DTLS reassembly: no fragmentation (openssl server)" \
3132 "$O_SRV -dtls1 -mtu 2048" \
3133 "$P_CLI dtls=1 debug_level=2" \
3134 0 \
3135 -C "found fragmented DTLS handshake message" \
3136 -C "error"
3137
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003138run_test "DTLS reassembly: some fragmentation (openssl server)" \
3139 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003140 "$P_CLI dtls=1 debug_level=2" \
3141 0 \
3142 -c "found fragmented DTLS handshake message" \
3143 -C "error"
3144
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003145run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003146 "$O_SRV -dtls1 -mtu 256" \
3147 "$P_CLI dtls=1 debug_level=2" \
3148 0 \
3149 -c "found fragmented DTLS handshake message" \
3150 -C "error"
3151
3152run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3153 "$O_SRV -dtls1 -mtu 256" \
3154 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3155 0 \
3156 -c "found fragmented DTLS handshake message" \
3157 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003158
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003159# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003160
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003161not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003162run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003163 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003164 "$P_SRV dtls=1 debug_level=2" \
3165 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003166 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003167 -C "replayed record" \
3168 -S "replayed record" \
3169 -C "record from another epoch" \
3170 -S "record from another epoch" \
3171 -C "discarding invalid record" \
3172 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003173 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003174 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003175 -c "HTTP/1.0 200 OK"
3176
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003177not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003178run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003179 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003180 "$P_SRV dtls=1 debug_level=2" \
3181 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003182 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003183 -c "replayed record" \
3184 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003185 -c "discarding invalid record" \
3186 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003187 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003188 -s "Extra-header:" \
3189 -c "HTTP/1.0 200 OK"
3190
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003191run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3192 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003193 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3194 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003195 0 \
3196 -c "replayed record" \
3197 -S "replayed record" \
3198 -c "discarding invalid record" \
3199 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003200 -c "resend" \
3201 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003202 -s "Extra-header:" \
3203 -c "HTTP/1.0 200 OK"
3204
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003205run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003206 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003207 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003208 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003209 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003210 -c "discarding invalid record (mac)" \
3211 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003212 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003213 -c "HTTP/1.0 200 OK" \
3214 -S "too many records with bad MAC" \
3215 -S "Verification of the message MAC failed"
3216
3217run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3218 -p "$P_PXY bad_ad=1" \
3219 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3220 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3221 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003222 -C "discarding invalid record (mac)" \
3223 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003224 -S "Extra-header:" \
3225 -C "HTTP/1.0 200 OK" \
3226 -s "too many records with bad MAC" \
3227 -s "Verification of the message MAC failed"
3228
3229run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3230 -p "$P_PXY bad_ad=1" \
3231 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3232 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3233 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003234 -c "discarding invalid record (mac)" \
3235 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003236 -s "Extra-header:" \
3237 -c "HTTP/1.0 200 OK" \
3238 -S "too many records with bad MAC" \
3239 -S "Verification of the message MAC failed"
3240
3241run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3242 -p "$P_PXY bad_ad=1" \
3243 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3244 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3245 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003246 -c "discarding invalid record (mac)" \
3247 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003248 -s "Extra-header:" \
3249 -c "HTTP/1.0 200 OK" \
3250 -s "too many records with bad MAC" \
3251 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003252
3253run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003254 -p "$P_PXY delay_ccs=1" \
3255 "$P_SRV dtls=1 debug_level=1" \
3256 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003257 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003258 -c "record from another epoch" \
3259 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003260 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003261 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003262 -s "Extra-header:" \
3263 -c "HTTP/1.0 200 OK"
3264
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003265# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003266
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003267needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003268run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003269 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003270 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3271 psk=abc123" \
3272 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003273 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3274 0 \
3275 -s "Extra-header:" \
3276 -c "HTTP/1.0 200 OK"
3277
3278needs_more_time 2
3279run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3280 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003281 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3282 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003283 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3284 0 \
3285 -s "Extra-header:" \
3286 -c "HTTP/1.0 200 OK"
3287
3288needs_more_time 2
3289run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3290 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003291 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3292 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003293 0 \
3294 -s "Extra-header:" \
3295 -c "HTTP/1.0 200 OK"
3296
3297needs_more_time 2
3298run_test "DTLS proxy: 3d, FS, client auth" \
3299 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003300 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3301 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003302 0 \
3303 -s "Extra-header:" \
3304 -c "HTTP/1.0 200 OK"
3305
3306needs_more_time 2
3307run_test "DTLS proxy: 3d, FS, ticket" \
3308 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003309 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3310 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003311 0 \
3312 -s "Extra-header:" \
3313 -c "HTTP/1.0 200 OK"
3314
3315needs_more_time 2
3316run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3317 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003318 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3319 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003320 0 \
3321 -s "Extra-header:" \
3322 -c "HTTP/1.0 200 OK"
3323
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003324needs_more_time 2
3325run_test "DTLS proxy: 3d, max handshake, nbio" \
3326 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003327 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3328 auth_mode=required" \
3329 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003330 0 \
3331 -s "Extra-header:" \
3332 -c "HTTP/1.0 200 OK"
3333
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003334needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003335run_test "DTLS proxy: 3d, min handshake, resumption" \
3336 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3337 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3338 psk=abc123 debug_level=3" \
3339 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3340 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3341 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3342 0 \
3343 -s "a session has been resumed" \
3344 -c "a session has been resumed" \
3345 -s "Extra-header:" \
3346 -c "HTTP/1.0 200 OK"
3347
3348needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003349run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3350 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3351 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3352 psk=abc123 debug_level=3 nbio=2" \
3353 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3354 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3355 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3356 0 \
3357 -s "a session has been resumed" \
3358 -c "a session has been resumed" \
3359 -s "Extra-header:" \
3360 -c "HTTP/1.0 200 OK"
3361
3362needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003363run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003364 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003365 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3366 psk=abc123 renegotiation=1 debug_level=2" \
3367 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3368 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003369 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3370 0 \
3371 -c "=> renegotiate" \
3372 -s "=> renegotiate" \
3373 -s "Extra-header:" \
3374 -c "HTTP/1.0 200 OK"
3375
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003376needs_more_time 4
3377run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3378 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003379 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3380 psk=abc123 renegotiation=1 debug_level=2" \
3381 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3382 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003383 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3384 0 \
3385 -c "=> renegotiate" \
3386 -s "=> renegotiate" \
3387 -s "Extra-header:" \
3388 -c "HTTP/1.0 200 OK"
3389
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003390needs_more_time 4
3391run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003392 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003393 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003394 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003395 debug_level=2" \
3396 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003397 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003398 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3399 0 \
3400 -c "=> renegotiate" \
3401 -s "=> renegotiate" \
3402 -s "Extra-header:" \
3403 -c "HTTP/1.0 200 OK"
3404
3405needs_more_time 4
3406run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003407 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003408 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003409 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003410 debug_level=2 nbio=2" \
3411 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003412 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003413 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3414 0 \
3415 -c "=> renegotiate" \
3416 -s "=> renegotiate" \
3417 -s "Extra-header:" \
3418 -c "HTTP/1.0 200 OK"
3419
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003420needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003421not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003422run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003423 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3424 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003425 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003426 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003427 -c "HTTP/1.0 200 OK"
3428
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003429needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003430not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003431run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3432 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3433 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003434 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003435 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003436 -c "HTTP/1.0 200 OK"
3437
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003438needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003439not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003440run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3441 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3442 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003443 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003444 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003445 -c "HTTP/1.0 200 OK"
3446
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003447requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003448needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003449not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003450run_test "DTLS proxy: 3d, gnutls server" \
3451 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3452 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003453 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003454 0 \
3455 -s "Extra-header:" \
3456 -c "Extra-header:"
3457
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003458requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003459needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003460not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003461run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3462 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3463 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003464 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003465 0 \
3466 -s "Extra-header:" \
3467 -c "Extra-header:"
3468
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003469requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003470needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003471not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003472run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3473 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3474 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003475 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003476 0 \
3477 -s "Extra-header:" \
3478 -c "Extra-header:"
3479
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003480# Final report
3481
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003482echo "------------------------------------------------------------------------"
3483
3484if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003485 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003486else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003487 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003488fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003489PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003490echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003491
3492exit $FAILS