blob: f62466fa8857e9a0e657925faa90a25dd80c1a38 [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
Paul Bakkere20310a2016-05-10 11:18:17 +010036SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010037RUN_TEST_NUMBER=''
38
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010039print_usage() {
40 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010041 printf " -h|--help\tPrint this help.\n"
42 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
43 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
44 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010045 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010046 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010047}
48
49get_options() {
50 while [ $# -gt 0 ]; do
51 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010052 -f|--filter)
53 shift; FILTER=$1
54 ;;
55 -e|--exclude)
56 shift; EXCLUDE=$1
57 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010058 -m|--memcheck)
59 MEMCHECK=1
60 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010061 -n|--number)
62 shift; RUN_TEST_NUMBER=$1
63 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010064 -s|--show-numbers)
65 SHOW_TEST_NUMBER=1
66 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010067 -h|--help)
68 print_usage
69 exit 0
70 ;;
71 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020072 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010073 print_usage
74 exit 1
75 ;;
76 esac
77 shift
78 done
79}
80
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010081# skip next test if the flag is not enabled in config.h
82requires_config_enabled() {
83 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
84 SKIP_NEXT="YES"
85 fi
86}
87
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020088# skip next test if OpenSSL doesn't support FALLBACK_SCSV
89requires_openssl_with_fallback_scsv() {
90 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
91 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
92 then
93 OPENSSL_HAS_FBSCSV="YES"
94 else
95 OPENSSL_HAS_FBSCSV="NO"
96 fi
97 fi
98 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
99 SKIP_NEXT="YES"
100 fi
101}
102
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200103# skip next test if GnuTLS isn't available
104requires_gnutls() {
105 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200106 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200107 GNUTLS_AVAILABLE="YES"
108 else
109 GNUTLS_AVAILABLE="NO"
110 fi
111 fi
112 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
113 SKIP_NEXT="YES"
114 fi
115}
116
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200117# skip next test if IPv6 isn't available on this host
118requires_ipv6() {
119 if [ -z "${HAS_IPV6:-}" ]; then
120 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
121 SRV_PID=$!
122 sleep 1
123 kill $SRV_PID >/dev/null 2>&1
124 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
125 HAS_IPV6="NO"
126 else
127 HAS_IPV6="YES"
128 fi
129 rm -r $SRV_OUT
130 fi
131
132 if [ "$HAS_IPV6" = "NO" ]; then
133 SKIP_NEXT="YES"
134 fi
135}
136
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200137# skip the next test if valgrind is in use
138not_with_valgrind() {
139 if [ "$MEMCHECK" -gt 0 ]; then
140 SKIP_NEXT="YES"
141 fi
142}
143
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200144# multiply the client timeout delay by the given factor for the next test
145needs_more_time() {
146 CLI_DELAY_FACTOR=$1
147}
148
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100149# print_name <name>
150print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100151 TESTS=$(( $TESTS + 1 ))
152 LINE=""
153
154 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
155 LINE="$TESTS "
156 fi
157
158 LINE="$LINE$1"
159 printf "$LINE "
160 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100161 for i in `seq 1 $LEN`; do printf '.'; done
162 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100163
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100164}
165
166# fail <message>
167fail() {
168 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100169 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100170
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200171 mv $SRV_OUT o-srv-${TESTS}.log
172 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200173 if [ -n "$PXY_CMD" ]; then
174 mv $PXY_OUT o-pxy-${TESTS}.log
175 fi
176 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100177
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200178 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
179 echo " ! server output:"
180 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200181 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200182 echo " ! client output:"
183 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200184 if [ -n "$PXY_CMD" ]; then
185 echo " ! ========================================================"
186 echo " ! proxy output:"
187 cat o-pxy-${TESTS}.log
188 fi
189 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200190 fi
191
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200192 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100193}
194
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100195# is_polar <cmd_line>
196is_polar() {
197 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
198}
199
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200200# openssl s_server doesn't have -www with DTLS
201check_osrv_dtls() {
202 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
203 NEEDS_INPUT=1
204 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
205 else
206 NEEDS_INPUT=0
207 fi
208}
209
210# provide input to commands that need it
211provide_input() {
212 if [ $NEEDS_INPUT -eq 0 ]; then
213 return
214 fi
215
216 while true; do
217 echo "HTTP/1.0 200 OK"
218 sleep 1
219 done
220}
221
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100222# has_mem_err <log_file_name>
223has_mem_err() {
224 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
225 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
226 then
227 return 1 # false: does not have errors
228 else
229 return 0 # true: has errors
230 fi
231}
232
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200233# wait for server to start: two versions depending on lsof availability
234wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200235 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200236 START_TIME=$( date +%s )
237 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200238
239 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200240 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200241 while [ $DONE -eq 0 ]; do
242 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
243 then
244 DONE=1
245 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
246 echo "SERVERSTART TIMEOUT"
247 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
248 DONE=1
249 fi
250 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200251 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200252 while [ $DONE -eq 0 ]; do
253 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
254 then
255 DONE=1
256 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
257 echo "SERVERSTART TIMEOUT"
258 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
259 DONE=1
260 fi
261 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200262 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200263 else
264 sleep "$START_DELAY"
265 fi
266}
267
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200268# wait for client to terminate and set CLI_EXIT
269# must be called right after starting the client
270wait_client_done() {
271 CLI_PID=$!
272
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200273 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
274 CLI_DELAY_FACTOR=1
275
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200276 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200277 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200278
279 wait $CLI_PID
280 CLI_EXIT=$?
281
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200282 kill $DOG_PID >/dev/null 2>&1
283 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200284
285 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
286}
287
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200288# check if the given command uses dtls and sets global variable DTLS
289detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200290 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200291 DTLS=1
292 else
293 DTLS=0
294 fi
295}
296
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200297# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100298# Options: -s pattern pattern that must be present in server output
299# -c pattern pattern that must be present in client output
300# -S pattern pattern that must be absent in server output
301# -C pattern pattern that must be absent in client output
302run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100303 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200304 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100305
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100306 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
307 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200308 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100309 return
310 fi
311
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100312 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100313
Paul Bakkerb7584a52016-05-10 10:50:43 +0100314 # Do we only run numbered tests?
315 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
316 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
317 else
318 SKIP_NEXT="YES"
319 fi
320
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200321 # should we skip?
322 if [ "X$SKIP_NEXT" = "XYES" ]; then
323 SKIP_NEXT="NO"
324 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200325 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200326 return
327 fi
328
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200329 # does this test use a proxy?
330 if [ "X$1" = "X-p" ]; then
331 PXY_CMD="$2"
332 shift 2
333 else
334 PXY_CMD=""
335 fi
336
337 # get commands and client output
338 SRV_CMD="$1"
339 CLI_CMD="$2"
340 CLI_EXPECT="$3"
341 shift 3
342
343 # fix client port
344 if [ -n "$PXY_CMD" ]; then
345 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
346 else
347 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
348 fi
349
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200350 # update DTLS variable
351 detect_dtls "$SRV_CMD"
352
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100353 # prepend valgrind to our commands if active
354 if [ "$MEMCHECK" -gt 0 ]; then
355 if is_polar "$SRV_CMD"; then
356 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
357 fi
358 if is_polar "$CLI_CMD"; then
359 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
360 fi
361 fi
362
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200363 TIMES_LEFT=2
364 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200365 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200366
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200367 # run the commands
368 if [ -n "$PXY_CMD" ]; then
369 echo "$PXY_CMD" > $PXY_OUT
370 $PXY_CMD >> $PXY_OUT 2>&1 &
371 PXY_PID=$!
372 # assume proxy starts faster than server
373 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200374
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200375 check_osrv_dtls
376 echo "$SRV_CMD" > $SRV_OUT
377 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
378 SRV_PID=$!
379 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200380
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200381 echo "$CLI_CMD" > $CLI_OUT
382 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
383 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100384
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200385 # terminate the server (and the proxy)
386 kill $SRV_PID
387 wait $SRV_PID
388 if [ -n "$PXY_CMD" ]; then
389 kill $PXY_PID >/dev/null 2>&1
390 wait $PXY_PID
391 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100392
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200393 # retry only on timeouts
394 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
395 printf "RETRY "
396 else
397 TIMES_LEFT=0
398 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200399 done
400
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100401 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200402 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100403 # expected client exit to incorrectly succeed in case of catastrophic
404 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100405 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200406 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100407 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100408 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100409 return
410 fi
411 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100412 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200413 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100414 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100415 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100416 return
417 fi
418 fi
419
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100420 # check server exit code
421 if [ $? != 0 ]; then
422 fail "server fail"
423 return
424 fi
425
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100426 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100427 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
428 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100429 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200430 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100431 return
432 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100433
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100434 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200435 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100436 while [ $# -gt 0 ]
437 do
438 case $1 in
439 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200440 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100441 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100442 return
443 fi
444 ;;
445
446 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200447 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100448 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100449 return
450 fi
451 ;;
452
453 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200454 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100455 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100456 return
457 fi
458 ;;
459
460 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200461 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100462 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100463 return
464 fi
465 ;;
466
467 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200468 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100469 exit 1
470 esac
471 shift 2
472 done
473
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100474 # check valgrind's results
475 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200476 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100477 fail "Server has memory errors"
478 return
479 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200480 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100481 fail "Client has memory errors"
482 return
483 fi
484 fi
485
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100486 # if we're here, everything is ok
487 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200488 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100489}
490
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100491cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200492 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200493 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
494 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
495 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
496 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100497 exit 1
498}
499
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100500#
501# MAIN
502#
503
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000504if cd $( dirname $0 ); then :; else
505 echo "cd $( dirname $0 ) failed" >&2
506 exit 1
507fi
508
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100509get_options "$@"
510
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100511# sanity checks, avoid an avalanche of errors
512if [ ! -x "$P_SRV" ]; then
513 echo "Command '$P_SRV' is not an executable file"
514 exit 1
515fi
516if [ ! -x "$P_CLI" ]; then
517 echo "Command '$P_CLI' is not an executable file"
518 exit 1
519fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200520if [ ! -x "$P_PXY" ]; then
521 echo "Command '$P_PXY' is not an executable file"
522 exit 1
523fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100524if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
525 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100526 exit 1
527fi
528
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200529# used by watchdog
530MAIN_PID="$$"
531
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200532# be more patient with valgrind
533if [ "$MEMCHECK" -gt 0 ]; then
534 START_DELAY=3
535 DOG_DELAY=30
536else
537 START_DELAY=1
538 DOG_DELAY=10
539fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200540CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200541
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200542# Pick a "unique" server port in the range 10000-19999, and a proxy port
543PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000544PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200545SRV_PORT="1$PORT_BASE"
546PXY_PORT="2$PORT_BASE"
547unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200548
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200549# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000550# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200551P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
552P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
553P_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 +0200554O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200555O_CLI="$O_CLI -connect localhost:+SRV_PORT"
556G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000557G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200558
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200559# Also pick a unique name for intermediate files
560SRV_OUT="srv_out.$$"
561CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200562PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200563SESSION="session.$$"
564
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200565SKIP_NEXT="NO"
566
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100567trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100568
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200569# Basic test
570
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200571# Checks that:
572# - things work with all ciphersuites active (used with config-full in all.sh)
573# - the expected (highest security) parameters are selected
574# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200575run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200576 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200577 "$P_CLI" \
578 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200579 -s "Protocol is TLSv1.2" \
580 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
581 -s "client hello v3, signature_algorithm ext: 6" \
582 -s "ECDHE curve: secp521r1" \
583 -S "error" \
584 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200585
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000586run_test "Default, DTLS" \
587 "$P_SRV dtls=1" \
588 "$P_CLI dtls=1" \
589 0 \
590 -s "Protocol is DTLSv1.2" \
591 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
592
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100593# Tests for rc4 option
594
595run_test "RC4: server disabled, client enabled" \
596 "$P_SRV" \
597 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
598 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100599 -s "SSL - The server has no ciphersuites in common"
600
601run_test "RC4: server half, client enabled" \
602 "$P_SRV arc4=1" \
603 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
604 1 \
605 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100606
607run_test "RC4: server enabled, client disabled" \
608 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
609 "$P_CLI" \
610 1 \
611 -s "SSL - The server has no ciphersuites in common"
612
613run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100614 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100615 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
616 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100617 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100618 -S "SSL - The server has no ciphersuites in common"
619
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100620# Tests for Truncated HMAC extension
621
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100622run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200623 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100624 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100625 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100626 -s "dumping 'computed mac' (20 bytes)" \
627 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100628
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100629run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200630 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100631 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
632 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100633 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100634 -s "dumping 'computed mac' (20 bytes)" \
635 -S "dumping 'computed mac' (10 bytes)"
636
637run_test "Truncated HMAC: client enabled, server default" \
638 "$P_SRV debug_level=4" \
639 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
640 trunc_hmac=1" \
641 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100642 -s "dumping 'computed mac' (20 bytes)" \
643 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100644
645run_test "Truncated HMAC: client enabled, server disabled" \
646 "$P_SRV debug_level=4 trunc_hmac=0" \
647 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
648 trunc_hmac=1" \
649 0 \
650 -s "dumping 'computed mac' (20 bytes)" \
651 -S "dumping 'computed mac' (10 bytes)"
652
653run_test "Truncated HMAC: client enabled, server enabled" \
654 "$P_SRV debug_level=4 trunc_hmac=1" \
655 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
656 trunc_hmac=1" \
657 0 \
658 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100659 -s "dumping 'computed mac' (10 bytes)"
660
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100661# Tests for Encrypt-then-MAC extension
662
663run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100664 "$P_SRV debug_level=3 \
665 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100666 "$P_CLI debug_level=3" \
667 0 \
668 -c "client hello, adding encrypt_then_mac extension" \
669 -s "found encrypt then mac extension" \
670 -s "server hello, adding encrypt then mac extension" \
671 -c "found encrypt_then_mac extension" \
672 -c "using encrypt then mac" \
673 -s "using encrypt then mac"
674
675run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100676 "$P_SRV debug_level=3 etm=0 \
677 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100678 "$P_CLI debug_level=3 etm=1" \
679 0 \
680 -c "client hello, adding encrypt_then_mac extension" \
681 -s "found encrypt then mac extension" \
682 -S "server hello, adding encrypt then mac extension" \
683 -C "found encrypt_then_mac extension" \
684 -C "using encrypt then mac" \
685 -S "using encrypt then mac"
686
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100687run_test "Encrypt then MAC: client enabled, aead cipher" \
688 "$P_SRV debug_level=3 etm=1 \
689 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
690 "$P_CLI debug_level=3 etm=1" \
691 0 \
692 -c "client hello, adding encrypt_then_mac extension" \
693 -s "found encrypt then mac extension" \
694 -S "server hello, adding encrypt then mac extension" \
695 -C "found encrypt_then_mac extension" \
696 -C "using encrypt then mac" \
697 -S "using encrypt then mac"
698
699run_test "Encrypt then MAC: client enabled, stream cipher" \
700 "$P_SRV debug_level=3 etm=1 \
701 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100702 "$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 +0100703 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
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100711run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100712 "$P_SRV debug_level=3 etm=1 \
713 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100714 "$P_CLI debug_level=3 etm=0" \
715 0 \
716 -C "client hello, adding encrypt_then_mac extension" \
717 -S "found encrypt then mac extension" \
718 -S "server hello, adding encrypt then mac extension" \
719 -C "found encrypt_then_mac extension" \
720 -C "using encrypt then mac" \
721 -S "using encrypt then mac"
722
Janos Follathe2681a42016-03-07 15:57:05 +0000723requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100724run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100725 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100726 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100727 "$P_CLI debug_level=3 force_version=ssl3" \
728 0 \
729 -C "client hello, adding encrypt_then_mac extension" \
730 -S "found encrypt then mac extension" \
731 -S "server hello, adding encrypt then mac extension" \
732 -C "found encrypt_then_mac extension" \
733 -C "using encrypt then mac" \
734 -S "using encrypt then mac"
735
Janos Follathe2681a42016-03-07 15:57:05 +0000736requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100737run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100738 "$P_SRV debug_level=3 force_version=ssl3 \
739 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100740 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100741 0 \
742 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100743 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100744 -S "server hello, adding encrypt then mac extension" \
745 -C "found encrypt_then_mac extension" \
746 -C "using encrypt then mac" \
747 -S "using encrypt then mac"
748
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200749# Tests for Extended Master Secret extension
750
751run_test "Extended Master Secret: default" \
752 "$P_SRV debug_level=3" \
753 "$P_CLI debug_level=3" \
754 0 \
755 -c "client hello, adding extended_master_secret extension" \
756 -s "found extended master secret extension" \
757 -s "server hello, adding extended master secret extension" \
758 -c "found extended_master_secret extension" \
759 -c "using extended master secret" \
760 -s "using extended master secret"
761
762run_test "Extended Master Secret: client enabled, server disabled" \
763 "$P_SRV debug_level=3 extended_ms=0" \
764 "$P_CLI debug_level=3 extended_ms=1" \
765 0 \
766 -c "client hello, adding extended_master_secret extension" \
767 -s "found extended master secret extension" \
768 -S "server hello, adding extended master secret extension" \
769 -C "found extended_master_secret extension" \
770 -C "using extended master secret" \
771 -S "using extended master secret"
772
773run_test "Extended Master Secret: client disabled, server enabled" \
774 "$P_SRV debug_level=3 extended_ms=1" \
775 "$P_CLI debug_level=3 extended_ms=0" \
776 0 \
777 -C "client hello, adding extended_master_secret extension" \
778 -S "found extended master secret extension" \
779 -S "server hello, adding extended master secret extension" \
780 -C "found extended_master_secret extension" \
781 -C "using extended master secret" \
782 -S "using extended master secret"
783
Janos Follathe2681a42016-03-07 15:57:05 +0000784requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200785run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100786 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200787 "$P_CLI debug_level=3 force_version=ssl3" \
788 0 \
789 -C "client hello, adding extended_master_secret extension" \
790 -S "found extended master secret extension" \
791 -S "server hello, adding extended master secret extension" \
792 -C "found extended_master_secret extension" \
793 -C "using extended master secret" \
794 -S "using extended master secret"
795
Janos Follathe2681a42016-03-07 15:57:05 +0000796requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200797run_test "Extended Master Secret: client enabled, server SSLv3" \
798 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100799 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200800 0 \
801 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100802 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200803 -S "server hello, adding extended master secret extension" \
804 -C "found extended_master_secret extension" \
805 -C "using extended master secret" \
806 -S "using extended master secret"
807
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200808# Tests for FALLBACK_SCSV
809
810run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200811 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200812 "$P_CLI debug_level=3 force_version=tls1_1" \
813 0 \
814 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200815 -S "received FALLBACK_SCSV" \
816 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200817 -C "is a fatal alert message (msg 86)"
818
819run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200820 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200821 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
822 0 \
823 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200824 -S "received FALLBACK_SCSV" \
825 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200826 -C "is a fatal alert message (msg 86)"
827
828run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200829 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200830 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200831 1 \
832 -c "adding FALLBACK_SCSV" \
833 -s "received FALLBACK_SCSV" \
834 -s "inapropriate fallback" \
835 -c "is a fatal alert message (msg 86)"
836
837run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200838 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200839 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200840 0 \
841 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200842 -s "received FALLBACK_SCSV" \
843 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200844 -C "is a fatal alert message (msg 86)"
845
846requires_openssl_with_fallback_scsv
847run_test "Fallback SCSV: default, openssl server" \
848 "$O_SRV" \
849 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
850 0 \
851 -C "adding FALLBACK_SCSV" \
852 -C "is a fatal alert message (msg 86)"
853
854requires_openssl_with_fallback_scsv
855run_test "Fallback SCSV: enabled, openssl server" \
856 "$O_SRV" \
857 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
858 1 \
859 -c "adding FALLBACK_SCSV" \
860 -c "is a fatal alert message (msg 86)"
861
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200862requires_openssl_with_fallback_scsv
863run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200864 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200865 "$O_CLI -tls1_1" \
866 0 \
867 -S "received FALLBACK_SCSV" \
868 -S "inapropriate fallback"
869
870requires_openssl_with_fallback_scsv
871run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200872 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200873 "$O_CLI -tls1_1 -fallback_scsv" \
874 1 \
875 -s "received FALLBACK_SCSV" \
876 -s "inapropriate fallback"
877
878requires_openssl_with_fallback_scsv
879run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200880 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200881 "$O_CLI -fallback_scsv" \
882 0 \
883 -s "received FALLBACK_SCSV" \
884 -S "inapropriate fallback"
885
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100886# Tests for CBC 1/n-1 record splitting
887
888run_test "CBC Record splitting: TLS 1.2, no splitting" \
889 "$P_SRV" \
890 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
891 request_size=123 force_version=tls1_2" \
892 0 \
893 -s "Read from client: 123 bytes read" \
894 -S "Read from client: 1 bytes read" \
895 -S "122 bytes read"
896
897run_test "CBC Record splitting: TLS 1.1, no splitting" \
898 "$P_SRV" \
899 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
900 request_size=123 force_version=tls1_1" \
901 0 \
902 -s "Read from client: 123 bytes read" \
903 -S "Read from client: 1 bytes read" \
904 -S "122 bytes read"
905
906run_test "CBC Record splitting: TLS 1.0, splitting" \
907 "$P_SRV" \
908 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
909 request_size=123 force_version=tls1" \
910 0 \
911 -S "Read from client: 123 bytes read" \
912 -s "Read from client: 1 bytes read" \
913 -s "122 bytes read"
914
Janos Follathe2681a42016-03-07 15:57:05 +0000915requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100916run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100917 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100918 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
919 request_size=123 force_version=ssl3" \
920 0 \
921 -S "Read from client: 123 bytes read" \
922 -s "Read from client: 1 bytes read" \
923 -s "122 bytes read"
924
925run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100926 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100927 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
928 request_size=123 force_version=tls1" \
929 0 \
930 -s "Read from client: 123 bytes read" \
931 -S "Read from client: 1 bytes read" \
932 -S "122 bytes read"
933
934run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
935 "$P_SRV" \
936 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
937 request_size=123 force_version=tls1 recsplit=0" \
938 0 \
939 -s "Read from client: 123 bytes read" \
940 -S "Read from client: 1 bytes read" \
941 -S "122 bytes read"
942
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100943run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
944 "$P_SRV nbio=2" \
945 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
946 request_size=123 force_version=tls1" \
947 0 \
948 -S "Read from client: 123 bytes read" \
949 -s "Read from client: 1 bytes read" \
950 -s "122 bytes read"
951
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100952# Tests for Session Tickets
953
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200954run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200955 "$P_SRV debug_level=3 tickets=1" \
956 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100957 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100958 -c "client hello, adding session ticket extension" \
959 -s "found session ticket extension" \
960 -s "server hello, adding session ticket extension" \
961 -c "found session_ticket extension" \
962 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100963 -S "session successfully restored from cache" \
964 -s "session successfully restored from ticket" \
965 -s "a session has been resumed" \
966 -c "a session has been resumed"
967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200968run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200969 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
970 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100971 0 \
972 -c "client hello, adding session ticket extension" \
973 -s "found session ticket extension" \
974 -s "server hello, adding session ticket extension" \
975 -c "found session_ticket extension" \
976 -c "parse new session ticket" \
977 -S "session successfully restored from cache" \
978 -s "session successfully restored from ticket" \
979 -s "a session has been resumed" \
980 -c "a session has been resumed"
981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200982run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200983 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
984 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100985 0 \
986 -c "client hello, adding session ticket extension" \
987 -s "found session ticket extension" \
988 -s "server hello, adding session ticket extension" \
989 -c "found session_ticket extension" \
990 -c "parse new session ticket" \
991 -S "session successfully restored from cache" \
992 -S "session successfully restored from ticket" \
993 -S "a session has been resumed" \
994 -C "a session has been resumed"
995
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200996run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100997 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200998 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100999 0 \
1000 -c "client hello, adding session ticket extension" \
1001 -c "found session_ticket extension" \
1002 -c "parse new session ticket" \
1003 -c "a session has been resumed"
1004
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001005run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001006 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001007 "( $O_CLI -sess_out $SESSION; \
1008 $O_CLI -sess_in $SESSION; \
1009 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001010 0 \
1011 -s "found session ticket extension" \
1012 -s "server hello, adding session ticket extension" \
1013 -S "session successfully restored from cache" \
1014 -s "session successfully restored from ticket" \
1015 -s "a session has been resumed"
1016
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001017# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001019run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001020 "$P_SRV debug_level=3 tickets=0" \
1021 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001022 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001023 -c "client hello, adding session ticket extension" \
1024 -s "found session ticket extension" \
1025 -S "server hello, adding session ticket extension" \
1026 -C "found session_ticket extension" \
1027 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001028 -s "session successfully restored from cache" \
1029 -S "session successfully restored from ticket" \
1030 -s "a session has been resumed" \
1031 -c "a session has been resumed"
1032
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001033run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001034 "$P_SRV debug_level=3 tickets=1" \
1035 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001036 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001037 -C "client hello, adding session ticket extension" \
1038 -S "found session ticket extension" \
1039 -S "server hello, adding session ticket extension" \
1040 -C "found session_ticket extension" \
1041 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001042 -s "session successfully restored from cache" \
1043 -S "session successfully restored from ticket" \
1044 -s "a session has been resumed" \
1045 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001047run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001048 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1049 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001050 0 \
1051 -S "session successfully restored from cache" \
1052 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001053 -S "a session has been resumed" \
1054 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001055
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001056run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001057 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1058 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001059 0 \
1060 -s "session successfully restored from cache" \
1061 -S "session successfully restored from ticket" \
1062 -s "a session has been resumed" \
1063 -c "a session has been resumed"
1064
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001065run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001066 "$P_SRV debug_level=3 tickets=0" \
1067 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001068 0 \
1069 -s "session successfully restored from cache" \
1070 -S "session successfully restored from ticket" \
1071 -s "a session has been resumed" \
1072 -c "a session has been resumed"
1073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001074run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001075 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1076 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001077 0 \
1078 -S "session successfully restored from cache" \
1079 -S "session successfully restored from ticket" \
1080 -S "a session has been resumed" \
1081 -C "a session has been resumed"
1082
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001083run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001084 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1085 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001086 0 \
1087 -s "session successfully restored from cache" \
1088 -S "session successfully restored from ticket" \
1089 -s "a session has been resumed" \
1090 -c "a session has been resumed"
1091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001092run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001093 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001094 "( $O_CLI -sess_out $SESSION; \
1095 $O_CLI -sess_in $SESSION; \
1096 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001097 0 \
1098 -s "found session ticket extension" \
1099 -S "server hello, adding session ticket extension" \
1100 -s "session successfully restored from cache" \
1101 -S "session successfully restored from ticket" \
1102 -s "a session has been resumed"
1103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001104run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001105 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001106 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001107 0 \
1108 -C "found session_ticket extension" \
1109 -C "parse new session ticket" \
1110 -c "a session has been resumed"
1111
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001112# Tests for Max Fragment Length extension
1113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001114run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001115 "$P_SRV debug_level=3" \
1116 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001117 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001118 -c "Maximum fragment length is 16384" \
1119 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001120 -C "client hello, adding max_fragment_length extension" \
1121 -S "found max fragment length extension" \
1122 -S "server hello, max_fragment_length extension" \
1123 -C "found max_fragment_length extension"
1124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001125run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001126 "$P_SRV debug_level=3" \
1127 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001128 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001129 -c "Maximum fragment length is 4096" \
1130 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001131 -c "client hello, adding max_fragment_length extension" \
1132 -s "found max fragment length extension" \
1133 -s "server hello, max_fragment_length extension" \
1134 -c "found max_fragment_length extension"
1135
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001136run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001137 "$P_SRV debug_level=3 max_frag_len=4096" \
1138 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001139 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001140 -c "Maximum fragment length is 16384" \
1141 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001142 -C "client hello, adding max_fragment_length extension" \
1143 -S "found max fragment length extension" \
1144 -S "server hello, max_fragment_length extension" \
1145 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001146
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001147requires_gnutls
1148run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001149 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001150 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001151 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001152 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001153 -c "client hello, adding max_fragment_length extension" \
1154 -c "found max_fragment_length extension"
1155
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001156run_test "Max fragment length: client, message just fits" \
1157 "$P_SRV debug_level=3" \
1158 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1159 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001160 -c "Maximum fragment length is 2048" \
1161 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001162 -c "client hello, adding max_fragment_length extension" \
1163 -s "found max fragment length extension" \
1164 -s "server hello, max_fragment_length extension" \
1165 -c "found max_fragment_length extension" \
1166 -c "2048 bytes written in 1 fragments" \
1167 -s "2048 bytes read"
1168
1169run_test "Max fragment length: client, larger message" \
1170 "$P_SRV debug_level=3" \
1171 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1172 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001173 -c "Maximum fragment length is 2048" \
1174 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001175 -c "client hello, adding max_fragment_length extension" \
1176 -s "found max fragment length extension" \
1177 -s "server hello, max_fragment_length extension" \
1178 -c "found max_fragment_length extension" \
1179 -c "2345 bytes written in 2 fragments" \
1180 -s "2048 bytes read" \
1181 -s "297 bytes read"
1182
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001183run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001184 "$P_SRV debug_level=3 dtls=1" \
1185 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1186 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001187 -c "Maximum fragment length is 2048" \
1188 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001189 -c "client hello, adding max_fragment_length extension" \
1190 -s "found max fragment length extension" \
1191 -s "server hello, max_fragment_length extension" \
1192 -c "found max_fragment_length extension" \
1193 -c "fragment larger than.*maximum"
1194
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001195# Tests for renegotiation
1196
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001197run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001198 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001199 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001200 0 \
1201 -C "client hello, adding renegotiation extension" \
1202 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1203 -S "found renegotiation extension" \
1204 -s "server hello, secure renegotiation extension" \
1205 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001206 -C "=> renegotiate" \
1207 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001208 -S "write hello request"
1209
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001210run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001211 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001212 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001213 0 \
1214 -c "client hello, adding renegotiation extension" \
1215 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1216 -s "found renegotiation extension" \
1217 -s "server hello, secure renegotiation extension" \
1218 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001219 -c "=> renegotiate" \
1220 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001221 -S "write hello request"
1222
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001223run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001224 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001225 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001226 0 \
1227 -c "client hello, adding renegotiation extension" \
1228 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1229 -s "found renegotiation extension" \
1230 -s "server hello, secure renegotiation extension" \
1231 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001232 -c "=> renegotiate" \
1233 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001234 -s "write hello request"
1235
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001236run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001237 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001238 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001239 0 \
1240 -c "client hello, adding renegotiation extension" \
1241 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1242 -s "found renegotiation extension" \
1243 -s "server hello, secure renegotiation extension" \
1244 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001245 -c "=> renegotiate" \
1246 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001247 -s "write hello request"
1248
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001249run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001250 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001251 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001252 1 \
1253 -c "client hello, adding renegotiation extension" \
1254 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1255 -S "found renegotiation extension" \
1256 -s "server hello, secure renegotiation extension" \
1257 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001258 -c "=> renegotiate" \
1259 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001260 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001261 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001262 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001263
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001264run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001265 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001266 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001267 0 \
1268 -C "client hello, adding renegotiation extension" \
1269 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1270 -S "found renegotiation extension" \
1271 -s "server hello, secure renegotiation extension" \
1272 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001273 -C "=> renegotiate" \
1274 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001275 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001276 -S "SSL - An unexpected message was received from our peer" \
1277 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001279run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001280 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001281 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001282 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001283 0 \
1284 -C "client hello, adding renegotiation extension" \
1285 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1286 -S "found renegotiation extension" \
1287 -s "server hello, secure renegotiation extension" \
1288 -c "found renegotiation extension" \
1289 -C "=> renegotiate" \
1290 -S "=> renegotiate" \
1291 -s "write hello request" \
1292 -S "SSL - An unexpected message was received from our peer" \
1293 -S "failed"
1294
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001295# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001296run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001297 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001298 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001299 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001300 0 \
1301 -C "client hello, adding renegotiation extension" \
1302 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1303 -S "found renegotiation extension" \
1304 -s "server hello, secure renegotiation extension" \
1305 -c "found renegotiation extension" \
1306 -C "=> renegotiate" \
1307 -S "=> renegotiate" \
1308 -s "write hello request" \
1309 -S "SSL - An unexpected message was received from our peer" \
1310 -S "failed"
1311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001312run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001313 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001314 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001315 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001316 0 \
1317 -C "client hello, adding renegotiation extension" \
1318 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1319 -S "found renegotiation extension" \
1320 -s "server hello, secure renegotiation extension" \
1321 -c "found renegotiation extension" \
1322 -C "=> renegotiate" \
1323 -S "=> renegotiate" \
1324 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001325 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001326
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001327run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001328 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001329 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001330 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001331 0 \
1332 -c "client hello, adding renegotiation extension" \
1333 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1334 -s "found renegotiation extension" \
1335 -s "server hello, secure renegotiation extension" \
1336 -c "found renegotiation extension" \
1337 -c "=> renegotiate" \
1338 -s "=> renegotiate" \
1339 -s "write hello request" \
1340 -S "SSL - An unexpected message was received from our peer" \
1341 -S "failed"
1342
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001343run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001344 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001345 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1346 0 \
1347 -C "client hello, adding renegotiation extension" \
1348 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1349 -S "found renegotiation extension" \
1350 -s "server hello, secure renegotiation extension" \
1351 -c "found renegotiation extension" \
1352 -S "record counter limit reached: renegotiate" \
1353 -C "=> renegotiate" \
1354 -S "=> renegotiate" \
1355 -S "write hello request" \
1356 -S "SSL - An unexpected message was received from our peer" \
1357 -S "failed"
1358
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001359# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001360run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001361 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001362 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001363 0 \
1364 -c "client hello, adding renegotiation extension" \
1365 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1366 -s "found renegotiation extension" \
1367 -s "server hello, secure renegotiation extension" \
1368 -c "found renegotiation extension" \
1369 -s "record counter limit reached: renegotiate" \
1370 -c "=> renegotiate" \
1371 -s "=> renegotiate" \
1372 -s "write hello request" \
1373 -S "SSL - An unexpected message was received from our peer" \
1374 -S "failed"
1375
1376run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001377 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001378 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001379 0 \
1380 -c "client hello, adding renegotiation extension" \
1381 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1382 -s "found renegotiation extension" \
1383 -s "server hello, secure renegotiation extension" \
1384 -c "found renegotiation extension" \
1385 -s "record counter limit reached: renegotiate" \
1386 -c "=> renegotiate" \
1387 -s "=> renegotiate" \
1388 -s "write hello request" \
1389 -S "SSL - An unexpected message was received from our peer" \
1390 -S "failed"
1391
1392run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001393 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001394 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1395 0 \
1396 -C "client hello, adding renegotiation extension" \
1397 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1398 -S "found renegotiation extension" \
1399 -s "server hello, secure renegotiation extension" \
1400 -c "found renegotiation extension" \
1401 -S "record counter limit reached: renegotiate" \
1402 -C "=> renegotiate" \
1403 -S "=> renegotiate" \
1404 -S "write hello request" \
1405 -S "SSL - An unexpected message was received from our peer" \
1406 -S "failed"
1407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001408run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001409 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001410 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001411 0 \
1412 -c "client hello, adding renegotiation extension" \
1413 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1414 -s "found renegotiation extension" \
1415 -s "server hello, secure renegotiation extension" \
1416 -c "found renegotiation extension" \
1417 -c "=> renegotiate" \
1418 -s "=> renegotiate" \
1419 -S "write hello request"
1420
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001421run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001422 "$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 +02001423 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001424 0 \
1425 -c "client hello, adding renegotiation extension" \
1426 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1427 -s "found renegotiation extension" \
1428 -s "server hello, secure renegotiation extension" \
1429 -c "found renegotiation extension" \
1430 -c "=> renegotiate" \
1431 -s "=> renegotiate" \
1432 -s "write hello request"
1433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001434run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001435 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001436 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001437 0 \
1438 -c "client hello, adding renegotiation extension" \
1439 -c "found renegotiation extension" \
1440 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001441 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001442 -C "error" \
1443 -c "HTTP/1.0 200 [Oo][Kk]"
1444
Paul Bakker539d9722015-02-08 16:18:35 +01001445requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001446run_test "Renegotiation: gnutls server strict, client-initiated" \
1447 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001448 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001449 0 \
1450 -c "client hello, adding renegotiation extension" \
1451 -c "found renegotiation extension" \
1452 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001453 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001454 -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-initiated default" \
1459 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1460 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1461 1 \
1462 -c "client hello, adding renegotiation extension" \
1463 -C "found renegotiation extension" \
1464 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001465 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001466 -c "error" \
1467 -C "HTTP/1.0 200 [Oo][Kk]"
1468
Paul Bakker539d9722015-02-08 16:18:35 +01001469requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001470run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1471 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1472 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1473 allow_legacy=0" \
1474 1 \
1475 -c "client hello, adding renegotiation extension" \
1476 -C "found renegotiation extension" \
1477 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001478 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001479 -c "error" \
1480 -C "HTTP/1.0 200 [Oo][Kk]"
1481
Paul Bakker539d9722015-02-08 16:18:35 +01001482requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001483run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1484 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1485 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1486 allow_legacy=1" \
1487 0 \
1488 -c "client hello, adding renegotiation extension" \
1489 -C "found renegotiation extension" \
1490 -c "=> renegotiate" \
1491 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001492 -C "error" \
1493 -c "HTTP/1.0 200 [Oo][Kk]"
1494
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001495run_test "Renegotiation: DTLS, client-initiated" \
1496 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1497 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1498 0 \
1499 -c "client hello, adding renegotiation extension" \
1500 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1501 -s "found renegotiation extension" \
1502 -s "server hello, secure renegotiation extension" \
1503 -c "found renegotiation extension" \
1504 -c "=> renegotiate" \
1505 -s "=> renegotiate" \
1506 -S "write hello request"
1507
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001508run_test "Renegotiation: DTLS, server-initiated" \
1509 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001510 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1511 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001512 0 \
1513 -c "client hello, adding renegotiation extension" \
1514 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1515 -s "found renegotiation extension" \
1516 -s "server hello, secure renegotiation extension" \
1517 -c "found renegotiation extension" \
1518 -c "=> renegotiate" \
1519 -s "=> renegotiate" \
1520 -s "write hello request"
1521
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001522requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001523run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1524 "$G_SRV -u --mtu 4096" \
1525 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1526 0 \
1527 -c "client hello, adding renegotiation extension" \
1528 -c "found renegotiation extension" \
1529 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001530 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001531 -C "error" \
1532 -s "Extra-header:"
1533
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001534# Test for the "secure renegotation" extension only (no actual renegotiation)
1535
Paul Bakker539d9722015-02-08 16:18:35 +01001536requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001537run_test "Renego ext: gnutls server strict, client default" \
1538 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1539 "$P_CLI debug_level=3" \
1540 0 \
1541 -c "found renegotiation extension" \
1542 -C "error" \
1543 -c "HTTP/1.0 200 [Oo][Kk]"
1544
Paul Bakker539d9722015-02-08 16:18:35 +01001545requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001546run_test "Renego ext: gnutls server unsafe, client default" \
1547 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1548 "$P_CLI debug_level=3" \
1549 0 \
1550 -C "found renegotiation extension" \
1551 -C "error" \
1552 -c "HTTP/1.0 200 [Oo][Kk]"
1553
Paul Bakker539d9722015-02-08 16:18:35 +01001554requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001555run_test "Renego ext: gnutls server unsafe, client break legacy" \
1556 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1557 "$P_CLI debug_level=3 allow_legacy=-1" \
1558 1 \
1559 -C "found renegotiation extension" \
1560 -c "error" \
1561 -C "HTTP/1.0 200 [Oo][Kk]"
1562
Paul Bakker539d9722015-02-08 16:18:35 +01001563requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001564run_test "Renego ext: gnutls client strict, server default" \
1565 "$P_SRV debug_level=3" \
1566 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1567 0 \
1568 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1569 -s "server hello, secure renegotiation extension"
1570
Paul Bakker539d9722015-02-08 16:18:35 +01001571requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001572run_test "Renego ext: gnutls client unsafe, server default" \
1573 "$P_SRV debug_level=3" \
1574 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1575 0 \
1576 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1577 -S "server hello, secure renegotiation extension"
1578
Paul Bakker539d9722015-02-08 16:18:35 +01001579requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001580run_test "Renego ext: gnutls client unsafe, server break legacy" \
1581 "$P_SRV debug_level=3 allow_legacy=-1" \
1582 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1583 1 \
1584 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1585 -S "server hello, secure renegotiation extension"
1586
Janos Follath0b242342016-02-17 10:11:21 +00001587# Tests for silently dropping trailing extra bytes in .der certificates
1588
1589requires_gnutls
1590run_test "DER format: no trailing bytes" \
1591 "$P_SRV crt_file=data_files/server5-der0.crt \
1592 key_file=data_files/server5.key" \
1593 "$G_CLI " \
1594 0 \
1595 -c "Handshake was completed" \
1596
1597requires_gnutls
1598run_test "DER format: with a trailing zero byte" \
1599 "$P_SRV crt_file=data_files/server5-der1a.crt \
1600 key_file=data_files/server5.key" \
1601 "$G_CLI " \
1602 0 \
1603 -c "Handshake was completed" \
1604
1605requires_gnutls
1606run_test "DER format: with a trailing random byte" \
1607 "$P_SRV crt_file=data_files/server5-der1b.crt \
1608 key_file=data_files/server5.key" \
1609 "$G_CLI " \
1610 0 \
1611 -c "Handshake was completed" \
1612
1613requires_gnutls
1614run_test "DER format: with 2 trailing random bytes" \
1615 "$P_SRV crt_file=data_files/server5-der2.crt \
1616 key_file=data_files/server5.key" \
1617 "$G_CLI " \
1618 0 \
1619 -c "Handshake was completed" \
1620
1621requires_gnutls
1622run_test "DER format: with 4 trailing random bytes" \
1623 "$P_SRV crt_file=data_files/server5-der4.crt \
1624 key_file=data_files/server5.key" \
1625 "$G_CLI " \
1626 0 \
1627 -c "Handshake was completed" \
1628
1629requires_gnutls
1630run_test "DER format: with 8 trailing random bytes" \
1631 "$P_SRV crt_file=data_files/server5-der8.crt \
1632 key_file=data_files/server5.key" \
1633 "$G_CLI " \
1634 0 \
1635 -c "Handshake was completed" \
1636
1637requires_gnutls
1638run_test "DER format: with 9 trailing random bytes" \
1639 "$P_SRV crt_file=data_files/server5-der9.crt \
1640 key_file=data_files/server5.key" \
1641 "$G_CLI " \
1642 0 \
1643 -c "Handshake was completed" \
1644
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001645# Tests for auth_mode
1646
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001647run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001648 "$P_SRV crt_file=data_files/server5-badsign.crt \
1649 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001650 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001651 1 \
1652 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001653 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001654 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001655 -c "X509 - Certificate verification failed"
1656
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001657run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001658 "$P_SRV crt_file=data_files/server5-badsign.crt \
1659 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001660 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001661 0 \
1662 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001663 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001664 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001665 -C "X509 - Certificate verification failed"
1666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001667run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001668 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001669 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001670 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001671 0 \
1672 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001673 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001674 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001675 -C "X509 - Certificate verification failed"
1676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001677run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001678 "$P_SRV debug_level=3 auth_mode=required" \
1679 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001680 key_file=data_files/server5.key" \
1681 1 \
1682 -S "skip write certificate request" \
1683 -C "skip parse certificate request" \
1684 -c "got a certificate request" \
1685 -C "skip write certificate" \
1686 -C "skip write certificate verify" \
1687 -S "skip parse certificate verify" \
1688 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001689 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001690 -s "! mbedtls_ssl_handshake returned" \
1691 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001692 -s "X509 - Certificate verification failed"
1693
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001694run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001695 "$P_SRV debug_level=3 auth_mode=optional" \
1696 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001697 key_file=data_files/server5.key" \
1698 0 \
1699 -S "skip write certificate request" \
1700 -C "skip parse certificate request" \
1701 -c "got a certificate request" \
1702 -C "skip write certificate" \
1703 -C "skip write certificate verify" \
1704 -S "skip parse certificate verify" \
1705 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001706 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001707 -S "! mbedtls_ssl_handshake returned" \
1708 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001709 -S "X509 - Certificate verification failed"
1710
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001711run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001712 "$P_SRV debug_level=3 auth_mode=none" \
1713 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001714 key_file=data_files/server5.key" \
1715 0 \
1716 -s "skip write certificate request" \
1717 -C "skip parse certificate request" \
1718 -c "got no certificate request" \
1719 -c "skip write certificate" \
1720 -c "skip write certificate verify" \
1721 -s "skip parse certificate verify" \
1722 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001723 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001724 -S "! mbedtls_ssl_handshake returned" \
1725 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001726 -S "X509 - Certificate verification failed"
1727
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001728run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001729 "$P_SRV debug_level=3 auth_mode=optional" \
1730 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001731 0 \
1732 -S "skip write certificate request" \
1733 -C "skip parse certificate request" \
1734 -c "got a certificate request" \
1735 -C "skip write certificate$" \
1736 -C "got no certificate to send" \
1737 -S "SSLv3 client has no certificate" \
1738 -c "skip write certificate verify" \
1739 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001740 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001741 -S "! mbedtls_ssl_handshake returned" \
1742 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001743 -S "X509 - Certificate verification failed"
1744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001745run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001746 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001747 "$O_CLI" \
1748 0 \
1749 -S "skip write certificate request" \
1750 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001751 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001752 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001753 -S "X509 - Certificate verification failed"
1754
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001755run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001756 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001757 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001758 0 \
1759 -C "skip parse certificate request" \
1760 -c "got a certificate request" \
1761 -C "skip write certificate$" \
1762 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001763 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001764
Janos Follathe2681a42016-03-07 15:57:05 +00001765requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001766run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001767 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001768 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001769 0 \
1770 -S "skip write certificate request" \
1771 -C "skip parse certificate request" \
1772 -c "got a certificate request" \
1773 -C "skip write certificate$" \
1774 -c "skip write certificate verify" \
1775 -c "got no certificate to send" \
1776 -s "SSLv3 client has no certificate" \
1777 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001778 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001779 -S "! mbedtls_ssl_handshake returned" \
1780 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001781 -S "X509 - Certificate verification failed"
1782
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001783# Tests for certificate selection based on SHA verson
1784
1785run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1786 "$P_SRV crt_file=data_files/server5.crt \
1787 key_file=data_files/server5.key \
1788 crt_file2=data_files/server5-sha1.crt \
1789 key_file2=data_files/server5.key" \
1790 "$P_CLI force_version=tls1_2" \
1791 0 \
1792 -c "signed using.*ECDSA with SHA256" \
1793 -C "signed using.*ECDSA with SHA1"
1794
1795run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1796 "$P_SRV crt_file=data_files/server5.crt \
1797 key_file=data_files/server5.key \
1798 crt_file2=data_files/server5-sha1.crt \
1799 key_file2=data_files/server5.key" \
1800 "$P_CLI force_version=tls1_1" \
1801 0 \
1802 -C "signed using.*ECDSA with SHA256" \
1803 -c "signed using.*ECDSA with SHA1"
1804
1805run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1806 "$P_SRV crt_file=data_files/server5.crt \
1807 key_file=data_files/server5.key \
1808 crt_file2=data_files/server5-sha1.crt \
1809 key_file2=data_files/server5.key" \
1810 "$P_CLI force_version=tls1" \
1811 0 \
1812 -C "signed using.*ECDSA with SHA256" \
1813 -c "signed using.*ECDSA with SHA1"
1814
1815run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1816 "$P_SRV crt_file=data_files/server5.crt \
1817 key_file=data_files/server5.key \
1818 crt_file2=data_files/server6.crt \
1819 key_file2=data_files/server6.key" \
1820 "$P_CLI force_version=tls1_1" \
1821 0 \
1822 -c "serial number.*09" \
1823 -c "signed using.*ECDSA with SHA256" \
1824 -C "signed using.*ECDSA with SHA1"
1825
1826run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1827 "$P_SRV crt_file=data_files/server6.crt \
1828 key_file=data_files/server6.key \
1829 crt_file2=data_files/server5.crt \
1830 key_file2=data_files/server5.key" \
1831 "$P_CLI force_version=tls1_1" \
1832 0 \
1833 -c "serial number.*0A" \
1834 -c "signed using.*ECDSA with SHA256" \
1835 -C "signed using.*ECDSA with SHA1"
1836
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001837# tests for SNI
1838
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001839run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001840 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001841 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001842 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001843 0 \
1844 -S "parse ServerName extension" \
1845 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1846 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001847
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001848run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001849 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001850 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001851 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 +02001852 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001853 0 \
1854 -s "parse ServerName extension" \
1855 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1856 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001858run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001859 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001860 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001861 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 +02001862 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001863 0 \
1864 -s "parse ServerName extension" \
1865 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1866 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001868run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001869 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001870 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001871 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 +02001872 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001873 1 \
1874 -s "parse ServerName extension" \
1875 -s "ssl_sni_wrapper() returned" \
1876 -s "mbedtls_ssl_handshake returned" \
1877 -c "mbedtls_ssl_handshake returned" \
1878 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001879
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001880run_test "SNI: client auth no override: optional" \
1881 "$P_SRV debug_level=3 auth_mode=optional \
1882 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1883 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1884 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001885 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001886 -S "skip write certificate request" \
1887 -C "skip parse certificate request" \
1888 -c "got a certificate request" \
1889 -C "skip write certificate" \
1890 -C "skip write certificate verify" \
1891 -S "skip parse certificate verify"
1892
1893run_test "SNI: client auth override: none -> optional" \
1894 "$P_SRV debug_level=3 auth_mode=none \
1895 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1896 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1897 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001898 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001899 -S "skip write certificate request" \
1900 -C "skip parse certificate request" \
1901 -c "got a certificate request" \
1902 -C "skip write certificate" \
1903 -C "skip write certificate verify" \
1904 -S "skip parse certificate verify"
1905
1906run_test "SNI: client auth override: optional -> none" \
1907 "$P_SRV debug_level=3 auth_mode=optional \
1908 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1909 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1910 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001911 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001912 -s "skip write certificate request" \
1913 -C "skip parse certificate request" \
1914 -c "got no certificate request" \
1915 -c "skip write certificate" \
1916 -c "skip write certificate verify" \
1917 -s "skip parse certificate verify"
1918
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001919run_test "SNI: CA no override" \
1920 "$P_SRV debug_level=3 auth_mode=optional \
1921 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1922 ca_file=data_files/test-ca.crt \
1923 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1924 "$P_CLI debug_level=3 server_name=localhost \
1925 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1926 1 \
1927 -S "skip write certificate request" \
1928 -C "skip parse certificate request" \
1929 -c "got a certificate request" \
1930 -C "skip write certificate" \
1931 -C "skip write certificate verify" \
1932 -S "skip parse certificate verify" \
1933 -s "x509_verify_cert() returned" \
1934 -s "! The certificate is not correctly signed by the trusted CA" \
1935 -S "The certificate has been revoked (is on a CRL)"
1936
1937run_test "SNI: CA override" \
1938 "$P_SRV debug_level=3 auth_mode=optional \
1939 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1940 ca_file=data_files/test-ca.crt \
1941 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1942 "$P_CLI debug_level=3 server_name=localhost \
1943 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1944 0 \
1945 -S "skip write certificate request" \
1946 -C "skip parse certificate request" \
1947 -c "got a certificate request" \
1948 -C "skip write certificate" \
1949 -C "skip write certificate verify" \
1950 -S "skip parse certificate verify" \
1951 -S "x509_verify_cert() returned" \
1952 -S "! The certificate is not correctly signed by the trusted CA" \
1953 -S "The certificate has been revoked (is on a CRL)"
1954
1955run_test "SNI: CA override with CRL" \
1956 "$P_SRV debug_level=3 auth_mode=optional \
1957 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1958 ca_file=data_files/test-ca.crt \
1959 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1960 "$P_CLI debug_level=3 server_name=localhost \
1961 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1962 1 \
1963 -S "skip write certificate request" \
1964 -C "skip parse certificate request" \
1965 -c "got a certificate request" \
1966 -C "skip write certificate" \
1967 -C "skip write certificate verify" \
1968 -S "skip parse certificate verify" \
1969 -s "x509_verify_cert() returned" \
1970 -S "! The certificate is not correctly signed by the trusted CA" \
1971 -s "The certificate has been revoked (is on a CRL)"
1972
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001973# Tests for non-blocking I/O: exercise a variety of handshake flows
1974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001975run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001976 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1977 "$P_CLI nbio=2 tickets=0" \
1978 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001979 -S "mbedtls_ssl_handshake returned" \
1980 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001981 -c "Read from server: .* bytes read"
1982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001983run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001984 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1985 "$P_CLI nbio=2 tickets=0" \
1986 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001987 -S "mbedtls_ssl_handshake returned" \
1988 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001989 -c "Read from server: .* bytes read"
1990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001991run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001992 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1993 "$P_CLI nbio=2 tickets=1" \
1994 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001995 -S "mbedtls_ssl_handshake returned" \
1996 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001997 -c "Read from server: .* bytes read"
1998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001999run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002000 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2001 "$P_CLI nbio=2 tickets=1" \
2002 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002003 -S "mbedtls_ssl_handshake returned" \
2004 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002005 -c "Read from server: .* bytes read"
2006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002007run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002008 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2009 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2010 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002011 -S "mbedtls_ssl_handshake returned" \
2012 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002013 -c "Read from server: .* bytes read"
2014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002015run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002016 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2017 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2018 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002019 -S "mbedtls_ssl_handshake returned" \
2020 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002021 -c "Read from server: .* bytes read"
2022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002023run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002024 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2025 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2026 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002027 -S "mbedtls_ssl_handshake returned" \
2028 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002029 -c "Read from server: .* bytes read"
2030
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002031# Tests for version negotiation
2032
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002033run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002034 "$P_SRV" \
2035 "$P_CLI" \
2036 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002037 -S "mbedtls_ssl_handshake returned" \
2038 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002039 -s "Protocol is TLSv1.2" \
2040 -c "Protocol is TLSv1.2"
2041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002042run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002043 "$P_SRV" \
2044 "$P_CLI max_version=tls1_1" \
2045 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002046 -S "mbedtls_ssl_handshake returned" \
2047 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002048 -s "Protocol is TLSv1.1" \
2049 -c "Protocol is TLSv1.1"
2050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002051run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002052 "$P_SRV max_version=tls1_1" \
2053 "$P_CLI" \
2054 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002055 -S "mbedtls_ssl_handshake returned" \
2056 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002057 -s "Protocol is TLSv1.1" \
2058 -c "Protocol is TLSv1.1"
2059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002060run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002061 "$P_SRV max_version=tls1_1" \
2062 "$P_CLI max_version=tls1_1" \
2063 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002064 -S "mbedtls_ssl_handshake returned" \
2065 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002066 -s "Protocol is TLSv1.1" \
2067 -c "Protocol is TLSv1.1"
2068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002069run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002070 "$P_SRV min_version=tls1_1" \
2071 "$P_CLI max_version=tls1_1" \
2072 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002073 -S "mbedtls_ssl_handshake returned" \
2074 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002075 -s "Protocol is TLSv1.1" \
2076 -c "Protocol is TLSv1.1"
2077
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002078run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002079 "$P_SRV max_version=tls1_1" \
2080 "$P_CLI min_version=tls1_1" \
2081 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002082 -S "mbedtls_ssl_handshake returned" \
2083 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002084 -s "Protocol is TLSv1.1" \
2085 -c "Protocol is TLSv1.1"
2086
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002087run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002088 "$P_SRV max_version=tls1_1" \
2089 "$P_CLI min_version=tls1_2" \
2090 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002091 -s "mbedtls_ssl_handshake returned" \
2092 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002093 -c "SSL - Handshake protocol not within min/max boundaries"
2094
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002095run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002096 "$P_SRV min_version=tls1_2" \
2097 "$P_CLI max_version=tls1_1" \
2098 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002099 -s "mbedtls_ssl_handshake returned" \
2100 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002101 -s "SSL - Handshake protocol not within min/max boundaries"
2102
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002103# Tests for ALPN extension
2104
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002105run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002106 "$P_SRV debug_level=3" \
2107 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002108 0 \
2109 -C "client hello, adding alpn extension" \
2110 -S "found alpn extension" \
2111 -C "got an alert message, type: \\[2:120]" \
2112 -S "server hello, adding alpn extension" \
2113 -C "found alpn extension " \
2114 -C "Application Layer Protocol is" \
2115 -S "Application Layer Protocol is"
2116
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002117run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002118 "$P_SRV debug_level=3" \
2119 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002120 0 \
2121 -c "client hello, adding alpn extension" \
2122 -s "found alpn extension" \
2123 -C "got an alert message, type: \\[2:120]" \
2124 -S "server hello, adding alpn extension" \
2125 -C "found alpn extension " \
2126 -c "Application Layer Protocol is (none)" \
2127 -S "Application Layer Protocol is"
2128
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002129run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002130 "$P_SRV debug_level=3 alpn=abc,1234" \
2131 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002132 0 \
2133 -C "client hello, adding alpn extension" \
2134 -S "found alpn extension" \
2135 -C "got an alert message, type: \\[2:120]" \
2136 -S "server hello, adding alpn extension" \
2137 -C "found alpn extension " \
2138 -C "Application Layer Protocol is" \
2139 -s "Application Layer Protocol is (none)"
2140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002141run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002142 "$P_SRV debug_level=3 alpn=abc,1234" \
2143 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002144 0 \
2145 -c "client hello, adding alpn extension" \
2146 -s "found alpn extension" \
2147 -C "got an alert message, type: \\[2:120]" \
2148 -s "server hello, adding alpn extension" \
2149 -c "found alpn extension" \
2150 -c "Application Layer Protocol is abc" \
2151 -s "Application Layer Protocol is abc"
2152
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002153run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002154 "$P_SRV debug_level=3 alpn=abc,1234" \
2155 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002156 0 \
2157 -c "client hello, adding alpn extension" \
2158 -s "found alpn extension" \
2159 -C "got an alert message, type: \\[2:120]" \
2160 -s "server hello, adding alpn extension" \
2161 -c "found alpn extension" \
2162 -c "Application Layer Protocol is abc" \
2163 -s "Application Layer Protocol is abc"
2164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002165run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002166 "$P_SRV debug_level=3 alpn=abc,1234" \
2167 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002168 0 \
2169 -c "client hello, adding alpn extension" \
2170 -s "found alpn extension" \
2171 -C "got an alert message, type: \\[2:120]" \
2172 -s "server hello, adding alpn extension" \
2173 -c "found alpn extension" \
2174 -c "Application Layer Protocol is 1234" \
2175 -s "Application Layer Protocol is 1234"
2176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002177run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002178 "$P_SRV debug_level=3 alpn=abc,123" \
2179 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002180 1 \
2181 -c "client hello, adding alpn extension" \
2182 -s "found alpn extension" \
2183 -c "got an alert message, type: \\[2:120]" \
2184 -S "server hello, adding alpn extension" \
2185 -C "found alpn extension" \
2186 -C "Application Layer Protocol is 1234" \
2187 -S "Application Layer Protocol is 1234"
2188
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002189
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002190# Tests for keyUsage in leaf certificates, part 1:
2191# server-side certificate/suite selection
2192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002193run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002194 "$P_SRV key_file=data_files/server2.key \
2195 crt_file=data_files/server2.ku-ds.crt" \
2196 "$P_CLI" \
2197 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002198 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002199
2200
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002201run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002202 "$P_SRV key_file=data_files/server2.key \
2203 crt_file=data_files/server2.ku-ke.crt" \
2204 "$P_CLI" \
2205 0 \
2206 -c "Ciphersuite is TLS-RSA-WITH-"
2207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002208run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002209 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002210 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002211 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002212 1 \
2213 -C "Ciphersuite is "
2214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002215run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002216 "$P_SRV key_file=data_files/server5.key \
2217 crt_file=data_files/server5.ku-ds.crt" \
2218 "$P_CLI" \
2219 0 \
2220 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2221
2222
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002223run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002224 "$P_SRV key_file=data_files/server5.key \
2225 crt_file=data_files/server5.ku-ka.crt" \
2226 "$P_CLI" \
2227 0 \
2228 -c "Ciphersuite is TLS-ECDH-"
2229
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002230run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002231 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002232 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002233 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002234 1 \
2235 -C "Ciphersuite is "
2236
2237# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002238# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002239
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002240run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002241 "$O_SRV -key data_files/server2.key \
2242 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002243 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002244 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2245 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002246 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002247 -C "Processing of the Certificate handshake message failed" \
2248 -c "Ciphersuite is TLS-"
2249
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002250run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002251 "$O_SRV -key data_files/server2.key \
2252 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002253 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002254 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2255 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002256 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002257 -C "Processing of the Certificate handshake message failed" \
2258 -c "Ciphersuite is TLS-"
2259
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002260run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002261 "$O_SRV -key data_files/server2.key \
2262 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002263 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002264 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2265 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002266 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002267 -C "Processing of the Certificate handshake message failed" \
2268 -c "Ciphersuite is TLS-"
2269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002270run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002271 "$O_SRV -key data_files/server2.key \
2272 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002273 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002274 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2275 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002276 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002277 -c "Processing of the Certificate handshake message failed" \
2278 -C "Ciphersuite is TLS-"
2279
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002280run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2281 "$O_SRV -key data_files/server2.key \
2282 -cert data_files/server2.ku-ke.crt" \
2283 "$P_CLI debug_level=1 auth_mode=optional \
2284 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2285 0 \
2286 -c "bad certificate (usage extensions)" \
2287 -C "Processing of the Certificate handshake message failed" \
2288 -c "Ciphersuite is TLS-" \
2289 -c "! Usage does not match the keyUsage extension"
2290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002291run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002292 "$O_SRV -key data_files/server2.key \
2293 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002294 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002295 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2296 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002297 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002298 -C "Processing of the Certificate handshake message failed" \
2299 -c "Ciphersuite is TLS-"
2300
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002301run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002302 "$O_SRV -key data_files/server2.key \
2303 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002304 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002305 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2306 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002307 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002308 -c "Processing of the Certificate handshake message failed" \
2309 -C "Ciphersuite is TLS-"
2310
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002311run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2312 "$O_SRV -key data_files/server2.key \
2313 -cert data_files/server2.ku-ds.crt" \
2314 "$P_CLI debug_level=1 auth_mode=optional \
2315 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2316 0 \
2317 -c "bad certificate (usage extensions)" \
2318 -C "Processing of the Certificate handshake message failed" \
2319 -c "Ciphersuite is TLS-" \
2320 -c "! Usage does not match the keyUsage extension"
2321
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002322# Tests for keyUsage in leaf certificates, part 3:
2323# server-side checking of client cert
2324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002325run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002326 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002327 "$O_CLI -key data_files/server2.key \
2328 -cert data_files/server2.ku-ds.crt" \
2329 0 \
2330 -S "bad certificate (usage extensions)" \
2331 -S "Processing of the Certificate handshake message failed"
2332
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002333run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002334 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002335 "$O_CLI -key data_files/server2.key \
2336 -cert data_files/server2.ku-ke.crt" \
2337 0 \
2338 -s "bad certificate (usage extensions)" \
2339 -S "Processing of the Certificate handshake message failed"
2340
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002341run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002342 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002343 "$O_CLI -key data_files/server2.key \
2344 -cert data_files/server2.ku-ke.crt" \
2345 1 \
2346 -s "bad certificate (usage extensions)" \
2347 -s "Processing of the Certificate handshake message failed"
2348
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002349run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002350 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002351 "$O_CLI -key data_files/server5.key \
2352 -cert data_files/server5.ku-ds.crt" \
2353 0 \
2354 -S "bad certificate (usage extensions)" \
2355 -S "Processing of the Certificate handshake message failed"
2356
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002357run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002358 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002359 "$O_CLI -key data_files/server5.key \
2360 -cert data_files/server5.ku-ka.crt" \
2361 0 \
2362 -s "bad certificate (usage extensions)" \
2363 -S "Processing of the Certificate handshake message failed"
2364
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002365# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002367run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002368 "$P_SRV key_file=data_files/server5.key \
2369 crt_file=data_files/server5.eku-srv.crt" \
2370 "$P_CLI" \
2371 0
2372
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002373run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002374 "$P_SRV key_file=data_files/server5.key \
2375 crt_file=data_files/server5.eku-srv.crt" \
2376 "$P_CLI" \
2377 0
2378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002379run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002380 "$P_SRV key_file=data_files/server5.key \
2381 crt_file=data_files/server5.eku-cs_any.crt" \
2382 "$P_CLI" \
2383 0
2384
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002385run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002386 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002387 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002388 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002389 1
2390
2391# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2392
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002393run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002394 "$O_SRV -key data_files/server5.key \
2395 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002396 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002397 0 \
2398 -C "bad certificate (usage extensions)" \
2399 -C "Processing of the Certificate handshake message failed" \
2400 -c "Ciphersuite is TLS-"
2401
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002402run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002403 "$O_SRV -key data_files/server5.key \
2404 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002405 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002406 0 \
2407 -C "bad certificate (usage extensions)" \
2408 -C "Processing of the Certificate handshake message failed" \
2409 -c "Ciphersuite is TLS-"
2410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002411run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002412 "$O_SRV -key data_files/server5.key \
2413 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002414 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002415 0 \
2416 -C "bad certificate (usage extensions)" \
2417 -C "Processing of the Certificate handshake message failed" \
2418 -c "Ciphersuite is TLS-"
2419
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002420run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002421 "$O_SRV -key data_files/server5.key \
2422 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002423 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002424 1 \
2425 -c "bad certificate (usage extensions)" \
2426 -c "Processing of the Certificate handshake message failed" \
2427 -C "Ciphersuite is TLS-"
2428
2429# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002431run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002432 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002433 "$O_CLI -key data_files/server5.key \
2434 -cert data_files/server5.eku-cli.crt" \
2435 0 \
2436 -S "bad certificate (usage extensions)" \
2437 -S "Processing of the Certificate handshake message failed"
2438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002439run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002440 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002441 "$O_CLI -key data_files/server5.key \
2442 -cert data_files/server5.eku-srv_cli.crt" \
2443 0 \
2444 -S "bad certificate (usage extensions)" \
2445 -S "Processing of the Certificate handshake message failed"
2446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002447run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002448 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002449 "$O_CLI -key data_files/server5.key \
2450 -cert data_files/server5.eku-cs_any.crt" \
2451 0 \
2452 -S "bad certificate (usage extensions)" \
2453 -S "Processing of the Certificate handshake message failed"
2454
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002455run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002456 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002457 "$O_CLI -key data_files/server5.key \
2458 -cert data_files/server5.eku-cs.crt" \
2459 0 \
2460 -s "bad certificate (usage extensions)" \
2461 -S "Processing of the Certificate handshake message failed"
2462
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002463run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002464 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002465 "$O_CLI -key data_files/server5.key \
2466 -cert data_files/server5.eku-cs.crt" \
2467 1 \
2468 -s "bad certificate (usage extensions)" \
2469 -s "Processing of the Certificate handshake message failed"
2470
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002471# Tests for DHM parameters loading
2472
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002473run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002474 "$P_SRV" \
2475 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2476 debug_level=3" \
2477 0 \
2478 -c "value of 'DHM: P ' (2048 bits)" \
2479 -c "value of 'DHM: G ' (2048 bits)"
2480
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002481run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002482 "$P_SRV dhm_file=data_files/dhparams.pem" \
2483 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2484 debug_level=3" \
2485 0 \
2486 -c "value of 'DHM: P ' (1024 bits)" \
2487 -c "value of 'DHM: G ' (2 bits)"
2488
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002489# Tests for DHM client-side size checking
2490
2491run_test "DHM size: server default, client default, OK" \
2492 "$P_SRV" \
2493 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2494 debug_level=1" \
2495 0 \
2496 -C "DHM prime too short:"
2497
2498run_test "DHM size: server default, client 2048, OK" \
2499 "$P_SRV" \
2500 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2501 debug_level=1 dhmlen=2048" \
2502 0 \
2503 -C "DHM prime too short:"
2504
2505run_test "DHM size: server 1024, client default, OK" \
2506 "$P_SRV dhm_file=data_files/dhparams.pem" \
2507 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2508 debug_level=1" \
2509 0 \
2510 -C "DHM prime too short:"
2511
2512run_test "DHM size: server 1000, client default, rejected" \
2513 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2514 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2515 debug_level=1" \
2516 1 \
2517 -c "DHM prime too short:"
2518
2519run_test "DHM size: server default, client 2049, rejected" \
2520 "$P_SRV" \
2521 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2522 debug_level=1 dhmlen=2049" \
2523 1 \
2524 -c "DHM prime too short:"
2525
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002526# Tests for PSK callback
2527
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002528run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002529 "$P_SRV psk=abc123 psk_identity=foo" \
2530 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2531 psk_identity=foo psk=abc123" \
2532 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002533 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002534 -S "SSL - Unknown identity received" \
2535 -S "SSL - Verification of the message MAC failed"
2536
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002537run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002538 "$P_SRV" \
2539 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2540 psk_identity=foo psk=abc123" \
2541 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002542 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002543 -S "SSL - Unknown identity received" \
2544 -S "SSL - Verification of the message MAC failed"
2545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002546run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002547 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2548 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2549 psk_identity=foo psk=abc123" \
2550 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002551 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002552 -s "SSL - Unknown identity received" \
2553 -S "SSL - Verification of the message MAC failed"
2554
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002555run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002556 "$P_SRV psk_list=abc,dead,def,beef" \
2557 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2558 psk_identity=abc psk=dead" \
2559 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002560 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002561 -S "SSL - Unknown identity received" \
2562 -S "SSL - Verification of the message MAC failed"
2563
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002564run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002565 "$P_SRV psk_list=abc,dead,def,beef" \
2566 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2567 psk_identity=def psk=beef" \
2568 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002569 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002570 -S "SSL - Unknown identity received" \
2571 -S "SSL - Verification of the message MAC failed"
2572
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002573run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002574 "$P_SRV psk_list=abc,dead,def,beef" \
2575 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2576 psk_identity=ghi psk=beef" \
2577 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002578 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002579 -s "SSL - Unknown identity received" \
2580 -S "SSL - Verification of the message MAC failed"
2581
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002582run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002583 "$P_SRV psk_list=abc,dead,def,beef" \
2584 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2585 psk_identity=abc psk=beef" \
2586 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002587 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002588 -S "SSL - Unknown identity received" \
2589 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002590
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002591# Tests for EC J-PAKE
2592
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002593requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002594run_test "ECJPAKE: client not configured" \
2595 "$P_SRV debug_level=3" \
2596 "$P_CLI debug_level=3" \
2597 0 \
2598 -C "add ciphersuite: c0ff" \
2599 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002600 -S "found ecjpake kkpp extension" \
2601 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002602 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002603 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002604 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002605 -S "None of the common ciphersuites is usable"
2606
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002607requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002608run_test "ECJPAKE: server not configured" \
2609 "$P_SRV debug_level=3" \
2610 "$P_CLI debug_level=3 ecjpake_pw=bla \
2611 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2612 1 \
2613 -c "add ciphersuite: c0ff" \
2614 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002615 -s "found ecjpake kkpp extension" \
2616 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002617 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002618 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002619 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002620 -s "None of the common ciphersuites is usable"
2621
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002622requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002623run_test "ECJPAKE: working, TLS" \
2624 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2625 "$P_CLI debug_level=3 ecjpake_pw=bla \
2626 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002627 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002628 -c "add ciphersuite: c0ff" \
2629 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002630 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002631 -s "found ecjpake kkpp extension" \
2632 -S "skip ecjpake kkpp extension" \
2633 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002634 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002635 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002636 -S "None of the common ciphersuites is usable" \
2637 -S "SSL - Verification of the message MAC failed"
2638
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002639requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002640run_test "ECJPAKE: password mismatch, TLS" \
2641 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2642 "$P_CLI debug_level=3 ecjpake_pw=bad \
2643 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2644 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002645 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002646 -s "SSL - Verification of the message MAC failed"
2647
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002648requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002649run_test "ECJPAKE: working, DTLS" \
2650 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2651 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2652 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2653 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002654 -c "re-using cached ecjpake parameters" \
2655 -S "SSL - Verification of the message MAC failed"
2656
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002657requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002658run_test "ECJPAKE: working, DTLS, no cookie" \
2659 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2660 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2661 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2662 0 \
2663 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002664 -S "SSL - Verification of the message MAC failed"
2665
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002666requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002667run_test "ECJPAKE: password mismatch, DTLS" \
2668 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2669 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2670 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2671 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002672 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002673 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002674
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002675# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002676requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002677run_test "ECJPAKE: working, DTLS, nolog" \
2678 "$P_SRV dtls=1 ecjpake_pw=bla" \
2679 "$P_CLI dtls=1 ecjpake_pw=bla \
2680 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2681 0
2682
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002683# Tests for ciphersuites per version
2684
Janos Follathe2681a42016-03-07 15:57:05 +00002685requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002686run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002687 "$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 +02002688 "$P_CLI force_version=ssl3" \
2689 0 \
2690 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2691
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002692run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002693 "$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 +01002694 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002695 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002696 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002697
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002698run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002699 "$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 +02002700 "$P_CLI force_version=tls1_1" \
2701 0 \
2702 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2703
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002704run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002705 "$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 +02002706 "$P_CLI force_version=tls1_2" \
2707 0 \
2708 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2709
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002710# Test for ClientHello without extensions
2711
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002712requires_gnutls
2713run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002714 "$P_SRV debug_level=3" \
2715 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2716 0 \
2717 -s "dumping 'client hello extensions' (0 bytes)"
2718
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002719# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002720
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002721run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002722 "$P_SRV" \
2723 "$P_CLI request_size=100" \
2724 0 \
2725 -s "Read from client: 100 bytes read$"
2726
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002727run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002728 "$P_SRV" \
2729 "$P_CLI request_size=500" \
2730 0 \
2731 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002732
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002733# Tests for small packets
2734
Janos Follathe2681a42016-03-07 15:57:05 +00002735requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002736run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002737 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002738 "$P_CLI request_size=1 force_version=ssl3 \
2739 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2740 0 \
2741 -s "Read from client: 1 bytes read"
2742
Janos Follathe2681a42016-03-07 15:57:05 +00002743requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002744run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002745 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002746 "$P_CLI request_size=1 force_version=ssl3 \
2747 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2748 0 \
2749 -s "Read from client: 1 bytes read"
2750
2751run_test "Small packet TLS 1.0 BlockCipher" \
2752 "$P_SRV" \
2753 "$P_CLI request_size=1 force_version=tls1 \
2754 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2755 0 \
2756 -s "Read from client: 1 bytes read"
2757
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002758run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2759 "$P_SRV" \
2760 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2761 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2762 0 \
2763 -s "Read from client: 1 bytes read"
2764
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002765run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2766 "$P_SRV" \
2767 "$P_CLI request_size=1 force_version=tls1 \
2768 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2769 trunc_hmac=1" \
2770 0 \
2771 -s "Read from client: 1 bytes read"
2772
2773run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002774 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002775 "$P_CLI request_size=1 force_version=tls1 \
2776 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2777 trunc_hmac=1" \
2778 0 \
2779 -s "Read from client: 1 bytes read"
2780
2781run_test "Small packet TLS 1.1 BlockCipher" \
2782 "$P_SRV" \
2783 "$P_CLI request_size=1 force_version=tls1_1 \
2784 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2785 0 \
2786 -s "Read from client: 1 bytes read"
2787
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002788run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2789 "$P_SRV" \
2790 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2791 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2792 0 \
2793 -s "Read from client: 1 bytes read"
2794
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002795run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002796 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002797 "$P_CLI request_size=1 force_version=tls1_1 \
2798 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2799 0 \
2800 -s "Read from client: 1 bytes read"
2801
2802run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2803 "$P_SRV" \
2804 "$P_CLI request_size=1 force_version=tls1_1 \
2805 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2806 trunc_hmac=1" \
2807 0 \
2808 -s "Read from client: 1 bytes read"
2809
2810run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002811 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002812 "$P_CLI request_size=1 force_version=tls1_1 \
2813 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2814 trunc_hmac=1" \
2815 0 \
2816 -s "Read from client: 1 bytes read"
2817
2818run_test "Small packet TLS 1.2 BlockCipher" \
2819 "$P_SRV" \
2820 "$P_CLI request_size=1 force_version=tls1_2 \
2821 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2822 0 \
2823 -s "Read from client: 1 bytes read"
2824
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002825run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2826 "$P_SRV" \
2827 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2828 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2829 0 \
2830 -s "Read from client: 1 bytes read"
2831
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002832run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2833 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002834 "$P_CLI request_size=1 force_version=tls1_2 \
2835 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002836 0 \
2837 -s "Read from client: 1 bytes read"
2838
2839run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2840 "$P_SRV" \
2841 "$P_CLI request_size=1 force_version=tls1_2 \
2842 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2843 trunc_hmac=1" \
2844 0 \
2845 -s "Read from client: 1 bytes read"
2846
2847run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002848 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002849 "$P_CLI request_size=1 force_version=tls1_2 \
2850 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2851 0 \
2852 -s "Read from client: 1 bytes read"
2853
2854run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002855 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002856 "$P_CLI request_size=1 force_version=tls1_2 \
2857 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2858 trunc_hmac=1" \
2859 0 \
2860 -s "Read from client: 1 bytes read"
2861
2862run_test "Small packet TLS 1.2 AEAD" \
2863 "$P_SRV" \
2864 "$P_CLI request_size=1 force_version=tls1_2 \
2865 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2866 0 \
2867 -s "Read from client: 1 bytes read"
2868
2869run_test "Small packet TLS 1.2 AEAD shorter tag" \
2870 "$P_SRV" \
2871 "$P_CLI request_size=1 force_version=tls1_2 \
2872 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2873 0 \
2874 -s "Read from client: 1 bytes read"
2875
Janos Follath00efff72016-05-06 13:48:23 +01002876# A test for extensions in SSLv3
2877
2878requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2879run_test "SSLv3 with extensions, server side" \
2880 "$P_SRV min_version=ssl3 debug_level=3" \
2881 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2882 0 \
2883 -S "dumping 'client hello extensions'" \
2884 -S "server hello, total extension length:"
2885
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002886# Test for large packets
2887
Janos Follathe2681a42016-03-07 15:57:05 +00002888requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002889run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002890 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002891 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002892 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2893 0 \
2894 -s "Read from client: 16384 bytes read"
2895
Janos Follathe2681a42016-03-07 15:57:05 +00002896requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002897run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002898 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002899 "$P_CLI request_size=16384 force_version=ssl3 \
2900 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2901 0 \
2902 -s "Read from client: 16384 bytes read"
2903
2904run_test "Large packet TLS 1.0 BlockCipher" \
2905 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002906 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002907 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2908 0 \
2909 -s "Read from client: 16384 bytes read"
2910
2911run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2912 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002913 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002914 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2915 trunc_hmac=1" \
2916 0 \
2917 -s "Read from client: 16384 bytes read"
2918
2919run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002920 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002921 "$P_CLI request_size=16384 force_version=tls1 \
2922 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2923 trunc_hmac=1" \
2924 0 \
2925 -s "Read from client: 16384 bytes read"
2926
2927run_test "Large packet TLS 1.1 BlockCipher" \
2928 "$P_SRV" \
2929 "$P_CLI request_size=16384 force_version=tls1_1 \
2930 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2931 0 \
2932 -s "Read from client: 16384 bytes read"
2933
2934run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002935 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002936 "$P_CLI request_size=16384 force_version=tls1_1 \
2937 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2938 0 \
2939 -s "Read from client: 16384 bytes read"
2940
2941run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2942 "$P_SRV" \
2943 "$P_CLI request_size=16384 force_version=tls1_1 \
2944 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2945 trunc_hmac=1" \
2946 0 \
2947 -s "Read from client: 16384 bytes read"
2948
2949run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002950 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002951 "$P_CLI request_size=16384 force_version=tls1_1 \
2952 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2953 trunc_hmac=1" \
2954 0 \
2955 -s "Read from client: 16384 bytes read"
2956
2957run_test "Large packet TLS 1.2 BlockCipher" \
2958 "$P_SRV" \
2959 "$P_CLI request_size=16384 force_version=tls1_2 \
2960 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2961 0 \
2962 -s "Read from client: 16384 bytes read"
2963
2964run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2965 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002966 "$P_CLI request_size=16384 force_version=tls1_2 \
2967 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002968 0 \
2969 -s "Read from client: 16384 bytes read"
2970
2971run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2972 "$P_SRV" \
2973 "$P_CLI request_size=16384 force_version=tls1_2 \
2974 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2975 trunc_hmac=1" \
2976 0 \
2977 -s "Read from client: 16384 bytes read"
2978
2979run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002980 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002981 "$P_CLI request_size=16384 force_version=tls1_2 \
2982 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2983 0 \
2984 -s "Read from client: 16384 bytes read"
2985
2986run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002987 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002988 "$P_CLI request_size=16384 force_version=tls1_2 \
2989 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2990 trunc_hmac=1" \
2991 0 \
2992 -s "Read from client: 16384 bytes read"
2993
2994run_test "Large packet TLS 1.2 AEAD" \
2995 "$P_SRV" \
2996 "$P_CLI request_size=16384 force_version=tls1_2 \
2997 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2998 0 \
2999 -s "Read from client: 16384 bytes read"
3000
3001run_test "Large packet TLS 1.2 AEAD shorter tag" \
3002 "$P_SRV" \
3003 "$P_CLI request_size=16384 force_version=tls1_2 \
3004 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3005 0 \
3006 -s "Read from client: 16384 bytes read"
3007
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003008# Tests for DTLS HelloVerifyRequest
3009
3010run_test "DTLS cookie: enabled" \
3011 "$P_SRV dtls=1 debug_level=2" \
3012 "$P_CLI dtls=1 debug_level=2" \
3013 0 \
3014 -s "cookie verification failed" \
3015 -s "cookie verification passed" \
3016 -S "cookie verification skipped" \
3017 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003018 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003019 -S "SSL - The requested feature is not available"
3020
3021run_test "DTLS cookie: disabled" \
3022 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3023 "$P_CLI dtls=1 debug_level=2" \
3024 0 \
3025 -S "cookie verification failed" \
3026 -S "cookie verification passed" \
3027 -s "cookie verification skipped" \
3028 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003029 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003030 -S "SSL - The requested feature is not available"
3031
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003032run_test "DTLS cookie: default (failing)" \
3033 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3034 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3035 1 \
3036 -s "cookie verification failed" \
3037 -S "cookie verification passed" \
3038 -S "cookie verification skipped" \
3039 -C "received hello verify request" \
3040 -S "hello verification requested" \
3041 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003042
3043requires_ipv6
3044run_test "DTLS cookie: enabled, IPv6" \
3045 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3046 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3047 0 \
3048 -s "cookie verification failed" \
3049 -s "cookie verification passed" \
3050 -S "cookie verification skipped" \
3051 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003052 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003053 -S "SSL - The requested feature is not available"
3054
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003055run_test "DTLS cookie: enabled, nbio" \
3056 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3057 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3058 0 \
3059 -s "cookie verification failed" \
3060 -s "cookie verification passed" \
3061 -S "cookie verification skipped" \
3062 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003063 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003064 -S "SSL - The requested feature is not available"
3065
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003066# Tests for client reconnecting from the same port with DTLS
3067
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003068not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003069run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003070 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3071 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003072 0 \
3073 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003074 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003075 -S "Client initiated reconnection from same port"
3076
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003077not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003078run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003079 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3080 "$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 +02003081 0 \
3082 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003083 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003084 -s "Client initiated reconnection from same port"
3085
3086run_test "DTLS client reconnect from same port: reconnect, nbio" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003087 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3088 "$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 +02003089 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003090 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003091 -s "Client initiated reconnection from same port"
3092
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003093run_test "DTLS client reconnect from same port: no cookies" \
3094 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003095 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3096 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003097 -s "The operation timed out" \
3098 -S "Client initiated reconnection from same port"
3099
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003100# Tests for various cases of client authentication with DTLS
3101# (focused on handshake flows and message parsing)
3102
3103run_test "DTLS client auth: required" \
3104 "$P_SRV dtls=1 auth_mode=required" \
3105 "$P_CLI dtls=1" \
3106 0 \
3107 -s "Verifying peer X.509 certificate... ok"
3108
3109run_test "DTLS client auth: optional, client has no cert" \
3110 "$P_SRV dtls=1 auth_mode=optional" \
3111 "$P_CLI dtls=1 crt_file=none key_file=none" \
3112 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003113 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003114
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003115run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003116 "$P_SRV dtls=1 auth_mode=none" \
3117 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3118 0 \
3119 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003120 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003121
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003122run_test "DTLS wrong PSK: badmac alert" \
3123 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3124 "$P_CLI dtls=1 psk=abc124" \
3125 1 \
3126 -s "SSL - Verification of the message MAC failed" \
3127 -c "SSL - A fatal alert message was received from our peer"
3128
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003129# Tests for receiving fragmented handshake messages with DTLS
3130
3131requires_gnutls
3132run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3133 "$G_SRV -u --mtu 2048 -a" \
3134 "$P_CLI dtls=1 debug_level=2" \
3135 0 \
3136 -C "found fragmented DTLS handshake message" \
3137 -C "error"
3138
3139requires_gnutls
3140run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3141 "$G_SRV -u --mtu 512" \
3142 "$P_CLI dtls=1 debug_level=2" \
3143 0 \
3144 -c "found fragmented DTLS handshake message" \
3145 -C "error"
3146
3147requires_gnutls
3148run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3149 "$G_SRV -u --mtu 128" \
3150 "$P_CLI dtls=1 debug_level=2" \
3151 0 \
3152 -c "found fragmented DTLS handshake message" \
3153 -C "error"
3154
3155requires_gnutls
3156run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3157 "$G_SRV -u --mtu 128" \
3158 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3159 0 \
3160 -c "found fragmented DTLS handshake message" \
3161 -C "error"
3162
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003163requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003164run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3165 "$G_SRV -u --mtu 256" \
3166 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3167 0 \
3168 -c "found fragmented DTLS handshake message" \
3169 -c "client hello, adding renegotiation extension" \
3170 -c "found renegotiation extension" \
3171 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003172 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003173 -C "error" \
3174 -s "Extra-header:"
3175
3176requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003177run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3178 "$G_SRV -u --mtu 256" \
3179 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3180 0 \
3181 -c "found fragmented DTLS handshake message" \
3182 -c "client hello, adding renegotiation extension" \
3183 -c "found renegotiation extension" \
3184 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003185 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003186 -C "error" \
3187 -s "Extra-header:"
3188
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003189run_test "DTLS reassembly: no fragmentation (openssl server)" \
3190 "$O_SRV -dtls1 -mtu 2048" \
3191 "$P_CLI dtls=1 debug_level=2" \
3192 0 \
3193 -C "found fragmented DTLS handshake message" \
3194 -C "error"
3195
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003196run_test "DTLS reassembly: some fragmentation (openssl server)" \
3197 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003198 "$P_CLI dtls=1 debug_level=2" \
3199 0 \
3200 -c "found fragmented DTLS handshake message" \
3201 -C "error"
3202
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003203run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003204 "$O_SRV -dtls1 -mtu 256" \
3205 "$P_CLI dtls=1 debug_level=2" \
3206 0 \
3207 -c "found fragmented DTLS handshake message" \
3208 -C "error"
3209
3210run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3211 "$O_SRV -dtls1 -mtu 256" \
3212 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3213 0 \
3214 -c "found fragmented DTLS handshake message" \
3215 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003216
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003217# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003218
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003219not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003220run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003221 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003222 "$P_SRV dtls=1 debug_level=2" \
3223 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003224 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003225 -C "replayed record" \
3226 -S "replayed record" \
3227 -C "record from another epoch" \
3228 -S "record from another epoch" \
3229 -C "discarding invalid record" \
3230 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003231 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003232 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003233 -c "HTTP/1.0 200 OK"
3234
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003235not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003236run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003237 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003238 "$P_SRV dtls=1 debug_level=2" \
3239 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003240 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003241 -c "replayed record" \
3242 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003243 -c "discarding invalid record" \
3244 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003245 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003246 -s "Extra-header:" \
3247 -c "HTTP/1.0 200 OK"
3248
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003249run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3250 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003251 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3252 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003253 0 \
3254 -c "replayed record" \
3255 -S "replayed record" \
3256 -c "discarding invalid record" \
3257 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003258 -c "resend" \
3259 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003260 -s "Extra-header:" \
3261 -c "HTTP/1.0 200 OK"
3262
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003263run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003264 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003265 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003266 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003267 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003268 -c "discarding invalid record (mac)" \
3269 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003270 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003271 -c "HTTP/1.0 200 OK" \
3272 -S "too many records with bad MAC" \
3273 -S "Verification of the message MAC failed"
3274
3275run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3276 -p "$P_PXY bad_ad=1" \
3277 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3278 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3279 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003280 -C "discarding invalid record (mac)" \
3281 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003282 -S "Extra-header:" \
3283 -C "HTTP/1.0 200 OK" \
3284 -s "too many records with bad MAC" \
3285 -s "Verification of the message MAC failed"
3286
3287run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3288 -p "$P_PXY bad_ad=1" \
3289 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3290 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3291 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003292 -c "discarding invalid record (mac)" \
3293 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003294 -s "Extra-header:" \
3295 -c "HTTP/1.0 200 OK" \
3296 -S "too many records with bad MAC" \
3297 -S "Verification of the message MAC failed"
3298
3299run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3300 -p "$P_PXY bad_ad=1" \
3301 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3302 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3303 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003304 -c "discarding invalid record (mac)" \
3305 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003306 -s "Extra-header:" \
3307 -c "HTTP/1.0 200 OK" \
3308 -s "too many records with bad MAC" \
3309 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003310
3311run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003312 -p "$P_PXY delay_ccs=1" \
3313 "$P_SRV dtls=1 debug_level=1" \
3314 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003315 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003316 -c "record from another epoch" \
3317 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003318 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003319 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003320 -s "Extra-header:" \
3321 -c "HTTP/1.0 200 OK"
3322
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003323# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003324
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003325needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003326run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003327 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003328 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3329 psk=abc123" \
3330 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003331 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3332 0 \
3333 -s "Extra-header:" \
3334 -c "HTTP/1.0 200 OK"
3335
3336needs_more_time 2
3337run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3338 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003339 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3340 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003341 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3342 0 \
3343 -s "Extra-header:" \
3344 -c "HTTP/1.0 200 OK"
3345
3346needs_more_time 2
3347run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3348 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003349 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3350 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003351 0 \
3352 -s "Extra-header:" \
3353 -c "HTTP/1.0 200 OK"
3354
3355needs_more_time 2
3356run_test "DTLS proxy: 3d, FS, client auth" \
3357 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003358 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3359 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003360 0 \
3361 -s "Extra-header:" \
3362 -c "HTTP/1.0 200 OK"
3363
3364needs_more_time 2
3365run_test "DTLS proxy: 3d, FS, ticket" \
3366 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003367 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3368 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003369 0 \
3370 -s "Extra-header:" \
3371 -c "HTTP/1.0 200 OK"
3372
3373needs_more_time 2
3374run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3375 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003376 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3377 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003378 0 \
3379 -s "Extra-header:" \
3380 -c "HTTP/1.0 200 OK"
3381
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003382needs_more_time 2
3383run_test "DTLS proxy: 3d, max handshake, nbio" \
3384 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003385 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3386 auth_mode=required" \
3387 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003388 0 \
3389 -s "Extra-header:" \
3390 -c "HTTP/1.0 200 OK"
3391
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003392needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003393run_test "DTLS proxy: 3d, min handshake, resumption" \
3394 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3395 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3396 psk=abc123 debug_level=3" \
3397 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3398 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3399 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3400 0 \
3401 -s "a session has been resumed" \
3402 -c "a session has been resumed" \
3403 -s "Extra-header:" \
3404 -c "HTTP/1.0 200 OK"
3405
3406needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003407run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3408 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3409 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3410 psk=abc123 debug_level=3 nbio=2" \
3411 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3412 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3413 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3414 0 \
3415 -s "a session has been resumed" \
3416 -c "a session has been resumed" \
3417 -s "Extra-header:" \
3418 -c "HTTP/1.0 200 OK"
3419
3420needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003421run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003422 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003423 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3424 psk=abc123 renegotiation=1 debug_level=2" \
3425 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3426 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003427 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3428 0 \
3429 -c "=> renegotiate" \
3430 -s "=> renegotiate" \
3431 -s "Extra-header:" \
3432 -c "HTTP/1.0 200 OK"
3433
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003434needs_more_time 4
3435run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3436 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003437 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3438 psk=abc123 renegotiation=1 debug_level=2" \
3439 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3440 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003441 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3442 0 \
3443 -c "=> renegotiate" \
3444 -s "=> renegotiate" \
3445 -s "Extra-header:" \
3446 -c "HTTP/1.0 200 OK"
3447
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003448needs_more_time 4
3449run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003450 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003451 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003452 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003453 debug_level=2" \
3454 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003455 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003456 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3457 0 \
3458 -c "=> renegotiate" \
3459 -s "=> renegotiate" \
3460 -s "Extra-header:" \
3461 -c "HTTP/1.0 200 OK"
3462
3463needs_more_time 4
3464run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003465 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003466 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003467 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003468 debug_level=2 nbio=2" \
3469 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003470 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003471 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3472 0 \
3473 -c "=> renegotiate" \
3474 -s "=> renegotiate" \
3475 -s "Extra-header:" \
3476 -c "HTTP/1.0 200 OK"
3477
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003478needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003479not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003480run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003481 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3482 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003483 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003484 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003485 -c "HTTP/1.0 200 OK"
3486
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003487needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003488not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003489run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3490 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3491 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003492 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003493 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003494 -c "HTTP/1.0 200 OK"
3495
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003496needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003497not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003498run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3499 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3500 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003501 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003502 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003503 -c "HTTP/1.0 200 OK"
3504
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003505requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003506needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003507not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003508run_test "DTLS proxy: 3d, gnutls server" \
3509 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3510 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003511 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003512 0 \
3513 -s "Extra-header:" \
3514 -c "Extra-header:"
3515
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003516requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003517needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003518not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003519run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3520 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3521 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003522 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003523 0 \
3524 -s "Extra-header:" \
3525 -c "Extra-header:"
3526
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003527requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003528needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003529not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003530run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3531 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3532 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003533 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003534 0 \
3535 -s "Extra-header:" \
3536 -c "Extra-header:"
3537
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003538# Final report
3539
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003540echo "------------------------------------------------------------------------"
3541
3542if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003543 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003544else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003545 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003546fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003547PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003548echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003549
3550exit $FAILS