blob: 4f633fc9634347ac59a572ac9ef0f09ccc04b49b [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010031
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020032O_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 +010033O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020034G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010035G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010036
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010037TESTS=0
38FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020039SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010040
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000041CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020042
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010043MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010044FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020045EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010046
Paul Bakkere20310a2016-05-10 11:18:17 +010047SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010048RUN_TEST_NUMBER=''
49
Paul Bakkeracaac852016-05-10 11:47:13 +010050PRESERVE_LOGS=0
51
Gilles Peskinef93c7d32017-04-14 17:55:28 +020052# Pick a "unique" server port in the range 10000-19999, and a proxy
53# port which is this plus 10000. Each port number may be independently
54# overridden by a command line option.
55SRV_PORT=$(($$ % 10000 + 10000))
56PXY_PORT=$((SRV_PORT + 10000))
57
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010058print_usage() {
59 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010060 printf " -h|--help\tPrint this help.\n"
61 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020062 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
63 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010064 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010065 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010066 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020067 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
68 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010069 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010070}
71
72get_options() {
73 while [ $# -gt 0 ]; do
74 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010075 -f|--filter)
76 shift; FILTER=$1
77 ;;
78 -e|--exclude)
79 shift; EXCLUDE=$1
80 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010081 -m|--memcheck)
82 MEMCHECK=1
83 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010084 -n|--number)
85 shift; RUN_TEST_NUMBER=$1
86 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010087 -s|--show-numbers)
88 SHOW_TEST_NUMBER=1
89 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010090 -p|--preserve-logs)
91 PRESERVE_LOGS=1
92 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020093 --port)
94 shift; SRV_PORT=$1
95 ;;
96 --proxy-port)
97 shift; PXY_PORT=$1
98 ;;
Andres AGf04f54d2016-10-10 15:46:20 +010099 --seed)
100 shift; SEED="$1"
101 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100102 -h|--help)
103 print_usage
104 exit 0
105 ;;
106 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200107 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100108 print_usage
109 exit 1
110 ;;
111 esac
112 shift
113 done
114}
115
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100116# skip next test if the flag is not enabled in config.h
117requires_config_enabled() {
118 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
119 SKIP_NEXT="YES"
120 fi
121}
122
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200123# skip next test if OpenSSL doesn't support FALLBACK_SCSV
124requires_openssl_with_fallback_scsv() {
125 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
126 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
127 then
128 OPENSSL_HAS_FBSCSV="YES"
129 else
130 OPENSSL_HAS_FBSCSV="NO"
131 fi
132 fi
133 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
134 SKIP_NEXT="YES"
135 fi
136}
137
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200138# skip next test if GnuTLS isn't available
139requires_gnutls() {
140 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200141 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200142 GNUTLS_AVAILABLE="YES"
143 else
144 GNUTLS_AVAILABLE="NO"
145 fi
146 fi
147 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
148 SKIP_NEXT="YES"
149 fi
150}
151
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200152# skip next test if IPv6 isn't available on this host
153requires_ipv6() {
154 if [ -z "${HAS_IPV6:-}" ]; then
155 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
156 SRV_PID=$!
157 sleep 1
158 kill $SRV_PID >/dev/null 2>&1
159 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
160 HAS_IPV6="NO"
161 else
162 HAS_IPV6="YES"
163 fi
164 rm -r $SRV_OUT
165 fi
166
167 if [ "$HAS_IPV6" = "NO" ]; then
168 SKIP_NEXT="YES"
169 fi
170}
171
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200172# skip the next test if valgrind is in use
173not_with_valgrind() {
174 if [ "$MEMCHECK" -gt 0 ]; then
175 SKIP_NEXT="YES"
176 fi
177}
178
Paul Bakker362689d2016-05-13 10:33:25 +0100179# skip the next test if valgrind is NOT in use
180only_with_valgrind() {
181 if [ "$MEMCHECK" -eq 0 ]; then
182 SKIP_NEXT="YES"
183 fi
184}
185
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200186# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100187client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200188 CLI_DELAY_FACTOR=$1
189}
190
Janos Follath74537a62016-09-02 13:45:28 +0100191# wait for the given seconds after the client finished in the next test
192server_needs_more_time() {
193 SRV_DELAY_SECONDS=$1
194}
195
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100196# print_name <name>
197print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100198 TESTS=$(( $TESTS + 1 ))
199 LINE=""
200
201 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
202 LINE="$TESTS "
203 fi
204
205 LINE="$LINE$1"
206 printf "$LINE "
207 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100208 for i in `seq 1 $LEN`; do printf '.'; done
209 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100210
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100211}
212
213# fail <message>
214fail() {
215 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100216 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100217
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200218 mv $SRV_OUT o-srv-${TESTS}.log
219 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200220 if [ -n "$PXY_CMD" ]; then
221 mv $PXY_OUT o-pxy-${TESTS}.log
222 fi
223 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100224
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200225 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
226 echo " ! server output:"
227 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200228 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200229 echo " ! client output:"
230 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200231 if [ -n "$PXY_CMD" ]; then
232 echo " ! ========================================================"
233 echo " ! proxy output:"
234 cat o-pxy-${TESTS}.log
235 fi
236 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200237 fi
238
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200239 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100240}
241
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100242# is_polar <cmd_line>
243is_polar() {
244 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
245}
246
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200247# openssl s_server doesn't have -www with DTLS
248check_osrv_dtls() {
249 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
250 NEEDS_INPUT=1
251 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
252 else
253 NEEDS_INPUT=0
254 fi
255}
256
257# provide input to commands that need it
258provide_input() {
259 if [ $NEEDS_INPUT -eq 0 ]; then
260 return
261 fi
262
263 while true; do
264 echo "HTTP/1.0 200 OK"
265 sleep 1
266 done
267}
268
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100269# has_mem_err <log_file_name>
270has_mem_err() {
271 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
272 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
273 then
274 return 1 # false: does not have errors
275 else
276 return 0 # true: has errors
277 fi
278}
279
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200280# wait for server to start: two versions depending on lsof availability
281wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200282 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200283 START_TIME=$( date +%s )
284 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200285
286 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200287 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200288 while [ $DONE -eq 0 ]; do
289 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
290 then
291 DONE=1
292 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
293 echo "SERVERSTART TIMEOUT"
294 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
295 DONE=1
296 fi
297 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200298 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200299 while [ $DONE -eq 0 ]; do
300 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
301 then
302 DONE=1
303 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
304 echo "SERVERSTART TIMEOUT"
305 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
306 DONE=1
307 fi
308 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200309 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200310 else
311 sleep "$START_DELAY"
312 fi
313}
314
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200315# wait for client to terminate and set CLI_EXIT
316# must be called right after starting the client
317wait_client_done() {
318 CLI_PID=$!
319
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200320 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
321 CLI_DELAY_FACTOR=1
322
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200323 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200324 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200325
326 wait $CLI_PID
327 CLI_EXIT=$?
328
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200329 kill $DOG_PID >/dev/null 2>&1
330 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200331
332 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100333
334 sleep $SRV_DELAY_SECONDS
335 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200336}
337
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200338# check if the given command uses dtls and sets global variable DTLS
339detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200340 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200341 DTLS=1
342 else
343 DTLS=0
344 fi
345}
346
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200347# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100348# Options: -s pattern pattern that must be present in server output
349# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100350# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100351# -S pattern pattern that must be absent in server output
352# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100353# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100354run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100355 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200356 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100357
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100358 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
359 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200360 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100361 return
362 fi
363
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100364 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100365
Paul Bakkerb7584a52016-05-10 10:50:43 +0100366 # Do we only run numbered tests?
367 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
368 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
369 else
370 SKIP_NEXT="YES"
371 fi
372
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200373 # should we skip?
374 if [ "X$SKIP_NEXT" = "XYES" ]; then
375 SKIP_NEXT="NO"
376 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200377 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200378 return
379 fi
380
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200381 # does this test use a proxy?
382 if [ "X$1" = "X-p" ]; then
383 PXY_CMD="$2"
384 shift 2
385 else
386 PXY_CMD=""
387 fi
388
389 # get commands and client output
390 SRV_CMD="$1"
391 CLI_CMD="$2"
392 CLI_EXPECT="$3"
393 shift 3
394
395 # fix client port
396 if [ -n "$PXY_CMD" ]; then
397 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
398 else
399 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
400 fi
401
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200402 # update DTLS variable
403 detect_dtls "$SRV_CMD"
404
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100405 # prepend valgrind to our commands if active
406 if [ "$MEMCHECK" -gt 0 ]; then
407 if is_polar "$SRV_CMD"; then
408 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
409 fi
410 if is_polar "$CLI_CMD"; then
411 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
412 fi
413 fi
414
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200415 TIMES_LEFT=2
416 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200417 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200418
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200419 # run the commands
420 if [ -n "$PXY_CMD" ]; then
421 echo "$PXY_CMD" > $PXY_OUT
422 $PXY_CMD >> $PXY_OUT 2>&1 &
423 PXY_PID=$!
424 # assume proxy starts faster than server
425 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200426
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200427 check_osrv_dtls
428 echo "$SRV_CMD" > $SRV_OUT
429 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
430 SRV_PID=$!
431 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200432
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200433 echo "$CLI_CMD" > $CLI_OUT
434 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
435 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100436
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200437 # terminate the server (and the proxy)
438 kill $SRV_PID
439 wait $SRV_PID
440 if [ -n "$PXY_CMD" ]; then
441 kill $PXY_PID >/dev/null 2>&1
442 wait $PXY_PID
443 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100444
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200445 # retry only on timeouts
446 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
447 printf "RETRY "
448 else
449 TIMES_LEFT=0
450 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200451 done
452
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100453 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200454 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100455 # expected client exit to incorrectly succeed in case of catastrophic
456 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100457 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200458 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100459 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100460 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100461 return
462 fi
463 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100464 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200465 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100466 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100467 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100468 return
469 fi
470 fi
471
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100472 # check server exit code
473 if [ $? != 0 ]; then
474 fail "server fail"
475 return
476 fi
477
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100478 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100479 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
480 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100481 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200482 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100483 return
484 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100485
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100486 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200487 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100488 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100489 while [ $# -gt 0 ]
490 do
491 case $1 in
492 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100493 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100494 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100495 return
496 fi
497 ;;
498
499 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100500 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100501 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100502 return
503 fi
504 ;;
505
506 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100507 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100508 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100509 return
510 fi
511 ;;
512
513 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100514 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100515 fail "pattern '$2' MUST NOT be present in the Client output"
516 return
517 fi
518 ;;
519
520 # The filtering in the following two options (-u and -U) do the following
521 # - ignore valgrind output
522 # - filter out everything but lines right after the pattern occurances
523 # - keep one of each non-unique line
524 # - count how many lines remain
525 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
526 # if there were no duplicates.
527 "-U")
528 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
529 fail "lines following pattern '$2' must be unique in Server output"
530 return
531 fi
532 ;;
533
534 "-u")
535 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
536 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100537 return
538 fi
539 ;;
540
541 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200542 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100543 exit 1
544 esac
545 shift 2
546 done
547
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100548 # check valgrind's results
549 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200550 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100551 fail "Server has memory errors"
552 return
553 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200554 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100555 fail "Client has memory errors"
556 return
557 fi
558 fi
559
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100560 # if we're here, everything is ok
561 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100562 if [ "$PRESERVE_LOGS" -gt 0 ]; then
563 mv $SRV_OUT o-srv-${TESTS}.log
564 mv $CLI_OUT o-cli-${TESTS}.log
565 fi
566
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200567 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100568}
569
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100570cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200571 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200572 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
573 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
574 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
575 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100576 exit 1
577}
578
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100579#
580# MAIN
581#
582
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000583if cd $( dirname $0 ); then :; else
584 echo "cd $( dirname $0 ) failed" >&2
585 exit 1
586fi
587
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100588get_options "$@"
589
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100590# sanity checks, avoid an avalanche of errors
591if [ ! -x "$P_SRV" ]; then
592 echo "Command '$P_SRV' is not an executable file"
593 exit 1
594fi
595if [ ! -x "$P_CLI" ]; then
596 echo "Command '$P_CLI' is not an executable file"
597 exit 1
598fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200599if [ ! -x "$P_PXY" ]; then
600 echo "Command '$P_PXY' is not an executable file"
601 exit 1
602fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100603if [ "$MEMCHECK" -gt 0 ]; then
604 if which valgrind >/dev/null 2>&1; then :; else
605 echo "Memcheck not possible. Valgrind not found"
606 exit 1
607 fi
608fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100609if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
610 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100611 exit 1
612fi
613
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200614# used by watchdog
615MAIN_PID="$$"
616
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200617# be more patient with valgrind
618if [ "$MEMCHECK" -gt 0 ]; then
619 START_DELAY=3
620 DOG_DELAY=30
621else
622 START_DELAY=1
623 DOG_DELAY=10
624fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200625CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100626SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200627
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200628# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000629# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200630P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
631P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100632P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200633O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200634O_CLI="$O_CLI -connect localhost:+SRV_PORT"
635G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000636G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200637
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200638# Also pick a unique name for intermediate files
639SRV_OUT="srv_out.$$"
640CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200641PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200642SESSION="session.$$"
643
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200644SKIP_NEXT="NO"
645
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100646trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100647
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200648# Basic test
649
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200650# Checks that:
651# - things work with all ciphersuites active (used with config-full in all.sh)
652# - the expected (highest security) parameters are selected
653# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200654run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200655 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200656 "$P_CLI" \
657 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200658 -s "Protocol is TLSv1.2" \
659 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
660 -s "client hello v3, signature_algorithm ext: 6" \
661 -s "ECDHE curve: secp521r1" \
662 -S "error" \
663 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200664
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000665run_test "Default, DTLS" \
666 "$P_SRV dtls=1" \
667 "$P_CLI dtls=1" \
668 0 \
669 -s "Protocol is DTLSv1.2" \
670 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
671
Simon Butcher8e004102016-10-14 00:48:33 +0100672# Test for uniqueness of IVs in AEAD ciphersuites
673run_test "Unique IV in GCM" \
674 "$P_SRV exchanges=20 debug_level=4" \
675 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
676 0 \
677 -u "IV used" \
678 -U "IV used"
679
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100680# Tests for rc4 option
681
Simon Butchera410af52016-05-19 22:12:18 +0100682requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100683run_test "RC4: server disabled, client enabled" \
684 "$P_SRV" \
685 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
686 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100687 -s "SSL - The server has no ciphersuites in common"
688
Simon Butchera410af52016-05-19 22:12:18 +0100689requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100690run_test "RC4: server half, client enabled" \
691 "$P_SRV arc4=1" \
692 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
693 1 \
694 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100695
696run_test "RC4: server enabled, client disabled" \
697 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
698 "$P_CLI" \
699 1 \
700 -s "SSL - The server has no ciphersuites in common"
701
702run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100703 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100704 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
705 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100706 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100707 -S "SSL - The server has no ciphersuites in common"
708
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100709# Tests for Truncated HMAC extension
710
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100711run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200712 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100713 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100714 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100715 -s "dumping 'computed mac' (20 bytes)" \
716 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100717
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100718run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200719 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100720 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
721 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100722 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100723 -s "dumping 'computed mac' (20 bytes)" \
724 -S "dumping 'computed mac' (10 bytes)"
725
726run_test "Truncated HMAC: client enabled, server default" \
727 "$P_SRV debug_level=4" \
728 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
729 trunc_hmac=1" \
730 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100731 -s "dumping 'computed mac' (20 bytes)" \
732 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100733
734run_test "Truncated HMAC: client enabled, server disabled" \
735 "$P_SRV debug_level=4 trunc_hmac=0" \
736 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
737 trunc_hmac=1" \
738 0 \
739 -s "dumping 'computed mac' (20 bytes)" \
740 -S "dumping 'computed mac' (10 bytes)"
741
742run_test "Truncated HMAC: client enabled, server enabled" \
743 "$P_SRV debug_level=4 trunc_hmac=1" \
744 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
745 trunc_hmac=1" \
746 0 \
747 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100748 -s "dumping 'computed mac' (10 bytes)"
749
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100750# Tests for Encrypt-then-MAC extension
751
752run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100753 "$P_SRV debug_level=3 \
754 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100755 "$P_CLI debug_level=3" \
756 0 \
757 -c "client hello, adding encrypt_then_mac extension" \
758 -s "found encrypt then mac extension" \
759 -s "server hello, adding encrypt then mac extension" \
760 -c "found encrypt_then_mac extension" \
761 -c "using encrypt then mac" \
762 -s "using encrypt then mac"
763
764run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100765 "$P_SRV debug_level=3 etm=0 \
766 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100767 "$P_CLI debug_level=3 etm=1" \
768 0 \
769 -c "client hello, adding encrypt_then_mac extension" \
770 -s "found encrypt then mac extension" \
771 -S "server hello, adding encrypt then mac extension" \
772 -C "found encrypt_then_mac extension" \
773 -C "using encrypt then mac" \
774 -S "using encrypt then mac"
775
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100776run_test "Encrypt then MAC: client enabled, aead cipher" \
777 "$P_SRV debug_level=3 etm=1 \
778 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
779 "$P_CLI debug_level=3 etm=1" \
780 0 \
781 -c "client hello, adding encrypt_then_mac extension" \
782 -s "found encrypt then mac extension" \
783 -S "server hello, adding encrypt then mac extension" \
784 -C "found encrypt_then_mac extension" \
785 -C "using encrypt then mac" \
786 -S "using encrypt then mac"
787
788run_test "Encrypt then MAC: client enabled, stream cipher" \
789 "$P_SRV debug_level=3 etm=1 \
790 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100791 "$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 +0100792 0 \
793 -c "client hello, adding encrypt_then_mac extension" \
794 -s "found encrypt then mac extension" \
795 -S "server hello, adding encrypt then mac extension" \
796 -C "found encrypt_then_mac extension" \
797 -C "using encrypt then mac" \
798 -S "using encrypt then mac"
799
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100800run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100801 "$P_SRV debug_level=3 etm=1 \
802 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100803 "$P_CLI debug_level=3 etm=0" \
804 0 \
805 -C "client hello, adding encrypt_then_mac extension" \
806 -S "found encrypt then mac extension" \
807 -S "server hello, adding encrypt then mac extension" \
808 -C "found encrypt_then_mac extension" \
809 -C "using encrypt then mac" \
810 -S "using encrypt then mac"
811
Janos Follathe2681a42016-03-07 15:57:05 +0000812requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100813run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100814 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100815 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100816 "$P_CLI debug_level=3 force_version=ssl3" \
817 0 \
818 -C "client hello, adding encrypt_then_mac extension" \
819 -S "found encrypt then mac extension" \
820 -S "server hello, adding encrypt then mac extension" \
821 -C "found encrypt_then_mac extension" \
822 -C "using encrypt then mac" \
823 -S "using encrypt then mac"
824
Janos Follathe2681a42016-03-07 15:57:05 +0000825requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100826run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100827 "$P_SRV debug_level=3 force_version=ssl3 \
828 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100829 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100830 0 \
831 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100832 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100833 -S "server hello, adding encrypt then mac extension" \
834 -C "found encrypt_then_mac extension" \
835 -C "using encrypt then mac" \
836 -S "using encrypt then mac"
837
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200838# Tests for Extended Master Secret extension
839
840run_test "Extended Master Secret: default" \
841 "$P_SRV debug_level=3" \
842 "$P_CLI debug_level=3" \
843 0 \
844 -c "client hello, adding extended_master_secret extension" \
845 -s "found extended master secret extension" \
846 -s "server hello, adding extended master secret extension" \
847 -c "found extended_master_secret extension" \
848 -c "using extended master secret" \
849 -s "using extended master secret"
850
851run_test "Extended Master Secret: client enabled, server disabled" \
852 "$P_SRV debug_level=3 extended_ms=0" \
853 "$P_CLI debug_level=3 extended_ms=1" \
854 0 \
855 -c "client hello, adding extended_master_secret extension" \
856 -s "found extended master secret extension" \
857 -S "server hello, adding extended master secret extension" \
858 -C "found extended_master_secret extension" \
859 -C "using extended master secret" \
860 -S "using extended master secret"
861
862run_test "Extended Master Secret: client disabled, server enabled" \
863 "$P_SRV debug_level=3 extended_ms=1" \
864 "$P_CLI debug_level=3 extended_ms=0" \
865 0 \
866 -C "client hello, adding extended_master_secret extension" \
867 -S "found extended master secret extension" \
868 -S "server hello, adding extended master secret extension" \
869 -C "found extended_master_secret extension" \
870 -C "using extended master secret" \
871 -S "using extended master secret"
872
Janos Follathe2681a42016-03-07 15:57:05 +0000873requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200874run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100875 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200876 "$P_CLI debug_level=3 force_version=ssl3" \
877 0 \
878 -C "client hello, adding extended_master_secret extension" \
879 -S "found extended master secret extension" \
880 -S "server hello, adding extended master secret extension" \
881 -C "found extended_master_secret extension" \
882 -C "using extended master secret" \
883 -S "using extended master secret"
884
Janos Follathe2681a42016-03-07 15:57:05 +0000885requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200886run_test "Extended Master Secret: client enabled, server SSLv3" \
887 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100888 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200889 0 \
890 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100891 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200892 -S "server hello, adding extended master secret extension" \
893 -C "found extended_master_secret extension" \
894 -C "using extended master secret" \
895 -S "using extended master secret"
896
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200897# Tests for FALLBACK_SCSV
898
899run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200900 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200901 "$P_CLI debug_level=3 force_version=tls1_1" \
902 0 \
903 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200904 -S "received FALLBACK_SCSV" \
905 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200906 -C "is a fatal alert message (msg 86)"
907
908run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200909 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200910 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
911 0 \
912 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200913 -S "received FALLBACK_SCSV" \
914 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200915 -C "is a fatal alert message (msg 86)"
916
917run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200918 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200919 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200920 1 \
921 -c "adding FALLBACK_SCSV" \
922 -s "received FALLBACK_SCSV" \
923 -s "inapropriate fallback" \
924 -c "is a fatal alert message (msg 86)"
925
926run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200927 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200928 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200929 0 \
930 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200931 -s "received FALLBACK_SCSV" \
932 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200933 -C "is a fatal alert message (msg 86)"
934
935requires_openssl_with_fallback_scsv
936run_test "Fallback SCSV: default, openssl server" \
937 "$O_SRV" \
938 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
939 0 \
940 -C "adding FALLBACK_SCSV" \
941 -C "is a fatal alert message (msg 86)"
942
943requires_openssl_with_fallback_scsv
944run_test "Fallback SCSV: enabled, openssl server" \
945 "$O_SRV" \
946 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
947 1 \
948 -c "adding FALLBACK_SCSV" \
949 -c "is a fatal alert message (msg 86)"
950
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200951requires_openssl_with_fallback_scsv
952run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200953 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200954 "$O_CLI -tls1_1" \
955 0 \
956 -S "received FALLBACK_SCSV" \
957 -S "inapropriate fallback"
958
959requires_openssl_with_fallback_scsv
960run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200961 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200962 "$O_CLI -tls1_1 -fallback_scsv" \
963 1 \
964 -s "received FALLBACK_SCSV" \
965 -s "inapropriate fallback"
966
967requires_openssl_with_fallback_scsv
968run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200969 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200970 "$O_CLI -fallback_scsv" \
971 0 \
972 -s "received FALLBACK_SCSV" \
973 -S "inapropriate fallback"
974
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100975# Tests for CBC 1/n-1 record splitting
976
977run_test "CBC Record splitting: TLS 1.2, no splitting" \
978 "$P_SRV" \
979 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
980 request_size=123 force_version=tls1_2" \
981 0 \
982 -s "Read from client: 123 bytes read" \
983 -S "Read from client: 1 bytes read" \
984 -S "122 bytes read"
985
986run_test "CBC Record splitting: TLS 1.1, no splitting" \
987 "$P_SRV" \
988 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
989 request_size=123 force_version=tls1_1" \
990 0 \
991 -s "Read from client: 123 bytes read" \
992 -S "Read from client: 1 bytes read" \
993 -S "122 bytes read"
994
995run_test "CBC Record splitting: TLS 1.0, splitting" \
996 "$P_SRV" \
997 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
998 request_size=123 force_version=tls1" \
999 0 \
1000 -S "Read from client: 123 bytes read" \
1001 -s "Read from client: 1 bytes read" \
1002 -s "122 bytes read"
1003
Janos Follathe2681a42016-03-07 15:57:05 +00001004requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001005run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001006 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001007 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1008 request_size=123 force_version=ssl3" \
1009 0 \
1010 -S "Read from client: 123 bytes read" \
1011 -s "Read from client: 1 bytes read" \
1012 -s "122 bytes read"
1013
1014run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001015 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001016 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1017 request_size=123 force_version=tls1" \
1018 0 \
1019 -s "Read from client: 123 bytes read" \
1020 -S "Read from client: 1 bytes read" \
1021 -S "122 bytes read"
1022
1023run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1024 "$P_SRV" \
1025 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1026 request_size=123 force_version=tls1 recsplit=0" \
1027 0 \
1028 -s "Read from client: 123 bytes read" \
1029 -S "Read from client: 1 bytes read" \
1030 -S "122 bytes read"
1031
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001032run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1033 "$P_SRV nbio=2" \
1034 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1035 request_size=123 force_version=tls1" \
1036 0 \
1037 -S "Read from client: 123 bytes read" \
1038 -s "Read from client: 1 bytes read" \
1039 -s "122 bytes read"
1040
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001041# Tests for Session Tickets
1042
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001043run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001044 "$P_SRV debug_level=3 tickets=1" \
1045 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001046 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001047 -c "client hello, adding session ticket extension" \
1048 -s "found session ticket extension" \
1049 -s "server hello, adding session ticket extension" \
1050 -c "found session_ticket extension" \
1051 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001052 -S "session successfully restored from cache" \
1053 -s "session successfully restored from ticket" \
1054 -s "a session has been resumed" \
1055 -c "a session has been resumed"
1056
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001057run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001058 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1059 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001060 0 \
1061 -c "client hello, adding session ticket extension" \
1062 -s "found session ticket extension" \
1063 -s "server hello, adding session ticket extension" \
1064 -c "found session_ticket extension" \
1065 -c "parse new session ticket" \
1066 -S "session successfully restored from cache" \
1067 -s "session successfully restored from ticket" \
1068 -s "a session has been resumed" \
1069 -c "a session has been resumed"
1070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001071run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001072 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1073 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001074 0 \
1075 -c "client hello, adding session ticket extension" \
1076 -s "found session ticket extension" \
1077 -s "server hello, adding session ticket extension" \
1078 -c "found session_ticket extension" \
1079 -c "parse new session ticket" \
1080 -S "session successfully restored from cache" \
1081 -S "session successfully restored from ticket" \
1082 -S "a session has been resumed" \
1083 -C "a session has been resumed"
1084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001085run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001086 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001087 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001088 0 \
1089 -c "client hello, adding session ticket extension" \
1090 -c "found session_ticket extension" \
1091 -c "parse new session ticket" \
1092 -c "a session has been resumed"
1093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001094run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001095 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001096 "( $O_CLI -sess_out $SESSION; \
1097 $O_CLI -sess_in $SESSION; \
1098 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001099 0 \
1100 -s "found session ticket extension" \
1101 -s "server hello, adding session ticket extension" \
1102 -S "session successfully restored from cache" \
1103 -s "session successfully restored from ticket" \
1104 -s "a session has been resumed"
1105
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001106# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001108run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001109 "$P_SRV debug_level=3 tickets=0" \
1110 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001111 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001112 -c "client hello, adding session ticket extension" \
1113 -s "found session ticket extension" \
1114 -S "server hello, adding session ticket extension" \
1115 -C "found session_ticket extension" \
1116 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001117 -s "session successfully restored from cache" \
1118 -S "session successfully restored from ticket" \
1119 -s "a session has been resumed" \
1120 -c "a session has been resumed"
1121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001122run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001123 "$P_SRV debug_level=3 tickets=1" \
1124 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001125 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001126 -C "client hello, adding session ticket extension" \
1127 -S "found session ticket extension" \
1128 -S "server hello, adding session ticket extension" \
1129 -C "found session_ticket extension" \
1130 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001131 -s "session successfully restored from cache" \
1132 -S "session successfully restored from ticket" \
1133 -s "a session has been resumed" \
1134 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001135
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001136run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001137 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1138 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001139 0 \
1140 -S "session successfully restored from cache" \
1141 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001142 -S "a session has been resumed" \
1143 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001144
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001145run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001146 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1147 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001148 0 \
1149 -s "session successfully restored from cache" \
1150 -S "session successfully restored from ticket" \
1151 -s "a session has been resumed" \
1152 -c "a session has been resumed"
1153
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001154run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001155 "$P_SRV debug_level=3 tickets=0" \
1156 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001157 0 \
1158 -s "session successfully restored from cache" \
1159 -S "session successfully restored from ticket" \
1160 -s "a session has been resumed" \
1161 -c "a session has been resumed"
1162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001163run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001164 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1165 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001166 0 \
1167 -S "session successfully restored from cache" \
1168 -S "session successfully restored from ticket" \
1169 -S "a session has been resumed" \
1170 -C "a session has been resumed"
1171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001172run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001173 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1174 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001175 0 \
1176 -s "session successfully restored from cache" \
1177 -S "session successfully restored from ticket" \
1178 -s "a session has been resumed" \
1179 -c "a session has been resumed"
1180
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001181run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001182 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001183 "( $O_CLI -sess_out $SESSION; \
1184 $O_CLI -sess_in $SESSION; \
1185 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001186 0 \
1187 -s "found session ticket extension" \
1188 -S "server hello, adding session ticket extension" \
1189 -s "session successfully restored from cache" \
1190 -S "session successfully restored from ticket" \
1191 -s "a session has been resumed"
1192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001193run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001194 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001195 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001196 0 \
1197 -C "found session_ticket extension" \
1198 -C "parse new session ticket" \
1199 -c "a session has been resumed"
1200
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001201# Tests for Max Fragment Length extension
1202
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001203run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001204 "$P_SRV debug_level=3" \
1205 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001206 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001207 -c "Maximum fragment length is 16384" \
1208 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001209 -C "client hello, adding max_fragment_length extension" \
1210 -S "found max fragment length extension" \
1211 -S "server hello, max_fragment_length extension" \
1212 -C "found max_fragment_length extension"
1213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001214run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001215 "$P_SRV debug_level=3" \
1216 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001217 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001218 -c "Maximum fragment length is 4096" \
1219 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001220 -c "client hello, adding max_fragment_length extension" \
1221 -s "found max fragment length extension" \
1222 -s "server hello, max_fragment_length extension" \
1223 -c "found max_fragment_length extension"
1224
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001225run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001226 "$P_SRV debug_level=3 max_frag_len=4096" \
1227 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001228 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001229 -c "Maximum fragment length is 16384" \
1230 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001231 -C "client hello, adding max_fragment_length extension" \
1232 -S "found max fragment length extension" \
1233 -S "server hello, max_fragment_length extension" \
1234 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001235
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001236requires_gnutls
1237run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001238 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001239 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001240 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001241 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001242 -c "client hello, adding max_fragment_length extension" \
1243 -c "found max_fragment_length extension"
1244
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001245run_test "Max fragment length: client, message just fits" \
1246 "$P_SRV debug_level=3" \
1247 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1248 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001249 -c "Maximum fragment length is 2048" \
1250 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001251 -c "client hello, adding max_fragment_length extension" \
1252 -s "found max fragment length extension" \
1253 -s "server hello, max_fragment_length extension" \
1254 -c "found max_fragment_length extension" \
1255 -c "2048 bytes written in 1 fragments" \
1256 -s "2048 bytes read"
1257
1258run_test "Max fragment length: client, larger message" \
1259 "$P_SRV debug_level=3" \
1260 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1261 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001262 -c "Maximum fragment length is 2048" \
1263 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001264 -c "client hello, adding max_fragment_length extension" \
1265 -s "found max fragment length extension" \
1266 -s "server hello, max_fragment_length extension" \
1267 -c "found max_fragment_length extension" \
1268 -c "2345 bytes written in 2 fragments" \
1269 -s "2048 bytes read" \
1270 -s "297 bytes read"
1271
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001272run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001273 "$P_SRV debug_level=3 dtls=1" \
1274 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1275 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001276 -c "Maximum fragment length is 2048" \
1277 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001278 -c "client hello, adding max_fragment_length extension" \
1279 -s "found max fragment length extension" \
1280 -s "server hello, max_fragment_length extension" \
1281 -c "found max_fragment_length extension" \
1282 -c "fragment larger than.*maximum"
1283
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001284# Tests for renegotiation
1285
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001286run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001287 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001288 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001289 0 \
1290 -C "client hello, adding renegotiation extension" \
1291 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1292 -S "found renegotiation extension" \
1293 -s "server hello, secure renegotiation extension" \
1294 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001295 -C "=> renegotiate" \
1296 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001297 -S "write hello request"
1298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001299run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001300 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001301 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001302 0 \
1303 -c "client hello, adding renegotiation extension" \
1304 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1305 -s "found renegotiation extension" \
1306 -s "server hello, secure renegotiation extension" \
1307 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001308 -c "=> renegotiate" \
1309 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001310 -S "write hello request"
1311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001312run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001313 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001314 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001315 0 \
1316 -c "client hello, adding renegotiation extension" \
1317 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1318 -s "found renegotiation extension" \
1319 -s "server hello, secure renegotiation extension" \
1320 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001321 -c "=> renegotiate" \
1322 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001323 -s "write hello request"
1324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001325run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001326 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001327 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001328 0 \
1329 -c "client hello, adding renegotiation extension" \
1330 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1331 -s "found renegotiation extension" \
1332 -s "server hello, secure renegotiation extension" \
1333 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001334 -c "=> renegotiate" \
1335 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001336 -s "write hello request"
1337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001338run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001339 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001340 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001341 1 \
1342 -c "client hello, adding renegotiation extension" \
1343 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1344 -S "found renegotiation extension" \
1345 -s "server hello, secure renegotiation extension" \
1346 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001347 -c "=> renegotiate" \
1348 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001349 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001350 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001351 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001352
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001353run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001354 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001355 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001356 0 \
1357 -C "client hello, adding renegotiation extension" \
1358 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1359 -S "found renegotiation extension" \
1360 -s "server hello, secure renegotiation extension" \
1361 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001362 -C "=> renegotiate" \
1363 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001364 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001365 -S "SSL - An unexpected message was received from our peer" \
1366 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001367
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001368run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001369 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001370 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001371 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001372 0 \
1373 -C "client hello, adding renegotiation extension" \
1374 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1375 -S "found renegotiation extension" \
1376 -s "server hello, secure renegotiation extension" \
1377 -c "found renegotiation extension" \
1378 -C "=> renegotiate" \
1379 -S "=> renegotiate" \
1380 -s "write hello request" \
1381 -S "SSL - An unexpected message was received from our peer" \
1382 -S "failed"
1383
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001384# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001385run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001386 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001387 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001388 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001389 0 \
1390 -C "client hello, adding renegotiation extension" \
1391 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1392 -S "found renegotiation extension" \
1393 -s "server hello, secure renegotiation extension" \
1394 -c "found renegotiation extension" \
1395 -C "=> renegotiate" \
1396 -S "=> renegotiate" \
1397 -s "write hello request" \
1398 -S "SSL - An unexpected message was received from our peer" \
1399 -S "failed"
1400
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001401run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001402 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001403 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001404 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001405 0 \
1406 -C "client hello, adding renegotiation extension" \
1407 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1408 -S "found renegotiation extension" \
1409 -s "server hello, secure renegotiation extension" \
1410 -c "found renegotiation extension" \
1411 -C "=> renegotiate" \
1412 -S "=> renegotiate" \
1413 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001414 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001416run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001417 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001418 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001419 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001420 0 \
1421 -c "client hello, adding renegotiation extension" \
1422 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1423 -s "found renegotiation extension" \
1424 -s "server hello, secure renegotiation extension" \
1425 -c "found renegotiation extension" \
1426 -c "=> renegotiate" \
1427 -s "=> renegotiate" \
1428 -s "write hello request" \
1429 -S "SSL - An unexpected message was received from our peer" \
1430 -S "failed"
1431
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001432run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001433 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001434 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1435 0 \
1436 -C "client hello, adding renegotiation extension" \
1437 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1438 -S "found renegotiation extension" \
1439 -s "server hello, secure renegotiation extension" \
1440 -c "found renegotiation extension" \
1441 -S "record counter limit reached: renegotiate" \
1442 -C "=> renegotiate" \
1443 -S "=> renegotiate" \
1444 -S "write hello request" \
1445 -S "SSL - An unexpected message was received from our peer" \
1446 -S "failed"
1447
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001448# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001449run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001450 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001451 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001452 0 \
1453 -c "client hello, adding renegotiation extension" \
1454 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1455 -s "found renegotiation extension" \
1456 -s "server hello, secure renegotiation extension" \
1457 -c "found renegotiation extension" \
1458 -s "record counter limit reached: renegotiate" \
1459 -c "=> renegotiate" \
1460 -s "=> renegotiate" \
1461 -s "write hello request" \
1462 -S "SSL - An unexpected message was received from our peer" \
1463 -S "failed"
1464
1465run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001466 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001467 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001468 0 \
1469 -c "client hello, adding renegotiation extension" \
1470 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1471 -s "found renegotiation extension" \
1472 -s "server hello, secure renegotiation extension" \
1473 -c "found renegotiation extension" \
1474 -s "record counter limit reached: renegotiate" \
1475 -c "=> renegotiate" \
1476 -s "=> renegotiate" \
1477 -s "write hello request" \
1478 -S "SSL - An unexpected message was received from our peer" \
1479 -S "failed"
1480
1481run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001482 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001483 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1484 0 \
1485 -C "client hello, adding renegotiation extension" \
1486 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1487 -S "found renegotiation extension" \
1488 -s "server hello, secure renegotiation extension" \
1489 -c "found renegotiation extension" \
1490 -S "record counter limit reached: renegotiate" \
1491 -C "=> renegotiate" \
1492 -S "=> renegotiate" \
1493 -S "write hello request" \
1494 -S "SSL - An unexpected message was received from our peer" \
1495 -S "failed"
1496
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001497run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001498 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001499 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001500 0 \
1501 -c "client hello, adding renegotiation extension" \
1502 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1503 -s "found renegotiation extension" \
1504 -s "server hello, secure renegotiation extension" \
1505 -c "found renegotiation extension" \
1506 -c "=> renegotiate" \
1507 -s "=> renegotiate" \
1508 -S "write hello request"
1509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001510run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001511 "$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 +02001512 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001513 0 \
1514 -c "client hello, adding renegotiation extension" \
1515 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1516 -s "found renegotiation extension" \
1517 -s "server hello, secure renegotiation extension" \
1518 -c "found renegotiation extension" \
1519 -c "=> renegotiate" \
1520 -s "=> renegotiate" \
1521 -s "write hello request"
1522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001523run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001524 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001525 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001526 0 \
1527 -c "client hello, adding renegotiation extension" \
1528 -c "found renegotiation extension" \
1529 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001530 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001531 -C "error" \
1532 -c "HTTP/1.0 200 [Oo][Kk]"
1533
Paul Bakker539d9722015-02-08 16:18:35 +01001534requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001535run_test "Renegotiation: gnutls server strict, client-initiated" \
1536 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001537 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001538 0 \
1539 -c "client hello, adding renegotiation extension" \
1540 -c "found renegotiation extension" \
1541 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001542 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001543 -C "error" \
1544 -c "HTTP/1.0 200 [Oo][Kk]"
1545
Paul Bakker539d9722015-02-08 16:18:35 +01001546requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001547run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1548 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1549 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1550 1 \
1551 -c "client hello, adding renegotiation extension" \
1552 -C "found renegotiation extension" \
1553 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001554 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001555 -c "error" \
1556 -C "HTTP/1.0 200 [Oo][Kk]"
1557
Paul Bakker539d9722015-02-08 16:18:35 +01001558requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001559run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1560 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1561 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1562 allow_legacy=0" \
1563 1 \
1564 -c "client hello, adding renegotiation extension" \
1565 -C "found renegotiation extension" \
1566 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001567 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001568 -c "error" \
1569 -C "HTTP/1.0 200 [Oo][Kk]"
1570
Paul Bakker539d9722015-02-08 16:18:35 +01001571requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001572run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1573 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1574 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1575 allow_legacy=1" \
1576 0 \
1577 -c "client hello, adding renegotiation extension" \
1578 -C "found renegotiation extension" \
1579 -c "=> renegotiate" \
1580 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001581 -C "error" \
1582 -c "HTTP/1.0 200 [Oo][Kk]"
1583
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001584run_test "Renegotiation: DTLS, client-initiated" \
1585 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1586 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1587 0 \
1588 -c "client hello, adding renegotiation extension" \
1589 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1590 -s "found renegotiation extension" \
1591 -s "server hello, secure renegotiation extension" \
1592 -c "found renegotiation extension" \
1593 -c "=> renegotiate" \
1594 -s "=> renegotiate" \
1595 -S "write hello request"
1596
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001597run_test "Renegotiation: DTLS, server-initiated" \
1598 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001599 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1600 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001601 0 \
1602 -c "client hello, adding renegotiation extension" \
1603 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1604 -s "found renegotiation extension" \
1605 -s "server hello, secure renegotiation extension" \
1606 -c "found renegotiation extension" \
1607 -c "=> renegotiate" \
1608 -s "=> renegotiate" \
1609 -s "write hello request"
1610
Andres AG692ad842017-01-19 16:30:57 +00001611run_test "Renegotiation: DTLS, renego_period overflow" \
1612 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1613 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1614 0 \
1615 -c "client hello, adding renegotiation extension" \
1616 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1617 -s "found renegotiation extension" \
1618 -s "server hello, secure renegotiation extension" \
1619 -s "record counter limit reached: renegotiate" \
1620 -c "=> renegotiate" \
1621 -s "=> renegotiate" \
1622 -s "write hello request" \
1623
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001624requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001625run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1626 "$G_SRV -u --mtu 4096" \
1627 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1628 0 \
1629 -c "client hello, adding renegotiation extension" \
1630 -c "found renegotiation extension" \
1631 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001632 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001633 -C "error" \
1634 -s "Extra-header:"
1635
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001636# Test for the "secure renegotation" extension only (no actual renegotiation)
1637
Paul Bakker539d9722015-02-08 16:18:35 +01001638requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001639run_test "Renego ext: gnutls server strict, client default" \
1640 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1641 "$P_CLI debug_level=3" \
1642 0 \
1643 -c "found renegotiation extension" \
1644 -C "error" \
1645 -c "HTTP/1.0 200 [Oo][Kk]"
1646
Paul Bakker539d9722015-02-08 16:18:35 +01001647requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001648run_test "Renego ext: gnutls server unsafe, client default" \
1649 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1650 "$P_CLI debug_level=3" \
1651 0 \
1652 -C "found renegotiation extension" \
1653 -C "error" \
1654 -c "HTTP/1.0 200 [Oo][Kk]"
1655
Paul Bakker539d9722015-02-08 16:18:35 +01001656requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001657run_test "Renego ext: gnutls server unsafe, client break legacy" \
1658 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1659 "$P_CLI debug_level=3 allow_legacy=-1" \
1660 1 \
1661 -C "found renegotiation extension" \
1662 -c "error" \
1663 -C "HTTP/1.0 200 [Oo][Kk]"
1664
Paul Bakker539d9722015-02-08 16:18:35 +01001665requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001666run_test "Renego ext: gnutls client strict, server default" \
1667 "$P_SRV debug_level=3" \
1668 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1669 0 \
1670 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1671 -s "server hello, secure renegotiation extension"
1672
Paul Bakker539d9722015-02-08 16:18:35 +01001673requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001674run_test "Renego ext: gnutls client unsafe, server default" \
1675 "$P_SRV debug_level=3" \
1676 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1677 0 \
1678 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1679 -S "server hello, secure renegotiation extension"
1680
Paul Bakker539d9722015-02-08 16:18:35 +01001681requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001682run_test "Renego ext: gnutls client unsafe, server break legacy" \
1683 "$P_SRV debug_level=3 allow_legacy=-1" \
1684 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1685 1 \
1686 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1687 -S "server hello, secure renegotiation extension"
1688
Janos Follath0b242342016-02-17 10:11:21 +00001689# Tests for silently dropping trailing extra bytes in .der certificates
1690
1691requires_gnutls
1692run_test "DER format: no trailing bytes" \
1693 "$P_SRV crt_file=data_files/server5-der0.crt \
1694 key_file=data_files/server5.key" \
1695 "$G_CLI " \
1696 0 \
1697 -c "Handshake was completed" \
1698
1699requires_gnutls
1700run_test "DER format: with a trailing zero byte" \
1701 "$P_SRV crt_file=data_files/server5-der1a.crt \
1702 key_file=data_files/server5.key" \
1703 "$G_CLI " \
1704 0 \
1705 -c "Handshake was completed" \
1706
1707requires_gnutls
1708run_test "DER format: with a trailing random byte" \
1709 "$P_SRV crt_file=data_files/server5-der1b.crt \
1710 key_file=data_files/server5.key" \
1711 "$G_CLI " \
1712 0 \
1713 -c "Handshake was completed" \
1714
1715requires_gnutls
1716run_test "DER format: with 2 trailing random bytes" \
1717 "$P_SRV crt_file=data_files/server5-der2.crt \
1718 key_file=data_files/server5.key" \
1719 "$G_CLI " \
1720 0 \
1721 -c "Handshake was completed" \
1722
1723requires_gnutls
1724run_test "DER format: with 4 trailing random bytes" \
1725 "$P_SRV crt_file=data_files/server5-der4.crt \
1726 key_file=data_files/server5.key" \
1727 "$G_CLI " \
1728 0 \
1729 -c "Handshake was completed" \
1730
1731requires_gnutls
1732run_test "DER format: with 8 trailing random bytes" \
1733 "$P_SRV crt_file=data_files/server5-der8.crt \
1734 key_file=data_files/server5.key" \
1735 "$G_CLI " \
1736 0 \
1737 -c "Handshake was completed" \
1738
1739requires_gnutls
1740run_test "DER format: with 9 trailing random bytes" \
1741 "$P_SRV crt_file=data_files/server5-der9.crt \
1742 key_file=data_files/server5.key" \
1743 "$G_CLI " \
1744 0 \
1745 -c "Handshake was completed" \
1746
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001747# Tests for auth_mode
1748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001749run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001750 "$P_SRV crt_file=data_files/server5-badsign.crt \
1751 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001752 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001753 1 \
1754 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001755 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001756 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001757 -c "X509 - Certificate verification failed"
1758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001759run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001760 "$P_SRV crt_file=data_files/server5-badsign.crt \
1761 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001762 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001763 0 \
1764 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001765 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001766 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001767 -C "X509 - Certificate verification failed"
1768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001769run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001770 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001771 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001772 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001773 0 \
1774 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001775 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001776 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001777 -C "X509 - Certificate verification failed"
1778
Simon Butcher99000142016-10-13 17:21:01 +01001779run_test "Authentication: client SHA256, server required" \
1780 "$P_SRV auth_mode=required" \
1781 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1782 key_file=data_files/server6.key \
1783 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1784 0 \
1785 -c "Supported Signature Algorithm found: 4," \
1786 -c "Supported Signature Algorithm found: 5,"
1787
1788run_test "Authentication: client SHA384, server required" \
1789 "$P_SRV auth_mode=required" \
1790 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1791 key_file=data_files/server6.key \
1792 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
1793 0 \
1794 -c "Supported Signature Algorithm found: 4," \
1795 -c "Supported Signature Algorithm found: 5,"
1796
Gilles Peskinefd8332e2017-05-03 16:25:07 +02001797requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
1798run_test "Authentication: client has no cert, server required (SSLv3)" \
1799 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
1800 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
1801 key_file=data_files/server5.key" \
1802 1 \
1803 -S "skip write certificate request" \
1804 -C "skip parse certificate request" \
1805 -c "got a certificate request" \
1806 -c "got no certificate to send" \
1807 -S "x509_verify_cert() returned" \
1808 -s "client has no certificate" \
1809 -s "! mbedtls_ssl_handshake returned" \
1810 -c "! mbedtls_ssl_handshake returned" \
1811 -s "No client certification received from the client, but required by the authentication mode"
1812
1813run_test "Authentication: client has no cert, server required (TLS)" \
1814 "$P_SRV debug_level=3 auth_mode=required" \
1815 "$P_CLI debug_level=3 crt_file=none \
1816 key_file=data_files/server5.key" \
1817 1 \
1818 -S "skip write certificate request" \
1819 -C "skip parse certificate request" \
1820 -c "got a certificate request" \
1821 -c "= write certificate$" \
1822 -C "skip write certificate$" \
1823 -S "x509_verify_cert() returned" \
1824 -s "client has no certificate" \
1825 -s "! mbedtls_ssl_handshake returned" \
1826 -c "! mbedtls_ssl_handshake returned" \
1827 -s "No client certification received from the client, but required by the authentication mode"
1828
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001829run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001830 "$P_SRV debug_level=3 auth_mode=required" \
1831 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001832 key_file=data_files/server5.key" \
1833 1 \
1834 -S "skip write certificate request" \
1835 -C "skip parse certificate request" \
1836 -c "got a certificate request" \
1837 -C "skip write certificate" \
1838 -C "skip write certificate verify" \
1839 -S "skip parse certificate verify" \
1840 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001841 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001842 -s "! mbedtls_ssl_handshake returned" \
1843 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001844 -s "X509 - Certificate verification failed"
1845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001846run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001847 "$P_SRV debug_level=3 auth_mode=optional" \
1848 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001849 key_file=data_files/server5.key" \
1850 0 \
1851 -S "skip write certificate request" \
1852 -C "skip parse certificate request" \
1853 -c "got a certificate request" \
1854 -C "skip write certificate" \
1855 -C "skip write certificate verify" \
1856 -S "skip parse certificate verify" \
1857 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001858 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001859 -S "! mbedtls_ssl_handshake returned" \
1860 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001861 -S "X509 - Certificate verification failed"
1862
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001863run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001864 "$P_SRV debug_level=3 auth_mode=none" \
1865 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001866 key_file=data_files/server5.key" \
1867 0 \
1868 -s "skip write certificate request" \
1869 -C "skip parse certificate request" \
1870 -c "got no certificate request" \
1871 -c "skip write certificate" \
1872 -c "skip write certificate verify" \
1873 -s "skip parse certificate verify" \
1874 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001875 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001876 -S "! mbedtls_ssl_handshake returned" \
1877 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001878 -S "X509 - Certificate verification failed"
1879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001880run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001881 "$P_SRV debug_level=3 auth_mode=optional" \
1882 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001883 0 \
1884 -S "skip write certificate request" \
1885 -C "skip parse certificate request" \
1886 -c "got a certificate request" \
1887 -C "skip write certificate$" \
1888 -C "got no certificate to send" \
1889 -S "SSLv3 client has no certificate" \
1890 -c "skip write certificate verify" \
1891 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001892 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001893 -S "! mbedtls_ssl_handshake returned" \
1894 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001895 -S "X509 - Certificate verification failed"
1896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001897run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001898 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001899 "$O_CLI" \
1900 0 \
1901 -S "skip write certificate request" \
1902 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001903 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001904 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001905 -S "X509 - Certificate verification failed"
1906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001907run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001908 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001909 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001910 0 \
1911 -C "skip parse certificate request" \
1912 -c "got a certificate request" \
1913 -C "skip write certificate$" \
1914 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001915 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001916
Gilles Peskinefd8332e2017-05-03 16:25:07 +02001917run_test "Authentication: client no cert, openssl server required" \
1918 "$O_SRV -Verify 10" \
1919 "$P_CLI debug_level=3 crt_file=none key_file=none" \
1920 1 \
1921 -C "skip parse certificate request" \
1922 -c "got a certificate request" \
1923 -C "skip write certificate$" \
1924 -c "skip write certificate verify" \
1925 -c "! mbedtls_ssl_handshake returned"
1926
Janos Follathe2681a42016-03-07 15:57:05 +00001927requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001928run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001929 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001930 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001931 0 \
1932 -S "skip write certificate request" \
1933 -C "skip parse certificate request" \
1934 -c "got a certificate request" \
1935 -C "skip write certificate$" \
1936 -c "skip write certificate verify" \
1937 -c "got no certificate to send" \
1938 -s "SSLv3 client has no certificate" \
1939 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001940 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001941 -S "! mbedtls_ssl_handshake returned" \
1942 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001943 -S "X509 - Certificate verification failed"
1944
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001945# Tests for certificate selection based on SHA verson
1946
1947run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1948 "$P_SRV crt_file=data_files/server5.crt \
1949 key_file=data_files/server5.key \
1950 crt_file2=data_files/server5-sha1.crt \
1951 key_file2=data_files/server5.key" \
1952 "$P_CLI force_version=tls1_2" \
1953 0 \
1954 -c "signed using.*ECDSA with SHA256" \
1955 -C "signed using.*ECDSA with SHA1"
1956
1957run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1958 "$P_SRV crt_file=data_files/server5.crt \
1959 key_file=data_files/server5.key \
1960 crt_file2=data_files/server5-sha1.crt \
1961 key_file2=data_files/server5.key" \
1962 "$P_CLI force_version=tls1_1" \
1963 0 \
1964 -C "signed using.*ECDSA with SHA256" \
1965 -c "signed using.*ECDSA with SHA1"
1966
1967run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1968 "$P_SRV crt_file=data_files/server5.crt \
1969 key_file=data_files/server5.key \
1970 crt_file2=data_files/server5-sha1.crt \
1971 key_file2=data_files/server5.key" \
1972 "$P_CLI force_version=tls1" \
1973 0 \
1974 -C "signed using.*ECDSA with SHA256" \
1975 -c "signed using.*ECDSA with SHA1"
1976
1977run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1978 "$P_SRV crt_file=data_files/server5.crt \
1979 key_file=data_files/server5.key \
1980 crt_file2=data_files/server6.crt \
1981 key_file2=data_files/server6.key" \
1982 "$P_CLI force_version=tls1_1" \
1983 0 \
1984 -c "serial number.*09" \
1985 -c "signed using.*ECDSA with SHA256" \
1986 -C "signed using.*ECDSA with SHA1"
1987
1988run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1989 "$P_SRV crt_file=data_files/server6.crt \
1990 key_file=data_files/server6.key \
1991 crt_file2=data_files/server5.crt \
1992 key_file2=data_files/server5.key" \
1993 "$P_CLI force_version=tls1_1" \
1994 0 \
1995 -c "serial number.*0A" \
1996 -c "signed using.*ECDSA with SHA256" \
1997 -C "signed using.*ECDSA with SHA1"
1998
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001999# tests for SNI
2000
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002001run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002002 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002003 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002004 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002005 0 \
2006 -S "parse ServerName extension" \
2007 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2008 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002009
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002010run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002011 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002012 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002013 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 +02002014 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002015 0 \
2016 -s "parse ServerName extension" \
2017 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2018 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002020run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002021 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002022 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002023 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 +02002024 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002025 0 \
2026 -s "parse ServerName extension" \
2027 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2028 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002030run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002031 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002032 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002033 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 +02002034 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002035 1 \
2036 -s "parse ServerName extension" \
2037 -s "ssl_sni_wrapper() returned" \
2038 -s "mbedtls_ssl_handshake returned" \
2039 -c "mbedtls_ssl_handshake returned" \
2040 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002041
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002042run_test "SNI: client auth no override: optional" \
2043 "$P_SRV debug_level=3 auth_mode=optional \
2044 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2045 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2046 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002047 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002048 -S "skip write certificate request" \
2049 -C "skip parse certificate request" \
2050 -c "got a certificate request" \
2051 -C "skip write certificate" \
2052 -C "skip write certificate verify" \
2053 -S "skip parse certificate verify"
2054
2055run_test "SNI: client auth override: none -> optional" \
2056 "$P_SRV debug_level=3 auth_mode=none \
2057 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2058 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2059 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002060 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002061 -S "skip write certificate request" \
2062 -C "skip parse certificate request" \
2063 -c "got a certificate request" \
2064 -C "skip write certificate" \
2065 -C "skip write certificate verify" \
2066 -S "skip parse certificate verify"
2067
2068run_test "SNI: client auth override: optional -> none" \
2069 "$P_SRV debug_level=3 auth_mode=optional \
2070 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2071 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2072 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002073 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002074 -s "skip write certificate request" \
2075 -C "skip parse certificate request" \
2076 -c "got no certificate request" \
2077 -c "skip write certificate" \
2078 -c "skip write certificate verify" \
2079 -s "skip parse certificate verify"
2080
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002081run_test "SNI: CA no override" \
2082 "$P_SRV debug_level=3 auth_mode=optional \
2083 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2084 ca_file=data_files/test-ca.crt \
2085 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2086 "$P_CLI debug_level=3 server_name=localhost \
2087 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2088 1 \
2089 -S "skip write certificate request" \
2090 -C "skip parse certificate request" \
2091 -c "got a certificate request" \
2092 -C "skip write certificate" \
2093 -C "skip write certificate verify" \
2094 -S "skip parse certificate verify" \
2095 -s "x509_verify_cert() returned" \
2096 -s "! The certificate is not correctly signed by the trusted CA" \
2097 -S "The certificate has been revoked (is on a CRL)"
2098
2099run_test "SNI: CA override" \
2100 "$P_SRV debug_level=3 auth_mode=optional \
2101 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2102 ca_file=data_files/test-ca.crt \
2103 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2104 "$P_CLI debug_level=3 server_name=localhost \
2105 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2106 0 \
2107 -S "skip write certificate request" \
2108 -C "skip parse certificate request" \
2109 -c "got a certificate request" \
2110 -C "skip write certificate" \
2111 -C "skip write certificate verify" \
2112 -S "skip parse certificate verify" \
2113 -S "x509_verify_cert() returned" \
2114 -S "! The certificate is not correctly signed by the trusted CA" \
2115 -S "The certificate has been revoked (is on a CRL)"
2116
2117run_test "SNI: CA override with CRL" \
2118 "$P_SRV debug_level=3 auth_mode=optional \
2119 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2120 ca_file=data_files/test-ca.crt \
2121 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2122 "$P_CLI debug_level=3 server_name=localhost \
2123 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2124 1 \
2125 -S "skip write certificate request" \
2126 -C "skip parse certificate request" \
2127 -c "got a certificate request" \
2128 -C "skip write certificate" \
2129 -C "skip write certificate verify" \
2130 -S "skip parse certificate verify" \
2131 -s "x509_verify_cert() returned" \
2132 -S "! The certificate is not correctly signed by the trusted CA" \
2133 -s "The certificate has been revoked (is on a CRL)"
2134
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002135# Tests for non-blocking I/O: exercise a variety of handshake flows
2136
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002137run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002138 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2139 "$P_CLI nbio=2 tickets=0" \
2140 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002141 -S "mbedtls_ssl_handshake returned" \
2142 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002143 -c "Read from server: .* bytes read"
2144
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002145run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002146 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2147 "$P_CLI nbio=2 tickets=0" \
2148 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002149 -S "mbedtls_ssl_handshake returned" \
2150 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002151 -c "Read from server: .* bytes read"
2152
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002153run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002154 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2155 "$P_CLI nbio=2 tickets=1" \
2156 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002157 -S "mbedtls_ssl_handshake returned" \
2158 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002159 -c "Read from server: .* bytes read"
2160
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002161run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002162 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2163 "$P_CLI nbio=2 tickets=1" \
2164 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002165 -S "mbedtls_ssl_handshake returned" \
2166 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002167 -c "Read from server: .* bytes read"
2168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002169run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002170 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2171 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2172 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002173 -S "mbedtls_ssl_handshake returned" \
2174 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002175 -c "Read from server: .* bytes read"
2176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002177run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002178 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2179 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2180 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002181 -S "mbedtls_ssl_handshake returned" \
2182 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002183 -c "Read from server: .* bytes read"
2184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002185run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002186 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2187 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2188 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002189 -S "mbedtls_ssl_handshake returned" \
2190 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002191 -c "Read from server: .* bytes read"
2192
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002193# Tests for version negotiation
2194
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002195run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002196 "$P_SRV" \
2197 "$P_CLI" \
2198 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002199 -S "mbedtls_ssl_handshake returned" \
2200 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002201 -s "Protocol is TLSv1.2" \
2202 -c "Protocol is TLSv1.2"
2203
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002204run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002205 "$P_SRV" \
2206 "$P_CLI max_version=tls1_1" \
2207 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002208 -S "mbedtls_ssl_handshake returned" \
2209 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002210 -s "Protocol is TLSv1.1" \
2211 -c "Protocol is TLSv1.1"
2212
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002213run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002214 "$P_SRV max_version=tls1_1" \
2215 "$P_CLI" \
2216 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002217 -S "mbedtls_ssl_handshake returned" \
2218 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002219 -s "Protocol is TLSv1.1" \
2220 -c "Protocol is TLSv1.1"
2221
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002222run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002223 "$P_SRV max_version=tls1_1" \
2224 "$P_CLI max_version=tls1_1" \
2225 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002226 -S "mbedtls_ssl_handshake returned" \
2227 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002228 -s "Protocol is TLSv1.1" \
2229 -c "Protocol is TLSv1.1"
2230
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002231run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002232 "$P_SRV min_version=tls1_1" \
2233 "$P_CLI max_version=tls1_1" \
2234 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002235 -S "mbedtls_ssl_handshake returned" \
2236 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002237 -s "Protocol is TLSv1.1" \
2238 -c "Protocol is TLSv1.1"
2239
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002240run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002241 "$P_SRV max_version=tls1_1" \
2242 "$P_CLI min_version=tls1_1" \
2243 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002244 -S "mbedtls_ssl_handshake returned" \
2245 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002246 -s "Protocol is TLSv1.1" \
2247 -c "Protocol is TLSv1.1"
2248
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002249run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002250 "$P_SRV max_version=tls1_1" \
2251 "$P_CLI min_version=tls1_2" \
2252 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002253 -s "mbedtls_ssl_handshake returned" \
2254 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002255 -c "SSL - Handshake protocol not within min/max boundaries"
2256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002257run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002258 "$P_SRV min_version=tls1_2" \
2259 "$P_CLI max_version=tls1_1" \
2260 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002261 -s "mbedtls_ssl_handshake returned" \
2262 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002263 -s "SSL - Handshake protocol not within min/max boundaries"
2264
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002265# Tests for ALPN extension
2266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002267run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002268 "$P_SRV debug_level=3" \
2269 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002270 0 \
2271 -C "client hello, adding alpn extension" \
2272 -S "found alpn extension" \
2273 -C "got an alert message, type: \\[2:120]" \
2274 -S "server hello, adding alpn extension" \
2275 -C "found alpn extension " \
2276 -C "Application Layer Protocol is" \
2277 -S "Application Layer Protocol is"
2278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002279run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002280 "$P_SRV debug_level=3" \
2281 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002282 0 \
2283 -c "client hello, adding alpn extension" \
2284 -s "found alpn extension" \
2285 -C "got an alert message, type: \\[2:120]" \
2286 -S "server hello, adding alpn extension" \
2287 -C "found alpn extension " \
2288 -c "Application Layer Protocol is (none)" \
2289 -S "Application Layer Protocol is"
2290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002291run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002292 "$P_SRV debug_level=3 alpn=abc,1234" \
2293 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002294 0 \
2295 -C "client hello, adding alpn extension" \
2296 -S "found alpn extension" \
2297 -C "got an alert message, type: \\[2:120]" \
2298 -S "server hello, adding alpn extension" \
2299 -C "found alpn extension " \
2300 -C "Application Layer Protocol is" \
2301 -s "Application Layer Protocol is (none)"
2302
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002303run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002304 "$P_SRV debug_level=3 alpn=abc,1234" \
2305 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002306 0 \
2307 -c "client hello, adding alpn extension" \
2308 -s "found alpn extension" \
2309 -C "got an alert message, type: \\[2:120]" \
2310 -s "server hello, adding alpn extension" \
2311 -c "found alpn extension" \
2312 -c "Application Layer Protocol is abc" \
2313 -s "Application Layer Protocol is abc"
2314
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002315run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002316 "$P_SRV debug_level=3 alpn=abc,1234" \
2317 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002318 0 \
2319 -c "client hello, adding alpn extension" \
2320 -s "found alpn extension" \
2321 -C "got an alert message, type: \\[2:120]" \
2322 -s "server hello, adding alpn extension" \
2323 -c "found alpn extension" \
2324 -c "Application Layer Protocol is abc" \
2325 -s "Application Layer Protocol is abc"
2326
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002327run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002328 "$P_SRV debug_level=3 alpn=abc,1234" \
2329 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002330 0 \
2331 -c "client hello, adding alpn extension" \
2332 -s "found alpn extension" \
2333 -C "got an alert message, type: \\[2:120]" \
2334 -s "server hello, adding alpn extension" \
2335 -c "found alpn extension" \
2336 -c "Application Layer Protocol is 1234" \
2337 -s "Application Layer Protocol is 1234"
2338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002339run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002340 "$P_SRV debug_level=3 alpn=abc,123" \
2341 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002342 1 \
2343 -c "client hello, adding alpn extension" \
2344 -s "found alpn extension" \
2345 -c "got an alert message, type: \\[2:120]" \
2346 -S "server hello, adding alpn extension" \
2347 -C "found alpn extension" \
2348 -C "Application Layer Protocol is 1234" \
2349 -S "Application Layer Protocol is 1234"
2350
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002351
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002352# Tests for keyUsage in leaf certificates, part 1:
2353# server-side certificate/suite selection
2354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002355run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002356 "$P_SRV key_file=data_files/server2.key \
2357 crt_file=data_files/server2.ku-ds.crt" \
2358 "$P_CLI" \
2359 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002360 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002361
2362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002363run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002364 "$P_SRV key_file=data_files/server2.key \
2365 crt_file=data_files/server2.ku-ke.crt" \
2366 "$P_CLI" \
2367 0 \
2368 -c "Ciphersuite is TLS-RSA-WITH-"
2369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002370run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002371 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002372 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002373 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002374 1 \
2375 -C "Ciphersuite is "
2376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002377run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002378 "$P_SRV key_file=data_files/server5.key \
2379 crt_file=data_files/server5.ku-ds.crt" \
2380 "$P_CLI" \
2381 0 \
2382 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2383
2384
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002385run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002386 "$P_SRV key_file=data_files/server5.key \
2387 crt_file=data_files/server5.ku-ka.crt" \
2388 "$P_CLI" \
2389 0 \
2390 -c "Ciphersuite is TLS-ECDH-"
2391
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002392run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002393 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002394 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002395 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002396 1 \
2397 -C "Ciphersuite is "
2398
2399# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002400# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002401
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002402run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002403 "$O_SRV -key data_files/server2.key \
2404 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002405 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002406 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2407 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002408 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002409 -C "Processing of the Certificate handshake message failed" \
2410 -c "Ciphersuite is TLS-"
2411
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002412run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002413 "$O_SRV -key data_files/server2.key \
2414 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002415 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002416 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2417 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002418 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002419 -C "Processing of the Certificate handshake message failed" \
2420 -c "Ciphersuite is TLS-"
2421
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002422run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002423 "$O_SRV -key data_files/server2.key \
2424 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002425 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002426 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2427 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002428 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002429 -C "Processing of the Certificate handshake message failed" \
2430 -c "Ciphersuite is TLS-"
2431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002432run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002433 "$O_SRV -key data_files/server2.key \
2434 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002435 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002436 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2437 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002438 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002439 -c "Processing of the Certificate handshake message failed" \
2440 -C "Ciphersuite is TLS-"
2441
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002442run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2443 "$O_SRV -key data_files/server2.key \
2444 -cert data_files/server2.ku-ke.crt" \
2445 "$P_CLI debug_level=1 auth_mode=optional \
2446 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2447 0 \
2448 -c "bad certificate (usage extensions)" \
2449 -C "Processing of the Certificate handshake message failed" \
2450 -c "Ciphersuite is TLS-" \
2451 -c "! Usage does not match the keyUsage extension"
2452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002453run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002454 "$O_SRV -key data_files/server2.key \
2455 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002456 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002457 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2458 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002459 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002460 -C "Processing of the Certificate handshake message failed" \
2461 -c "Ciphersuite is TLS-"
2462
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002463run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002464 "$O_SRV -key data_files/server2.key \
2465 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002466 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002467 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2468 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002469 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002470 -c "Processing of the Certificate handshake message failed" \
2471 -C "Ciphersuite is TLS-"
2472
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002473run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2474 "$O_SRV -key data_files/server2.key \
2475 -cert data_files/server2.ku-ds.crt" \
2476 "$P_CLI debug_level=1 auth_mode=optional \
2477 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2478 0 \
2479 -c "bad certificate (usage extensions)" \
2480 -C "Processing of the Certificate handshake message failed" \
2481 -c "Ciphersuite is TLS-" \
2482 -c "! Usage does not match the keyUsage extension"
2483
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002484# Tests for keyUsage in leaf certificates, part 3:
2485# server-side checking of client cert
2486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002487run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002488 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002489 "$O_CLI -key data_files/server2.key \
2490 -cert data_files/server2.ku-ds.crt" \
2491 0 \
2492 -S "bad certificate (usage extensions)" \
2493 -S "Processing of the Certificate handshake message failed"
2494
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002495run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002496 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002497 "$O_CLI -key data_files/server2.key \
2498 -cert data_files/server2.ku-ke.crt" \
2499 0 \
2500 -s "bad certificate (usage extensions)" \
2501 -S "Processing of the Certificate handshake message failed"
2502
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002503run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002504 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002505 "$O_CLI -key data_files/server2.key \
2506 -cert data_files/server2.ku-ke.crt" \
2507 1 \
2508 -s "bad certificate (usage extensions)" \
2509 -s "Processing of the Certificate handshake message failed"
2510
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002511run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002512 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002513 "$O_CLI -key data_files/server5.key \
2514 -cert data_files/server5.ku-ds.crt" \
2515 0 \
2516 -S "bad certificate (usage extensions)" \
2517 -S "Processing of the Certificate handshake message failed"
2518
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002519run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002520 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002521 "$O_CLI -key data_files/server5.key \
2522 -cert data_files/server5.ku-ka.crt" \
2523 0 \
2524 -s "bad certificate (usage extensions)" \
2525 -S "Processing of the Certificate handshake message failed"
2526
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002527# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2528
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002529run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002530 "$P_SRV key_file=data_files/server5.key \
2531 crt_file=data_files/server5.eku-srv.crt" \
2532 "$P_CLI" \
2533 0
2534
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002535run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002536 "$P_SRV key_file=data_files/server5.key \
2537 crt_file=data_files/server5.eku-srv.crt" \
2538 "$P_CLI" \
2539 0
2540
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002541run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002542 "$P_SRV key_file=data_files/server5.key \
2543 crt_file=data_files/server5.eku-cs_any.crt" \
2544 "$P_CLI" \
2545 0
2546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002547run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002548 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002549 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002550 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002551 1
2552
2553# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2554
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002555run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002556 "$O_SRV -key data_files/server5.key \
2557 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002558 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002559 0 \
2560 -C "bad certificate (usage extensions)" \
2561 -C "Processing of the Certificate handshake message failed" \
2562 -c "Ciphersuite is TLS-"
2563
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002564run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002565 "$O_SRV -key data_files/server5.key \
2566 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002567 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002568 0 \
2569 -C "bad certificate (usage extensions)" \
2570 -C "Processing of the Certificate handshake message failed" \
2571 -c "Ciphersuite is TLS-"
2572
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002573run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002574 "$O_SRV -key data_files/server5.key \
2575 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002576 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002577 0 \
2578 -C "bad certificate (usage extensions)" \
2579 -C "Processing of the Certificate handshake message failed" \
2580 -c "Ciphersuite is TLS-"
2581
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002582run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002583 "$O_SRV -key data_files/server5.key \
2584 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002585 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002586 1 \
2587 -c "bad certificate (usage extensions)" \
2588 -c "Processing of the Certificate handshake message failed" \
2589 -C "Ciphersuite is TLS-"
2590
2591# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002593run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002594 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002595 "$O_CLI -key data_files/server5.key \
2596 -cert data_files/server5.eku-cli.crt" \
2597 0 \
2598 -S "bad certificate (usage extensions)" \
2599 -S "Processing of the Certificate handshake message failed"
2600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002601run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002602 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002603 "$O_CLI -key data_files/server5.key \
2604 -cert data_files/server5.eku-srv_cli.crt" \
2605 0 \
2606 -S "bad certificate (usage extensions)" \
2607 -S "Processing of the Certificate handshake message failed"
2608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002609run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002610 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002611 "$O_CLI -key data_files/server5.key \
2612 -cert data_files/server5.eku-cs_any.crt" \
2613 0 \
2614 -S "bad certificate (usage extensions)" \
2615 -S "Processing of the Certificate handshake message failed"
2616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002617run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002618 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002619 "$O_CLI -key data_files/server5.key \
2620 -cert data_files/server5.eku-cs.crt" \
2621 0 \
2622 -s "bad certificate (usage extensions)" \
2623 -S "Processing of the Certificate handshake message failed"
2624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002625run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002626 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002627 "$O_CLI -key data_files/server5.key \
2628 -cert data_files/server5.eku-cs.crt" \
2629 1 \
2630 -s "bad certificate (usage extensions)" \
2631 -s "Processing of the Certificate handshake message failed"
2632
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002633# Tests for DHM parameters loading
2634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002635run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002636 "$P_SRV" \
2637 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2638 debug_level=3" \
2639 0 \
2640 -c "value of 'DHM: P ' (2048 bits)" \
2641 -c "value of 'DHM: G ' (2048 bits)"
2642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002643run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002644 "$P_SRV dhm_file=data_files/dhparams.pem" \
2645 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2646 debug_level=3" \
2647 0 \
2648 -c "value of 'DHM: P ' (1024 bits)" \
2649 -c "value of 'DHM: G ' (2 bits)"
2650
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002651# Tests for DHM client-side size checking
2652
2653run_test "DHM size: server default, client default, OK" \
2654 "$P_SRV" \
2655 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2656 debug_level=1" \
2657 0 \
2658 -C "DHM prime too short:"
2659
2660run_test "DHM size: server default, client 2048, OK" \
2661 "$P_SRV" \
2662 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2663 debug_level=1 dhmlen=2048" \
2664 0 \
2665 -C "DHM prime too short:"
2666
2667run_test "DHM size: server 1024, client default, OK" \
2668 "$P_SRV dhm_file=data_files/dhparams.pem" \
2669 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2670 debug_level=1" \
2671 0 \
2672 -C "DHM prime too short:"
2673
2674run_test "DHM size: server 1000, client default, rejected" \
2675 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2676 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2677 debug_level=1" \
2678 1 \
2679 -c "DHM prime too short:"
2680
2681run_test "DHM size: server default, client 2049, rejected" \
2682 "$P_SRV" \
2683 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2684 debug_level=1 dhmlen=2049" \
2685 1 \
2686 -c "DHM prime too short:"
2687
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002688# Tests for PSK callback
2689
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002690run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002691 "$P_SRV psk=abc123 psk_identity=foo" \
2692 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2693 psk_identity=foo psk=abc123" \
2694 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002695 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002696 -S "SSL - Unknown identity received" \
2697 -S "SSL - Verification of the message MAC failed"
2698
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002699run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002700 "$P_SRV" \
2701 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2702 psk_identity=foo psk=abc123" \
2703 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002704 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002705 -S "SSL - Unknown identity received" \
2706 -S "SSL - Verification of the message MAC failed"
2707
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002708run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002709 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2710 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2711 psk_identity=foo psk=abc123" \
2712 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002713 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002714 -s "SSL - Unknown identity received" \
2715 -S "SSL - Verification of the message MAC failed"
2716
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002717run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002718 "$P_SRV psk_list=abc,dead,def,beef" \
2719 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2720 psk_identity=abc psk=dead" \
2721 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002722 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002723 -S "SSL - Unknown identity received" \
2724 -S "SSL - Verification of the message MAC failed"
2725
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002726run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002727 "$P_SRV psk_list=abc,dead,def,beef" \
2728 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2729 psk_identity=def psk=beef" \
2730 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002731 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002732 -S "SSL - Unknown identity received" \
2733 -S "SSL - Verification of the message MAC failed"
2734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002735run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002736 "$P_SRV psk_list=abc,dead,def,beef" \
2737 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2738 psk_identity=ghi psk=beef" \
2739 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002740 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002741 -s "SSL - Unknown identity received" \
2742 -S "SSL - Verification of the message MAC failed"
2743
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002744run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002745 "$P_SRV psk_list=abc,dead,def,beef" \
2746 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2747 psk_identity=abc psk=beef" \
2748 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002749 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002750 -S "SSL - Unknown identity received" \
2751 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002752
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002753# Tests for EC J-PAKE
2754
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002755requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002756run_test "ECJPAKE: client not configured" \
2757 "$P_SRV debug_level=3" \
2758 "$P_CLI debug_level=3" \
2759 0 \
2760 -C "add ciphersuite: c0ff" \
2761 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002762 -S "found ecjpake kkpp extension" \
2763 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002764 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002765 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002766 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002767 -S "None of the common ciphersuites is usable"
2768
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002769requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002770run_test "ECJPAKE: server not configured" \
2771 "$P_SRV debug_level=3" \
2772 "$P_CLI debug_level=3 ecjpake_pw=bla \
2773 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2774 1 \
2775 -c "add ciphersuite: c0ff" \
2776 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002777 -s "found ecjpake kkpp extension" \
2778 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002779 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002780 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002781 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002782 -s "None of the common ciphersuites is usable"
2783
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002784requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002785run_test "ECJPAKE: working, TLS" \
2786 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2787 "$P_CLI debug_level=3 ecjpake_pw=bla \
2788 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002789 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002790 -c "add ciphersuite: c0ff" \
2791 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002792 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002793 -s "found ecjpake kkpp extension" \
2794 -S "skip ecjpake kkpp extension" \
2795 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002796 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002797 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002798 -S "None of the common ciphersuites is usable" \
2799 -S "SSL - Verification of the message MAC failed"
2800
Janos Follath74537a62016-09-02 13:45:28 +01002801server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002802requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002803run_test "ECJPAKE: password mismatch, TLS" \
2804 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2805 "$P_CLI debug_level=3 ecjpake_pw=bad \
2806 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2807 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002808 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002809 -s "SSL - Verification of the message MAC failed"
2810
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002811requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002812run_test "ECJPAKE: working, DTLS" \
2813 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2814 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2815 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2816 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002817 -c "re-using cached ecjpake parameters" \
2818 -S "SSL - Verification of the message MAC failed"
2819
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002820requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002821run_test "ECJPAKE: working, DTLS, no cookie" \
2822 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2823 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2824 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2825 0 \
2826 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002827 -S "SSL - Verification of the message MAC failed"
2828
Janos Follath74537a62016-09-02 13:45:28 +01002829server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002830requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002831run_test "ECJPAKE: password mismatch, DTLS" \
2832 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2833 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2834 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2835 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002836 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002837 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002838
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002839# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002840requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002841run_test "ECJPAKE: working, DTLS, nolog" \
2842 "$P_SRV dtls=1 ecjpake_pw=bla" \
2843 "$P_CLI dtls=1 ecjpake_pw=bla \
2844 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2845 0
2846
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002847# Tests for ciphersuites per version
2848
Janos Follathe2681a42016-03-07 15:57:05 +00002849requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002850run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002851 "$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 +02002852 "$P_CLI force_version=ssl3" \
2853 0 \
2854 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2855
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002856run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002857 "$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 +01002858 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002859 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002860 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002862run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002863 "$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 +02002864 "$P_CLI force_version=tls1_1" \
2865 0 \
2866 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002868run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002869 "$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 +02002870 "$P_CLI force_version=tls1_2" \
2871 0 \
2872 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2873
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002874# Test for ClientHello without extensions
2875
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002876requires_gnutls
2877run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002878 "$P_SRV debug_level=3" \
2879 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2880 0 \
2881 -s "dumping 'client hello extensions' (0 bytes)"
2882
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002883# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002884
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002885run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002886 "$P_SRV" \
2887 "$P_CLI request_size=100" \
2888 0 \
2889 -s "Read from client: 100 bytes read$"
2890
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002891run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002892 "$P_SRV" \
2893 "$P_CLI request_size=500" \
2894 0 \
2895 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002896
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002897# Tests for small packets
2898
Janos Follathe2681a42016-03-07 15:57:05 +00002899requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002900run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002901 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002902 "$P_CLI request_size=1 force_version=ssl3 \
2903 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2904 0 \
2905 -s "Read from client: 1 bytes read"
2906
Janos Follathe2681a42016-03-07 15:57:05 +00002907requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002908run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002909 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002910 "$P_CLI request_size=1 force_version=ssl3 \
2911 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2912 0 \
2913 -s "Read from client: 1 bytes read"
2914
2915run_test "Small packet TLS 1.0 BlockCipher" \
2916 "$P_SRV" \
2917 "$P_CLI request_size=1 force_version=tls1 \
2918 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2919 0 \
2920 -s "Read from client: 1 bytes read"
2921
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002922run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2923 "$P_SRV" \
2924 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2925 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2926 0 \
2927 -s "Read from client: 1 bytes read"
2928
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002929run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2930 "$P_SRV" \
2931 "$P_CLI request_size=1 force_version=tls1 \
2932 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2933 trunc_hmac=1" \
2934 0 \
2935 -s "Read from client: 1 bytes read"
2936
2937run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002938 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002939 "$P_CLI request_size=1 force_version=tls1 \
2940 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2941 trunc_hmac=1" \
2942 0 \
2943 -s "Read from client: 1 bytes read"
2944
2945run_test "Small packet TLS 1.1 BlockCipher" \
2946 "$P_SRV" \
2947 "$P_CLI request_size=1 force_version=tls1_1 \
2948 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2949 0 \
2950 -s "Read from client: 1 bytes read"
2951
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002952run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2953 "$P_SRV" \
2954 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2955 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2956 0 \
2957 -s "Read from client: 1 bytes read"
2958
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002959run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002960 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002961 "$P_CLI request_size=1 force_version=tls1_1 \
2962 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2963 0 \
2964 -s "Read from client: 1 bytes read"
2965
2966run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2967 "$P_SRV" \
2968 "$P_CLI request_size=1 force_version=tls1_1 \
2969 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2970 trunc_hmac=1" \
2971 0 \
2972 -s "Read from client: 1 bytes read"
2973
2974run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002975 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002976 "$P_CLI request_size=1 force_version=tls1_1 \
2977 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2978 trunc_hmac=1" \
2979 0 \
2980 -s "Read from client: 1 bytes read"
2981
2982run_test "Small packet TLS 1.2 BlockCipher" \
2983 "$P_SRV" \
2984 "$P_CLI request_size=1 force_version=tls1_2 \
2985 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2986 0 \
2987 -s "Read from client: 1 bytes read"
2988
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002989run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2990 "$P_SRV" \
2991 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2992 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2993 0 \
2994 -s "Read from client: 1 bytes read"
2995
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002996run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2997 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002998 "$P_CLI request_size=1 force_version=tls1_2 \
2999 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003000 0 \
3001 -s "Read from client: 1 bytes read"
3002
3003run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3004 "$P_SRV" \
3005 "$P_CLI request_size=1 force_version=tls1_2 \
3006 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3007 trunc_hmac=1" \
3008 0 \
3009 -s "Read from client: 1 bytes read"
3010
3011run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003012 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003013 "$P_CLI request_size=1 force_version=tls1_2 \
3014 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3015 0 \
3016 -s "Read from client: 1 bytes read"
3017
3018run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003019 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003020 "$P_CLI request_size=1 force_version=tls1_2 \
3021 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3022 trunc_hmac=1" \
3023 0 \
3024 -s "Read from client: 1 bytes read"
3025
3026run_test "Small packet TLS 1.2 AEAD" \
3027 "$P_SRV" \
3028 "$P_CLI request_size=1 force_version=tls1_2 \
3029 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3030 0 \
3031 -s "Read from client: 1 bytes read"
3032
3033run_test "Small packet TLS 1.2 AEAD shorter tag" \
3034 "$P_SRV" \
3035 "$P_CLI request_size=1 force_version=tls1_2 \
3036 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3037 0 \
3038 -s "Read from client: 1 bytes read"
3039
Janos Follath00efff72016-05-06 13:48:23 +01003040# A test for extensions in SSLv3
3041
3042requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3043run_test "SSLv3 with extensions, server side" \
3044 "$P_SRV min_version=ssl3 debug_level=3" \
3045 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3046 0 \
3047 -S "dumping 'client hello extensions'" \
3048 -S "server hello, total extension length:"
3049
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003050# Test for large packets
3051
Janos Follathe2681a42016-03-07 15:57:05 +00003052requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003053run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003054 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003055 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003056 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3057 0 \
3058 -s "Read from client: 16384 bytes read"
3059
Janos Follathe2681a42016-03-07 15:57:05 +00003060requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003061run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003062 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003063 "$P_CLI request_size=16384 force_version=ssl3 \
3064 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3065 0 \
3066 -s "Read from client: 16384 bytes read"
3067
3068run_test "Large packet TLS 1.0 BlockCipher" \
3069 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003070 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003071 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3072 0 \
3073 -s "Read from client: 16384 bytes read"
3074
3075run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3076 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003077 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003078 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3079 trunc_hmac=1" \
3080 0 \
3081 -s "Read from client: 16384 bytes read"
3082
3083run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003084 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003085 "$P_CLI request_size=16384 force_version=tls1 \
3086 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3087 trunc_hmac=1" \
3088 0 \
3089 -s "Read from client: 16384 bytes read"
3090
3091run_test "Large packet TLS 1.1 BlockCipher" \
3092 "$P_SRV" \
3093 "$P_CLI request_size=16384 force_version=tls1_1 \
3094 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3095 0 \
3096 -s "Read from client: 16384 bytes read"
3097
3098run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003099 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003100 "$P_CLI request_size=16384 force_version=tls1_1 \
3101 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3102 0 \
3103 -s "Read from client: 16384 bytes read"
3104
3105run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3106 "$P_SRV" \
3107 "$P_CLI request_size=16384 force_version=tls1_1 \
3108 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3109 trunc_hmac=1" \
3110 0 \
3111 -s "Read from client: 16384 bytes read"
3112
3113run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003114 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003115 "$P_CLI request_size=16384 force_version=tls1_1 \
3116 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3117 trunc_hmac=1" \
3118 0 \
3119 -s "Read from client: 16384 bytes read"
3120
3121run_test "Large packet TLS 1.2 BlockCipher" \
3122 "$P_SRV" \
3123 "$P_CLI request_size=16384 force_version=tls1_2 \
3124 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3125 0 \
3126 -s "Read from client: 16384 bytes read"
3127
3128run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3129 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003130 "$P_CLI request_size=16384 force_version=tls1_2 \
3131 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003132 0 \
3133 -s "Read from client: 16384 bytes read"
3134
3135run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3136 "$P_SRV" \
3137 "$P_CLI request_size=16384 force_version=tls1_2 \
3138 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3139 trunc_hmac=1" \
3140 0 \
3141 -s "Read from client: 16384 bytes read"
3142
3143run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003144 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003145 "$P_CLI request_size=16384 force_version=tls1_2 \
3146 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3147 0 \
3148 -s "Read from client: 16384 bytes read"
3149
3150run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003151 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003152 "$P_CLI request_size=16384 force_version=tls1_2 \
3153 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3154 trunc_hmac=1" \
3155 0 \
3156 -s "Read from client: 16384 bytes read"
3157
3158run_test "Large packet TLS 1.2 AEAD" \
3159 "$P_SRV" \
3160 "$P_CLI request_size=16384 force_version=tls1_2 \
3161 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3162 0 \
3163 -s "Read from client: 16384 bytes read"
3164
3165run_test "Large packet TLS 1.2 AEAD shorter tag" \
3166 "$P_SRV" \
3167 "$P_CLI request_size=16384 force_version=tls1_2 \
3168 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3169 0 \
3170 -s "Read from client: 16384 bytes read"
3171
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003172# Tests for DTLS HelloVerifyRequest
3173
3174run_test "DTLS cookie: enabled" \
3175 "$P_SRV dtls=1 debug_level=2" \
3176 "$P_CLI dtls=1 debug_level=2" \
3177 0 \
3178 -s "cookie verification failed" \
3179 -s "cookie verification passed" \
3180 -S "cookie verification skipped" \
3181 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003182 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003183 -S "SSL - The requested feature is not available"
3184
3185run_test "DTLS cookie: disabled" \
3186 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3187 "$P_CLI dtls=1 debug_level=2" \
3188 0 \
3189 -S "cookie verification failed" \
3190 -S "cookie verification passed" \
3191 -s "cookie verification skipped" \
3192 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003193 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003194 -S "SSL - The requested feature is not available"
3195
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003196run_test "DTLS cookie: default (failing)" \
3197 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3198 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3199 1 \
3200 -s "cookie verification failed" \
3201 -S "cookie verification passed" \
3202 -S "cookie verification skipped" \
3203 -C "received hello verify request" \
3204 -S "hello verification requested" \
3205 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003206
3207requires_ipv6
3208run_test "DTLS cookie: enabled, IPv6" \
3209 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3210 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3211 0 \
3212 -s "cookie verification failed" \
3213 -s "cookie verification passed" \
3214 -S "cookie verification skipped" \
3215 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003216 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003217 -S "SSL - The requested feature is not available"
3218
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003219run_test "DTLS cookie: enabled, nbio" \
3220 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3221 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3222 0 \
3223 -s "cookie verification failed" \
3224 -s "cookie verification passed" \
3225 -S "cookie verification skipped" \
3226 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003227 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003228 -S "SSL - The requested feature is not available"
3229
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003230# Tests for client reconnecting from the same port with DTLS
3231
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003232not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003233run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003234 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3235 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003236 0 \
3237 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003238 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003239 -S "Client initiated reconnection from same port"
3240
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003241not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003242run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003243 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3244 "$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 +02003245 0 \
3246 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003247 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003248 -s "Client initiated reconnection from same port"
3249
Paul Bakker362689d2016-05-13 10:33:25 +01003250not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3251run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003252 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3253 "$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 +02003254 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003255 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003256 -s "Client initiated reconnection from same port"
3257
Paul Bakker362689d2016-05-13 10:33:25 +01003258only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3259run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3260 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3261 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3262 0 \
3263 -S "The operation timed out" \
3264 -s "Client initiated reconnection from same port"
3265
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003266run_test "DTLS client reconnect from same port: no cookies" \
3267 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003268 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3269 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003270 -s "The operation timed out" \
3271 -S "Client initiated reconnection from same port"
3272
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003273# Tests for various cases of client authentication with DTLS
3274# (focused on handshake flows and message parsing)
3275
3276run_test "DTLS client auth: required" \
3277 "$P_SRV dtls=1 auth_mode=required" \
3278 "$P_CLI dtls=1" \
3279 0 \
3280 -s "Verifying peer X.509 certificate... ok"
3281
3282run_test "DTLS client auth: optional, client has no cert" \
3283 "$P_SRV dtls=1 auth_mode=optional" \
3284 "$P_CLI dtls=1 crt_file=none key_file=none" \
3285 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003286 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003287
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003288run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003289 "$P_SRV dtls=1 auth_mode=none" \
3290 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3291 0 \
3292 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003293 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003294
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003295run_test "DTLS wrong PSK: badmac alert" \
3296 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3297 "$P_CLI dtls=1 psk=abc124" \
3298 1 \
3299 -s "SSL - Verification of the message MAC failed" \
3300 -c "SSL - A fatal alert message was received from our peer"
3301
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003302# Tests for receiving fragmented handshake messages with DTLS
3303
3304requires_gnutls
3305run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3306 "$G_SRV -u --mtu 2048 -a" \
3307 "$P_CLI dtls=1 debug_level=2" \
3308 0 \
3309 -C "found fragmented DTLS handshake message" \
3310 -C "error"
3311
3312requires_gnutls
3313run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3314 "$G_SRV -u --mtu 512" \
3315 "$P_CLI dtls=1 debug_level=2" \
3316 0 \
3317 -c "found fragmented DTLS handshake message" \
3318 -C "error"
3319
3320requires_gnutls
3321run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3322 "$G_SRV -u --mtu 128" \
3323 "$P_CLI dtls=1 debug_level=2" \
3324 0 \
3325 -c "found fragmented DTLS handshake message" \
3326 -C "error"
3327
3328requires_gnutls
3329run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3330 "$G_SRV -u --mtu 128" \
3331 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3332 0 \
3333 -c "found fragmented DTLS handshake message" \
3334 -C "error"
3335
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003336requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003337run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3338 "$G_SRV -u --mtu 256" \
3339 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3340 0 \
3341 -c "found fragmented DTLS handshake message" \
3342 -c "client hello, adding renegotiation extension" \
3343 -c "found renegotiation extension" \
3344 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003345 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003346 -C "error" \
3347 -s "Extra-header:"
3348
3349requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003350run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3351 "$G_SRV -u --mtu 256" \
3352 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3353 0 \
3354 -c "found fragmented DTLS handshake message" \
3355 -c "client hello, adding renegotiation extension" \
3356 -c "found renegotiation extension" \
3357 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003358 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003359 -C "error" \
3360 -s "Extra-header:"
3361
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003362run_test "DTLS reassembly: no fragmentation (openssl server)" \
3363 "$O_SRV -dtls1 -mtu 2048" \
3364 "$P_CLI dtls=1 debug_level=2" \
3365 0 \
3366 -C "found fragmented DTLS handshake message" \
3367 -C "error"
3368
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003369run_test "DTLS reassembly: some fragmentation (openssl server)" \
3370 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003371 "$P_CLI dtls=1 debug_level=2" \
3372 0 \
3373 -c "found fragmented DTLS handshake message" \
3374 -C "error"
3375
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003376run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003377 "$O_SRV -dtls1 -mtu 256" \
3378 "$P_CLI dtls=1 debug_level=2" \
3379 0 \
3380 -c "found fragmented DTLS handshake message" \
3381 -C "error"
3382
3383run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3384 "$O_SRV -dtls1 -mtu 256" \
3385 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3386 0 \
3387 -c "found fragmented DTLS handshake message" \
3388 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003389
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003390# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003391
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003392not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003393run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003394 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003395 "$P_SRV dtls=1 debug_level=2" \
3396 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003397 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003398 -C "replayed record" \
3399 -S "replayed record" \
3400 -C "record from another epoch" \
3401 -S "record from another epoch" \
3402 -C "discarding invalid record" \
3403 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003404 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003405 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003406 -c "HTTP/1.0 200 OK"
3407
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003408not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003409run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003410 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003411 "$P_SRV dtls=1 debug_level=2" \
3412 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003413 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003414 -c "replayed record" \
3415 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003416 -c "discarding invalid record" \
3417 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003418 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003419 -s "Extra-header:" \
3420 -c "HTTP/1.0 200 OK"
3421
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003422run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3423 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003424 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3425 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003426 0 \
3427 -c "replayed record" \
3428 -S "replayed record" \
3429 -c "discarding invalid record" \
3430 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003431 -c "resend" \
3432 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003433 -s "Extra-header:" \
3434 -c "HTTP/1.0 200 OK"
3435
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003436run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003437 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003438 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003439 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003440 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003441 -c "discarding invalid record (mac)" \
3442 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003443 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003444 -c "HTTP/1.0 200 OK" \
3445 -S "too many records with bad MAC" \
3446 -S "Verification of the message MAC failed"
3447
3448run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3449 -p "$P_PXY bad_ad=1" \
3450 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3451 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3452 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003453 -C "discarding invalid record (mac)" \
3454 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003455 -S "Extra-header:" \
3456 -C "HTTP/1.0 200 OK" \
3457 -s "too many records with bad MAC" \
3458 -s "Verification of the message MAC failed"
3459
3460run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3461 -p "$P_PXY bad_ad=1" \
3462 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3463 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3464 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003465 -c "discarding invalid record (mac)" \
3466 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003467 -s "Extra-header:" \
3468 -c "HTTP/1.0 200 OK" \
3469 -S "too many records with bad MAC" \
3470 -S "Verification of the message MAC failed"
3471
3472run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3473 -p "$P_PXY bad_ad=1" \
3474 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3475 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3476 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003477 -c "discarding invalid record (mac)" \
3478 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003479 -s "Extra-header:" \
3480 -c "HTTP/1.0 200 OK" \
3481 -s "too many records with bad MAC" \
3482 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003483
3484run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003485 -p "$P_PXY delay_ccs=1" \
3486 "$P_SRV dtls=1 debug_level=1" \
3487 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003488 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003489 -c "record from another epoch" \
3490 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003491 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003492 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003493 -s "Extra-header:" \
3494 -c "HTTP/1.0 200 OK"
3495
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003496# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003497
Janos Follath74537a62016-09-02 13:45:28 +01003498client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003499run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003500 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003501 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3502 psk=abc123" \
3503 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003504 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3505 0 \
3506 -s "Extra-header:" \
3507 -c "HTTP/1.0 200 OK"
3508
Janos Follath74537a62016-09-02 13:45:28 +01003509client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003510run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3511 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003512 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3513 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003514 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3515 0 \
3516 -s "Extra-header:" \
3517 -c "HTTP/1.0 200 OK"
3518
Janos Follath74537a62016-09-02 13:45:28 +01003519client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003520run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3521 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003522 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3523 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003524 0 \
3525 -s "Extra-header:" \
3526 -c "HTTP/1.0 200 OK"
3527
Janos Follath74537a62016-09-02 13:45:28 +01003528client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003529run_test "DTLS proxy: 3d, FS, client auth" \
3530 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003531 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3532 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003533 0 \
3534 -s "Extra-header:" \
3535 -c "HTTP/1.0 200 OK"
3536
Janos Follath74537a62016-09-02 13:45:28 +01003537client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003538run_test "DTLS proxy: 3d, FS, ticket" \
3539 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003540 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3541 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003542 0 \
3543 -s "Extra-header:" \
3544 -c "HTTP/1.0 200 OK"
3545
Janos Follath74537a62016-09-02 13:45:28 +01003546client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003547run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3548 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003549 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3550 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003551 0 \
3552 -s "Extra-header:" \
3553 -c "HTTP/1.0 200 OK"
3554
Janos Follath74537a62016-09-02 13:45:28 +01003555client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003556run_test "DTLS proxy: 3d, max handshake, nbio" \
3557 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003558 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3559 auth_mode=required" \
3560 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003561 0 \
3562 -s "Extra-header:" \
3563 -c "HTTP/1.0 200 OK"
3564
Janos Follath74537a62016-09-02 13:45:28 +01003565client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003566run_test "DTLS proxy: 3d, min handshake, resumption" \
3567 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3568 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3569 psk=abc123 debug_level=3" \
3570 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3571 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3572 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3573 0 \
3574 -s "a session has been resumed" \
3575 -c "a session has been resumed" \
3576 -s "Extra-header:" \
3577 -c "HTTP/1.0 200 OK"
3578
Janos Follath74537a62016-09-02 13:45:28 +01003579client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003580run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3581 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3582 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3583 psk=abc123 debug_level=3 nbio=2" \
3584 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3585 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3586 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3587 0 \
3588 -s "a session has been resumed" \
3589 -c "a session has been resumed" \
3590 -s "Extra-header:" \
3591 -c "HTTP/1.0 200 OK"
3592
Janos Follath74537a62016-09-02 13:45:28 +01003593client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003594run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003595 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003596 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3597 psk=abc123 renegotiation=1 debug_level=2" \
3598 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3599 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003600 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3601 0 \
3602 -c "=> renegotiate" \
3603 -s "=> renegotiate" \
3604 -s "Extra-header:" \
3605 -c "HTTP/1.0 200 OK"
3606
Janos Follath74537a62016-09-02 13:45:28 +01003607client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003608run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3609 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003610 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3611 psk=abc123 renegotiation=1 debug_level=2" \
3612 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3613 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003614 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3615 0 \
3616 -c "=> renegotiate" \
3617 -s "=> renegotiate" \
3618 -s "Extra-header:" \
3619 -c "HTTP/1.0 200 OK"
3620
Janos Follath74537a62016-09-02 13:45:28 +01003621client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003622run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003623 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003624 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003625 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003626 debug_level=2" \
3627 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003628 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003629 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3630 0 \
3631 -c "=> renegotiate" \
3632 -s "=> renegotiate" \
3633 -s "Extra-header:" \
3634 -c "HTTP/1.0 200 OK"
3635
Janos Follath74537a62016-09-02 13:45:28 +01003636client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003637run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003638 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003639 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003640 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003641 debug_level=2 nbio=2" \
3642 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003643 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003644 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3645 0 \
3646 -c "=> renegotiate" \
3647 -s "=> renegotiate" \
3648 -s "Extra-header:" \
3649 -c "HTTP/1.0 200 OK"
3650
Janos Follath74537a62016-09-02 13:45:28 +01003651client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003652not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003653run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003654 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3655 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003656 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003657 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003658 -c "HTTP/1.0 200 OK"
3659
Janos Follath74537a62016-09-02 13:45:28 +01003660client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003661not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003662run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3663 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3664 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003665 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003666 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003667 -c "HTTP/1.0 200 OK"
3668
Janos Follath74537a62016-09-02 13:45:28 +01003669client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003670not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003671run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3672 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3673 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003674 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003675 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003676 -c "HTTP/1.0 200 OK"
3677
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003678requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003679client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003680not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003681run_test "DTLS proxy: 3d, gnutls server" \
3682 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3683 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003684 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003685 0 \
3686 -s "Extra-header:" \
3687 -c "Extra-header:"
3688
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003689requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003690client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003691not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003692run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3693 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3694 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003695 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003696 0 \
3697 -s "Extra-header:" \
3698 -c "Extra-header:"
3699
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003700requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003701client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003702not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003703run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3704 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3705 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003706 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003707 0 \
3708 -s "Extra-header:" \
3709 -c "Extra-header:"
3710
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003711# Final report
3712
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003713echo "------------------------------------------------------------------------"
3714
3715if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003716 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003717else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003718 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003719fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003720PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003721echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003722
3723exit $FAILS