blob: c08af7b04e4f6a163d870718985d07fdc564de83 [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
Janos Follathe2681a42016-03-07 15:57:05 +0000698requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100699run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100700 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100701 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100702 "$P_CLI debug_level=3 force_version=ssl3" \
703 0 \
704 -C "client hello, adding encrypt_then_mac extension" \
705 -S "found encrypt then mac extension" \
706 -S "server hello, adding encrypt then mac extension" \
707 -C "found encrypt_then_mac extension" \
708 -C "using encrypt then mac" \
709 -S "using encrypt then mac"
710
Janos Follathe2681a42016-03-07 15:57:05 +0000711requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100712run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100713 "$P_SRV debug_level=3 force_version=ssl3 \
714 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100715 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100716 0 \
717 -c "client hello, adding encrypt_then_mac extension" \
718 -s "found encrypt then mac extension" \
719 -S "server hello, adding encrypt then mac extension" \
720 -C "found encrypt_then_mac extension" \
721 -C "using encrypt then mac" \
722 -S "using encrypt then mac"
723
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200724# Tests for Extended Master Secret extension
725
726run_test "Extended Master Secret: default" \
727 "$P_SRV debug_level=3" \
728 "$P_CLI debug_level=3" \
729 0 \
730 -c "client hello, adding extended_master_secret extension" \
731 -s "found extended master secret extension" \
732 -s "server hello, adding extended master secret extension" \
733 -c "found extended_master_secret extension" \
734 -c "using extended master secret" \
735 -s "using extended master secret"
736
737run_test "Extended Master Secret: client enabled, server disabled" \
738 "$P_SRV debug_level=3 extended_ms=0" \
739 "$P_CLI debug_level=3 extended_ms=1" \
740 0 \
741 -c "client hello, adding extended_master_secret extension" \
742 -s "found extended master secret extension" \
743 -S "server hello, adding extended master secret extension" \
744 -C "found extended_master_secret extension" \
745 -C "using extended master secret" \
746 -S "using extended master secret"
747
748run_test "Extended Master Secret: client disabled, server enabled" \
749 "$P_SRV debug_level=3 extended_ms=1" \
750 "$P_CLI debug_level=3 extended_ms=0" \
751 0 \
752 -C "client hello, adding extended_master_secret extension" \
753 -S "found extended master secret extension" \
754 -S "server hello, adding extended master secret extension" \
755 -C "found extended_master_secret extension" \
756 -C "using extended master secret" \
757 -S "using extended master secret"
758
Janos Follathe2681a42016-03-07 15:57:05 +0000759requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200760run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100761 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200762 "$P_CLI debug_level=3 force_version=ssl3" \
763 0 \
764 -C "client hello, adding extended_master_secret extension" \
765 -S "found extended master secret extension" \
766 -S "server hello, adding extended master secret extension" \
767 -C "found extended_master_secret extension" \
768 -C "using extended master secret" \
769 -S "using extended master secret"
770
Janos Follathe2681a42016-03-07 15:57:05 +0000771requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200772run_test "Extended Master Secret: client enabled, server SSLv3" \
773 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100774 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200775 0 \
776 -c "client hello, adding extended_master_secret extension" \
777 -s "found extended master secret extension" \
778 -S "server hello, adding extended master secret extension" \
779 -C "found extended_master_secret extension" \
780 -C "using extended master secret" \
781 -S "using extended master secret"
782
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200783# Tests for FALLBACK_SCSV
784
785run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200786 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200787 "$P_CLI debug_level=3 force_version=tls1_1" \
788 0 \
789 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200790 -S "received FALLBACK_SCSV" \
791 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200792 -C "is a fatal alert message (msg 86)"
793
794run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200795 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200796 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
797 0 \
798 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200799 -S "received FALLBACK_SCSV" \
800 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200801 -C "is a fatal alert message (msg 86)"
802
803run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200804 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200805 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200806 1 \
807 -c "adding FALLBACK_SCSV" \
808 -s "received FALLBACK_SCSV" \
809 -s "inapropriate fallback" \
810 -c "is a fatal alert message (msg 86)"
811
812run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200813 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200814 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200815 0 \
816 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200817 -s "received FALLBACK_SCSV" \
818 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200819 -C "is a fatal alert message (msg 86)"
820
821requires_openssl_with_fallback_scsv
822run_test "Fallback SCSV: default, openssl server" \
823 "$O_SRV" \
824 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
825 0 \
826 -C "adding FALLBACK_SCSV" \
827 -C "is a fatal alert message (msg 86)"
828
829requires_openssl_with_fallback_scsv
830run_test "Fallback SCSV: enabled, openssl server" \
831 "$O_SRV" \
832 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
833 1 \
834 -c "adding FALLBACK_SCSV" \
835 -c "is a fatal alert message (msg 86)"
836
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200837requires_openssl_with_fallback_scsv
838run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200839 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200840 "$O_CLI -tls1_1" \
841 0 \
842 -S "received FALLBACK_SCSV" \
843 -S "inapropriate fallback"
844
845requires_openssl_with_fallback_scsv
846run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200847 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200848 "$O_CLI -tls1_1 -fallback_scsv" \
849 1 \
850 -s "received FALLBACK_SCSV" \
851 -s "inapropriate fallback"
852
853requires_openssl_with_fallback_scsv
854run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200855 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200856 "$O_CLI -fallback_scsv" \
857 0 \
858 -s "received FALLBACK_SCSV" \
859 -S "inapropriate fallback"
860
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100861# Tests for CBC 1/n-1 record splitting
862
863run_test "CBC Record splitting: TLS 1.2, no splitting" \
864 "$P_SRV" \
865 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
866 request_size=123 force_version=tls1_2" \
867 0 \
868 -s "Read from client: 123 bytes read" \
869 -S "Read from client: 1 bytes read" \
870 -S "122 bytes read"
871
872run_test "CBC Record splitting: TLS 1.1, no splitting" \
873 "$P_SRV" \
874 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
875 request_size=123 force_version=tls1_1" \
876 0 \
877 -s "Read from client: 123 bytes read" \
878 -S "Read from client: 1 bytes read" \
879 -S "122 bytes read"
880
881run_test "CBC Record splitting: TLS 1.0, splitting" \
882 "$P_SRV" \
883 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
884 request_size=123 force_version=tls1" \
885 0 \
886 -S "Read from client: 123 bytes read" \
887 -s "Read from client: 1 bytes read" \
888 -s "122 bytes read"
889
Janos Follathe2681a42016-03-07 15:57:05 +0000890requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100891run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100892 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100893 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
894 request_size=123 force_version=ssl3" \
895 0 \
896 -S "Read from client: 123 bytes read" \
897 -s "Read from client: 1 bytes read" \
898 -s "122 bytes read"
899
900run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100901 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100902 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
903 request_size=123 force_version=tls1" \
904 0 \
905 -s "Read from client: 123 bytes read" \
906 -S "Read from client: 1 bytes read" \
907 -S "122 bytes read"
908
909run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
910 "$P_SRV" \
911 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
912 request_size=123 force_version=tls1 recsplit=0" \
913 0 \
914 -s "Read from client: 123 bytes read" \
915 -S "Read from client: 1 bytes read" \
916 -S "122 bytes read"
917
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100918run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
919 "$P_SRV nbio=2" \
920 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
921 request_size=123 force_version=tls1" \
922 0 \
923 -S "Read from client: 123 bytes read" \
924 -s "Read from client: 1 bytes read" \
925 -s "122 bytes read"
926
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100927# Tests for Session Tickets
928
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200929run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200930 "$P_SRV debug_level=3 tickets=1" \
931 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100932 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100933 -c "client hello, adding session ticket extension" \
934 -s "found session ticket extension" \
935 -s "server hello, adding session ticket extension" \
936 -c "found session_ticket extension" \
937 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100938 -S "session successfully restored from cache" \
939 -s "session successfully restored from ticket" \
940 -s "a session has been resumed" \
941 -c "a session has been resumed"
942
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200943run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200944 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
945 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100946 0 \
947 -c "client hello, adding session ticket extension" \
948 -s "found session ticket extension" \
949 -s "server hello, adding session ticket extension" \
950 -c "found session_ticket extension" \
951 -c "parse new session ticket" \
952 -S "session successfully restored from cache" \
953 -s "session successfully restored from ticket" \
954 -s "a session has been resumed" \
955 -c "a session has been resumed"
956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200957run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200958 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
959 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100960 0 \
961 -c "client hello, adding session ticket extension" \
962 -s "found session ticket extension" \
963 -s "server hello, adding session ticket extension" \
964 -c "found session_ticket extension" \
965 -c "parse new session ticket" \
966 -S "session successfully restored from cache" \
967 -S "session successfully restored from ticket" \
968 -S "a session has been resumed" \
969 -C "a session has been resumed"
970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200971run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100972 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200973 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100974 0 \
975 -c "client hello, adding session ticket extension" \
976 -c "found session_ticket extension" \
977 -c "parse new session ticket" \
978 -c "a session has been resumed"
979
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200980run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200981 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200982 "( $O_CLI -sess_out $SESSION; \
983 $O_CLI -sess_in $SESSION; \
984 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100985 0 \
986 -s "found session ticket extension" \
987 -s "server hello, adding session ticket extension" \
988 -S "session successfully restored from cache" \
989 -s "session successfully restored from ticket" \
990 -s "a session has been resumed"
991
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100992# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200994run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200995 "$P_SRV debug_level=3 tickets=0" \
996 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100997 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100998 -c "client hello, adding session ticket extension" \
999 -s "found session ticket extension" \
1000 -S "server hello, adding session ticket extension" \
1001 -C "found session_ticket extension" \
1002 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001003 -s "session successfully restored from cache" \
1004 -S "session successfully restored from ticket" \
1005 -s "a session has been resumed" \
1006 -c "a session has been resumed"
1007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001008run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001009 "$P_SRV debug_level=3 tickets=1" \
1010 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001011 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001012 -C "client hello, adding session ticket extension" \
1013 -S "found session ticket extension" \
1014 -S "server hello, adding session ticket extension" \
1015 -C "found session_ticket extension" \
1016 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001017 -s "session successfully restored from cache" \
1018 -S "session successfully restored from ticket" \
1019 -s "a session has been resumed" \
1020 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001021
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001022run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001023 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1024 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001025 0 \
1026 -S "session successfully restored from cache" \
1027 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001028 -S "a session has been resumed" \
1029 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001031run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001032 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1033 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001034 0 \
1035 -s "session successfully restored from cache" \
1036 -S "session successfully restored from ticket" \
1037 -s "a session has been resumed" \
1038 -c "a session has been resumed"
1039
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001040run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001041 "$P_SRV debug_level=3 tickets=0" \
1042 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001043 0 \
1044 -s "session successfully restored from cache" \
1045 -S "session successfully restored from ticket" \
1046 -s "a session has been resumed" \
1047 -c "a session has been resumed"
1048
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001049run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001050 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1051 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001052 0 \
1053 -S "session successfully restored from cache" \
1054 -S "session successfully restored from ticket" \
1055 -S "a session has been resumed" \
1056 -C "a session has been resumed"
1057
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001058run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001059 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1060 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001061 0 \
1062 -s "session successfully restored from cache" \
1063 -S "session successfully restored from ticket" \
1064 -s "a session has been resumed" \
1065 -c "a session has been resumed"
1066
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001067run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001068 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001069 "( $O_CLI -sess_out $SESSION; \
1070 $O_CLI -sess_in $SESSION; \
1071 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001072 0 \
1073 -s "found session ticket extension" \
1074 -S "server hello, adding session ticket extension" \
1075 -s "session successfully restored from cache" \
1076 -S "session successfully restored from ticket" \
1077 -s "a session has been resumed"
1078
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001079run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001080 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001081 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001082 0 \
1083 -C "found session_ticket extension" \
1084 -C "parse new session ticket" \
1085 -c "a session has been resumed"
1086
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001087# Tests for Max Fragment Length extension
1088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001089run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001090 "$P_SRV debug_level=3" \
1091 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001092 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001093 -c "Maximum fragment length is 16384" \
1094 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001095 -C "client hello, adding max_fragment_length extension" \
1096 -S "found max fragment length extension" \
1097 -S "server hello, max_fragment_length extension" \
1098 -C "found max_fragment_length extension"
1099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001100run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001101 "$P_SRV debug_level=3" \
1102 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001103 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001104 -c "Maximum fragment length is 4096" \
1105 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001106 -c "client hello, adding max_fragment_length extension" \
1107 -s "found max fragment length extension" \
1108 -s "server hello, max_fragment_length extension" \
1109 -c "found max_fragment_length extension"
1110
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001111run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001112 "$P_SRV debug_level=3 max_frag_len=4096" \
1113 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001114 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001115 -c "Maximum fragment length is 16384" \
1116 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001117 -C "client hello, adding max_fragment_length extension" \
1118 -S "found max fragment length extension" \
1119 -S "server hello, max_fragment_length extension" \
1120 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001122requires_gnutls
1123run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001124 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001125 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001126 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001127 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001128 -c "client hello, adding max_fragment_length extension" \
1129 -c "found max_fragment_length extension"
1130
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001131run_test "Max fragment length: client, message just fits" \
1132 "$P_SRV debug_level=3" \
1133 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1134 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001135 -c "Maximum fragment length is 2048" \
1136 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001137 -c "client hello, adding max_fragment_length extension" \
1138 -s "found max fragment length extension" \
1139 -s "server hello, max_fragment_length extension" \
1140 -c "found max_fragment_length extension" \
1141 -c "2048 bytes written in 1 fragments" \
1142 -s "2048 bytes read"
1143
1144run_test "Max fragment length: client, larger message" \
1145 "$P_SRV debug_level=3" \
1146 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1147 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001148 -c "Maximum fragment length is 2048" \
1149 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001150 -c "client hello, adding max_fragment_length extension" \
1151 -s "found max fragment length extension" \
1152 -s "server hello, max_fragment_length extension" \
1153 -c "found max_fragment_length extension" \
1154 -c "2345 bytes written in 2 fragments" \
1155 -s "2048 bytes read" \
1156 -s "297 bytes read"
1157
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001158run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001159 "$P_SRV debug_level=3 dtls=1" \
1160 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1161 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001162 -c "Maximum fragment length is 2048" \
1163 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001164 -c "client hello, adding max_fragment_length extension" \
1165 -s "found max fragment length extension" \
1166 -s "server hello, max_fragment_length extension" \
1167 -c "found max_fragment_length extension" \
1168 -c "fragment larger than.*maximum"
1169
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001170# Tests for renegotiation
1171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001172run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001173 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001174 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001175 0 \
1176 -C "client hello, adding renegotiation extension" \
1177 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1178 -S "found renegotiation extension" \
1179 -s "server hello, secure renegotiation extension" \
1180 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001181 -C "=> renegotiate" \
1182 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001183 -S "write hello request"
1184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001185run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001186 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001187 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001188 0 \
1189 -c "client hello, adding renegotiation extension" \
1190 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1191 -s "found renegotiation extension" \
1192 -s "server hello, secure renegotiation extension" \
1193 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001194 -c "=> renegotiate" \
1195 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001196 -S "write hello request"
1197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001198run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001199 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001200 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001201 0 \
1202 -c "client hello, adding renegotiation extension" \
1203 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1204 -s "found renegotiation extension" \
1205 -s "server hello, secure renegotiation extension" \
1206 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001207 -c "=> renegotiate" \
1208 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001209 -s "write hello request"
1210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001211run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001212 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001213 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001214 0 \
1215 -c "client hello, adding renegotiation extension" \
1216 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1217 -s "found renegotiation extension" \
1218 -s "server hello, secure renegotiation extension" \
1219 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001220 -c "=> renegotiate" \
1221 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001222 -s "write hello request"
1223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001224run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001225 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001226 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001227 1 \
1228 -c "client hello, adding renegotiation extension" \
1229 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1230 -S "found renegotiation extension" \
1231 -s "server hello, secure renegotiation extension" \
1232 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001233 -c "=> renegotiate" \
1234 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001235 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001236 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001237 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001238
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001239run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001240 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001241 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001242 0 \
1243 -C "client hello, adding renegotiation extension" \
1244 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1245 -S "found renegotiation extension" \
1246 -s "server hello, secure renegotiation extension" \
1247 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001248 -C "=> renegotiate" \
1249 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001250 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001251 -S "SSL - An unexpected message was received from our peer" \
1252 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001253
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001254run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001255 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001256 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001258 0 \
1259 -C "client hello, adding renegotiation extension" \
1260 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1261 -S "found renegotiation extension" \
1262 -s "server hello, secure renegotiation extension" \
1263 -c "found renegotiation extension" \
1264 -C "=> renegotiate" \
1265 -S "=> renegotiate" \
1266 -s "write hello request" \
1267 -S "SSL - An unexpected message was received from our peer" \
1268 -S "failed"
1269
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001270# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001271run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001272 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001273 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001274 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001275 0 \
1276 -C "client hello, adding renegotiation extension" \
1277 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1278 -S "found renegotiation extension" \
1279 -s "server hello, secure renegotiation extension" \
1280 -c "found renegotiation extension" \
1281 -C "=> renegotiate" \
1282 -S "=> renegotiate" \
1283 -s "write hello request" \
1284 -S "SSL - An unexpected message was received from our peer" \
1285 -S "failed"
1286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001287run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001288 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001289 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001290 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001291 0 \
1292 -C "client hello, adding renegotiation extension" \
1293 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1294 -S "found renegotiation extension" \
1295 -s "server hello, secure renegotiation extension" \
1296 -c "found renegotiation extension" \
1297 -C "=> renegotiate" \
1298 -S "=> renegotiate" \
1299 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001300 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001302run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001303 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001304 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001305 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001306 0 \
1307 -c "client hello, adding renegotiation extension" \
1308 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1309 -s "found renegotiation extension" \
1310 -s "server hello, secure renegotiation extension" \
1311 -c "found renegotiation extension" \
1312 -c "=> renegotiate" \
1313 -s "=> renegotiate" \
1314 -s "write hello request" \
1315 -S "SSL - An unexpected message was received from our peer" \
1316 -S "failed"
1317
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001318run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001319 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001320 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1321 0 \
1322 -C "client hello, adding renegotiation extension" \
1323 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1324 -S "found renegotiation extension" \
1325 -s "server hello, secure renegotiation extension" \
1326 -c "found renegotiation extension" \
1327 -S "record counter limit reached: renegotiate" \
1328 -C "=> renegotiate" \
1329 -S "=> renegotiate" \
1330 -S "write hello request" \
1331 -S "SSL - An unexpected message was received from our peer" \
1332 -S "failed"
1333
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001334# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001335run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001336 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001337 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001338 0 \
1339 -c "client hello, adding renegotiation extension" \
1340 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1341 -s "found renegotiation extension" \
1342 -s "server hello, secure renegotiation extension" \
1343 -c "found renegotiation extension" \
1344 -s "record counter limit reached: renegotiate" \
1345 -c "=> renegotiate" \
1346 -s "=> renegotiate" \
1347 -s "write hello request" \
1348 -S "SSL - An unexpected message was received from our peer" \
1349 -S "failed"
1350
1351run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001352 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001353 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001354 0 \
1355 -c "client hello, adding renegotiation extension" \
1356 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1357 -s "found renegotiation extension" \
1358 -s "server hello, secure renegotiation extension" \
1359 -c "found renegotiation extension" \
1360 -s "record counter limit reached: renegotiate" \
1361 -c "=> renegotiate" \
1362 -s "=> renegotiate" \
1363 -s "write hello request" \
1364 -S "SSL - An unexpected message was received from our peer" \
1365 -S "failed"
1366
1367run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001368 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001369 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1370 0 \
1371 -C "client hello, adding renegotiation extension" \
1372 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1373 -S "found renegotiation extension" \
1374 -s "server hello, secure renegotiation extension" \
1375 -c "found renegotiation extension" \
1376 -S "record counter limit reached: renegotiate" \
1377 -C "=> renegotiate" \
1378 -S "=> renegotiate" \
1379 -S "write hello request" \
1380 -S "SSL - An unexpected message was received from our peer" \
1381 -S "failed"
1382
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001383run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001384 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001385 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001386 0 \
1387 -c "client hello, adding renegotiation extension" \
1388 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1389 -s "found renegotiation extension" \
1390 -s "server hello, secure renegotiation extension" \
1391 -c "found renegotiation extension" \
1392 -c "=> renegotiate" \
1393 -s "=> renegotiate" \
1394 -S "write hello request"
1395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001396run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001397 "$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 +02001398 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001399 0 \
1400 -c "client hello, adding renegotiation extension" \
1401 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1402 -s "found renegotiation extension" \
1403 -s "server hello, secure renegotiation extension" \
1404 -c "found renegotiation extension" \
1405 -c "=> renegotiate" \
1406 -s "=> renegotiate" \
1407 -s "write hello request"
1408
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001409run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001410 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001411 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001412 0 \
1413 -c "client hello, adding renegotiation extension" \
1414 -c "found renegotiation extension" \
1415 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001416 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001417 -C "error" \
1418 -c "HTTP/1.0 200 [Oo][Kk]"
1419
Paul Bakker539d9722015-02-08 16:18:35 +01001420requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001421run_test "Renegotiation: gnutls server strict, client-initiated" \
1422 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001423 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001424 0 \
1425 -c "client hello, adding renegotiation extension" \
1426 -c "found renegotiation extension" \
1427 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001428 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001429 -C "error" \
1430 -c "HTTP/1.0 200 [Oo][Kk]"
1431
Paul Bakker539d9722015-02-08 16:18:35 +01001432requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001433run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1434 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1435 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1436 1 \
1437 -c "client hello, adding renegotiation extension" \
1438 -C "found renegotiation extension" \
1439 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001440 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001441 -c "error" \
1442 -C "HTTP/1.0 200 [Oo][Kk]"
1443
Paul Bakker539d9722015-02-08 16:18:35 +01001444requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001445run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1446 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1447 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1448 allow_legacy=0" \
1449 1 \
1450 -c "client hello, adding renegotiation extension" \
1451 -C "found renegotiation extension" \
1452 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001453 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001454 -c "error" \
1455 -C "HTTP/1.0 200 [Oo][Kk]"
1456
Paul Bakker539d9722015-02-08 16:18:35 +01001457requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001458run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1459 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1460 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1461 allow_legacy=1" \
1462 0 \
1463 -c "client hello, adding renegotiation extension" \
1464 -C "found renegotiation extension" \
1465 -c "=> renegotiate" \
1466 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001467 -C "error" \
1468 -c "HTTP/1.0 200 [Oo][Kk]"
1469
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001470run_test "Renegotiation: DTLS, client-initiated" \
1471 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1472 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1473 0 \
1474 -c "client hello, adding renegotiation extension" \
1475 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1476 -s "found renegotiation extension" \
1477 -s "server hello, secure renegotiation extension" \
1478 -c "found renegotiation extension" \
1479 -c "=> renegotiate" \
1480 -s "=> renegotiate" \
1481 -S "write hello request"
1482
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001483run_test "Renegotiation: DTLS, server-initiated" \
1484 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001485 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1486 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001487 0 \
1488 -c "client hello, adding renegotiation extension" \
1489 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1490 -s "found renegotiation extension" \
1491 -s "server hello, secure renegotiation extension" \
1492 -c "found renegotiation extension" \
1493 -c "=> renegotiate" \
1494 -s "=> renegotiate" \
1495 -s "write hello request"
1496
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001497requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001498run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1499 "$G_SRV -u --mtu 4096" \
1500 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1501 0 \
1502 -c "client hello, adding renegotiation extension" \
1503 -c "found renegotiation extension" \
1504 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001505 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001506 -C "error" \
1507 -s "Extra-header:"
1508
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001509# Test for the "secure renegotation" extension only (no actual renegotiation)
1510
Paul Bakker539d9722015-02-08 16:18:35 +01001511requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001512run_test "Renego ext: gnutls server strict, client default" \
1513 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1514 "$P_CLI debug_level=3" \
1515 0 \
1516 -c "found renegotiation extension" \
1517 -C "error" \
1518 -c "HTTP/1.0 200 [Oo][Kk]"
1519
Paul Bakker539d9722015-02-08 16:18:35 +01001520requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001521run_test "Renego ext: gnutls server unsafe, client default" \
1522 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1523 "$P_CLI debug_level=3" \
1524 0 \
1525 -C "found renegotiation extension" \
1526 -C "error" \
1527 -c "HTTP/1.0 200 [Oo][Kk]"
1528
Paul Bakker539d9722015-02-08 16:18:35 +01001529requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001530run_test "Renego ext: gnutls server unsafe, client break legacy" \
1531 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1532 "$P_CLI debug_level=3 allow_legacy=-1" \
1533 1 \
1534 -C "found renegotiation extension" \
1535 -c "error" \
1536 -C "HTTP/1.0 200 [Oo][Kk]"
1537
Paul Bakker539d9722015-02-08 16:18:35 +01001538requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001539run_test "Renego ext: gnutls client strict, server default" \
1540 "$P_SRV debug_level=3" \
1541 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1542 0 \
1543 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1544 -s "server hello, secure renegotiation extension"
1545
Paul Bakker539d9722015-02-08 16:18:35 +01001546requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001547run_test "Renego ext: gnutls client unsafe, server default" \
1548 "$P_SRV debug_level=3" \
1549 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1550 0 \
1551 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1552 -S "server hello, secure renegotiation extension"
1553
Paul Bakker539d9722015-02-08 16:18:35 +01001554requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001555run_test "Renego ext: gnutls client unsafe, server break legacy" \
1556 "$P_SRV debug_level=3 allow_legacy=-1" \
1557 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1558 1 \
1559 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1560 -S "server hello, secure renegotiation extension"
1561
Janos Follath0b242342016-02-17 10:11:21 +00001562# Tests for silently dropping trailing extra bytes in .der certificates
1563
1564requires_gnutls
1565run_test "DER format: no trailing bytes" \
1566 "$P_SRV crt_file=data_files/server5-der0.crt \
1567 key_file=data_files/server5.key" \
1568 "$G_CLI " \
1569 0 \
1570 -c "Handshake was completed" \
1571
1572requires_gnutls
1573run_test "DER format: with a trailing zero byte" \
1574 "$P_SRV crt_file=data_files/server5-der1a.crt \
1575 key_file=data_files/server5.key" \
1576 "$G_CLI " \
1577 0 \
1578 -c "Handshake was completed" \
1579
1580requires_gnutls
1581run_test "DER format: with a trailing random byte" \
1582 "$P_SRV crt_file=data_files/server5-der1b.crt \
1583 key_file=data_files/server5.key" \
1584 "$G_CLI " \
1585 0 \
1586 -c "Handshake was completed" \
1587
1588requires_gnutls
1589run_test "DER format: with 2 trailing random bytes" \
1590 "$P_SRV crt_file=data_files/server5-der2.crt \
1591 key_file=data_files/server5.key" \
1592 "$G_CLI " \
1593 0 \
1594 -c "Handshake was completed" \
1595
1596requires_gnutls
1597run_test "DER format: with 4 trailing random bytes" \
1598 "$P_SRV crt_file=data_files/server5-der4.crt \
1599 key_file=data_files/server5.key" \
1600 "$G_CLI " \
1601 0 \
1602 -c "Handshake was completed" \
1603
1604requires_gnutls
1605run_test "DER format: with 8 trailing random bytes" \
1606 "$P_SRV crt_file=data_files/server5-der8.crt \
1607 key_file=data_files/server5.key" \
1608 "$G_CLI " \
1609 0 \
1610 -c "Handshake was completed" \
1611
1612requires_gnutls
1613run_test "DER format: with 9 trailing random bytes" \
1614 "$P_SRV crt_file=data_files/server5-der9.crt \
1615 key_file=data_files/server5.key" \
1616 "$G_CLI " \
1617 0 \
1618 -c "Handshake was completed" \
1619
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001620# Tests for auth_mode
1621
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001622run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001623 "$P_SRV crt_file=data_files/server5-badsign.crt \
1624 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001625 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001626 1 \
1627 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001628 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001629 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001630 -c "X509 - Certificate verification failed"
1631
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001632run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001633 "$P_SRV crt_file=data_files/server5-badsign.crt \
1634 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001635 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001636 0 \
1637 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001638 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001639 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001640 -C "X509 - Certificate verification failed"
1641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001642run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001643 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001644 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001645 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001646 0 \
1647 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001648 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001649 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001650 -C "X509 - Certificate verification failed"
1651
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001652run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001653 "$P_SRV debug_level=3 auth_mode=required" \
1654 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001655 key_file=data_files/server5.key" \
1656 1 \
1657 -S "skip write certificate request" \
1658 -C "skip parse certificate request" \
1659 -c "got a certificate request" \
1660 -C "skip write certificate" \
1661 -C "skip write certificate verify" \
1662 -S "skip parse certificate verify" \
1663 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001664 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001665 -s "! mbedtls_ssl_handshake returned" \
1666 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001667 -s "X509 - Certificate verification failed"
1668
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001669run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001670 "$P_SRV debug_level=3 auth_mode=optional" \
1671 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001672 key_file=data_files/server5.key" \
1673 0 \
1674 -S "skip write certificate request" \
1675 -C "skip parse certificate request" \
1676 -c "got a certificate request" \
1677 -C "skip write certificate" \
1678 -C "skip write certificate verify" \
1679 -S "skip parse certificate verify" \
1680 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001681 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001682 -S "! mbedtls_ssl_handshake returned" \
1683 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001684 -S "X509 - Certificate verification failed"
1685
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001686run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001687 "$P_SRV debug_level=3 auth_mode=none" \
1688 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001689 key_file=data_files/server5.key" \
1690 0 \
1691 -s "skip write certificate request" \
1692 -C "skip parse certificate request" \
1693 -c "got no certificate request" \
1694 -c "skip write certificate" \
1695 -c "skip write certificate verify" \
1696 -s "skip parse certificate verify" \
1697 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001698 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001699 -S "! mbedtls_ssl_handshake returned" \
1700 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001701 -S "X509 - Certificate verification failed"
1702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001703run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001704 "$P_SRV debug_level=3 auth_mode=optional" \
1705 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001706 0 \
1707 -S "skip write certificate request" \
1708 -C "skip parse certificate request" \
1709 -c "got a certificate request" \
1710 -C "skip write certificate$" \
1711 -C "got no certificate to send" \
1712 -S "SSLv3 client has no certificate" \
1713 -c "skip write certificate verify" \
1714 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001715 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001716 -S "! mbedtls_ssl_handshake returned" \
1717 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001718 -S "X509 - Certificate verification failed"
1719
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001720run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001721 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001722 "$O_CLI" \
1723 0 \
1724 -S "skip write certificate request" \
1725 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001726 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001727 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001728 -S "X509 - Certificate verification failed"
1729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001730run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001731 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001732 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001733 0 \
1734 -C "skip parse certificate request" \
1735 -c "got a certificate request" \
1736 -C "skip write certificate$" \
1737 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001738 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001739
Janos Follathe2681a42016-03-07 15:57:05 +00001740requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001741run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001742 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001743 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001744 0 \
1745 -S "skip write certificate request" \
1746 -C "skip parse certificate request" \
1747 -c "got a certificate request" \
1748 -C "skip write certificate$" \
1749 -c "skip write certificate verify" \
1750 -c "got no certificate to send" \
1751 -s "SSLv3 client has no certificate" \
1752 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001753 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001754 -S "! mbedtls_ssl_handshake returned" \
1755 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001756 -S "X509 - Certificate verification failed"
1757
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001758# Tests for certificate selection based on SHA verson
1759
1760run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1761 "$P_SRV crt_file=data_files/server5.crt \
1762 key_file=data_files/server5.key \
1763 crt_file2=data_files/server5-sha1.crt \
1764 key_file2=data_files/server5.key" \
1765 "$P_CLI force_version=tls1_2" \
1766 0 \
1767 -c "signed using.*ECDSA with SHA256" \
1768 -C "signed using.*ECDSA with SHA1"
1769
1770run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1771 "$P_SRV crt_file=data_files/server5.crt \
1772 key_file=data_files/server5.key \
1773 crt_file2=data_files/server5-sha1.crt \
1774 key_file2=data_files/server5.key" \
1775 "$P_CLI force_version=tls1_1" \
1776 0 \
1777 -C "signed using.*ECDSA with SHA256" \
1778 -c "signed using.*ECDSA with SHA1"
1779
1780run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1781 "$P_SRV crt_file=data_files/server5.crt \
1782 key_file=data_files/server5.key \
1783 crt_file2=data_files/server5-sha1.crt \
1784 key_file2=data_files/server5.key" \
1785 "$P_CLI force_version=tls1" \
1786 0 \
1787 -C "signed using.*ECDSA with SHA256" \
1788 -c "signed using.*ECDSA with SHA1"
1789
1790run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1791 "$P_SRV crt_file=data_files/server5.crt \
1792 key_file=data_files/server5.key \
1793 crt_file2=data_files/server6.crt \
1794 key_file2=data_files/server6.key" \
1795 "$P_CLI force_version=tls1_1" \
1796 0 \
1797 -c "serial number.*09" \
1798 -c "signed using.*ECDSA with SHA256" \
1799 -C "signed using.*ECDSA with SHA1"
1800
1801run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1802 "$P_SRV crt_file=data_files/server6.crt \
1803 key_file=data_files/server6.key \
1804 crt_file2=data_files/server5.crt \
1805 key_file2=data_files/server5.key" \
1806 "$P_CLI force_version=tls1_1" \
1807 0 \
1808 -c "serial number.*0A" \
1809 -c "signed using.*ECDSA with SHA256" \
1810 -C "signed using.*ECDSA with SHA1"
1811
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001812# tests for SNI
1813
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001814run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001815 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001816 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001817 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001818 0 \
1819 -S "parse ServerName extension" \
1820 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1821 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001822
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001823run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001824 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001825 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001826 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 +02001827 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001828 0 \
1829 -s "parse ServerName extension" \
1830 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1831 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001832
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001833run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001834 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001835 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001836 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 +02001837 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001838 0 \
1839 -s "parse ServerName extension" \
1840 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1841 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001842
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001843run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001844 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001845 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001846 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 +02001847 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001848 1 \
1849 -s "parse ServerName extension" \
1850 -s "ssl_sni_wrapper() returned" \
1851 -s "mbedtls_ssl_handshake returned" \
1852 -c "mbedtls_ssl_handshake returned" \
1853 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001854
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001855run_test "SNI: client auth no override: optional" \
1856 "$P_SRV debug_level=3 auth_mode=optional \
1857 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1858 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1859 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001860 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001861 -S "skip write certificate request" \
1862 -C "skip parse certificate request" \
1863 -c "got a certificate request" \
1864 -C "skip write certificate" \
1865 -C "skip write certificate verify" \
1866 -S "skip parse certificate verify"
1867
1868run_test "SNI: client auth override: none -> optional" \
1869 "$P_SRV debug_level=3 auth_mode=none \
1870 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1871 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1872 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001873 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001874 -S "skip write certificate request" \
1875 -C "skip parse certificate request" \
1876 -c "got a certificate request" \
1877 -C "skip write certificate" \
1878 -C "skip write certificate verify" \
1879 -S "skip parse certificate verify"
1880
1881run_test "SNI: client auth override: optional -> none" \
1882 "$P_SRV debug_level=3 auth_mode=optional \
1883 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1884 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1885 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001886 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001887 -s "skip write certificate request" \
1888 -C "skip parse certificate request" \
1889 -c "got no certificate request" \
1890 -c "skip write certificate" \
1891 -c "skip write certificate verify" \
1892 -s "skip parse certificate verify"
1893
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001894run_test "SNI: CA no 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,-,-,required" \
1899 "$P_CLI debug_level=3 server_name=localhost \
1900 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1901 1 \
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" \
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,-,required" \
1917 "$P_CLI debug_level=3 server_name=localhost \
1918 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1919 0 \
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
1930run_test "SNI: CA override with CRL" \
1931 "$P_SRV debug_level=3 auth_mode=optional \
1932 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1933 ca_file=data_files/test-ca.crt \
1934 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1935 "$P_CLI debug_level=3 server_name=localhost \
1936 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1937 1 \
1938 -S "skip write certificate request" \
1939 -C "skip parse certificate request" \
1940 -c "got a certificate request" \
1941 -C "skip write certificate" \
1942 -C "skip write certificate verify" \
1943 -S "skip parse certificate verify" \
1944 -s "x509_verify_cert() returned" \
1945 -S "! The certificate is not correctly signed by the trusted CA" \
1946 -s "The certificate has been revoked (is on a CRL)"
1947
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001948# Tests for non-blocking I/O: exercise a variety of handshake flows
1949
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001950run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001951 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1952 "$P_CLI nbio=2 tickets=0" \
1953 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001954 -S "mbedtls_ssl_handshake returned" \
1955 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001956 -c "Read from server: .* bytes read"
1957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001958run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001959 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1960 "$P_CLI nbio=2 tickets=0" \
1961 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001962 -S "mbedtls_ssl_handshake returned" \
1963 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001964 -c "Read from server: .* bytes read"
1965
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001966run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001967 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1968 "$P_CLI nbio=2 tickets=1" \
1969 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001970 -S "mbedtls_ssl_handshake returned" \
1971 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001972 -c "Read from server: .* bytes read"
1973
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001974run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001975 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1976 "$P_CLI nbio=2 tickets=1" \
1977 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001978 -S "mbedtls_ssl_handshake returned" \
1979 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001980 -c "Read from server: .* bytes read"
1981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001982run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001983 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1984 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1985 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001986 -S "mbedtls_ssl_handshake returned" \
1987 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001988 -c "Read from server: .* bytes read"
1989
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001990run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001991 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1992 "$P_CLI nbio=2 tickets=1 reconnect=1" \
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é-Gonnard0b6609b2014-02-26 14:45:12 +01001996 -c "Read from server: .* bytes read"
1997
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001998run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001999 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2000 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2001 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002002 -S "mbedtls_ssl_handshake returned" \
2003 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002004 -c "Read from server: .* bytes read"
2005
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002006# Tests for version negotiation
2007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002008run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002009 "$P_SRV" \
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.2" \
2015 -c "Protocol is TLSv1.2"
2016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002017run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002018 "$P_SRV" \
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: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002027 "$P_SRV max_version=tls1_1" \
2028 "$P_CLI" \
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+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 max_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 max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002045 "$P_SRV min_version=tls1_1" \
2046 "$P_CLI max_version=tls1_1" \
2047 0 \
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 -s "Protocol is TLSv1.1" \
2051 -c "Protocol is TLSv1.1"
2052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002053run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002054 "$P_SRV max_version=tls1_1" \
2055 "$P_CLI min_version=tls1_1" \
2056 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002057 -S "mbedtls_ssl_handshake returned" \
2058 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002059 -s "Protocol is TLSv1.1" \
2060 -c "Protocol is TLSv1.1"
2061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002062run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002063 "$P_SRV max_version=tls1_1" \
2064 "$P_CLI min_version=tls1_2" \
2065 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002066 -s "mbedtls_ssl_handshake returned" \
2067 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002068 -c "SSL - Handshake protocol not within min/max boundaries"
2069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002070run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002071 "$P_SRV min_version=tls1_2" \
2072 "$P_CLI max_version=tls1_1" \
2073 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002074 -s "mbedtls_ssl_handshake returned" \
2075 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002076 -s "SSL - Handshake protocol not within min/max boundaries"
2077
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002078# Tests for ALPN extension
2079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002080run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002081 "$P_SRV debug_level=3" \
2082 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002083 0 \
2084 -C "client hello, adding alpn extension" \
2085 -S "found alpn extension" \
2086 -C "got an alert message, type: \\[2:120]" \
2087 -S "server hello, adding alpn extension" \
2088 -C "found alpn extension " \
2089 -C "Application Layer Protocol is" \
2090 -S "Application Layer Protocol is"
2091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002092run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002093 "$P_SRV debug_level=3" \
2094 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002095 0 \
2096 -c "client hello, adding alpn extension" \
2097 -s "found alpn extension" \
2098 -C "got an alert message, type: \\[2:120]" \
2099 -S "server hello, adding alpn extension" \
2100 -C "found alpn extension " \
2101 -c "Application Layer Protocol is (none)" \
2102 -S "Application Layer Protocol is"
2103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002104run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002105 "$P_SRV debug_level=3 alpn=abc,1234" \
2106 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002107 0 \
2108 -C "client hello, adding alpn extension" \
2109 -S "found alpn extension" \
2110 -C "got an alert message, type: \\[2:120]" \
2111 -S "server hello, adding alpn extension" \
2112 -C "found alpn extension " \
2113 -C "Application Layer Protocol is" \
2114 -s "Application Layer Protocol is (none)"
2115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002116run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002117 "$P_SRV debug_level=3 alpn=abc,1234" \
2118 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002119 0 \
2120 -c "client hello, adding alpn extension" \
2121 -s "found alpn extension" \
2122 -C "got an alert message, type: \\[2:120]" \
2123 -s "server hello, adding alpn extension" \
2124 -c "found alpn extension" \
2125 -c "Application Layer Protocol is abc" \
2126 -s "Application Layer Protocol is abc"
2127
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002128run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002129 "$P_SRV debug_level=3 alpn=abc,1234" \
2130 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002131 0 \
2132 -c "client hello, adding alpn extension" \
2133 -s "found alpn extension" \
2134 -C "got an alert message, type: \\[2:120]" \
2135 -s "server hello, adding alpn extension" \
2136 -c "found alpn extension" \
2137 -c "Application Layer Protocol is abc" \
2138 -s "Application Layer Protocol is abc"
2139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002140run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002141 "$P_SRV debug_level=3 alpn=abc,1234" \
2142 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002143 0 \
2144 -c "client hello, adding alpn extension" \
2145 -s "found alpn extension" \
2146 -C "got an alert message, type: \\[2:120]" \
2147 -s "server hello, adding alpn extension" \
2148 -c "found alpn extension" \
2149 -c "Application Layer Protocol is 1234" \
2150 -s "Application Layer Protocol is 1234"
2151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002152run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002153 "$P_SRV debug_level=3 alpn=abc,123" \
2154 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002155 1 \
2156 -c "client hello, adding alpn extension" \
2157 -s "found alpn extension" \
2158 -c "got an alert message, type: \\[2:120]" \
2159 -S "server hello, adding alpn extension" \
2160 -C "found alpn extension" \
2161 -C "Application Layer Protocol is 1234" \
2162 -S "Application Layer Protocol is 1234"
2163
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002164
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002165# Tests for keyUsage in leaf certificates, part 1:
2166# server-side certificate/suite selection
2167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002168run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002169 "$P_SRV key_file=data_files/server2.key \
2170 crt_file=data_files/server2.ku-ds.crt" \
2171 "$P_CLI" \
2172 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002173 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002174
2175
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002176run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002177 "$P_SRV key_file=data_files/server2.key \
2178 crt_file=data_files/server2.ku-ke.crt" \
2179 "$P_CLI" \
2180 0 \
2181 -c "Ciphersuite is TLS-RSA-WITH-"
2182
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002183run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002184 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002185 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002186 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002187 1 \
2188 -C "Ciphersuite is "
2189
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002190run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002191 "$P_SRV key_file=data_files/server5.key \
2192 crt_file=data_files/server5.ku-ds.crt" \
2193 "$P_CLI" \
2194 0 \
2195 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2196
2197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002198run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002199 "$P_SRV key_file=data_files/server5.key \
2200 crt_file=data_files/server5.ku-ka.crt" \
2201 "$P_CLI" \
2202 0 \
2203 -c "Ciphersuite is TLS-ECDH-"
2204
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002205run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002206 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002207 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002208 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002209 1 \
2210 -C "Ciphersuite is "
2211
2212# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002213# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002215run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002216 "$O_SRV -key data_files/server2.key \
2217 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002218 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002219 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2220 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002221 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002222 -C "Processing of the Certificate handshake message failed" \
2223 -c "Ciphersuite is TLS-"
2224
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002225run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002226 "$O_SRV -key data_files/server2.key \
2227 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002228 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002229 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2230 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002231 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002232 -C "Processing of the Certificate handshake message failed" \
2233 -c "Ciphersuite is TLS-"
2234
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002235run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002236 "$O_SRV -key data_files/server2.key \
2237 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002238 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002239 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2240 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002241 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002242 -C "Processing of the Certificate handshake message failed" \
2243 -c "Ciphersuite is TLS-"
2244
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002245run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002246 "$O_SRV -key data_files/server2.key \
2247 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002248 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002249 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2250 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002251 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002252 -c "Processing of the Certificate handshake message failed" \
2253 -C "Ciphersuite is TLS-"
2254
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002255run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2256 "$O_SRV -key data_files/server2.key \
2257 -cert data_files/server2.ku-ke.crt" \
2258 "$P_CLI debug_level=1 auth_mode=optional \
2259 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2260 0 \
2261 -c "bad certificate (usage extensions)" \
2262 -C "Processing of the Certificate handshake message failed" \
2263 -c "Ciphersuite is TLS-" \
2264 -c "! Usage does not match the keyUsage extension"
2265
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002266run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002267 "$O_SRV -key data_files/server2.key \
2268 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002269 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002270 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2271 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002272 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002273 -C "Processing of the Certificate handshake message failed" \
2274 -c "Ciphersuite is TLS-"
2275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002276run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002277 "$O_SRV -key data_files/server2.key \
2278 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002279 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002280 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2281 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002282 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002283 -c "Processing of the Certificate handshake message failed" \
2284 -C "Ciphersuite is TLS-"
2285
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002286run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2287 "$O_SRV -key data_files/server2.key \
2288 -cert data_files/server2.ku-ds.crt" \
2289 "$P_CLI debug_level=1 auth_mode=optional \
2290 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2291 0 \
2292 -c "bad certificate (usage extensions)" \
2293 -C "Processing of the Certificate handshake message failed" \
2294 -c "Ciphersuite is TLS-" \
2295 -c "! Usage does not match the keyUsage extension"
2296
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002297# Tests for keyUsage in leaf certificates, part 3:
2298# server-side checking of client cert
2299
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002300run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002301 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002302 "$O_CLI -key data_files/server2.key \
2303 -cert data_files/server2.ku-ds.crt" \
2304 0 \
2305 -S "bad certificate (usage extensions)" \
2306 -S "Processing of the Certificate handshake message failed"
2307
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002308run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002309 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002310 "$O_CLI -key data_files/server2.key \
2311 -cert data_files/server2.ku-ke.crt" \
2312 0 \
2313 -s "bad certificate (usage extensions)" \
2314 -S "Processing of the Certificate handshake message failed"
2315
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002316run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002317 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002318 "$O_CLI -key data_files/server2.key \
2319 -cert data_files/server2.ku-ke.crt" \
2320 1 \
2321 -s "bad certificate (usage extensions)" \
2322 -s "Processing of the Certificate handshake message failed"
2323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002324run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002325 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002326 "$O_CLI -key data_files/server5.key \
2327 -cert data_files/server5.ku-ds.crt" \
2328 0 \
2329 -S "bad certificate (usage extensions)" \
2330 -S "Processing of the Certificate handshake message failed"
2331
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002332run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002333 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002334 "$O_CLI -key data_files/server5.key \
2335 -cert data_files/server5.ku-ka.crt" \
2336 0 \
2337 -s "bad certificate (usage extensions)" \
2338 -S "Processing of the Certificate handshake message failed"
2339
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002340# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2341
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002342run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002343 "$P_SRV key_file=data_files/server5.key \
2344 crt_file=data_files/server5.eku-srv.crt" \
2345 "$P_CLI" \
2346 0
2347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002348run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002349 "$P_SRV key_file=data_files/server5.key \
2350 crt_file=data_files/server5.eku-srv.crt" \
2351 "$P_CLI" \
2352 0
2353
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002354run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002355 "$P_SRV key_file=data_files/server5.key \
2356 crt_file=data_files/server5.eku-cs_any.crt" \
2357 "$P_CLI" \
2358 0
2359
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002360run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002361 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002362 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002363 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002364 1
2365
2366# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2367
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002368run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002369 "$O_SRV -key data_files/server5.key \
2370 -cert data_files/server5.eku-srv.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: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002378 "$O_SRV -key data_files/server5.key \
2379 -cert data_files/server5.eku-srv_cli.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 0 \
2382 -C "bad certificate (usage extensions)" \
2383 -C "Processing of the Certificate handshake message failed" \
2384 -c "Ciphersuite is TLS-"
2385
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002386run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002387 "$O_SRV -key data_files/server5.key \
2388 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002389 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002390 0 \
2391 -C "bad certificate (usage extensions)" \
2392 -C "Processing of the Certificate handshake message failed" \
2393 -c "Ciphersuite is TLS-"
2394
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002395run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002396 "$O_SRV -key data_files/server5.key \
2397 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002398 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002399 1 \
2400 -c "bad certificate (usage extensions)" \
2401 -c "Processing of the Certificate handshake message failed" \
2402 -C "Ciphersuite is TLS-"
2403
2404# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2405
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002406run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002407 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002408 "$O_CLI -key data_files/server5.key \
2409 -cert data_files/server5.eku-cli.crt" \
2410 0 \
2411 -S "bad certificate (usage extensions)" \
2412 -S "Processing of the Certificate handshake message failed"
2413
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002414run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002415 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002416 "$O_CLI -key data_files/server5.key \
2417 -cert data_files/server5.eku-srv_cli.crt" \
2418 0 \
2419 -S "bad certificate (usage extensions)" \
2420 -S "Processing of the Certificate handshake message failed"
2421
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002422run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002423 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002424 "$O_CLI -key data_files/server5.key \
2425 -cert data_files/server5.eku-cs_any.crt" \
2426 0 \
2427 -S "bad certificate (usage extensions)" \
2428 -S "Processing of the Certificate handshake message failed"
2429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002430run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002431 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002432 "$O_CLI -key data_files/server5.key \
2433 -cert data_files/server5.eku-cs.crt" \
2434 0 \
2435 -s "bad certificate (usage extensions)" \
2436 -S "Processing of the Certificate handshake message failed"
2437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002438run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002439 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002440 "$O_CLI -key data_files/server5.key \
2441 -cert data_files/server5.eku-cs.crt" \
2442 1 \
2443 -s "bad certificate (usage extensions)" \
2444 -s "Processing of the Certificate handshake message failed"
2445
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002446# Tests for DHM parameters loading
2447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002448run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002449 "$P_SRV" \
2450 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2451 debug_level=3" \
2452 0 \
2453 -c "value of 'DHM: P ' (2048 bits)" \
2454 -c "value of 'DHM: G ' (2048 bits)"
2455
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002456run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002457 "$P_SRV dhm_file=data_files/dhparams.pem" \
2458 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2459 debug_level=3" \
2460 0 \
2461 -c "value of 'DHM: P ' (1024 bits)" \
2462 -c "value of 'DHM: G ' (2 bits)"
2463
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002464# Tests for DHM client-side size checking
2465
2466run_test "DHM size: server default, client default, OK" \
2467 "$P_SRV" \
2468 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2469 debug_level=1" \
2470 0 \
2471 -C "DHM prime too short:"
2472
2473run_test "DHM size: server default, client 2048, OK" \
2474 "$P_SRV" \
2475 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2476 debug_level=1 dhmlen=2048" \
2477 0 \
2478 -C "DHM prime too short:"
2479
2480run_test "DHM size: server 1024, client default, OK" \
2481 "$P_SRV dhm_file=data_files/dhparams.pem" \
2482 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2483 debug_level=1" \
2484 0 \
2485 -C "DHM prime too short:"
2486
2487run_test "DHM size: server 1000, client default, rejected" \
2488 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2489 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2490 debug_level=1" \
2491 1 \
2492 -c "DHM prime too short:"
2493
2494run_test "DHM size: server default, client 2049, rejected" \
2495 "$P_SRV" \
2496 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2497 debug_level=1 dhmlen=2049" \
2498 1 \
2499 -c "DHM prime too short:"
2500
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002501# Tests for PSK callback
2502
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002503run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002504 "$P_SRV psk=abc123 psk_identity=foo" \
2505 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2506 psk_identity=foo psk=abc123" \
2507 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002508 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +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: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002513 "$P_SRV" \
2514 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2515 psk_identity=foo psk=abc123" \
2516 1 \
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: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002522 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2523 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2524 psk_identity=foo psk=abc123" \
2525 1 \
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: first id matches" \
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=abc psk=dead" \
2534 0 \
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: second id matches" \
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=def psk=beef" \
2543 0 \
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"
2547
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002548run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002549 "$P_SRV psk_list=abc,dead,def,beef" \
2550 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2551 psk_identity=ghi psk=beef" \
2552 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002553 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002554 -s "SSL - Unknown identity received" \
2555 -S "SSL - Verification of the message MAC failed"
2556
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002557run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002558 "$P_SRV psk_list=abc,dead,def,beef" \
2559 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2560 psk_identity=abc psk=beef" \
2561 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002562 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002563 -S "SSL - Unknown identity received" \
2564 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002565
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002566# Tests for EC J-PAKE
2567
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002568requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002569run_test "ECJPAKE: client not configured" \
2570 "$P_SRV debug_level=3" \
2571 "$P_CLI debug_level=3" \
2572 0 \
2573 -C "add ciphersuite: c0ff" \
2574 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002575 -S "found ecjpake kkpp extension" \
2576 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002577 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002578 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002579 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002580 -S "None of the common ciphersuites is usable"
2581
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002582requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002583run_test "ECJPAKE: server not configured" \
2584 "$P_SRV debug_level=3" \
2585 "$P_CLI debug_level=3 ecjpake_pw=bla \
2586 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2587 1 \
2588 -c "add ciphersuite: c0ff" \
2589 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002590 -s "found ecjpake kkpp extension" \
2591 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002592 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002593 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002594 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002595 -s "None of the common ciphersuites is usable"
2596
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002597requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002598run_test "ECJPAKE: working, TLS" \
2599 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2600 "$P_CLI debug_level=3 ecjpake_pw=bla \
2601 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002602 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002603 -c "add ciphersuite: c0ff" \
2604 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002605 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002606 -s "found ecjpake kkpp extension" \
2607 -S "skip ecjpake kkpp extension" \
2608 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002609 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002610 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002611 -S "None of the common ciphersuites is usable" \
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é-Gonnard921f2d02015-09-16 22:52:18 +02002615run_test "ECJPAKE: password mismatch, TLS" \
2616 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2617 "$P_CLI debug_level=3 ecjpake_pw=bad \
2618 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2619 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002620 -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: working, DTLS" \
2625 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2626 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2627 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2628 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002629 -c "re-using cached ecjpake parameters" \
2630 -S "SSL - Verification of the message MAC failed"
2631
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002632requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002633run_test "ECJPAKE: working, DTLS, no cookie" \
2634 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2635 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2636 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2637 0 \
2638 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002639 -S "SSL - Verification of the message MAC failed"
2640
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002641requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002642run_test "ECJPAKE: password mismatch, DTLS" \
2643 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2644 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2645 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2646 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002647 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002648 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002649
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002650# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002651requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002652run_test "ECJPAKE: working, DTLS, nolog" \
2653 "$P_SRV dtls=1 ecjpake_pw=bla" \
2654 "$P_CLI dtls=1 ecjpake_pw=bla \
2655 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2656 0
2657
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002658# Tests for ciphersuites per version
2659
Janos Follathe2681a42016-03-07 15:57:05 +00002660requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002661run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002662 "$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 +02002663 "$P_CLI force_version=ssl3" \
2664 0 \
2665 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002667run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002668 "$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 +01002669 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002670 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002671 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002672
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002673run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002674 "$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 +02002675 "$P_CLI force_version=tls1_1" \
2676 0 \
2677 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2678
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002679run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002680 "$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 +02002681 "$P_CLI force_version=tls1_2" \
2682 0 \
2683 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2684
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002685# Test for ClientHello without extensions
2686
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002687requires_gnutls
2688run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002689 "$P_SRV debug_level=3" \
2690 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2691 0 \
2692 -s "dumping 'client hello extensions' (0 bytes)"
2693
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002694# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002695
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002696run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002697 "$P_SRV" \
2698 "$P_CLI request_size=100" \
2699 0 \
2700 -s "Read from client: 100 bytes read$"
2701
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002702run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002703 "$P_SRV" \
2704 "$P_CLI request_size=500" \
2705 0 \
2706 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002707
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002708# Tests for small packets
2709
Janos Follathe2681a42016-03-07 15:57:05 +00002710requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002711run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002712 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002713 "$P_CLI request_size=1 force_version=ssl3 \
2714 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2715 0 \
2716 -s "Read from client: 1 bytes read"
2717
Janos Follathe2681a42016-03-07 15:57:05 +00002718requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002719run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002720 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002721 "$P_CLI request_size=1 force_version=ssl3 \
2722 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2723 0 \
2724 -s "Read from client: 1 bytes read"
2725
2726run_test "Small packet TLS 1.0 BlockCipher" \
2727 "$P_SRV" \
2728 "$P_CLI request_size=1 force_version=tls1 \
2729 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2730 0 \
2731 -s "Read from client: 1 bytes read"
2732
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002733run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2734 "$P_SRV" \
2735 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2736 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2737 0 \
2738 -s "Read from client: 1 bytes read"
2739
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002740run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2741 "$P_SRV" \
2742 "$P_CLI request_size=1 force_version=tls1 \
2743 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2744 trunc_hmac=1" \
2745 0 \
2746 -s "Read from client: 1 bytes read"
2747
2748run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002749 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002750 "$P_CLI request_size=1 force_version=tls1 \
2751 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2752 trunc_hmac=1" \
2753 0 \
2754 -s "Read from client: 1 bytes read"
2755
2756run_test "Small packet TLS 1.1 BlockCipher" \
2757 "$P_SRV" \
2758 "$P_CLI request_size=1 force_version=tls1_1 \
2759 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2760 0 \
2761 -s "Read from client: 1 bytes read"
2762
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002763run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2764 "$P_SRV" \
2765 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2766 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2767 0 \
2768 -s "Read from client: 1 bytes read"
2769
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002770run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002771 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002772 "$P_CLI request_size=1 force_version=tls1_1 \
2773 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2774 0 \
2775 -s "Read from client: 1 bytes read"
2776
2777run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2778 "$P_SRV" \
2779 "$P_CLI request_size=1 force_version=tls1_1 \
2780 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2781 trunc_hmac=1" \
2782 0 \
2783 -s "Read from client: 1 bytes read"
2784
2785run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002786 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002787 "$P_CLI request_size=1 force_version=tls1_1 \
2788 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2789 trunc_hmac=1" \
2790 0 \
2791 -s "Read from client: 1 bytes read"
2792
2793run_test "Small packet TLS 1.2 BlockCipher" \
2794 "$P_SRV" \
2795 "$P_CLI request_size=1 force_version=tls1_2 \
2796 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2797 0 \
2798 -s "Read from client: 1 bytes read"
2799
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002800run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2801 "$P_SRV" \
2802 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2803 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2804 0 \
2805 -s "Read from client: 1 bytes read"
2806
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002807run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2808 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002809 "$P_CLI request_size=1 force_version=tls1_2 \
2810 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002811 0 \
2812 -s "Read from client: 1 bytes read"
2813
2814run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2815 "$P_SRV" \
2816 "$P_CLI request_size=1 force_version=tls1_2 \
2817 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2818 trunc_hmac=1" \
2819 0 \
2820 -s "Read from client: 1 bytes read"
2821
2822run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002823 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002824 "$P_CLI request_size=1 force_version=tls1_2 \
2825 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2826 0 \
2827 -s "Read from client: 1 bytes read"
2828
2829run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002830 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002831 "$P_CLI request_size=1 force_version=tls1_2 \
2832 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2833 trunc_hmac=1" \
2834 0 \
2835 -s "Read from client: 1 bytes read"
2836
2837run_test "Small packet TLS 1.2 AEAD" \
2838 "$P_SRV" \
2839 "$P_CLI request_size=1 force_version=tls1_2 \
2840 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2841 0 \
2842 -s "Read from client: 1 bytes read"
2843
2844run_test "Small packet TLS 1.2 AEAD shorter tag" \
2845 "$P_SRV" \
2846 "$P_CLI request_size=1 force_version=tls1_2 \
2847 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2848 0 \
2849 -s "Read from client: 1 bytes read"
2850
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002851# Test for large packets
2852
Janos Follathe2681a42016-03-07 15:57:05 +00002853requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002854run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002855 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002856 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002857 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2858 0 \
2859 -s "Read from client: 16384 bytes read"
2860
Janos Follathe2681a42016-03-07 15:57:05 +00002861requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002862run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002863 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002864 "$P_CLI request_size=16384 force_version=ssl3 \
2865 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2866 0 \
2867 -s "Read from client: 16384 bytes read"
2868
2869run_test "Large packet TLS 1.0 BlockCipher" \
2870 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002871 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002872 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.0 BlockCipher truncated MAC" \
2877 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002878 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002879 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2880 trunc_hmac=1" \
2881 0 \
2882 -s "Read from client: 16384 bytes read"
2883
2884run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002885 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002886 "$P_CLI request_size=16384 force_version=tls1 \
2887 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2888 trunc_hmac=1" \
2889 0 \
2890 -s "Read from client: 16384 bytes read"
2891
2892run_test "Large packet TLS 1.1 BlockCipher" \
2893 "$P_SRV" \
2894 "$P_CLI request_size=16384 force_version=tls1_1 \
2895 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2896 0 \
2897 -s "Read from client: 16384 bytes read"
2898
2899run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002900 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002901 "$P_CLI request_size=16384 force_version=tls1_1 \
2902 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2903 0 \
2904 -s "Read from client: 16384 bytes read"
2905
2906run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2907 "$P_SRV" \
2908 "$P_CLI request_size=16384 force_version=tls1_1 \
2909 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2910 trunc_hmac=1" \
2911 0 \
2912 -s "Read from client: 16384 bytes read"
2913
2914run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002915 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002916 "$P_CLI request_size=16384 force_version=tls1_1 \
2917 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2918 trunc_hmac=1" \
2919 0 \
2920 -s "Read from client: 16384 bytes read"
2921
2922run_test "Large packet TLS 1.2 BlockCipher" \
2923 "$P_SRV" \
2924 "$P_CLI request_size=16384 force_version=tls1_2 \
2925 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2926 0 \
2927 -s "Read from client: 16384 bytes read"
2928
2929run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2930 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002931 "$P_CLI request_size=16384 force_version=tls1_2 \
2932 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002933 0 \
2934 -s "Read from client: 16384 bytes read"
2935
2936run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2937 "$P_SRV" \
2938 "$P_CLI request_size=16384 force_version=tls1_2 \
2939 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2940 trunc_hmac=1" \
2941 0 \
2942 -s "Read from client: 16384 bytes read"
2943
2944run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002945 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002946 "$P_CLI request_size=16384 force_version=tls1_2 \
2947 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2948 0 \
2949 -s "Read from client: 16384 bytes read"
2950
2951run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002952 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002953 "$P_CLI request_size=16384 force_version=tls1_2 \
2954 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2955 trunc_hmac=1" \
2956 0 \
2957 -s "Read from client: 16384 bytes read"
2958
2959run_test "Large packet TLS 1.2 AEAD" \
2960 "$P_SRV" \
2961 "$P_CLI request_size=16384 force_version=tls1_2 \
2962 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2963 0 \
2964 -s "Read from client: 16384 bytes read"
2965
2966run_test "Large packet TLS 1.2 AEAD shorter tag" \
2967 "$P_SRV" \
2968 "$P_CLI request_size=16384 force_version=tls1_2 \
2969 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2970 0 \
2971 -s "Read from client: 16384 bytes read"
2972
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002973# Tests for DTLS HelloVerifyRequest
2974
2975run_test "DTLS cookie: enabled" \
2976 "$P_SRV dtls=1 debug_level=2" \
2977 "$P_CLI dtls=1 debug_level=2" \
2978 0 \
2979 -s "cookie verification failed" \
2980 -s "cookie verification passed" \
2981 -S "cookie verification skipped" \
2982 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002983 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002984 -S "SSL - The requested feature is not available"
2985
2986run_test "DTLS cookie: disabled" \
2987 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2988 "$P_CLI dtls=1 debug_level=2" \
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é-Gonnardcaecdae2014-10-13 19:04:37 +02002997run_test "DTLS cookie: default (failing)" \
2998 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2999 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3000 1 \
3001 -s "cookie verification failed" \
3002 -S "cookie verification passed" \
3003 -S "cookie verification skipped" \
3004 -C "received hello verify request" \
3005 -S "hello verification requested" \
3006 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003007
3008requires_ipv6
3009run_test "DTLS cookie: enabled, IPv6" \
3010 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3011 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3012 0 \
3013 -s "cookie verification failed" \
3014 -s "cookie verification passed" \
3015 -S "cookie verification skipped" \
3016 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003017 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003018 -S "SSL - The requested feature is not available"
3019
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003020run_test "DTLS cookie: enabled, nbio" \
3021 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3022 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3023 0 \
3024 -s "cookie verification failed" \
3025 -s "cookie verification passed" \
3026 -S "cookie verification skipped" \
3027 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003028 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003029 -S "SSL - The requested feature is not available"
3030
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003031# Tests for client reconnecting from the same port with DTLS
3032
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003033not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003034run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003035 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3036 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003037 0 \
3038 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003039 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003040 -S "Client initiated reconnection from same port"
3041
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003042not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003043run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003044 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3045 "$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 +02003046 0 \
3047 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003048 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003049 -s "Client initiated reconnection from same port"
3050
3051run_test "DTLS client reconnect from same port: reconnect, nbio" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003052 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3053 "$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 +02003054 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003055 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003056 -s "Client initiated reconnection from same port"
3057
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003058run_test "DTLS client reconnect from same port: no cookies" \
3059 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003060 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3061 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003062 -s "The operation timed out" \
3063 -S "Client initiated reconnection from same port"
3064
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003065# Tests for various cases of client authentication with DTLS
3066# (focused on handshake flows and message parsing)
3067
3068run_test "DTLS client auth: required" \
3069 "$P_SRV dtls=1 auth_mode=required" \
3070 "$P_CLI dtls=1" \
3071 0 \
3072 -s "Verifying peer X.509 certificate... ok"
3073
3074run_test "DTLS client auth: optional, client has no cert" \
3075 "$P_SRV dtls=1 auth_mode=optional" \
3076 "$P_CLI dtls=1 crt_file=none key_file=none" \
3077 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003078 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003079
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003080run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003081 "$P_SRV dtls=1 auth_mode=none" \
3082 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3083 0 \
3084 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003085 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003086
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003087run_test "DTLS wrong PSK: badmac alert" \
3088 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3089 "$P_CLI dtls=1 psk=abc124" \
3090 1 \
3091 -s "SSL - Verification of the message MAC failed" \
3092 -c "SSL - A fatal alert message was received from our peer"
3093
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003094# Tests for receiving fragmented handshake messages with DTLS
3095
3096requires_gnutls
3097run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3098 "$G_SRV -u --mtu 2048 -a" \
3099 "$P_CLI dtls=1 debug_level=2" \
3100 0 \
3101 -C "found fragmented DTLS handshake message" \
3102 -C "error"
3103
3104requires_gnutls
3105run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3106 "$G_SRV -u --mtu 512" \
3107 "$P_CLI dtls=1 debug_level=2" \
3108 0 \
3109 -c "found fragmented DTLS handshake message" \
3110 -C "error"
3111
3112requires_gnutls
3113run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3114 "$G_SRV -u --mtu 128" \
3115 "$P_CLI dtls=1 debug_level=2" \
3116 0 \
3117 -c "found fragmented DTLS handshake message" \
3118 -C "error"
3119
3120requires_gnutls
3121run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3122 "$G_SRV -u --mtu 128" \
3123 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3124 0 \
3125 -c "found fragmented DTLS handshake message" \
3126 -C "error"
3127
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003128requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003129run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3130 "$G_SRV -u --mtu 256" \
3131 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3132 0 \
3133 -c "found fragmented DTLS handshake message" \
3134 -c "client hello, adding renegotiation extension" \
3135 -c "found renegotiation extension" \
3136 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003137 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003138 -C "error" \
3139 -s "Extra-header:"
3140
3141requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003142run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3143 "$G_SRV -u --mtu 256" \
3144 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3145 0 \
3146 -c "found fragmented DTLS handshake message" \
3147 -c "client hello, adding renegotiation extension" \
3148 -c "found renegotiation extension" \
3149 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003150 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003151 -C "error" \
3152 -s "Extra-header:"
3153
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003154run_test "DTLS reassembly: no fragmentation (openssl server)" \
3155 "$O_SRV -dtls1 -mtu 2048" \
3156 "$P_CLI dtls=1 debug_level=2" \
3157 0 \
3158 -C "found fragmented DTLS handshake message" \
3159 -C "error"
3160
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003161run_test "DTLS reassembly: some fragmentation (openssl server)" \
3162 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003163 "$P_CLI dtls=1 debug_level=2" \
3164 0 \
3165 -c "found fragmented DTLS handshake message" \
3166 -C "error"
3167
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003168run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003169 "$O_SRV -dtls1 -mtu 256" \
3170 "$P_CLI dtls=1 debug_level=2" \
3171 0 \
3172 -c "found fragmented DTLS handshake message" \
3173 -C "error"
3174
3175run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3176 "$O_SRV -dtls1 -mtu 256" \
3177 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3178 0 \
3179 -c "found fragmented DTLS handshake message" \
3180 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003181
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003182# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003183
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003184not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003185run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003186 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003187 "$P_SRV dtls=1 debug_level=2" \
3188 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003189 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003190 -C "replayed record" \
3191 -S "replayed record" \
3192 -C "record from another epoch" \
3193 -S "record from another epoch" \
3194 -C "discarding invalid record" \
3195 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003196 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003197 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003198 -c "HTTP/1.0 200 OK"
3199
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003200not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003201run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003202 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003203 "$P_SRV dtls=1 debug_level=2" \
3204 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003205 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003206 -c "replayed record" \
3207 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003208 -c "discarding invalid record" \
3209 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003210 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003211 -s "Extra-header:" \
3212 -c "HTTP/1.0 200 OK"
3213
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003214run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3215 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003216 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3217 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003218 0 \
3219 -c "replayed record" \
3220 -S "replayed record" \
3221 -c "discarding invalid record" \
3222 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003223 -c "resend" \
3224 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003225 -s "Extra-header:" \
3226 -c "HTTP/1.0 200 OK"
3227
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003228run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003229 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003230 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003231 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003232 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003233 -c "discarding invalid record (mac)" \
3234 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003235 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003236 -c "HTTP/1.0 200 OK" \
3237 -S "too many records with bad MAC" \
3238 -S "Verification of the message MAC failed"
3239
3240run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3241 -p "$P_PXY bad_ad=1" \
3242 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3243 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3244 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003245 -C "discarding invalid record (mac)" \
3246 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003247 -S "Extra-header:" \
3248 -C "HTTP/1.0 200 OK" \
3249 -s "too many records with bad MAC" \
3250 -s "Verification of the message MAC failed"
3251
3252run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3253 -p "$P_PXY bad_ad=1" \
3254 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3255 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3256 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003257 -c "discarding invalid record (mac)" \
3258 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003259 -s "Extra-header:" \
3260 -c "HTTP/1.0 200 OK" \
3261 -S "too many records with bad MAC" \
3262 -S "Verification of the message MAC failed"
3263
3264run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3265 -p "$P_PXY bad_ad=1" \
3266 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3267 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3268 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003269 -c "discarding invalid record (mac)" \
3270 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003271 -s "Extra-header:" \
3272 -c "HTTP/1.0 200 OK" \
3273 -s "too many records with bad MAC" \
3274 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003275
3276run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003277 -p "$P_PXY delay_ccs=1" \
3278 "$P_SRV dtls=1 debug_level=1" \
3279 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003280 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003281 -c "record from another epoch" \
3282 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003283 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003284 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003285 -s "Extra-header:" \
3286 -c "HTTP/1.0 200 OK"
3287
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003288# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003289
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003290needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003291run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003292 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003293 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3294 psk=abc123" \
3295 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003296 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3297 0 \
3298 -s "Extra-header:" \
3299 -c "HTTP/1.0 200 OK"
3300
3301needs_more_time 2
3302run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3303 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003304 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3305 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003306 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3307 0 \
3308 -s "Extra-header:" \
3309 -c "HTTP/1.0 200 OK"
3310
3311needs_more_time 2
3312run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3313 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003314 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3315 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003316 0 \
3317 -s "Extra-header:" \
3318 -c "HTTP/1.0 200 OK"
3319
3320needs_more_time 2
3321run_test "DTLS proxy: 3d, FS, client auth" \
3322 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003323 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3324 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003325 0 \
3326 -s "Extra-header:" \
3327 -c "HTTP/1.0 200 OK"
3328
3329needs_more_time 2
3330run_test "DTLS proxy: 3d, FS, ticket" \
3331 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003332 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3333 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003334 0 \
3335 -s "Extra-header:" \
3336 -c "HTTP/1.0 200 OK"
3337
3338needs_more_time 2
3339run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3340 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003341 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3342 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003343 0 \
3344 -s "Extra-header:" \
3345 -c "HTTP/1.0 200 OK"
3346
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003347needs_more_time 2
3348run_test "DTLS proxy: 3d, max handshake, nbio" \
3349 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003350 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3351 auth_mode=required" \
3352 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003353 0 \
3354 -s "Extra-header:" \
3355 -c "HTTP/1.0 200 OK"
3356
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003357needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003358run_test "DTLS proxy: 3d, min handshake, resumption" \
3359 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3360 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3361 psk=abc123 debug_level=3" \
3362 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3363 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3364 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3365 0 \
3366 -s "a session has been resumed" \
3367 -c "a session has been resumed" \
3368 -s "Extra-header:" \
3369 -c "HTTP/1.0 200 OK"
3370
3371needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003372run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3373 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3374 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3375 psk=abc123 debug_level=3 nbio=2" \
3376 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3377 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3378 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3379 0 \
3380 -s "a session has been resumed" \
3381 -c "a session has been resumed" \
3382 -s "Extra-header:" \
3383 -c "HTTP/1.0 200 OK"
3384
3385needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003386run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003387 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003388 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3389 psk=abc123 renegotiation=1 debug_level=2" \
3390 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3391 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003392 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3393 0 \
3394 -c "=> renegotiate" \
3395 -s "=> renegotiate" \
3396 -s "Extra-header:" \
3397 -c "HTTP/1.0 200 OK"
3398
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003399needs_more_time 4
3400run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3401 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003402 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3403 psk=abc123 renegotiation=1 debug_level=2" \
3404 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3405 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003406 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3407 0 \
3408 -c "=> renegotiate" \
3409 -s "=> renegotiate" \
3410 -s "Extra-header:" \
3411 -c "HTTP/1.0 200 OK"
3412
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003413needs_more_time 4
3414run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003415 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003416 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003417 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003418 debug_level=2" \
3419 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003420 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003421 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3422 0 \
3423 -c "=> renegotiate" \
3424 -s "=> renegotiate" \
3425 -s "Extra-header:" \
3426 -c "HTTP/1.0 200 OK"
3427
3428needs_more_time 4
3429run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003430 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003431 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003432 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003433 debug_level=2 nbio=2" \
3434 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003435 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003436 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3437 0 \
3438 -c "=> renegotiate" \
3439 -s "=> renegotiate" \
3440 -s "Extra-header:" \
3441 -c "HTTP/1.0 200 OK"
3442
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003443needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003444not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003445run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003446 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3447 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003448 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003449 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003450 -c "HTTP/1.0 200 OK"
3451
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003452needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003453not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003454run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3455 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3456 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003457 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003458 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003459 -c "HTTP/1.0 200 OK"
3460
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003461needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003462not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003463run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3464 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3465 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003466 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003467 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003468 -c "HTTP/1.0 200 OK"
3469
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003470requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003471needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003472not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003473run_test "DTLS proxy: 3d, gnutls server" \
3474 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3475 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003476 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003477 0 \
3478 -s "Extra-header:" \
3479 -c "Extra-header:"
3480
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003481requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003482needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003483not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003484run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3485 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3486 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003487 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003488 0 \
3489 -s "Extra-header:" \
3490 -c "Extra-header:"
3491
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003492requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003493needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003494not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003495run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3496 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3497 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003498 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003499 0 \
3500 -s "Extra-header:" \
3501 -c "Extra-header:"
3502
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003503# Final report
3504
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003505echo "------------------------------------------------------------------------"
3506
3507if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003508 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003509else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003510 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003511fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003512PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003513echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003514
3515exit $FAILS