blob: f3b978a7c7243255f90d92b914bba07668d13e5b [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02009# Assumes a build with default options.
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010010
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020016: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010017: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020018: ${GNUTLS_CLI:=gnutls-cli}
19: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskine39e29812017-05-16 17:53:03 +020020: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020022O_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 +010023O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020024G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010025G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskine39e29812017-05-16 17:53:03 +020026TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010027
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028TESTS=0
29FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020030SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010031
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000032CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020033
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010035FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020036EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010037
38print_usage() {
39 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010040 printf " -h|--help\tPrint this help.\n"
41 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
42 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
43 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Gilles Peskinebb4aaf12017-11-30 15:56:20 +010044 printf " --seed\tInteger seed value to use for this test run (default: random)\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045}
46
47get_options() {
48 while [ $# -gt 0 ]; do
49 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010050 -f|--filter)
51 shift; FILTER=$1
52 ;;
53 -e|--exclude)
54 shift; EXCLUDE=$1
55 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010056 -m|--memcheck)
57 MEMCHECK=1
58 ;;
Gilles Peskinebb4aaf12017-11-30 15:56:20 +010059 --seed)
60 shift; SEED="$1"
61 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062 -h|--help)
63 print_usage
64 exit 0
65 ;;
66 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020067 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010068 print_usage
69 exit 1
70 ;;
71 esac
72 shift
73 done
74}
75
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010076# skip next test if the flag is not enabled in config.h
77requires_config_enabled() {
78 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +020083# skip next test if the flag is enabled in config.h
84requires_config_disabled() {
85 if grep "^#define $1" $CONFIG_H > /dev/null; then
86 SKIP_NEXT="YES"
87 fi
88}
89
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020090# skip next test if OpenSSL doesn't support FALLBACK_SCSV
91requires_openssl_with_fallback_scsv() {
92 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
93 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
94 then
95 OPENSSL_HAS_FBSCSV="YES"
96 else
97 OPENSSL_HAS_FBSCSV="NO"
98 fi
99 fi
100 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
101 SKIP_NEXT="YES"
102 fi
103}
104
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200105# skip next test if GnuTLS isn't available
106requires_gnutls() {
107 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200108 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200109 GNUTLS_AVAILABLE="YES"
110 else
111 GNUTLS_AVAILABLE="NO"
112 fi
113 fi
114 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
115 SKIP_NEXT="YES"
116 fi
117}
118
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200119# skip next test if IPv6 isn't available on this host
120requires_ipv6() {
121 if [ -z "${HAS_IPV6:-}" ]; then
122 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
123 SRV_PID=$!
124 sleep 1
125 kill $SRV_PID >/dev/null 2>&1
126 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
127 HAS_IPV6="NO"
128 else
129 HAS_IPV6="YES"
130 fi
131 rm -r $SRV_OUT
132 fi
133
134 if [ "$HAS_IPV6" = "NO" ]; then
135 SKIP_NEXT="YES"
136 fi
137}
138
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200139# skip the next test if valgrind is in use
140not_with_valgrind() {
141 if [ "$MEMCHECK" -gt 0 ]; then
142 SKIP_NEXT="YES"
143 fi
144}
145
Paul Bakker3b224ff2016-05-13 10:33:25 +0100146# skip the next test if valgrind is NOT in use
147only_with_valgrind() {
148 if [ "$MEMCHECK" -eq 0 ]; then
149 SKIP_NEXT="YES"
150 fi
151}
152
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200153# multiply the client timeout delay by the given factor for the next test
154needs_more_time() {
155 CLI_DELAY_FACTOR=$1
156}
157
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100158# print_name <name>
159print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100160 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200161 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100162 for i in `seq 1 $LEN`; do printf '.'; done
163 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100164
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200165 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100166}
167
168# fail <message>
169fail() {
170 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100171 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100172
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200173 mv $SRV_OUT o-srv-${TESTS}.log
174 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200175 if [ -n "$PXY_CMD" ]; then
176 mv $PXY_OUT o-pxy-${TESTS}.log
177 fi
178 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100179
Azim Khan341e3782018-03-29 11:04:20 +0100180 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot -o "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200181 echo " ! server output:"
182 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200183 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200184 echo " ! client output:"
185 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200186 if [ -n "$PXY_CMD" ]; then
187 echo " ! ========================================================"
188 echo " ! proxy output:"
189 cat o-pxy-${TESTS}.log
190 fi
191 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200192 fi
193
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200194 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100195}
196
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100197# is_polar <cmd_line>
198is_polar() {
199 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
200}
201
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200202# openssl s_server doesn't have -www with DTLS
203check_osrv_dtls() {
204 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
205 NEEDS_INPUT=1
206 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
207 else
208 NEEDS_INPUT=0
209 fi
210}
211
212# provide input to commands that need it
213provide_input() {
214 if [ $NEEDS_INPUT -eq 0 ]; then
215 return
216 fi
217
218 while true; do
219 echo "HTTP/1.0 200 OK"
220 sleep 1
221 done
222}
223
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100224# has_mem_err <log_file_name>
225has_mem_err() {
226 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
227 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
228 then
229 return 1 # false: does not have errors
230 else
231 return 0 # true: has errors
232 fi
233}
234
Gilles Peskine684a5172017-12-14 18:58:42 +0100235# Wait for process $2 to be listening on port $1
236if type lsof >/dev/null 2>/dev/null; then
237 wait_server_start() {
238 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200239 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine684a5172017-12-14 18:58:42 +0100240 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200241 else
Gilles Peskine684a5172017-12-14 18:58:42 +0100242 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200243 fi
Gilles Peskine684a5172017-12-14 18:58:42 +0100244 # Make a tight loop, server normally takes less than 1s to start.
245 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
246 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
247 echo "SERVERSTART TIMEOUT"
248 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
249 break
250 fi
251 # Linux and *BSD support decimal arguments to sleep. On other
252 # OSes this may be a tight loop.
253 sleep 0.1 2>/dev/null || true
254 done
255 }
256else
Gilles Peskine784f41c2018-01-08 12:38:15 +0100257 echo "Warning: lsof not available, wait_server_start = sleep $START_DELAY"
Gilles Peskine684a5172017-12-14 18:58:42 +0100258 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200259 sleep "$START_DELAY"
Gilles Peskine684a5172017-12-14 18:58:42 +0100260 }
261fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200262
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200263# wait for client to terminate and set CLI_EXIT
264# must be called right after starting the client
265wait_client_done() {
266 CLI_PID=$!
267
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200268 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
269 CLI_DELAY_FACTOR=1
270
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200271 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200272 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200273
274 wait $CLI_PID
275 CLI_EXIT=$?
276
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200277 kill $DOG_PID >/dev/null 2>&1
278 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200279
280 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
281}
282
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200283# check if the given command uses dtls and sets global variable DTLS
284detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200285 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200286 DTLS=1
287 else
288 DTLS=0
289 fi
290}
291
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200292# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100293# Options: -s pattern pattern that must be present in server output
294# -c pattern pattern that must be present in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100295# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100296# -S pattern pattern that must be absent in server output
297# -C pattern pattern that must be absent in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100298# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100299run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100300 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200301 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100302
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100303 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
304 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200305 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100306 return
307 fi
308
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100309 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100310
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200311 # should we skip?
312 if [ "X$SKIP_NEXT" = "XYES" ]; then
313 SKIP_NEXT="NO"
314 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200315 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200316 return
317 fi
318
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200319 # does this test use a proxy?
320 if [ "X$1" = "X-p" ]; then
321 PXY_CMD="$2"
322 shift 2
323 else
324 PXY_CMD=""
325 fi
326
327 # get commands and client output
328 SRV_CMD="$1"
329 CLI_CMD="$2"
330 CLI_EXPECT="$3"
331 shift 3
332
333 # fix client port
334 if [ -n "$PXY_CMD" ]; then
335 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
336 else
337 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
338 fi
339
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200340 # update DTLS variable
341 detect_dtls "$SRV_CMD"
342
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100343 # prepend valgrind to our commands if active
344 if [ "$MEMCHECK" -gt 0 ]; then
345 if is_polar "$SRV_CMD"; then
346 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
347 fi
348 if is_polar "$CLI_CMD"; then
349 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
350 fi
351 fi
352
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200353 TIMES_LEFT=2
354 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200355 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200356
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200357 # run the commands
358 if [ -n "$PXY_CMD" ]; then
359 echo "$PXY_CMD" > $PXY_OUT
360 $PXY_CMD >> $PXY_OUT 2>&1 &
361 PXY_PID=$!
362 # assume proxy starts faster than server
363 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200364
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200365 check_osrv_dtls
366 echo "$SRV_CMD" > $SRV_OUT
367 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
368 SRV_PID=$!
Gilles Peskine684a5172017-12-14 18:58:42 +0100369 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200370
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200371 echo "$CLI_CMD" > $CLI_OUT
372 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
373 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100374
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200375 # terminate the server (and the proxy)
376 kill $SRV_PID
377 wait $SRV_PID
378 if [ -n "$PXY_CMD" ]; then
379 kill $PXY_PID >/dev/null 2>&1
380 wait $PXY_PID
381 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100382
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200383 # retry only on timeouts
384 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
385 printf "RETRY "
386 else
387 TIMES_LEFT=0
388 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200389 done
390
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100391 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200392 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100393 # expected client exit to incorrectly succeed in case of catastrophic
394 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100395 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200396 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100397 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100398 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100399 return
400 fi
401 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100402 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200403 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100404 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100405 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100406 return
407 fi
408 fi
409
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100410 # check server exit code
411 if [ $? != 0 ]; then
412 fail "server fail"
413 return
414 fi
415
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100416 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100417 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
418 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100419 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200420 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100421 return
422 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100423
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100424 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200425 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100426 while [ $# -gt 0 ]
427 do
428 case $1 in
429 "-s")
Janos Follath6d3e3382016-09-07 15:48:48 +0100430 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
431 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100432 return
433 fi
434 ;;
435
436 "-c")
Janos Follath6d3e3382016-09-07 15:48:48 +0100437 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
438 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100439 return
440 fi
441 ;;
442
443 "-S")
Janos Follath6d3e3382016-09-07 15:48:48 +0100444 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
445 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100446 return
447 fi
448 ;;
449
450 "-C")
Janos Follath6d3e3382016-09-07 15:48:48 +0100451 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
452 fail "pattern '$2' MUST NOT be present in the Client output"
453 return
454 fi
455 ;;
456
457 # The filtering in the following two options (-u and -U) do the following
458 # - ignore valgrind output
459 # - filter out everything but lines right after the pattern occurances
460 # - keep one of each non-unique line
461 # - count how many lines remain
462 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
463 # if there were no duplicates.
464 "-U")
465 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
466 fail "lines following pattern '$2' must be unique in Server output"
467 return
468 fi
469 ;;
470
471 "-u")
472 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
473 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100474 return
475 fi
476 ;;
477
478 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200479 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100480 exit 1
481 esac
482 shift 2
483 done
484
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100485 # check valgrind's results
486 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200487 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100488 fail "Server has memory errors"
489 return
490 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200491 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100492 fail "Client has memory errors"
493 return
494 fi
495 fi
496
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100497 # if we're here, everything is ok
498 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200499 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100500}
501
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100502cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200503 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200504 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
505 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
506 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
507 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100508 exit 1
509}
510
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100511#
512# MAIN
513#
514
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000515if cd $( dirname $0 ); then :; else
516 echo "cd $( dirname $0 ) failed" >&2
517 exit 1
518fi
519
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100520get_options "$@"
521
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100522# sanity checks, avoid an avalanche of errors
523if [ ! -x "$P_SRV" ]; then
524 echo "Command '$P_SRV' is not an executable file"
525 exit 1
526fi
527if [ ! -x "$P_CLI" ]; then
528 echo "Command '$P_CLI' is not an executable file"
529 exit 1
530fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200531if [ ! -x "$P_PXY" ]; then
532 echo "Command '$P_PXY' is not an executable file"
533 exit 1
534fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100535if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
536 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100537 exit 1
538fi
539
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200540# used by watchdog
541MAIN_PID="$$"
542
Manuel Pégourié-Gonnard3f69e542018-01-22 10:22:09 +0100543# We use somewhat arbitrary delays for tests:
544# - how long do we wait for the server to start (when lsof not available)?
545# - how long do we allow for the client to finish?
546# (not to check performance, just to avoid waiting indefinitely)
547# Things are slower with valgrind, so give extra time here.
548#
549# Note: without lsof, there is a trade-off between the running time of this
550# script and the risk of spurious errors because we didn't wait long enough.
551# The watchdog delay on the other hand doesn't affect normal running time of
552# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200553if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard3f69e542018-01-22 10:22:09 +0100554 START_DELAY=6
555 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200556else
Manuel Pégourié-Gonnard3f69e542018-01-22 10:22:09 +0100557 START_DELAY=2
558 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200559fi
Manuel Pégourié-Gonnard3f69e542018-01-22 10:22:09 +0100560
561# some particular tests need more time:
562# - for the client, we multiply the usual watchdog limit by a factor
563# - for the server, we sleep for a number of seconds after the client exits
564# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200565CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200566
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200567# Pick a "unique" server port in the range 10000-19999, and a proxy port
568PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000569PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200570SRV_PORT="1$PORT_BASE"
571PXY_PORT="2$PORT_BASE"
572unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200573
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200574# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000575# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200576P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
577P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Gilles Peskinebb4aaf12017-11-30 15:56:20 +0100578P_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 +0200579O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200580O_CLI="$O_CLI -connect localhost:+SRV_PORT"
581G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000582G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200583
Gilles Peskine35db5ba2017-05-10 10:13:59 +0200584# Allow SHA-1, because many of our test certificates use it
585P_SRV="$P_SRV allow_sha1=1"
586P_CLI="$P_CLI allow_sha1=1"
587
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200588# Also pick a unique name for intermediate files
589SRV_OUT="srv_out.$$"
590CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200591PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200592SESSION="session.$$"
593
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200594SKIP_NEXT="NO"
595
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100596trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100597
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200598# Basic test
599
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200600# Checks that:
601# - things work with all ciphersuites active (used with config-full in all.sh)
602# - the expected (highest security) parameters are selected
603# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200604run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200605 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200606 "$P_CLI" \
607 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200608 -s "Protocol is TLSv1.2" \
609 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
610 -s "client hello v3, signature_algorithm ext: 6" \
611 -s "ECDHE curve: secp521r1" \
612 -S "error" \
613 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200614
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000615run_test "Default, DTLS" \
616 "$P_SRV dtls=1" \
617 "$P_CLI dtls=1" \
618 0 \
619 -s "Protocol is DTLSv1.2" \
620 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
621
Janos Follath6d3e3382016-09-07 15:48:48 +0100622# Test for uniqueness of IVs in AEAD ciphersuites
623run_test "Unique IV in GCM" \
624 "$P_SRV exchanges=20 debug_level=4" \
625 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
626 0 \
627 -u "IV used" \
628 -U "IV used"
629
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100630# Tests for rc4 option
631
Simon Butcher6eb066e2016-05-19 22:12:18 +0100632requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100633run_test "RC4: server disabled, client enabled" \
634 "$P_SRV" \
635 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
636 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100637 -s "SSL - The server has no ciphersuites in common"
638
Simon Butcher6eb066e2016-05-19 22:12:18 +0100639requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100640run_test "RC4: server half, client enabled" \
641 "$P_SRV arc4=1" \
642 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
643 1 \
644 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100645
646run_test "RC4: server enabled, client disabled" \
647 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
648 "$P_CLI" \
649 1 \
650 -s "SSL - The server has no ciphersuites in common"
651
652run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100653 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100654 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
655 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100656 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100657 -S "SSL - The server has no ciphersuites in common"
658
Gilles Peskineae765992017-05-09 15:59:24 +0200659# Tests for SHA-1 support
660
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200661requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200662run_test "SHA-1 forbidden by default in server certificate" \
663 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
664 "$P_CLI debug_level=2 allow_sha1=0" \
665 1 \
666 -c "The certificate is signed with an unacceptable hash"
667
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200668requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
669run_test "SHA-1 forbidden by default in server certificate" \
670 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
671 "$P_CLI debug_level=2 allow_sha1=0" \
672 0
673
Gilles Peskineae765992017-05-09 15:59:24 +0200674run_test "SHA-1 explicitly allowed in server certificate" \
675 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
676 "$P_CLI allow_sha1=1" \
677 0
678
679run_test "SHA-256 allowed by default in server certificate" \
680 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
681 "$P_CLI allow_sha1=0" \
682 0
683
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200684requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200685run_test "SHA-1 forbidden by default in client certificate" \
686 "$P_SRV auth_mode=required allow_sha1=0" \
687 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
688 1 \
689 -s "The certificate is signed with an unacceptable hash"
690
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200691requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
692run_test "SHA-1 forbidden by default in client certificate" \
693 "$P_SRV auth_mode=required allow_sha1=0" \
694 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
695 0
696
Gilles Peskineae765992017-05-09 15:59:24 +0200697run_test "SHA-1 explicitly allowed in client certificate" \
698 "$P_SRV auth_mode=required allow_sha1=1" \
699 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
700 0
701
702run_test "SHA-256 allowed by default in client certificate" \
703 "$P_SRV auth_mode=required allow_sha1=0" \
704 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
705 0
706
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100707# Tests for Truncated HMAC extension
708
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100709run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200710 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100711 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100712 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000713 -s "dumping 'expected mac' (20 bytes)" \
714 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100715
Hanno Beckera83fafa2017-11-10 08:42:54 +0000716requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100717run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200718 "$P_SRV debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000719 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100720 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000721 -s "dumping 'expected mac' (20 bytes)" \
722 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100723
Hanno Beckera83fafa2017-11-10 08:42:54 +0000724requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100725run_test "Truncated HMAC: client enabled, server default" \
726 "$P_SRV debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000727 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100728 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000729 -s "dumping 'expected mac' (20 bytes)" \
730 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100731
Hanno Beckera83fafa2017-11-10 08:42:54 +0000732requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100733run_test "Truncated HMAC: client enabled, server disabled" \
734 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000735 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100736 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000737 -s "dumping 'expected mac' (20 bytes)" \
738 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100739
Hanno Beckera83fafa2017-11-10 08:42:54 +0000740requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Beckerd51bec72017-11-17 15:46:24 +0000741run_test "Truncated HMAC: client disabled, server enabled" \
742 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000743 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Beckerd51bec72017-11-17 15:46:24 +0000744 0 \
745 -s "dumping 'expected mac' (20 bytes)" \
746 -S "dumping 'expected mac' (10 bytes)"
747
748requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100749run_test "Truncated HMAC: client enabled, server enabled" \
750 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000751 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100752 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000753 -S "dumping 'expected mac' (20 bytes)" \
754 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100755
Hanno Becker02f632e2017-11-10 09:16:05 +0000756run_test "Truncated HMAC, DTLS: client default, server default" \
757 "$P_SRV dtls=1 debug_level=4" \
758 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
759 0 \
760 -s "dumping 'expected mac' (20 bytes)" \
761 -S "dumping 'expected mac' (10 bytes)"
762
763requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
764run_test "Truncated HMAC, DTLS: client disabled, server default" \
765 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000766 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000767 0 \
768 -s "dumping 'expected mac' (20 bytes)" \
769 -S "dumping 'expected mac' (10 bytes)"
770
771requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
772run_test "Truncated HMAC, DTLS: client enabled, server default" \
773 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000774 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000775 0 \
776 -s "dumping 'expected mac' (20 bytes)" \
777 -S "dumping 'expected mac' (10 bytes)"
778
779requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
780run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
781 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000782 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000783 0 \
784 -s "dumping 'expected mac' (20 bytes)" \
785 -S "dumping 'expected mac' (10 bytes)"
786
787requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
788run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
789 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000790 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000791 0 \
792 -s "dumping 'expected mac' (20 bytes)" \
793 -S "dumping 'expected mac' (10 bytes)"
794
795requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
796run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
797 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000798 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100799 0 \
800 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100801 -s "dumping 'expected mac' (10 bytes)"
802
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100803# Tests for Encrypt-then-MAC extension
804
805run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100806 "$P_SRV debug_level=3 \
807 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100808 "$P_CLI debug_level=3" \
809 0 \
810 -c "client hello, adding encrypt_then_mac extension" \
811 -s "found encrypt then mac extension" \
812 -s "server hello, adding encrypt then mac extension" \
813 -c "found encrypt_then_mac extension" \
814 -c "using encrypt then mac" \
815 -s "using encrypt then mac"
816
817run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100818 "$P_SRV debug_level=3 etm=0 \
819 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100820 "$P_CLI debug_level=3 etm=1" \
821 0 \
822 -c "client hello, adding encrypt_then_mac extension" \
823 -s "found encrypt then mac extension" \
824 -S "server hello, adding encrypt then mac extension" \
825 -C "found encrypt_then_mac extension" \
826 -C "using encrypt then mac" \
827 -S "using encrypt then mac"
828
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100829run_test "Encrypt then MAC: client enabled, aead cipher" \
830 "$P_SRV debug_level=3 etm=1 \
831 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
832 "$P_CLI debug_level=3 etm=1" \
833 0 \
834 -c "client hello, adding encrypt_then_mac extension" \
835 -s "found encrypt then mac extension" \
836 -S "server hello, adding encrypt then mac extension" \
837 -C "found encrypt_then_mac extension" \
838 -C "using encrypt then mac" \
839 -S "using encrypt then mac"
840
841run_test "Encrypt then MAC: client enabled, stream cipher" \
842 "$P_SRV debug_level=3 etm=1 \
843 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100844 "$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 +0100845 0 \
846 -c "client hello, adding encrypt_then_mac extension" \
847 -s "found encrypt then mac extension" \
848 -S "server hello, adding encrypt then mac extension" \
849 -C "found encrypt_then_mac extension" \
850 -C "using encrypt then mac" \
851 -S "using encrypt then mac"
852
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100853run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100854 "$P_SRV debug_level=3 etm=1 \
855 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100856 "$P_CLI debug_level=3 etm=0" \
857 0 \
858 -C "client hello, adding encrypt_then_mac extension" \
859 -S "found encrypt then mac extension" \
860 -S "server hello, adding encrypt then mac extension" \
861 -C "found encrypt_then_mac extension" \
862 -C "using encrypt then mac" \
863 -S "using encrypt then mac"
864
Janos Follath542ee5d2016-03-07 15:57:05 +0000865requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100866run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100867 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100868 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100869 "$P_CLI debug_level=3 force_version=ssl3" \
870 0 \
871 -C "client hello, adding encrypt_then_mac extension" \
872 -S "found encrypt then mac extension" \
873 -S "server hello, adding encrypt then mac extension" \
874 -C "found encrypt_then_mac extension" \
875 -C "using encrypt then mac" \
876 -S "using encrypt then mac"
877
Janos Follath542ee5d2016-03-07 15:57:05 +0000878requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100879run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100880 "$P_SRV debug_level=3 force_version=ssl3 \
881 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100882 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100883 0 \
884 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100885 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100886 -S "server hello, adding encrypt then mac extension" \
887 -C "found encrypt_then_mac extension" \
888 -C "using encrypt then mac" \
889 -S "using encrypt then mac"
890
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200891# Tests for Extended Master Secret extension
892
893run_test "Extended Master Secret: default" \
894 "$P_SRV debug_level=3" \
895 "$P_CLI debug_level=3" \
896 0 \
897 -c "client hello, adding extended_master_secret extension" \
898 -s "found extended master secret extension" \
899 -s "server hello, adding extended master secret extension" \
900 -c "found extended_master_secret extension" \
901 -c "using extended master secret" \
902 -s "using extended master secret"
903
904run_test "Extended Master Secret: client enabled, server disabled" \
905 "$P_SRV debug_level=3 extended_ms=0" \
906 "$P_CLI debug_level=3 extended_ms=1" \
907 0 \
908 -c "client hello, adding extended_master_secret extension" \
909 -s "found extended master secret extension" \
910 -S "server hello, adding extended master secret extension" \
911 -C "found extended_master_secret extension" \
912 -C "using extended master secret" \
913 -S "using extended master secret"
914
915run_test "Extended Master Secret: client disabled, server enabled" \
916 "$P_SRV debug_level=3 extended_ms=1" \
917 "$P_CLI debug_level=3 extended_ms=0" \
918 0 \
919 -C "client hello, adding extended_master_secret extension" \
920 -S "found extended master secret extension" \
921 -S "server hello, adding extended master secret extension" \
922 -C "found extended_master_secret extension" \
923 -C "using extended master secret" \
924 -S "using extended master secret"
925
Janos Follath542ee5d2016-03-07 15:57:05 +0000926requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200927run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100928 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200929 "$P_CLI debug_level=3 force_version=ssl3" \
930 0 \
931 -C "client hello, adding extended_master_secret extension" \
932 -S "found extended master secret extension" \
933 -S "server hello, adding extended master secret extension" \
934 -C "found extended_master_secret extension" \
935 -C "using extended master secret" \
936 -S "using extended master secret"
937
Janos Follath542ee5d2016-03-07 15:57:05 +0000938requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200939run_test "Extended Master Secret: client enabled, server SSLv3" \
940 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100941 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200942 0 \
943 -c "client hello, adding extended_master_secret extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100944 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200945 -S "server hello, adding extended master secret extension" \
946 -C "found extended_master_secret extension" \
947 -C "using extended master secret" \
948 -S "using extended master secret"
949
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200950# Tests for FALLBACK_SCSV
951
952run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200953 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200954 "$P_CLI debug_level=3 force_version=tls1_1" \
955 0 \
956 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200957 -S "received FALLBACK_SCSV" \
958 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200959 -C "is a fatal alert message (msg 86)"
960
961run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200962 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200963 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
964 0 \
965 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200966 -S "received FALLBACK_SCSV" \
967 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200968 -C "is a fatal alert message (msg 86)"
969
970run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200971 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200972 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200973 1 \
974 -c "adding FALLBACK_SCSV" \
975 -s "received FALLBACK_SCSV" \
976 -s "inapropriate fallback" \
977 -c "is a fatal alert message (msg 86)"
978
979run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200980 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200981 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200982 0 \
983 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200984 -s "received FALLBACK_SCSV" \
985 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200986 -C "is a fatal alert message (msg 86)"
987
988requires_openssl_with_fallback_scsv
989run_test "Fallback SCSV: default, openssl server" \
990 "$O_SRV" \
991 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
992 0 \
993 -C "adding FALLBACK_SCSV" \
994 -C "is a fatal alert message (msg 86)"
995
996requires_openssl_with_fallback_scsv
997run_test "Fallback SCSV: enabled, openssl server" \
998 "$O_SRV" \
999 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1000 1 \
1001 -c "adding FALLBACK_SCSV" \
1002 -c "is a fatal alert message (msg 86)"
1003
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001004requires_openssl_with_fallback_scsv
1005run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001006 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001007 "$O_CLI -tls1_1" \
1008 0 \
1009 -S "received FALLBACK_SCSV" \
1010 -S "inapropriate fallback"
1011
1012requires_openssl_with_fallback_scsv
1013run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001014 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001015 "$O_CLI -tls1_1 -fallback_scsv" \
1016 1 \
1017 -s "received FALLBACK_SCSV" \
1018 -s "inapropriate fallback"
1019
1020requires_openssl_with_fallback_scsv
1021run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001022 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001023 "$O_CLI -fallback_scsv" \
1024 0 \
1025 -s "received FALLBACK_SCSV" \
1026 -S "inapropriate fallback"
1027
Gilles Peskine39e29812017-05-16 17:53:03 +02001028## ClientHello generated with
1029## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1030## then manually twiddling the ciphersuite list.
1031## The ClientHello content is spelled out below as a hex string as
1032## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1033## The expected response is an inappropriate_fallback alert.
1034requires_openssl_with_fallback_scsv
1035run_test "Fallback SCSV: beginning of list" \
1036 "$P_SRV debug_level=2" \
1037 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1038 0 \
1039 -s "received FALLBACK_SCSV" \
1040 -s "inapropriate fallback"
1041
1042requires_openssl_with_fallback_scsv
1043run_test "Fallback SCSV: end of list" \
1044 "$P_SRV debug_level=2" \
1045 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1046 0 \
1047 -s "received FALLBACK_SCSV" \
1048 -s "inapropriate fallback"
1049
1050## Here the expected response is a valid ServerHello prefix, up to the random.
1051requires_openssl_with_fallback_scsv
1052run_test "Fallback SCSV: not in list" \
1053 "$P_SRV debug_level=2" \
1054 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1055 0 \
1056 -S "received FALLBACK_SCSV" \
1057 -S "inapropriate fallback"
1058
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001059# Tests for CBC 1/n-1 record splitting
1060
1061run_test "CBC Record splitting: TLS 1.2, no splitting" \
1062 "$P_SRV" \
1063 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1064 request_size=123 force_version=tls1_2" \
1065 0 \
1066 -s "Read from client: 123 bytes read" \
1067 -S "Read from client: 1 bytes read" \
1068 -S "122 bytes read"
1069
1070run_test "CBC Record splitting: TLS 1.1, no splitting" \
1071 "$P_SRV" \
1072 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1073 request_size=123 force_version=tls1_1" \
1074 0 \
1075 -s "Read from client: 123 bytes read" \
1076 -S "Read from client: 1 bytes read" \
1077 -S "122 bytes read"
1078
1079run_test "CBC Record splitting: TLS 1.0, splitting" \
1080 "$P_SRV" \
1081 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1082 request_size=123 force_version=tls1" \
1083 0 \
1084 -S "Read from client: 123 bytes read" \
1085 -s "Read from client: 1 bytes read" \
1086 -s "122 bytes read"
1087
Janos Follath542ee5d2016-03-07 15:57:05 +00001088requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001089run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001090 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001091 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1092 request_size=123 force_version=ssl3" \
1093 0 \
1094 -S "Read from client: 123 bytes read" \
1095 -s "Read from client: 1 bytes read" \
1096 -s "122 bytes read"
1097
1098run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001099 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001100 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1101 request_size=123 force_version=tls1" \
1102 0 \
1103 -s "Read from client: 123 bytes read" \
1104 -S "Read from client: 1 bytes read" \
1105 -S "122 bytes read"
1106
1107run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1108 "$P_SRV" \
1109 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1110 request_size=123 force_version=tls1 recsplit=0" \
1111 0 \
1112 -s "Read from client: 123 bytes read" \
1113 -S "Read from client: 1 bytes read" \
1114 -S "122 bytes read"
1115
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001116run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1117 "$P_SRV nbio=2" \
1118 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1119 request_size=123 force_version=tls1" \
1120 0 \
1121 -S "Read from client: 123 bytes read" \
1122 -s "Read from client: 1 bytes read" \
1123 -s "122 bytes read"
1124
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001125# Tests for Session Tickets
1126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001127run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001128 "$P_SRV debug_level=3 tickets=1" \
1129 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001130 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001131 -c "client hello, adding session ticket extension" \
1132 -s "found session ticket extension" \
1133 -s "server hello, adding session ticket extension" \
1134 -c "found session_ticket extension" \
1135 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001136 -S "session successfully restored from cache" \
1137 -s "session successfully restored from ticket" \
1138 -s "a session has been resumed" \
1139 -c "a session has been resumed"
1140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001141run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001142 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1143 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001144 0 \
1145 -c "client hello, adding session ticket extension" \
1146 -s "found session ticket extension" \
1147 -s "server hello, adding session ticket extension" \
1148 -c "found session_ticket extension" \
1149 -c "parse new session ticket" \
1150 -S "session successfully restored from cache" \
1151 -s "session successfully restored from ticket" \
1152 -s "a session has been resumed" \
1153 -c "a session has been resumed"
1154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001155run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001156 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1157 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001158 0 \
1159 -c "client hello, adding session ticket extension" \
1160 -s "found session ticket extension" \
1161 -s "server hello, adding session ticket extension" \
1162 -c "found session_ticket extension" \
1163 -c "parse new session ticket" \
1164 -S "session successfully restored from cache" \
1165 -S "session successfully restored from ticket" \
1166 -S "a session has been resumed" \
1167 -C "a session has been resumed"
1168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001169run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001170 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001171 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001172 0 \
1173 -c "client hello, adding session ticket extension" \
1174 -c "found session_ticket extension" \
1175 -c "parse new session ticket" \
1176 -c "a session has been resumed"
1177
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001178run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001179 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001180 "( $O_CLI -sess_out $SESSION; \
1181 $O_CLI -sess_in $SESSION; \
1182 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001183 0 \
1184 -s "found session ticket extension" \
1185 -s "server hello, adding session ticket extension" \
1186 -S "session successfully restored from cache" \
1187 -s "session successfully restored from ticket" \
1188 -s "a session has been resumed"
1189
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001190# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001192run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001193 "$P_SRV debug_level=3 tickets=0" \
1194 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001195 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001196 -c "client hello, adding session ticket extension" \
1197 -s "found session ticket extension" \
1198 -S "server hello, adding session ticket extension" \
1199 -C "found session_ticket extension" \
1200 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001201 -s "session successfully restored from cache" \
1202 -S "session successfully restored from ticket" \
1203 -s "a session has been resumed" \
1204 -c "a session has been resumed"
1205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001206run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001207 "$P_SRV debug_level=3 tickets=1" \
1208 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001209 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001210 -C "client hello, adding session ticket extension" \
1211 -S "found session ticket extension" \
1212 -S "server hello, adding session ticket extension" \
1213 -C "found session_ticket extension" \
1214 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001215 -s "session successfully restored from cache" \
1216 -S "session successfully restored from ticket" \
1217 -s "a session has been resumed" \
1218 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001220run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001221 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1222 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001223 0 \
1224 -S "session successfully restored from cache" \
1225 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001226 -S "a session has been resumed" \
1227 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001229run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001230 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1231 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001232 0 \
1233 -s "session successfully restored from cache" \
1234 -S "session successfully restored from ticket" \
1235 -s "a session has been resumed" \
1236 -c "a session has been resumed"
1237
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001238run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001239 "$P_SRV debug_level=3 tickets=0" \
1240 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001241 0 \
1242 -s "session successfully restored from cache" \
1243 -S "session successfully restored from ticket" \
1244 -s "a session has been resumed" \
1245 -c "a session has been resumed"
1246
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001247run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001248 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1249 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001250 0 \
1251 -S "session successfully restored from cache" \
1252 -S "session successfully restored from ticket" \
1253 -S "a session has been resumed" \
1254 -C "a session has been resumed"
1255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001256run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1258 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001259 0 \
1260 -s "session successfully restored from cache" \
1261 -S "session successfully restored from ticket" \
1262 -s "a session has been resumed" \
1263 -c "a session has been resumed"
1264
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001265run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001266 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001267 "( $O_CLI -sess_out $SESSION; \
1268 $O_CLI -sess_in $SESSION; \
1269 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001270 0 \
1271 -s "found session ticket extension" \
1272 -S "server hello, adding session ticket extension" \
1273 -s "session successfully restored from cache" \
1274 -S "session successfully restored from ticket" \
1275 -s "a session has been resumed"
1276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001277run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001278 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001279 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001280 0 \
1281 -C "found session_ticket extension" \
1282 -C "parse new session ticket" \
1283 -c "a session has been resumed"
1284
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001285# Tests for Max Fragment Length extension
1286
Hanno Becker64691dc2017-09-22 16:58:50 +01001287MAX_CONTENT_LEN_EXPECT='16384'
1288MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1289
1290if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1291 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1292 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1293 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1294 printf "\n"
1295 printf "The tests assume this value and if it changes, the tests in this\n"
1296 printf "script should also be adjusted.\n"
1297 printf "\n"
1298
1299 exit 1
1300fi
1301
Hanno Becker05607782017-09-18 15:00:34 +01001302requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001303run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001304 "$P_SRV debug_level=3" \
1305 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001306 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001307 -c "Maximum fragment length is 16384" \
1308 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001309 -C "client hello, adding max_fragment_length extension" \
1310 -S "found max fragment length extension" \
1311 -S "server hello, max_fragment_length extension" \
1312 -C "found max_fragment_length extension"
1313
Hanno Becker05607782017-09-18 15:00:34 +01001314requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001315run_test "Max fragment length: enabled, default, larger message" \
1316 "$P_SRV debug_level=3" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001317 "$P_CLI debug_level=3 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001318 0 \
1319 -c "Maximum fragment length is 16384" \
1320 -s "Maximum fragment length is 16384" \
1321 -C "client hello, adding max_fragment_length extension" \
1322 -S "found max fragment length extension" \
1323 -S "server hello, max_fragment_length extension" \
1324 -C "found max_fragment_length extension" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001325 -c "16385 bytes written in 2 fragments" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001326 -s "16384 bytes read" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001327 -s "1 bytes read"
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001328
1329requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1330run_test "Max fragment length, DTLS: enabled, default, larger message" \
1331 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001332 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001333 1 \
1334 -c "Maximum fragment length is 16384" \
1335 -s "Maximum fragment length is 16384" \
1336 -C "client hello, adding max_fragment_length extension" \
1337 -S "found max fragment length extension" \
1338 -S "server hello, max_fragment_length extension" \
1339 -C "found max_fragment_length extension" \
1340 -c "fragment larger than.*maximum "
1341
1342requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1343run_test "Max fragment length: disabled, larger message" \
1344 "$P_SRV debug_level=3" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001345 "$P_CLI debug_level=3 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001346 0 \
1347 -C "Maximum fragment length is 16384" \
1348 -S "Maximum fragment length is 16384" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001349 -c "16385 bytes written in 2 fragments" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001350 -s "16384 bytes read" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001351 -s "1 bytes read"
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001352
1353requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1354run_test "Max fragment length DTLS: disabled, larger message" \
1355 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001356 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001357 1 \
1358 -C "Maximum fragment length is 16384" \
1359 -S "Maximum fragment length is 16384" \
1360 -c "fragment larger than.*maximum "
1361
1362requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001363run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001364 "$P_SRV debug_level=3" \
1365 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001366 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001367 -c "Maximum fragment length is 4096" \
1368 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001369 -c "client hello, adding max_fragment_length extension" \
1370 -s "found max fragment length extension" \
1371 -s "server hello, max_fragment_length extension" \
1372 -c "found max_fragment_length extension"
1373
Hanno Becker05607782017-09-18 15:00:34 +01001374requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001375run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001376 "$P_SRV debug_level=3 max_frag_len=4096" \
1377 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001378 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001379 -c "Maximum fragment length is 16384" \
1380 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001381 -C "client hello, adding max_fragment_length extension" \
1382 -S "found max fragment length extension" \
1383 -S "server hello, max_fragment_length extension" \
1384 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001385
Hanno Becker05607782017-09-18 15:00:34 +01001386requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001387requires_gnutls
1388run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001389 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001390 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001391 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001392 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001393 -c "client hello, adding max_fragment_length extension" \
1394 -c "found max_fragment_length extension"
1395
Hanno Becker05607782017-09-18 15:00:34 +01001396requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001397run_test "Max fragment length: client, message just fits" \
1398 "$P_SRV debug_level=3" \
1399 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1400 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001401 -c "Maximum fragment length is 2048" \
1402 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001403 -c "client hello, adding max_fragment_length extension" \
1404 -s "found max fragment length extension" \
1405 -s "server hello, max_fragment_length extension" \
1406 -c "found max_fragment_length extension" \
1407 -c "2048 bytes written in 1 fragments" \
1408 -s "2048 bytes read"
1409
Hanno Becker05607782017-09-18 15:00:34 +01001410requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001411run_test "Max fragment length: client, larger message" \
1412 "$P_SRV debug_level=3" \
1413 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1414 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001415 -c "Maximum fragment length is 2048" \
1416 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001417 -c "client hello, adding max_fragment_length extension" \
1418 -s "found max fragment length extension" \
1419 -s "server hello, max_fragment_length extension" \
1420 -c "found max_fragment_length extension" \
1421 -c "2345 bytes written in 2 fragments" \
1422 -s "2048 bytes read" \
1423 -s "297 bytes read"
1424
Hanno Becker05607782017-09-18 15:00:34 +01001425requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001426run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001427 "$P_SRV debug_level=3 dtls=1" \
1428 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1429 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001430 -c "Maximum fragment length is 2048" \
1431 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001432 -c "client hello, adding max_fragment_length extension" \
1433 -s "found max fragment length extension" \
1434 -s "server hello, max_fragment_length extension" \
1435 -c "found max_fragment_length extension" \
1436 -c "fragment larger than.*maximum"
1437
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001438# Tests for renegotiation
1439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001440run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001441 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001442 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001443 0 \
1444 -C "client hello, adding renegotiation extension" \
1445 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1446 -S "found renegotiation extension" \
1447 -s "server hello, secure renegotiation extension" \
1448 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001449 -C "=> renegotiate" \
1450 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001451 -S "write hello request"
1452
Hanno Becker78891132017-10-24 11:54:55 +01001453requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001454run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001455 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001456 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001457 0 \
1458 -c "client hello, adding renegotiation extension" \
1459 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1460 -s "found renegotiation extension" \
1461 -s "server hello, secure renegotiation extension" \
1462 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001463 -c "=> renegotiate" \
1464 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001465 -S "write hello request"
1466
Hanno Becker78891132017-10-24 11:54:55 +01001467requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001468run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001469 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001470 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001471 0 \
1472 -c "client hello, adding renegotiation extension" \
1473 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1474 -s "found renegotiation extension" \
1475 -s "server hello, secure renegotiation extension" \
1476 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001477 -c "=> renegotiate" \
1478 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001479 -s "write hello request"
1480
Janos Follath5f1dd802017-10-05 12:29:42 +01001481# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1482# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1483# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker78891132017-10-24 11:54:55 +01001484requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follath5f1dd802017-10-05 12:29:42 +01001485run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1486 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1487 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1488 0 \
1489 -c "client hello, adding renegotiation extension" \
1490 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1491 -s "found renegotiation extension" \
1492 -s "server hello, secure renegotiation extension" \
1493 -c "found renegotiation extension" \
1494 -c "=> renegotiate" \
1495 -s "=> renegotiate" \
1496 -S "write hello request" \
1497 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1498
1499# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1500# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1501# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker78891132017-10-24 11:54:55 +01001502requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follath5f1dd802017-10-05 12:29:42 +01001503run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1504 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1505 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1506 0 \
1507 -c "client hello, adding renegotiation extension" \
1508 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1509 -s "found renegotiation extension" \
1510 -s "server hello, secure renegotiation extension" \
1511 -c "found renegotiation extension" \
1512 -c "=> renegotiate" \
1513 -s "=> renegotiate" \
1514 -s "write hello request" \
1515 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1516
Hanno Becker78891132017-10-24 11:54:55 +01001517requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001518run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001519 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001520 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001521 0 \
1522 -c "client hello, adding renegotiation extension" \
1523 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1524 -s "found renegotiation extension" \
1525 -s "server hello, secure renegotiation extension" \
1526 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001527 -c "=> renegotiate" \
1528 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001529 -s "write hello request"
1530
Hanno Becker78891132017-10-24 11:54:55 +01001531requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001532run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001533 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001534 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001535 1 \
1536 -c "client hello, adding renegotiation extension" \
1537 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1538 -S "found renegotiation extension" \
1539 -s "server hello, secure renegotiation extension" \
1540 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001541 -c "=> renegotiate" \
1542 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001543 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001544 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001545 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001546
Hanno Becker78891132017-10-24 11:54:55 +01001547requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001548run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001549 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001550 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001551 0 \
1552 -C "client hello, adding renegotiation extension" \
1553 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1554 -S "found renegotiation extension" \
1555 -s "server hello, secure renegotiation extension" \
1556 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001557 -C "=> renegotiate" \
1558 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001559 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001560 -S "SSL - An unexpected message was received from our peer" \
1561 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001562
Hanno Becker78891132017-10-24 11:54:55 +01001563requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001564run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001565 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001566 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001567 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001568 0 \
1569 -C "client hello, adding renegotiation extension" \
1570 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1571 -S "found renegotiation extension" \
1572 -s "server hello, secure renegotiation extension" \
1573 -c "found renegotiation extension" \
1574 -C "=> renegotiate" \
1575 -S "=> renegotiate" \
1576 -s "write hello request" \
1577 -S "SSL - An unexpected message was received from our peer" \
1578 -S "failed"
1579
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001580# delay 2 for 1 alert record + 1 application data record
Hanno Becker78891132017-10-24 11:54:55 +01001581requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001582run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001583 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001584 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001585 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001586 0 \
1587 -C "client hello, adding renegotiation extension" \
1588 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1589 -S "found renegotiation extension" \
1590 -s "server hello, secure renegotiation extension" \
1591 -c "found renegotiation extension" \
1592 -C "=> renegotiate" \
1593 -S "=> renegotiate" \
1594 -s "write hello request" \
1595 -S "SSL - An unexpected message was received from our peer" \
1596 -S "failed"
1597
Hanno Becker78891132017-10-24 11:54:55 +01001598requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001599run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001600 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001601 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001602 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001603 0 \
1604 -C "client hello, adding renegotiation extension" \
1605 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1606 -S "found renegotiation extension" \
1607 -s "server hello, secure renegotiation extension" \
1608 -c "found renegotiation extension" \
1609 -C "=> renegotiate" \
1610 -S "=> renegotiate" \
1611 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001612 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001613
Hanno Becker78891132017-10-24 11:54:55 +01001614requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001615run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001616 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001617 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001618 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001619 0 \
1620 -c "client hello, adding renegotiation extension" \
1621 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1622 -s "found renegotiation extension" \
1623 -s "server hello, secure renegotiation extension" \
1624 -c "found renegotiation extension" \
1625 -c "=> renegotiate" \
1626 -s "=> renegotiate" \
1627 -s "write hello request" \
1628 -S "SSL - An unexpected message was received from our peer" \
1629 -S "failed"
1630
Hanno Becker78891132017-10-24 11:54:55 +01001631requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001632run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001633 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001634 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1635 0 \
1636 -C "client hello, adding renegotiation extension" \
1637 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1638 -S "found renegotiation extension" \
1639 -s "server hello, secure renegotiation extension" \
1640 -c "found renegotiation extension" \
1641 -S "record counter limit reached: renegotiate" \
1642 -C "=> renegotiate" \
1643 -S "=> renegotiate" \
1644 -S "write hello request" \
1645 -S "SSL - An unexpected message was received from our peer" \
1646 -S "failed"
1647
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001648# one extra exchange to be able to complete renego
Hanno Becker78891132017-10-24 11:54:55 +01001649requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001650run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001651 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001652 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001653 0 \
1654 -c "client hello, adding renegotiation extension" \
1655 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1656 -s "found renegotiation extension" \
1657 -s "server hello, secure renegotiation extension" \
1658 -c "found renegotiation extension" \
1659 -s "record counter limit reached: renegotiate" \
1660 -c "=> renegotiate" \
1661 -s "=> renegotiate" \
1662 -s "write hello request" \
1663 -S "SSL - An unexpected message was received from our peer" \
1664 -S "failed"
1665
Hanno Becker78891132017-10-24 11:54:55 +01001666requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001667run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001668 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001669 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001670 0 \
1671 -c "client hello, adding renegotiation extension" \
1672 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1673 -s "found renegotiation extension" \
1674 -s "server hello, secure renegotiation extension" \
1675 -c "found renegotiation extension" \
1676 -s "record counter limit reached: renegotiate" \
1677 -c "=> renegotiate" \
1678 -s "=> renegotiate" \
1679 -s "write hello request" \
1680 -S "SSL - An unexpected message was received from our peer" \
1681 -S "failed"
1682
Hanno Becker78891132017-10-24 11:54:55 +01001683requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001684run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001685 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001686 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1687 0 \
1688 -C "client hello, adding renegotiation extension" \
1689 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1690 -S "found renegotiation extension" \
1691 -s "server hello, secure renegotiation extension" \
1692 -c "found renegotiation extension" \
1693 -S "record counter limit reached: renegotiate" \
1694 -C "=> renegotiate" \
1695 -S "=> renegotiate" \
1696 -S "write hello request" \
1697 -S "SSL - An unexpected message was received from our peer" \
1698 -S "failed"
1699
Hanno Becker78891132017-10-24 11:54:55 +01001700requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001701run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001702 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001703 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001704 0 \
1705 -c "client hello, adding renegotiation extension" \
1706 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1707 -s "found renegotiation extension" \
1708 -s "server hello, secure renegotiation extension" \
1709 -c "found renegotiation extension" \
1710 -c "=> renegotiate" \
1711 -s "=> renegotiate" \
1712 -S "write hello request"
1713
Hanno Becker78891132017-10-24 11:54:55 +01001714requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001715run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001716 "$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 +02001717 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001718 0 \
1719 -c "client hello, adding renegotiation extension" \
1720 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1721 -s "found renegotiation extension" \
1722 -s "server hello, secure renegotiation extension" \
1723 -c "found renegotiation extension" \
1724 -c "=> renegotiate" \
1725 -s "=> renegotiate" \
1726 -s "write hello request"
1727
Hanno Becker78891132017-10-24 11:54:55 +01001728requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001729run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001730 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001731 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001732 0 \
1733 -c "client hello, adding renegotiation extension" \
1734 -c "found renegotiation extension" \
1735 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001736 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001737 -C "error" \
1738 -c "HTTP/1.0 200 [Oo][Kk]"
1739
Paul Bakker539d9722015-02-08 16:18:35 +01001740requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001741requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001742run_test "Renegotiation: gnutls server strict, client-initiated" \
1743 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001744 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001745 0 \
1746 -c "client hello, adding renegotiation extension" \
1747 -c "found renegotiation extension" \
1748 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001749 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001750 -C "error" \
1751 -c "HTTP/1.0 200 [Oo][Kk]"
1752
Paul Bakker539d9722015-02-08 16:18:35 +01001753requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001754requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001755run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1756 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1757 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1758 1 \
1759 -c "client hello, adding renegotiation extension" \
1760 -C "found renegotiation extension" \
1761 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001762 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001763 -c "error" \
1764 -C "HTTP/1.0 200 [Oo][Kk]"
1765
Paul Bakker539d9722015-02-08 16:18:35 +01001766requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001767requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001768run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1769 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1770 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1771 allow_legacy=0" \
1772 1 \
1773 -c "client hello, adding renegotiation extension" \
1774 -C "found renegotiation extension" \
1775 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001776 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001777 -c "error" \
1778 -C "HTTP/1.0 200 [Oo][Kk]"
1779
Paul Bakker539d9722015-02-08 16:18:35 +01001780requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001781requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001782run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1783 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1784 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1785 allow_legacy=1" \
1786 0 \
1787 -c "client hello, adding renegotiation extension" \
1788 -C "found renegotiation extension" \
1789 -c "=> renegotiate" \
1790 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001791 -C "error" \
1792 -c "HTTP/1.0 200 [Oo][Kk]"
1793
Hanno Becker78891132017-10-24 11:54:55 +01001794requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001795run_test "Renegotiation: DTLS, client-initiated" \
1796 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1797 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1798 0 \
1799 -c "client hello, adding renegotiation extension" \
1800 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1801 -s "found renegotiation extension" \
1802 -s "server hello, secure renegotiation extension" \
1803 -c "found renegotiation extension" \
1804 -c "=> renegotiate" \
1805 -s "=> renegotiate" \
1806 -S "write hello request"
1807
Hanno Becker78891132017-10-24 11:54:55 +01001808requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001809run_test "Renegotiation: DTLS, server-initiated" \
1810 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001811 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1812 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001813 0 \
1814 -c "client hello, adding renegotiation extension" \
1815 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1816 -s "found renegotiation extension" \
1817 -s "server hello, secure renegotiation extension" \
1818 -c "found renegotiation extension" \
1819 -c "=> renegotiate" \
1820 -s "=> renegotiate" \
1821 -s "write hello request"
1822
Hanno Becker78891132017-10-24 11:54:55 +01001823requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG9b1927b2017-01-19 16:30:57 +00001824run_test "Renegotiation: DTLS, renego_period overflow" \
1825 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1826 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1827 0 \
1828 -c "client hello, adding renegotiation extension" \
1829 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1830 -s "found renegotiation extension" \
1831 -s "server hello, secure renegotiation extension" \
1832 -s "record counter limit reached: renegotiate" \
1833 -c "=> renegotiate" \
1834 -s "=> renegotiate" \
Hanno Becker78891132017-10-24 11:54:55 +01001835 -s "write hello request"
Andres AG9b1927b2017-01-19 16:30:57 +00001836
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001837requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001838requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001839run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1840 "$G_SRV -u --mtu 4096" \
1841 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1842 0 \
1843 -c "client hello, adding renegotiation extension" \
1844 -c "found renegotiation extension" \
1845 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001846 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001847 -C "error" \
1848 -s "Extra-header:"
1849
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001850# Test for the "secure renegotation" extension only (no actual renegotiation)
1851
Paul Bakker539d9722015-02-08 16:18:35 +01001852requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001853run_test "Renego ext: gnutls server strict, client default" \
1854 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1855 "$P_CLI debug_level=3" \
1856 0 \
1857 -c "found renegotiation extension" \
1858 -C "error" \
1859 -c "HTTP/1.0 200 [Oo][Kk]"
1860
Paul Bakker539d9722015-02-08 16:18:35 +01001861requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001862run_test "Renego ext: gnutls server unsafe, client default" \
1863 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1864 "$P_CLI debug_level=3" \
1865 0 \
1866 -C "found renegotiation extension" \
1867 -C "error" \
1868 -c "HTTP/1.0 200 [Oo][Kk]"
1869
Paul Bakker539d9722015-02-08 16:18:35 +01001870requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001871run_test "Renego ext: gnutls server unsafe, client break legacy" \
1872 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1873 "$P_CLI debug_level=3 allow_legacy=-1" \
1874 1 \
1875 -C "found renegotiation extension" \
1876 -c "error" \
1877 -C "HTTP/1.0 200 [Oo][Kk]"
1878
Paul Bakker539d9722015-02-08 16:18:35 +01001879requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001880run_test "Renego ext: gnutls client strict, server default" \
1881 "$P_SRV debug_level=3" \
1882 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1883 0 \
1884 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1885 -s "server hello, secure renegotiation extension"
1886
Paul Bakker539d9722015-02-08 16:18:35 +01001887requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001888run_test "Renego ext: gnutls client unsafe, server default" \
1889 "$P_SRV debug_level=3" \
1890 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1891 0 \
1892 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1893 -S "server hello, secure renegotiation extension"
1894
Paul Bakker539d9722015-02-08 16:18:35 +01001895requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001896run_test "Renego ext: gnutls client unsafe, server break legacy" \
1897 "$P_SRV debug_level=3 allow_legacy=-1" \
1898 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1899 1 \
1900 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1901 -S "server hello, secure renegotiation extension"
1902
Janos Follath365b2262016-02-17 10:11:21 +00001903# Tests for silently dropping trailing extra bytes in .der certificates
1904
1905requires_gnutls
1906run_test "DER format: no trailing bytes" \
1907 "$P_SRV crt_file=data_files/server5-der0.crt \
1908 key_file=data_files/server5.key" \
1909 "$G_CLI " \
1910 0 \
1911 -c "Handshake was completed" \
1912
1913requires_gnutls
1914run_test "DER format: with a trailing zero byte" \
1915 "$P_SRV crt_file=data_files/server5-der1a.crt \
1916 key_file=data_files/server5.key" \
1917 "$G_CLI " \
1918 0 \
1919 -c "Handshake was completed" \
1920
1921requires_gnutls
1922run_test "DER format: with a trailing random byte" \
1923 "$P_SRV crt_file=data_files/server5-der1b.crt \
1924 key_file=data_files/server5.key" \
1925 "$G_CLI " \
1926 0 \
1927 -c "Handshake was completed" \
1928
1929requires_gnutls
1930run_test "DER format: with 2 trailing random bytes" \
1931 "$P_SRV crt_file=data_files/server5-der2.crt \
1932 key_file=data_files/server5.key" \
1933 "$G_CLI " \
1934 0 \
1935 -c "Handshake was completed" \
1936
1937requires_gnutls
1938run_test "DER format: with 4 trailing random bytes" \
1939 "$P_SRV crt_file=data_files/server5-der4.crt \
1940 key_file=data_files/server5.key" \
1941 "$G_CLI " \
1942 0 \
1943 -c "Handshake was completed" \
1944
1945requires_gnutls
1946run_test "DER format: with 8 trailing random bytes" \
1947 "$P_SRV crt_file=data_files/server5-der8.crt \
1948 key_file=data_files/server5.key" \
1949 "$G_CLI " \
1950 0 \
1951 -c "Handshake was completed" \
1952
1953requires_gnutls
1954run_test "DER format: with 9 trailing random bytes" \
1955 "$P_SRV crt_file=data_files/server5-der9.crt \
1956 key_file=data_files/server5.key" \
1957 "$G_CLI " \
1958 0 \
1959 -c "Handshake was completed" \
1960
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001961# Tests for auth_mode
1962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001963run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001964 "$P_SRV crt_file=data_files/server5-badsign.crt \
1965 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001966 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001967 1 \
1968 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001969 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001970 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001971 -c "X509 - Certificate verification failed"
1972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001973run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001974 "$P_SRV crt_file=data_files/server5-badsign.crt \
1975 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001976 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001977 0 \
1978 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001979 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001980 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001981 -C "X509 - Certificate verification failed"
1982
Hanno Becker61c0c702017-05-15 16:05:15 +01001983run_test "Authentication: server goodcert, client optional, no trusted CA" \
1984 "$P_SRV" \
1985 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1986 0 \
1987 -c "x509_verify_cert() returned" \
1988 -c "! The certificate is not correctly signed by the trusted CA" \
1989 -c "! Certificate verification flags"\
1990 -C "! mbedtls_ssl_handshake returned" \
1991 -C "X509 - Certificate verification failed" \
1992 -C "SSL - No CA Chain is set, but required to operate"
1993
1994run_test "Authentication: server goodcert, client required, no trusted CA" \
1995 "$P_SRV" \
1996 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1997 1 \
1998 -c "x509_verify_cert() returned" \
1999 -c "! The certificate is not correctly signed by the trusted CA" \
2000 -c "! Certificate verification flags"\
2001 -c "! mbedtls_ssl_handshake returned" \
2002 -c "SSL - No CA Chain is set, but required to operate"
2003
2004# The purpose of the next two tests is to test the client's behaviour when receiving a server
2005# certificate with an unsupported elliptic curve. This should usually not happen because
2006# the client informs the server about the supported curves - it does, though, in the
2007# corner case of a static ECDH suite, because the server doesn't check the curve on that
2008# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2009# different means to have the server ignoring the client's supported curve list.
2010
2011requires_config_enabled MBEDTLS_ECP_C
2012run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2013 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2014 crt_file=data_files/server5.ku-ka.crt" \
2015 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2016 1 \
2017 -c "bad certificate (EC key curve)"\
2018 -c "! Certificate verification flags"\
2019 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2020
2021requires_config_enabled MBEDTLS_ECP_C
2022run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2023 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2024 crt_file=data_files/server5.ku-ka.crt" \
2025 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2026 1 \
2027 -c "bad certificate (EC key curve)"\
2028 -c "! Certificate verification flags"\
2029 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002031run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002032 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002033 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002034 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002035 0 \
2036 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002037 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002038 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002039 -C "X509 - Certificate verification failed"
2040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002041run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002042 "$P_SRV debug_level=3 auth_mode=required" \
2043 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002044 key_file=data_files/server5.key" \
2045 1 \
2046 -S "skip write certificate request" \
2047 -C "skip parse certificate request" \
2048 -c "got a certificate request" \
2049 -C "skip write certificate" \
2050 -C "skip write certificate verify" \
2051 -S "skip parse certificate verify" \
2052 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002053 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002054 -s "! mbedtls_ssl_handshake returned" \
2055 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002056 -s "X509 - Certificate verification failed"
2057
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002058run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002059 "$P_SRV debug_level=3 auth_mode=optional" \
2060 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002061 key_file=data_files/server5.key" \
2062 0 \
2063 -S "skip write certificate request" \
2064 -C "skip parse certificate request" \
2065 -c "got a certificate request" \
2066 -C "skip write certificate" \
2067 -C "skip write certificate verify" \
2068 -S "skip parse certificate verify" \
2069 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002070 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002071 -S "! mbedtls_ssl_handshake returned" \
2072 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002073 -S "X509 - Certificate verification failed"
2074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002075run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002076 "$P_SRV debug_level=3 auth_mode=none" \
2077 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002078 key_file=data_files/server5.key" \
2079 0 \
2080 -s "skip write certificate request" \
2081 -C "skip parse certificate request" \
2082 -c "got no certificate request" \
2083 -c "skip write certificate" \
2084 -c "skip write certificate verify" \
2085 -s "skip parse certificate verify" \
2086 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002087 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002088 -S "! mbedtls_ssl_handshake returned" \
2089 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002090 -S "X509 - Certificate verification failed"
2091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002092run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002093 "$P_SRV debug_level=3 auth_mode=optional" \
2094 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002095 0 \
2096 -S "skip write certificate request" \
2097 -C "skip parse certificate request" \
2098 -c "got a certificate request" \
2099 -C "skip write certificate$" \
2100 -C "got no certificate to send" \
2101 -S "SSLv3 client has no certificate" \
2102 -c "skip write certificate verify" \
2103 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002104 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002105 -S "! mbedtls_ssl_handshake returned" \
2106 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002107 -S "X509 - Certificate verification failed"
2108
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002109run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002110 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002111 "$O_CLI" \
2112 0 \
2113 -S "skip write certificate request" \
2114 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002115 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002116 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002117 -S "X509 - Certificate verification failed"
2118
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002119run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002120 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002121 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002122 0 \
2123 -C "skip parse certificate request" \
2124 -c "got a certificate request" \
2125 -C "skip write certificate$" \
2126 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002127 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002128
Janos Follath542ee5d2016-03-07 15:57:05 +00002129requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002130run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002131 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002132 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002133 0 \
2134 -S "skip write certificate request" \
2135 -C "skip parse certificate request" \
2136 -c "got a certificate request" \
2137 -C "skip write certificate$" \
2138 -c "skip write certificate verify" \
2139 -c "got no certificate to send" \
2140 -s "SSLv3 client has no certificate" \
2141 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002142 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002143 -S "! mbedtls_ssl_handshake returned" \
2144 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002145 -S "X509 - Certificate verification failed"
2146
Manuel Pégourié-Gonnard591035d2017-06-26 10:45:33 +02002147run_test "Authentication: server max_int chain, client default" \
2148 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2149 key_file=data_files/dir-maxpath/09.key" \
2150 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2151 0 \
2152 -C "X509 - A fatal error occured"
2153
2154run_test "Authentication: server max_int+1 chain, client default" \
2155 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2156 key_file=data_files/dir-maxpath/10.key" \
2157 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2158 1 \
2159 -c "X509 - A fatal error occured"
2160
2161run_test "Authentication: server max_int+1 chain, client optional" \
2162 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2163 key_file=data_files/dir-maxpath/10.key" \
2164 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2165 auth_mode=optional" \
2166 1 \
2167 -c "X509 - A fatal error occured"
2168
2169run_test "Authentication: server max_int+1 chain, client none" \
2170 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2171 key_file=data_files/dir-maxpath/10.key" \
2172 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2173 auth_mode=none" \
2174 0 \
2175 -C "X509 - A fatal error occured"
2176
2177run_test "Authentication: client max_int+1 chain, server default" \
2178 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2179 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2180 key_file=data_files/dir-maxpath/10.key" \
2181 0 \
2182 -S "X509 - A fatal error occured"
2183
2184run_test "Authentication: client max_int+1 chain, server optional" \
2185 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2186 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2187 key_file=data_files/dir-maxpath/10.key" \
2188 1 \
2189 -s "X509 - A fatal error occured"
2190
2191run_test "Authentication: client max_int+1 chain, server required" \
2192 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2193 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2194 key_file=data_files/dir-maxpath/10.key" \
2195 1 \
2196 -s "X509 - A fatal error occured"
2197
2198run_test "Authentication: client max_int chain, server required" \
2199 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2200 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2201 key_file=data_files/dir-maxpath/09.key" \
2202 0 \
2203 -S "X509 - A fatal error occured"
2204
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002205# Tests for certificate selection based on SHA verson
2206
2207run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2208 "$P_SRV crt_file=data_files/server5.crt \
2209 key_file=data_files/server5.key \
2210 crt_file2=data_files/server5-sha1.crt \
2211 key_file2=data_files/server5.key" \
2212 "$P_CLI force_version=tls1_2" \
2213 0 \
2214 -c "signed using.*ECDSA with SHA256" \
2215 -C "signed using.*ECDSA with SHA1"
2216
2217run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2218 "$P_SRV crt_file=data_files/server5.crt \
2219 key_file=data_files/server5.key \
2220 crt_file2=data_files/server5-sha1.crt \
2221 key_file2=data_files/server5.key" \
2222 "$P_CLI force_version=tls1_1" \
2223 0 \
2224 -C "signed using.*ECDSA with SHA256" \
2225 -c "signed using.*ECDSA with SHA1"
2226
2227run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2228 "$P_SRV crt_file=data_files/server5.crt \
2229 key_file=data_files/server5.key \
2230 crt_file2=data_files/server5-sha1.crt \
2231 key_file2=data_files/server5.key" \
2232 "$P_CLI force_version=tls1" \
2233 0 \
2234 -C "signed using.*ECDSA with SHA256" \
2235 -c "signed using.*ECDSA with SHA1"
2236
2237run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2238 "$P_SRV crt_file=data_files/server5.crt \
2239 key_file=data_files/server5.key \
2240 crt_file2=data_files/server6.crt \
2241 key_file2=data_files/server6.key" \
2242 "$P_CLI force_version=tls1_1" \
2243 0 \
2244 -c "serial number.*09" \
2245 -c "signed using.*ECDSA with SHA256" \
2246 -C "signed using.*ECDSA with SHA1"
2247
2248run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2249 "$P_SRV crt_file=data_files/server6.crt \
2250 key_file=data_files/server6.key \
2251 crt_file2=data_files/server5.crt \
2252 key_file2=data_files/server5.key" \
2253 "$P_CLI force_version=tls1_1" \
2254 0 \
2255 -c "serial number.*0A" \
2256 -c "signed using.*ECDSA with SHA256" \
2257 -C "signed using.*ECDSA with SHA1"
2258
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002259# tests for SNI
2260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002261run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002262 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002263 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002264 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002265 0 \
2266 -S "parse ServerName extension" \
2267 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2268 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002270run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002271 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002272 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002273 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 +02002274 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002275 0 \
2276 -s "parse ServerName extension" \
2277 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2278 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002279
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002280run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002281 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002282 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002283 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 +02002284 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002285 0 \
2286 -s "parse ServerName extension" \
2287 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2288 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002289
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002290run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002291 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002292 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002293 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 +02002294 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002295 1 \
2296 -s "parse ServerName extension" \
2297 -s "ssl_sni_wrapper() returned" \
2298 -s "mbedtls_ssl_handshake returned" \
2299 -c "mbedtls_ssl_handshake returned" \
2300 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002301
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002302run_test "SNI: client auth no override: optional" \
2303 "$P_SRV debug_level=3 auth_mode=optional \
2304 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2305 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2306 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002307 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002308 -S "skip write certificate request" \
2309 -C "skip parse certificate request" \
2310 -c "got a certificate request" \
2311 -C "skip write certificate" \
2312 -C "skip write certificate verify" \
2313 -S "skip parse certificate verify"
2314
2315run_test "SNI: client auth override: none -> optional" \
2316 "$P_SRV debug_level=3 auth_mode=none \
2317 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2318 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2319 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002320 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002321 -S "skip write certificate request" \
2322 -C "skip parse certificate request" \
2323 -c "got a certificate request" \
2324 -C "skip write certificate" \
2325 -C "skip write certificate verify" \
2326 -S "skip parse certificate verify"
2327
2328run_test "SNI: client auth override: optional -> none" \
2329 "$P_SRV debug_level=3 auth_mode=optional \
2330 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2331 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2332 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002333 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002334 -s "skip write certificate request" \
2335 -C "skip parse certificate request" \
2336 -c "got no certificate request" \
2337 -c "skip write certificate" \
2338 -c "skip write certificate verify" \
2339 -s "skip parse certificate verify"
2340
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002341run_test "SNI: CA no override" \
2342 "$P_SRV debug_level=3 auth_mode=optional \
2343 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2344 ca_file=data_files/test-ca.crt \
2345 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2346 "$P_CLI debug_level=3 server_name=localhost \
2347 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2348 1 \
2349 -S "skip write certificate request" \
2350 -C "skip parse certificate request" \
2351 -c "got a certificate request" \
2352 -C "skip write certificate" \
2353 -C "skip write certificate verify" \
2354 -S "skip parse certificate verify" \
2355 -s "x509_verify_cert() returned" \
2356 -s "! The certificate is not correctly signed by the trusted CA" \
2357 -S "The certificate has been revoked (is on a CRL)"
2358
2359run_test "SNI: CA override" \
2360 "$P_SRV debug_level=3 auth_mode=optional \
2361 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2362 ca_file=data_files/test-ca.crt \
2363 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2364 "$P_CLI debug_level=3 server_name=localhost \
2365 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2366 0 \
2367 -S "skip write certificate request" \
2368 -C "skip parse certificate request" \
2369 -c "got a certificate request" \
2370 -C "skip write certificate" \
2371 -C "skip write certificate verify" \
2372 -S "skip parse certificate verify" \
2373 -S "x509_verify_cert() returned" \
2374 -S "! The certificate is not correctly signed by the trusted CA" \
2375 -S "The certificate has been revoked (is on a CRL)"
2376
2377run_test "SNI: CA override with CRL" \
2378 "$P_SRV debug_level=3 auth_mode=optional \
2379 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2380 ca_file=data_files/test-ca.crt \
2381 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2382 "$P_CLI debug_level=3 server_name=localhost \
2383 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2384 1 \
2385 -S "skip write certificate request" \
2386 -C "skip parse certificate request" \
2387 -c "got a certificate request" \
2388 -C "skip write certificate" \
2389 -C "skip write certificate verify" \
2390 -S "skip parse certificate verify" \
2391 -s "x509_verify_cert() returned" \
2392 -S "! The certificate is not correctly signed by the trusted CA" \
2393 -s "The certificate has been revoked (is on a CRL)"
2394
Andres AG52142f12016-12-07 10:01:30 +00002395# Tests for SNI and DTLS
2396
Andres Amaya Garcia0b8eaa82018-05-01 20:27:37 +01002397run_test "SNI: DTLS, no SNI callback" \
2398 "$P_SRV debug_level=3 dtls=1 \
2399 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2400 "$P_CLI server_name=localhost dtls=1" \
2401 0 \
2402 -S "parse ServerName extension" \
2403 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2404 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2405
Andres Amaya Garcia021ad3d2018-05-01 20:26:47 +01002406run_test "SNI: DTLS, matching cert 1" \
Andres AG52142f12016-12-07 10:01:30 +00002407 "$P_SRV debug_level=3 dtls=1 \
2408 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2409 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2410 "$P_CLI server_name=localhost dtls=1" \
2411 0 \
2412 -s "parse ServerName extension" \
2413 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2414 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2415
Andres Amaya Garcia0b8eaa82018-05-01 20:27:37 +01002416run_test "SNI: DTLS, matching cert 2" \
2417 "$P_SRV debug_level=3 dtls=1 \
2418 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2419 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2420 "$P_CLI server_name=polarssl.example dtls=1" \
2421 0 \
2422 -s "parse ServerName extension" \
2423 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2424 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2425
2426run_test "SNI: DTLS, no matching cert" \
2427 "$P_SRV debug_level=3 dtls=1 \
2428 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2429 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2430 "$P_CLI server_name=nonesuch.example dtls=1" \
2431 1 \
2432 -s "parse ServerName extension" \
2433 -s "ssl_sni_wrapper() returned" \
2434 -s "mbedtls_ssl_handshake returned" \
2435 -c "mbedtls_ssl_handshake returned" \
2436 -c "SSL - A fatal alert message was received from our peer"
2437
2438run_test "SNI: DTLS, client auth no override: optional" \
2439 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2440 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2441 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2442 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2443 0 \
2444 -S "skip write certificate request" \
2445 -C "skip parse certificate request" \
2446 -c "got a certificate request" \
2447 -C "skip write certificate" \
2448 -C "skip write certificate verify" \
2449 -S "skip parse certificate verify"
2450
2451run_test "SNI: DTLS, client auth override: none -> optional" \
2452 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2453 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2454 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2455 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2456 0 \
2457 -S "skip write certificate request" \
2458 -C "skip parse certificate request" \
2459 -c "got a certificate request" \
2460 -C "skip write certificate" \
2461 -C "skip write certificate verify" \
2462 -S "skip parse certificate verify"
2463
2464run_test "SNI: DTLS, client auth override: optional -> none" \
2465 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2466 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2467 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2468 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2469 0 \
2470 -s "skip write certificate request" \
2471 -C "skip parse certificate request" \
2472 -c "got no certificate request" \
2473 -c "skip write certificate" \
2474 -c "skip write certificate verify" \
2475 -s "skip parse certificate verify"
2476
2477run_test "SNI: DTLS, CA no override" \
2478 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2479 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2480 ca_file=data_files/test-ca.crt \
2481 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2482 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2483 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2484 1 \
2485 -S "skip write certificate request" \
2486 -C "skip parse certificate request" \
2487 -c "got a certificate request" \
2488 -C "skip write certificate" \
2489 -C "skip write certificate verify" \
2490 -S "skip parse certificate verify" \
2491 -s "x509_verify_cert() returned" \
2492 -s "! The certificate is not correctly signed by the trusted CA" \
2493 -S "The certificate has been revoked (is on a CRL)"
2494
Andres Amaya Garcia021ad3d2018-05-01 20:26:47 +01002495run_test "SNI: DTLS, CA override" \
Andres AG52142f12016-12-07 10:01:30 +00002496 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2497 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2498 ca_file=data_files/test-ca.crt \
2499 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2500 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2501 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2502 0 \
2503 -S "skip write certificate request" \
2504 -C "skip parse certificate request" \
2505 -c "got a certificate request" \
2506 -C "skip write certificate" \
2507 -C "skip write certificate verify" \
2508 -S "skip parse certificate verify" \
2509 -S "x509_verify_cert() returned" \
2510 -S "! The certificate is not correctly signed by the trusted CA" \
2511 -S "The certificate has been revoked (is on a CRL)"
2512
Andres Amaya Garcia021ad3d2018-05-01 20:26:47 +01002513run_test "SNI: DTLS, CA override with CRL" \
Andres AG52142f12016-12-07 10:01:30 +00002514 "$P_SRV debug_level=3 auth_mode=optional \
2515 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2516 ca_file=data_files/test-ca.crt \
2517 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2518 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2519 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2520 1 \
2521 -S "skip write certificate request" \
2522 -C "skip parse certificate request" \
2523 -c "got a certificate request" \
2524 -C "skip write certificate" \
2525 -C "skip write certificate verify" \
2526 -S "skip parse certificate verify" \
2527 -s "x509_verify_cert() returned" \
2528 -S "! The certificate is not correctly signed by the trusted CA" \
2529 -s "The certificate has been revoked (is on a CRL)"
2530
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002531# Tests for non-blocking I/O: exercise a variety of handshake flows
2532
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002533run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002534 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2535 "$P_CLI nbio=2 tickets=0" \
2536 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002537 -S "mbedtls_ssl_handshake returned" \
2538 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002539 -c "Read from server: .* bytes read"
2540
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002541run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002542 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2543 "$P_CLI nbio=2 tickets=0" \
2544 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002545 -S "mbedtls_ssl_handshake returned" \
2546 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002547 -c "Read from server: .* bytes read"
2548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002549run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002550 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2551 "$P_CLI nbio=2 tickets=1" \
2552 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002553 -S "mbedtls_ssl_handshake returned" \
2554 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002555 -c "Read from server: .* bytes read"
2556
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002557run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002558 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2559 "$P_CLI nbio=2 tickets=1" \
2560 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002561 -S "mbedtls_ssl_handshake returned" \
2562 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002563 -c "Read from server: .* bytes read"
2564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002565run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002566 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2567 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2568 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002569 -S "mbedtls_ssl_handshake returned" \
2570 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002571 -c "Read from server: .* bytes read"
2572
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002573run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002574 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2575 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2576 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002577 -S "mbedtls_ssl_handshake returned" \
2578 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002579 -c "Read from server: .* bytes read"
2580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002581run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002582 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2583 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2584 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002585 -S "mbedtls_ssl_handshake returned" \
2586 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002587 -c "Read from server: .* bytes read"
2588
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002589# Tests for version negotiation
2590
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002591run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002592 "$P_SRV" \
2593 "$P_CLI" \
2594 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002595 -S "mbedtls_ssl_handshake returned" \
2596 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002597 -s "Protocol is TLSv1.2" \
2598 -c "Protocol is TLSv1.2"
2599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002600run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002601 "$P_SRV" \
2602 "$P_CLI max_version=tls1_1" \
2603 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002604 -S "mbedtls_ssl_handshake returned" \
2605 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002606 -s "Protocol is TLSv1.1" \
2607 -c "Protocol is TLSv1.1"
2608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002609run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002610 "$P_SRV max_version=tls1_1" \
2611 "$P_CLI" \
2612 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002613 -S "mbedtls_ssl_handshake returned" \
2614 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002615 -s "Protocol is TLSv1.1" \
2616 -c "Protocol is TLSv1.1"
2617
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002618run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002619 "$P_SRV max_version=tls1_1" \
2620 "$P_CLI max_version=tls1_1" \
2621 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002622 -S "mbedtls_ssl_handshake returned" \
2623 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002624 -s "Protocol is TLSv1.1" \
2625 -c "Protocol is TLSv1.1"
2626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002627run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002628 "$P_SRV min_version=tls1_1" \
2629 "$P_CLI max_version=tls1_1" \
2630 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002631 -S "mbedtls_ssl_handshake returned" \
2632 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002633 -s "Protocol is TLSv1.1" \
2634 -c "Protocol is TLSv1.1"
2635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002636run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002637 "$P_SRV max_version=tls1_1" \
2638 "$P_CLI min_version=tls1_1" \
2639 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002640 -S "mbedtls_ssl_handshake returned" \
2641 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002642 -s "Protocol is TLSv1.1" \
2643 -c "Protocol is TLSv1.1"
2644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002645run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002646 "$P_SRV max_version=tls1_1" \
2647 "$P_CLI min_version=tls1_2" \
2648 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002649 -s "mbedtls_ssl_handshake returned" \
2650 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002651 -c "SSL - Handshake protocol not within min/max boundaries"
2652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002653run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002654 "$P_SRV min_version=tls1_2" \
2655 "$P_CLI max_version=tls1_1" \
2656 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002657 -s "mbedtls_ssl_handshake returned" \
2658 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002659 -s "SSL - Handshake protocol not within min/max boundaries"
2660
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002661# Tests for ALPN extension
2662
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002663run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002664 "$P_SRV debug_level=3" \
2665 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002666 0 \
2667 -C "client hello, adding alpn extension" \
2668 -S "found alpn extension" \
2669 -C "got an alert message, type: \\[2:120]" \
2670 -S "server hello, adding alpn extension" \
2671 -C "found alpn extension " \
2672 -C "Application Layer Protocol is" \
2673 -S "Application Layer Protocol is"
2674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002675run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002676 "$P_SRV debug_level=3" \
2677 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002678 0 \
2679 -c "client hello, adding alpn extension" \
2680 -s "found alpn extension" \
2681 -C "got an alert message, type: \\[2:120]" \
2682 -S "server hello, adding alpn extension" \
2683 -C "found alpn extension " \
2684 -c "Application Layer Protocol is (none)" \
2685 -S "Application Layer Protocol is"
2686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002687run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002688 "$P_SRV debug_level=3 alpn=abc,1234" \
2689 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002690 0 \
2691 -C "client hello, adding alpn extension" \
2692 -S "found alpn extension" \
2693 -C "got an alert message, type: \\[2:120]" \
2694 -S "server hello, adding alpn extension" \
2695 -C "found alpn extension " \
2696 -C "Application Layer Protocol is" \
2697 -s "Application Layer Protocol is (none)"
2698
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002699run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002700 "$P_SRV debug_level=3 alpn=abc,1234" \
2701 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002702 0 \
2703 -c "client hello, adding alpn extension" \
2704 -s "found alpn extension" \
2705 -C "got an alert message, type: \\[2:120]" \
2706 -s "server hello, adding alpn extension" \
2707 -c "found alpn extension" \
2708 -c "Application Layer Protocol is abc" \
2709 -s "Application Layer Protocol is abc"
2710
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002711run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002712 "$P_SRV debug_level=3 alpn=abc,1234" \
2713 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002714 0 \
2715 -c "client hello, adding alpn extension" \
2716 -s "found alpn extension" \
2717 -C "got an alert message, type: \\[2:120]" \
2718 -s "server hello, adding alpn extension" \
2719 -c "found alpn extension" \
2720 -c "Application Layer Protocol is abc" \
2721 -s "Application Layer Protocol is abc"
2722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002723run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002724 "$P_SRV debug_level=3 alpn=abc,1234" \
2725 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002726 0 \
2727 -c "client hello, adding alpn extension" \
2728 -s "found alpn extension" \
2729 -C "got an alert message, type: \\[2:120]" \
2730 -s "server hello, adding alpn extension" \
2731 -c "found alpn extension" \
2732 -c "Application Layer Protocol is 1234" \
2733 -s "Application Layer Protocol is 1234"
2734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002735run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002736 "$P_SRV debug_level=3 alpn=abc,123" \
2737 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002738 1 \
2739 -c "client hello, adding alpn extension" \
2740 -s "found alpn extension" \
2741 -c "got an alert message, type: \\[2:120]" \
2742 -S "server hello, adding alpn extension" \
2743 -C "found alpn extension" \
2744 -C "Application Layer Protocol is 1234" \
2745 -S "Application Layer Protocol is 1234"
2746
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002747
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002748# Tests for keyUsage in leaf certificates, part 1:
2749# server-side certificate/suite selection
2750
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002751run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002752 "$P_SRV key_file=data_files/server2.key \
2753 crt_file=data_files/server2.ku-ds.crt" \
2754 "$P_CLI" \
2755 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002756 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002757
2758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002759run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002760 "$P_SRV key_file=data_files/server2.key \
2761 crt_file=data_files/server2.ku-ke.crt" \
2762 "$P_CLI" \
2763 0 \
2764 -c "Ciphersuite is TLS-RSA-WITH-"
2765
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002766run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002767 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002768 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002769 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002770 1 \
2771 -C "Ciphersuite is "
2772
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002773run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002774 "$P_SRV key_file=data_files/server5.key \
2775 crt_file=data_files/server5.ku-ds.crt" \
2776 "$P_CLI" \
2777 0 \
2778 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2779
2780
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002781run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002782 "$P_SRV key_file=data_files/server5.key \
2783 crt_file=data_files/server5.ku-ka.crt" \
2784 "$P_CLI" \
2785 0 \
2786 -c "Ciphersuite is TLS-ECDH-"
2787
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002788run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002789 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002790 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002791 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002792 1 \
2793 -C "Ciphersuite is "
2794
2795# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002796# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002797
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002798run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002799 "$O_SRV -key data_files/server2.key \
2800 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002801 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002802 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2803 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002804 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002805 -C "Processing of the Certificate handshake message failed" \
2806 -c "Ciphersuite is TLS-"
2807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002808run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002809 "$O_SRV -key data_files/server2.key \
2810 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002811 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002812 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2813 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002814 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002815 -C "Processing of the Certificate handshake message failed" \
2816 -c "Ciphersuite is TLS-"
2817
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002818run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002819 "$O_SRV -key data_files/server2.key \
2820 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002821 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002822 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2823 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002824 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002825 -C "Processing of the Certificate handshake message failed" \
2826 -c "Ciphersuite is TLS-"
2827
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002828run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002829 "$O_SRV -key data_files/server2.key \
2830 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002831 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002832 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2833 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002834 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002835 -c "Processing of the Certificate handshake message failed" \
2836 -C "Ciphersuite is TLS-"
2837
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002838run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2839 "$O_SRV -key data_files/server2.key \
2840 -cert data_files/server2.ku-ke.crt" \
2841 "$P_CLI debug_level=1 auth_mode=optional \
2842 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2843 0 \
2844 -c "bad certificate (usage extensions)" \
2845 -C "Processing of the Certificate handshake message failed" \
2846 -c "Ciphersuite is TLS-" \
2847 -c "! Usage does not match the keyUsage extension"
2848
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002849run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002850 "$O_SRV -key data_files/server2.key \
2851 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002852 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002853 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2854 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002855 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002856 -C "Processing of the Certificate handshake message failed" \
2857 -c "Ciphersuite is TLS-"
2858
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002859run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002860 "$O_SRV -key data_files/server2.key \
2861 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002862 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002863 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2864 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002865 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002866 -c "Processing of the Certificate handshake message failed" \
2867 -C "Ciphersuite is TLS-"
2868
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002869run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2870 "$O_SRV -key data_files/server2.key \
2871 -cert data_files/server2.ku-ds.crt" \
2872 "$P_CLI debug_level=1 auth_mode=optional \
2873 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2874 0 \
2875 -c "bad certificate (usage extensions)" \
2876 -C "Processing of the Certificate handshake message failed" \
2877 -c "Ciphersuite is TLS-" \
2878 -c "! Usage does not match the keyUsage extension"
2879
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002880# Tests for keyUsage in leaf certificates, part 3:
2881# server-side checking of client cert
2882
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002883run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002884 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002885 "$O_CLI -key data_files/server2.key \
2886 -cert data_files/server2.ku-ds.crt" \
2887 0 \
2888 -S "bad certificate (usage extensions)" \
2889 -S "Processing of the Certificate handshake message failed"
2890
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002891run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002892 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002893 "$O_CLI -key data_files/server2.key \
2894 -cert data_files/server2.ku-ke.crt" \
2895 0 \
2896 -s "bad certificate (usage extensions)" \
2897 -S "Processing of the Certificate handshake message failed"
2898
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002899run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002900 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002901 "$O_CLI -key data_files/server2.key \
2902 -cert data_files/server2.ku-ke.crt" \
2903 1 \
2904 -s "bad certificate (usage extensions)" \
2905 -s "Processing of the Certificate handshake message failed"
2906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002907run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002908 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002909 "$O_CLI -key data_files/server5.key \
2910 -cert data_files/server5.ku-ds.crt" \
2911 0 \
2912 -S "bad certificate (usage extensions)" \
2913 -S "Processing of the Certificate handshake message failed"
2914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002915run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002916 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002917 "$O_CLI -key data_files/server5.key \
2918 -cert data_files/server5.ku-ka.crt" \
2919 0 \
2920 -s "bad certificate (usage extensions)" \
2921 -S "Processing of the Certificate handshake message failed"
2922
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002923# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002925run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002926 "$P_SRV key_file=data_files/server5.key \
2927 crt_file=data_files/server5.eku-srv.crt" \
2928 "$P_CLI" \
2929 0
2930
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002931run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002932 "$P_SRV key_file=data_files/server5.key \
2933 crt_file=data_files/server5.eku-srv.crt" \
2934 "$P_CLI" \
2935 0
2936
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002937run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002938 "$P_SRV key_file=data_files/server5.key \
2939 crt_file=data_files/server5.eku-cs_any.crt" \
2940 "$P_CLI" \
2941 0
2942
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002943run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002944 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002945 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002946 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002947 1
2948
2949# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002951run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002952 "$O_SRV -key data_files/server5.key \
2953 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002954 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002955 0 \
2956 -C "bad certificate (usage extensions)" \
2957 -C "Processing of the Certificate handshake message failed" \
2958 -c "Ciphersuite is TLS-"
2959
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002960run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002961 "$O_SRV -key data_files/server5.key \
2962 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002963 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002964 0 \
2965 -C "bad certificate (usage extensions)" \
2966 -C "Processing of the Certificate handshake message failed" \
2967 -c "Ciphersuite is TLS-"
2968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002969run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002970 "$O_SRV -key data_files/server5.key \
2971 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002972 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002973 0 \
2974 -C "bad certificate (usage extensions)" \
2975 -C "Processing of the Certificate handshake message failed" \
2976 -c "Ciphersuite is TLS-"
2977
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002978run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002979 "$O_SRV -key data_files/server5.key \
2980 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002981 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002982 1 \
2983 -c "bad certificate (usage extensions)" \
2984 -c "Processing of the Certificate handshake message failed" \
2985 -C "Ciphersuite is TLS-"
2986
2987# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2988
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002989run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002990 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002991 "$O_CLI -key data_files/server5.key \
2992 -cert data_files/server5.eku-cli.crt" \
2993 0 \
2994 -S "bad certificate (usage extensions)" \
2995 -S "Processing of the Certificate handshake message failed"
2996
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002997run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002998 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002999 "$O_CLI -key data_files/server5.key \
3000 -cert data_files/server5.eku-srv_cli.crt" \
3001 0 \
3002 -S "bad certificate (usage extensions)" \
3003 -S "Processing of the Certificate handshake message failed"
3004
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003005run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003006 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003007 "$O_CLI -key data_files/server5.key \
3008 -cert data_files/server5.eku-cs_any.crt" \
3009 0 \
3010 -S "bad certificate (usage extensions)" \
3011 -S "Processing of the Certificate handshake message failed"
3012
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003013run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003014 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003015 "$O_CLI -key data_files/server5.key \
3016 -cert data_files/server5.eku-cs.crt" \
3017 0 \
3018 -s "bad certificate (usage extensions)" \
3019 -S "Processing of the Certificate handshake message failed"
3020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003021run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003022 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003023 "$O_CLI -key data_files/server5.key \
3024 -cert data_files/server5.eku-cs.crt" \
3025 1 \
3026 -s "bad certificate (usage extensions)" \
3027 -s "Processing of the Certificate handshake message failed"
3028
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003029# Tests for DHM parameters loading
3030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003031run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003032 "$P_SRV" \
3033 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3034 debug_level=3" \
3035 0 \
3036 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker80e0d462017-10-13 16:51:54 +01003037 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003038
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003039run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003040 "$P_SRV dhm_file=data_files/dhparams.pem" \
3041 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3042 debug_level=3" \
3043 0 \
3044 -c "value of 'DHM: P ' (1024 bits)" \
3045 -c "value of 'DHM: G ' (2 bits)"
3046
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003047# Tests for DHM client-side size checking
3048
3049run_test "DHM size: server default, client default, OK" \
3050 "$P_SRV" \
3051 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3052 debug_level=1" \
3053 0 \
3054 -C "DHM prime too short:"
3055
3056run_test "DHM size: server default, client 2048, OK" \
3057 "$P_SRV" \
3058 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3059 debug_level=1 dhmlen=2048" \
3060 0 \
3061 -C "DHM prime too short:"
3062
3063run_test "DHM size: server 1024, client default, OK" \
3064 "$P_SRV dhm_file=data_files/dhparams.pem" \
3065 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3066 debug_level=1" \
3067 0 \
3068 -C "DHM prime too short:"
3069
3070run_test "DHM size: server 1000, client default, rejected" \
3071 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3072 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3073 debug_level=1" \
3074 1 \
3075 -c "DHM prime too short:"
3076
3077run_test "DHM size: server default, client 2049, rejected" \
3078 "$P_SRV" \
3079 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3080 debug_level=1 dhmlen=2049" \
3081 1 \
3082 -c "DHM prime too short:"
3083
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003084# Tests for PSK callback
3085
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003086run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003087 "$P_SRV psk=abc123 psk_identity=foo" \
3088 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3089 psk_identity=foo psk=abc123" \
3090 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003091 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003092 -S "SSL - Unknown identity received" \
3093 -S "SSL - Verification of the message MAC failed"
3094
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003095run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003096 "$P_SRV" \
3097 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3098 psk_identity=foo psk=abc123" \
3099 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003100 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003101 -S "SSL - Unknown identity received" \
3102 -S "SSL - Verification of the message MAC failed"
3103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003104run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003105 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3106 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3107 psk_identity=foo psk=abc123" \
3108 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003109 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003110 -s "SSL - Unknown identity received" \
3111 -S "SSL - Verification of the message MAC failed"
3112
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003113run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003114 "$P_SRV psk_list=abc,dead,def,beef" \
3115 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3116 psk_identity=abc psk=dead" \
3117 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003118 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003119 -S "SSL - Unknown identity received" \
3120 -S "SSL - Verification of the message MAC failed"
3121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003122run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003123 "$P_SRV psk_list=abc,dead,def,beef" \
3124 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3125 psk_identity=def psk=beef" \
3126 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003127 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003128 -S "SSL - Unknown identity received" \
3129 -S "SSL - Verification of the message MAC failed"
3130
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003131run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003132 "$P_SRV psk_list=abc,dead,def,beef" \
3133 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3134 psk_identity=ghi psk=beef" \
3135 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003136 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003137 -s "SSL - Unknown identity received" \
3138 -S "SSL - Verification of the message MAC failed"
3139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003140run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003141 "$P_SRV psk_list=abc,dead,def,beef" \
3142 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3143 psk_identity=abc psk=beef" \
3144 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003145 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003146 -S "SSL - Unknown identity received" \
3147 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003148
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003149# Tests for ciphersuites per version
3150
Janos Follath542ee5d2016-03-07 15:57:05 +00003151requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003152run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003153 "$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 +02003154 "$P_CLI force_version=ssl3" \
3155 0 \
3156 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3157
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003158run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003159 "$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 +01003160 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003161 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003162 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003163
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003164run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003165 "$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 +02003166 "$P_CLI force_version=tls1_1" \
3167 0 \
3168 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3169
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003170run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003171 "$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 +02003172 "$P_CLI force_version=tls1_2" \
3173 0 \
3174 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3175
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003176# Test for ClientHello without extensions
3177
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003178requires_gnutls
Gilles Peskine7344e1b2017-05-12 13:16:40 +02003179run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003180 "$P_SRV debug_level=3" \
3181 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3182 0 \
3183 -s "dumping 'client hello extensions' (0 bytes)"
3184
Gilles Peskine7344e1b2017-05-12 13:16:40 +02003185requires_gnutls
3186run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3187 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3188 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3189 0 \
3190 -s "dumping 'client hello extensions' (0 bytes)"
3191
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003192# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003193
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003194run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003195 "$P_SRV" \
3196 "$P_CLI request_size=100" \
3197 0 \
3198 -s "Read from client: 100 bytes read$"
3199
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003200run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003201 "$P_SRV" \
3202 "$P_CLI request_size=500" \
3203 0 \
3204 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003205
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003206# Tests for small packets
3207
Janos Follath542ee5d2016-03-07 15:57:05 +00003208requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003209run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003210 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003211 "$P_CLI request_size=1 force_version=ssl3 \
3212 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3213 0 \
3214 -s "Read from client: 1 bytes read"
3215
Janos Follath542ee5d2016-03-07 15:57:05 +00003216requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003217run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003218 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003219 "$P_CLI request_size=1 force_version=ssl3 \
3220 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3221 0 \
3222 -s "Read from client: 1 bytes read"
3223
3224run_test "Small packet TLS 1.0 BlockCipher" \
3225 "$P_SRV" \
3226 "$P_CLI request_size=1 force_version=tls1 \
3227 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3228 0 \
3229 -s "Read from client: 1 bytes read"
3230
Hanno Becker7aae46c2017-11-10 08:59:04 +00003231run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003232 "$P_SRV" \
3233 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3234 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3235 0 \
3236 -s "Read from client: 1 bytes read"
3237
Hanno Beckera83fafa2017-11-10 08:42:54 +00003238requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003239run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003240 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003241 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003242 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003243 0 \
3244 -s "Read from client: 1 bytes read"
3245
Hanno Beckera83fafa2017-11-10 08:42:54 +00003246requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003247run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003248 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003249 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003250 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003251 0 \
3252 -s "Read from client: 1 bytes read"
3253
3254run_test "Small packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003255 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003256 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003257 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3258 0 \
3259 -s "Read from client: 1 bytes read"
3260
3261run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3262 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3263 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003264 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003265 0 \
3266 -s "Read from client: 1 bytes read"
3267
3268requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3269run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003270 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003271 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003272 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003273 0 \
3274 -s "Read from client: 1 bytes read"
3275
Hanno Becker7aae46c2017-11-10 08:59:04 +00003276requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3277run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003278 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3279 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3280 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003281 0 \
3282 -s "Read from client: 1 bytes read"
3283
3284run_test "Small packet TLS 1.1 BlockCipher" \
3285 "$P_SRV" \
3286 "$P_CLI request_size=1 force_version=tls1_1 \
3287 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3288 0 \
3289 -s "Read from client: 1 bytes read"
3290
Hanno Becker7aae46c2017-11-10 08:59:04 +00003291run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003292 "$P_SRV" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003293 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003294 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003295 0 \
3296 -s "Read from client: 1 bytes read"
3297
3298requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3299run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003300 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003301 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003302 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003303 0 \
3304 -s "Read from client: 1 bytes read"
3305
3306requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3307run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003308 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003309 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003310 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003311 0 \
3312 -s "Read from client: 1 bytes read"
3313
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003314run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003315 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003316 "$P_CLI request_size=1 force_version=tls1_1 \
3317 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3318 0 \
3319 -s "Read from client: 1 bytes read"
3320
Hanno Becker7aae46c2017-11-10 08:59:04 +00003321run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3322 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003323 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003324 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003325 0 \
3326 -s "Read from client: 1 bytes read"
3327
Hanno Becker7aae46c2017-11-10 08:59:04 +00003328requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3329run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003330 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003331 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003332 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003333 0 \
3334 -s "Read from client: 1 bytes read"
3335
Hanno Beckera83fafa2017-11-10 08:42:54 +00003336requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003337run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003338 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003339 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003340 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003341 0 \
3342 -s "Read from client: 1 bytes read"
3343
3344run_test "Small packet TLS 1.2 BlockCipher" \
3345 "$P_SRV" \
3346 "$P_CLI request_size=1 force_version=tls1_2 \
3347 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3348 0 \
3349 -s "Read from client: 1 bytes read"
3350
Hanno Becker7aae46c2017-11-10 08:59:04 +00003351run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003352 "$P_SRV" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003353 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003354 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003355 0 \
3356 -s "Read from client: 1 bytes read"
3357
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003358run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3359 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003360 "$P_CLI request_size=1 force_version=tls1_2 \
3361 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003362 0 \
3363 -s "Read from client: 1 bytes read"
3364
Hanno Beckera83fafa2017-11-10 08:42:54 +00003365requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003366run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003367 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003368 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003369 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003370 0 \
3371 -s "Read from client: 1 bytes read"
3372
Hanno Becker7aae46c2017-11-10 08:59:04 +00003373requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3374run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003375 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003376 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003377 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003378 0 \
3379 -s "Read from client: 1 bytes read"
3380
3381run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003382 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003383 "$P_CLI request_size=1 force_version=tls1_2 \
3384 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3385 0 \
3386 -s "Read from client: 1 bytes read"
3387
Hanno Becker7aae46c2017-11-10 08:59:04 +00003388run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003389 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003390 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003391 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003392 0 \
3393 -s "Read from client: 1 bytes read"
3394
Hanno Beckera83fafa2017-11-10 08:42:54 +00003395requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003396run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003397 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003398 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003399 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003400 0 \
3401 -s "Read from client: 1 bytes read"
3402
Hanno Becker7aae46c2017-11-10 08:59:04 +00003403requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3404run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003405 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003406 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003407 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003408 0 \
3409 -s "Read from client: 1 bytes read"
3410
3411run_test "Small packet TLS 1.2 AEAD" \
3412 "$P_SRV" \
3413 "$P_CLI request_size=1 force_version=tls1_2 \
3414 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3415 0 \
3416 -s "Read from client: 1 bytes read"
3417
3418run_test "Small packet TLS 1.2 AEAD shorter tag" \
3419 "$P_SRV" \
3420 "$P_CLI request_size=1 force_version=tls1_2 \
3421 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3422 0 \
3423 -s "Read from client: 1 bytes read"
3424
Hanno Becker461cb812017-11-10 08:59:18 +00003425# Tests for small packets in DTLS
3426
3427requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3428run_test "Small packet DTLS 1.0" \
3429 "$P_SRV dtls=1 force_version=dtls1" \
3430 "$P_CLI dtls=1 request_size=1 \
3431 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3432 0 \
3433 -s "Read from client: 1 bytes read"
3434
3435requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3436run_test "Small packet DTLS 1.0, without EtM" \
3437 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3438 "$P_CLI dtls=1 request_size=1 \
3439 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3440 0 \
3441 -s "Read from client: 1 bytes read"
3442
3443requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3444requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3445run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003446 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3447 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Becker461cb812017-11-10 08:59:18 +00003448 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3449 0 \
3450 -s "Read from client: 1 bytes read"
3451
3452requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3453requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3454run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003455 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Becker461cb812017-11-10 08:59:18 +00003456 "$P_CLI dtls=1 request_size=1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003457 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Becker461cb812017-11-10 08:59:18 +00003458 0 \
3459 -s "Read from client: 1 bytes read"
3460
3461requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3462run_test "Small packet DTLS 1.2" \
3463 "$P_SRV dtls=1 force_version=dtls1_2" \
3464 "$P_CLI dtls=1 request_size=1 \
3465 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3466 0 \
3467 -s "Read from client: 1 bytes read"
3468
3469requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3470run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003471 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Becker461cb812017-11-10 08:59:18 +00003472 "$P_CLI dtls=1 request_size=1 \
3473 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3474 0 \
3475 -s "Read from client: 1 bytes read"
3476
3477requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3478requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3479run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003480 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Becker461cb812017-11-10 08:59:18 +00003481 "$P_CLI dtls=1 request_size=1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003482 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker461cb812017-11-10 08:59:18 +00003483 0 \
3484 -s "Read from client: 1 bytes read"
3485
3486requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3487requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3488run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003489 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Becker461cb812017-11-10 08:59:18 +00003490 "$P_CLI dtls=1 request_size=1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003491 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Becker461cb812017-11-10 08:59:18 +00003492 0 \
3493 -s "Read from client: 1 bytes read"
3494
Janos Follathb700c462016-05-06 13:48:23 +01003495# A test for extensions in SSLv3
3496
3497requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3498run_test "SSLv3 with extensions, server side" \
3499 "$P_SRV min_version=ssl3 debug_level=3" \
3500 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3501 0 \
3502 -S "dumping 'client hello extensions'" \
3503 -S "server hello, total extension length:"
3504
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003505# Test for large packets
3506
Janos Follath542ee5d2016-03-07 15:57:05 +00003507requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003508run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003509 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003510 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003511 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3512 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003513 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003514 -s "Read from client: 16384 bytes read"
3515
Janos Follath542ee5d2016-03-07 15:57:05 +00003516requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003517run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003518 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003519 "$P_CLI request_size=16384 force_version=ssl3 \
3520 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3521 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003522 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003523 -s "Read from client: 16384 bytes read"
3524
3525run_test "Large packet TLS 1.0 BlockCipher" \
3526 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003527 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003528 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3529 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003530 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003531 -s "Read from client: 16384 bytes read"
3532
Hanno Becker0b9d9132017-11-10 09:16:28 +00003533run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003534 "$P_SRV" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003535 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3536 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3537 0 \
3538 -s "Read from client: 16384 bytes read"
3539
Hanno Beckera83fafa2017-11-10 08:42:54 +00003540requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003541run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003542 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003543 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003544 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003545 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003546 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003547 -s "Read from client: 16384 bytes read"
3548
Hanno Beckera83fafa2017-11-10 08:42:54 +00003549requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003550run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003551 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003552 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003553 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003554 0 \
3555 -s "Read from client: 16384 bytes read"
3556
3557run_test "Large packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003558 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003559 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003560 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3561 0 \
3562 -s "Read from client: 16384 bytes read"
3563
3564run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
3565 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3566 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003567 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003568 0 \
3569 -s "Read from client: 16384 bytes read"
3570
3571requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3572run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003573 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003574 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003575 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003576 0 \
3577 -s "Read from client: 16384 bytes read"
3578
Hanno Becker0b9d9132017-11-10 09:16:28 +00003579requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3580run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003581 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003582 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003583 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003584 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003585 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003586 -s "Read from client: 16384 bytes read"
3587
3588run_test "Large packet TLS 1.1 BlockCipher" \
3589 "$P_SRV" \
3590 "$P_CLI request_size=16384 force_version=tls1_1 \
3591 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3592 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003593 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003594 -s "Read from client: 16384 bytes read"
3595
Hanno Becker0b9d9132017-11-10 09:16:28 +00003596run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
3597 "$P_SRV" \
3598 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
3599 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003600 0 \
3601 -s "Read from client: 16384 bytes read"
3602
Hanno Beckera83fafa2017-11-10 08:42:54 +00003603requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003604run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003605 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003606 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003607 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003608 0 \
3609 -s "Read from client: 16384 bytes read"
3610
Hanno Beckera83fafa2017-11-10 08:42:54 +00003611requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003612run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003613 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003614 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003615 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003616 0 \
3617 -s "Read from client: 16384 bytes read"
3618
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003619run_test "Large packet TLS 1.1 StreamCipher" \
3620 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3621 "$P_CLI request_size=16384 force_version=tls1_1 \
3622 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3623 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003624 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003625 -s "Read from client: 16384 bytes read"
3626
Hanno Becker0b9d9132017-11-10 09:16:28 +00003627run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
3628 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003629 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003630 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003631 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003632 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003633 -s "Read from client: 16384 bytes read"
3634
Hanno Becker0b9d9132017-11-10 09:16:28 +00003635requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3636run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003637 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003638 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003639 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003640 0 \
3641 -s "Read from client: 16384 bytes read"
3642
Hanno Becker0b9d9132017-11-10 09:16:28 +00003643requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3644run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003645 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003646 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003647 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003648 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003649 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003650 -s "Read from client: 16384 bytes read"
3651
3652run_test "Large packet TLS 1.2 BlockCipher" \
3653 "$P_SRV" \
3654 "$P_CLI request_size=16384 force_version=tls1_2 \
3655 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3656 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003657 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003658 -s "Read from client: 16384 bytes read"
3659
Hanno Becker0b9d9132017-11-10 09:16:28 +00003660run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
3661 "$P_SRV" \
3662 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
3663 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3664 0 \
3665 -s "Read from client: 16384 bytes read"
3666
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003667run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3668 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003669 "$P_CLI request_size=16384 force_version=tls1_2 \
3670 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003671 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003672 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003673 -s "Read from client: 16384 bytes read"
3674
Hanno Beckera83fafa2017-11-10 08:42:54 +00003675requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003676run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003677 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003678 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003679 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003680 0 \
3681 -s "Read from client: 16384 bytes read"
3682
Hanno Becker0b9d9132017-11-10 09:16:28 +00003683requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3684run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003685 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003686 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003687 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003688 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003689 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003690 -s "Read from client: 16384 bytes read"
3691
3692run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003693 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003694 "$P_CLI request_size=16384 force_version=tls1_2 \
3695 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3696 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003697 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003698 -s "Read from client: 16384 bytes read"
3699
Hanno Becker0b9d9132017-11-10 09:16:28 +00003700run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003701 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003702 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003703 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
3704 0 \
3705 -s "Read from client: 16384 bytes read"
3706
Hanno Beckera83fafa2017-11-10 08:42:54 +00003707requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003708run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003709 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003710 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003711 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003712 0 \
3713 -s "Read from client: 16384 bytes read"
3714
Hanno Becker0b9d9132017-11-10 09:16:28 +00003715requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3716run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003717 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003718 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003719 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003720 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003721 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003722 -s "Read from client: 16384 bytes read"
3723
3724run_test "Large packet TLS 1.2 AEAD" \
3725 "$P_SRV" \
3726 "$P_CLI request_size=16384 force_version=tls1_2 \
3727 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3728 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003729 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003730 -s "Read from client: 16384 bytes read"
3731
3732run_test "Large packet TLS 1.2 AEAD shorter tag" \
3733 "$P_SRV" \
3734 "$P_CLI request_size=16384 force_version=tls1_2 \
3735 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3736 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003737 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003738 -s "Read from client: 16384 bytes read"
3739
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003740# Tests for DTLS HelloVerifyRequest
3741
3742run_test "DTLS cookie: enabled" \
3743 "$P_SRV dtls=1 debug_level=2" \
3744 "$P_CLI dtls=1 debug_level=2" \
3745 0 \
3746 -s "cookie verification failed" \
3747 -s "cookie verification passed" \
3748 -S "cookie verification skipped" \
3749 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003750 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003751 -S "SSL - The requested feature is not available"
3752
3753run_test "DTLS cookie: disabled" \
3754 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3755 "$P_CLI dtls=1 debug_level=2" \
3756 0 \
3757 -S "cookie verification failed" \
3758 -S "cookie verification passed" \
3759 -s "cookie verification skipped" \
3760 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003761 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003762 -S "SSL - The requested feature is not available"
3763
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003764run_test "DTLS cookie: default (failing)" \
3765 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3766 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3767 1 \
3768 -s "cookie verification failed" \
3769 -S "cookie verification passed" \
3770 -S "cookie verification skipped" \
3771 -C "received hello verify request" \
3772 -S "hello verification requested" \
3773 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003774
3775requires_ipv6
3776run_test "DTLS cookie: enabled, IPv6" \
3777 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3778 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3779 0 \
3780 -s "cookie verification failed" \
3781 -s "cookie verification passed" \
3782 -S "cookie verification skipped" \
3783 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003784 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003785 -S "SSL - The requested feature is not available"
3786
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003787run_test "DTLS cookie: enabled, nbio" \
3788 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3789 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3790 0 \
3791 -s "cookie verification failed" \
3792 -s "cookie verification passed" \
3793 -S "cookie verification skipped" \
3794 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003795 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003796 -S "SSL - The requested feature is not available"
3797
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003798# Tests for client reconnecting from the same port with DTLS
3799
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003800not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003801run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003802 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3803 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003804 0 \
3805 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003806 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003807 -S "Client initiated reconnection from same port"
3808
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003809not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003810run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003811 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3812 "$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 +02003813 0 \
3814 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003815 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003816 -s "Client initiated reconnection from same port"
3817
Paul Bakker3b224ff2016-05-13 10:33:25 +01003818not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3819run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003820 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3821 "$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 +02003822 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003823 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003824 -s "Client initiated reconnection from same port"
3825
Paul Bakker3b224ff2016-05-13 10:33:25 +01003826only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3827run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3828 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3829 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3830 0 \
3831 -S "The operation timed out" \
3832 -s "Client initiated reconnection from same port"
3833
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003834run_test "DTLS client reconnect from same port: no cookies" \
3835 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003836 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3837 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003838 -s "The operation timed out" \
3839 -S "Client initiated reconnection from same port"
3840
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003841# Tests for various cases of client authentication with DTLS
3842# (focused on handshake flows and message parsing)
3843
3844run_test "DTLS client auth: required" \
3845 "$P_SRV dtls=1 auth_mode=required" \
3846 "$P_CLI dtls=1" \
3847 0 \
3848 -s "Verifying peer X.509 certificate... ok"
3849
3850run_test "DTLS client auth: optional, client has no cert" \
3851 "$P_SRV dtls=1 auth_mode=optional" \
3852 "$P_CLI dtls=1 crt_file=none key_file=none" \
3853 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003854 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003855
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003856run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003857 "$P_SRV dtls=1 auth_mode=none" \
3858 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3859 0 \
3860 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003861 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003862
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003863run_test "DTLS wrong PSK: badmac alert" \
3864 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3865 "$P_CLI dtls=1 psk=abc124" \
3866 1 \
3867 -s "SSL - Verification of the message MAC failed" \
3868 -c "SSL - A fatal alert message was received from our peer"
3869
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003870# Tests for receiving fragmented handshake messages with DTLS
3871
3872requires_gnutls
3873run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3874 "$G_SRV -u --mtu 2048 -a" \
3875 "$P_CLI dtls=1 debug_level=2" \
3876 0 \
3877 -C "found fragmented DTLS handshake message" \
3878 -C "error"
3879
3880requires_gnutls
3881run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3882 "$G_SRV -u --mtu 512" \
3883 "$P_CLI dtls=1 debug_level=2" \
3884 0 \
3885 -c "found fragmented DTLS handshake message" \
3886 -C "error"
3887
3888requires_gnutls
3889run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3890 "$G_SRV -u --mtu 128" \
3891 "$P_CLI dtls=1 debug_level=2" \
3892 0 \
3893 -c "found fragmented DTLS handshake message" \
3894 -C "error"
3895
3896requires_gnutls
3897run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3898 "$G_SRV -u --mtu 128" \
3899 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3900 0 \
3901 -c "found fragmented DTLS handshake message" \
3902 -C "error"
3903
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003904requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01003905requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003906run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3907 "$G_SRV -u --mtu 256" \
3908 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3909 0 \
3910 -c "found fragmented DTLS handshake message" \
3911 -c "client hello, adding renegotiation extension" \
3912 -c "found renegotiation extension" \
3913 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003914 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003915 -C "error" \
3916 -s "Extra-header:"
3917
3918requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01003919requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003920run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3921 "$G_SRV -u --mtu 256" \
3922 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3923 0 \
3924 -c "found fragmented DTLS handshake message" \
3925 -c "client hello, adding renegotiation extension" \
3926 -c "found renegotiation extension" \
3927 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003928 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003929 -C "error" \
3930 -s "Extra-header:"
3931
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003932run_test "DTLS reassembly: no fragmentation (openssl server)" \
3933 "$O_SRV -dtls1 -mtu 2048" \
3934 "$P_CLI dtls=1 debug_level=2" \
3935 0 \
3936 -C "found fragmented DTLS handshake message" \
3937 -C "error"
3938
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003939run_test "DTLS reassembly: some fragmentation (openssl server)" \
3940 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003941 "$P_CLI dtls=1 debug_level=2" \
3942 0 \
3943 -c "found fragmented DTLS handshake message" \
3944 -C "error"
3945
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003946run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003947 "$O_SRV -dtls1 -mtu 256" \
3948 "$P_CLI dtls=1 debug_level=2" \
3949 0 \
3950 -c "found fragmented DTLS handshake message" \
3951 -C "error"
3952
3953run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3954 "$O_SRV -dtls1 -mtu 256" \
3955 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3956 0 \
3957 -c "found fragmented DTLS handshake message" \
3958 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003959
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003960# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003961
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003962not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003963run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003964 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003965 "$P_SRV dtls=1 debug_level=2" \
3966 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003967 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003968 -C "replayed record" \
3969 -S "replayed record" \
3970 -C "record from another epoch" \
3971 -S "record from another epoch" \
3972 -C "discarding invalid record" \
3973 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003974 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003975 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003976 -c "HTTP/1.0 200 OK"
3977
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003978not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003979run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003980 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003981 "$P_SRV dtls=1 debug_level=2" \
3982 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003983 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003984 -c "replayed record" \
3985 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003986 -c "discarding invalid record" \
3987 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003988 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003989 -s "Extra-header:" \
3990 -c "HTTP/1.0 200 OK"
3991
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003992run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3993 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003994 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3995 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003996 0 \
3997 -c "replayed record" \
3998 -S "replayed record" \
3999 -c "discarding invalid record" \
4000 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004001 -c "resend" \
4002 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004003 -s "Extra-header:" \
4004 -c "HTTP/1.0 200 OK"
4005
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004006run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004007 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004008 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004009 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004010 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004011 -c "discarding invalid record (mac)" \
4012 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004013 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004014 -c "HTTP/1.0 200 OK" \
4015 -S "too many records with bad MAC" \
4016 -S "Verification of the message MAC failed"
4017
4018run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4019 -p "$P_PXY bad_ad=1" \
4020 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4021 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4022 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004023 -C "discarding invalid record (mac)" \
4024 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004025 -S "Extra-header:" \
4026 -C "HTTP/1.0 200 OK" \
4027 -s "too many records with bad MAC" \
4028 -s "Verification of the message MAC failed"
4029
4030run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4031 -p "$P_PXY bad_ad=1" \
4032 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4033 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4034 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004035 -c "discarding invalid record (mac)" \
4036 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004037 -s "Extra-header:" \
4038 -c "HTTP/1.0 200 OK" \
4039 -S "too many records with bad MAC" \
4040 -S "Verification of the message MAC failed"
4041
4042run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4043 -p "$P_PXY bad_ad=1" \
4044 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4045 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4046 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004047 -c "discarding invalid record (mac)" \
4048 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004049 -s "Extra-header:" \
4050 -c "HTTP/1.0 200 OK" \
4051 -s "too many records with bad MAC" \
4052 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004053
4054run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004055 -p "$P_PXY delay_ccs=1" \
4056 "$P_SRV dtls=1 debug_level=1" \
4057 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004058 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004059 -c "record from another epoch" \
4060 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004061 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004062 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004063 -s "Extra-header:" \
4064 -c "HTTP/1.0 200 OK"
4065
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004066# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004067
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004068needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004069run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004070 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004071 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4072 psk=abc123" \
4073 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004074 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4075 0 \
4076 -s "Extra-header:" \
4077 -c "HTTP/1.0 200 OK"
4078
4079needs_more_time 2
4080run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4081 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004082 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4083 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004084 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4085 0 \
4086 -s "Extra-header:" \
4087 -c "HTTP/1.0 200 OK"
4088
4089needs_more_time 2
4090run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4091 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004092 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4093 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004094 0 \
4095 -s "Extra-header:" \
4096 -c "HTTP/1.0 200 OK"
4097
4098needs_more_time 2
4099run_test "DTLS proxy: 3d, FS, client auth" \
4100 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004101 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4102 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004103 0 \
4104 -s "Extra-header:" \
4105 -c "HTTP/1.0 200 OK"
4106
4107needs_more_time 2
4108run_test "DTLS proxy: 3d, FS, ticket" \
4109 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004110 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4111 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004112 0 \
4113 -s "Extra-header:" \
4114 -c "HTTP/1.0 200 OK"
4115
4116needs_more_time 2
4117run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
4118 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004119 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
4120 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004121 0 \
4122 -s "Extra-header:" \
4123 -c "HTTP/1.0 200 OK"
4124
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004125needs_more_time 2
4126run_test "DTLS proxy: 3d, max handshake, nbio" \
4127 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004128 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4129 auth_mode=required" \
4130 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004131 0 \
4132 -s "Extra-header:" \
4133 -c "HTTP/1.0 200 OK"
4134
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004135needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004136run_test "DTLS proxy: 3d, min handshake, resumption" \
4137 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4138 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4139 psk=abc123 debug_level=3" \
4140 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4141 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4142 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4143 0 \
4144 -s "a session has been resumed" \
4145 -c "a session has been resumed" \
4146 -s "Extra-header:" \
4147 -c "HTTP/1.0 200 OK"
4148
4149needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004150run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4151 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4152 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4153 psk=abc123 debug_level=3 nbio=2" \
4154 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4155 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4156 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4157 0 \
4158 -s "a session has been resumed" \
4159 -c "a session has been resumed" \
4160 -s "Extra-header:" \
4161 -c "HTTP/1.0 200 OK"
4162
4163needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004164requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004165run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004166 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004167 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4168 psk=abc123 renegotiation=1 debug_level=2" \
4169 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4170 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004171 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4172 0 \
4173 -c "=> renegotiate" \
4174 -s "=> renegotiate" \
4175 -s "Extra-header:" \
4176 -c "HTTP/1.0 200 OK"
4177
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004178needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004179requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004180run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4181 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004182 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4183 psk=abc123 renegotiation=1 debug_level=2" \
4184 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4185 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004186 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4187 0 \
4188 -c "=> renegotiate" \
4189 -s "=> renegotiate" \
4190 -s "Extra-header:" \
4191 -c "HTTP/1.0 200 OK"
4192
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004193needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004194requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004195run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004196 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004197 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004198 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004199 debug_level=2" \
4200 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004201 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004202 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4203 0 \
4204 -c "=> renegotiate" \
4205 -s "=> renegotiate" \
4206 -s "Extra-header:" \
4207 -c "HTTP/1.0 200 OK"
4208
4209needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004210requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004211run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004212 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004213 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004214 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004215 debug_level=2 nbio=2" \
4216 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004217 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004218 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4219 0 \
4220 -c "=> renegotiate" \
4221 -s "=> renegotiate" \
4222 -s "Extra-header:" \
4223 -c "HTTP/1.0 200 OK"
4224
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02004225needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004226not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004227run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004228 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4229 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004230 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004231 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004232 -c "HTTP/1.0 200 OK"
4233
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004234needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004235not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004236run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4237 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4238 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004239 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004240 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004241 -c "HTTP/1.0 200 OK"
4242
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004243needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004244not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004245run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4246 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4247 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004248 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004249 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004250 -c "HTTP/1.0 200 OK"
4251
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004252requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02004253needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004254not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004255run_test "DTLS proxy: 3d, gnutls server" \
4256 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4257 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004258 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004259 0 \
4260 -s "Extra-header:" \
4261 -c "Extra-header:"
4262
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004263requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004264needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004265not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004266run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4267 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4268 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004269 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004270 0 \
4271 -s "Extra-header:" \
4272 -c "Extra-header:"
4273
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004274requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004275needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004276not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004277run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4278 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4279 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004280 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004281 0 \
4282 -s "Extra-header:" \
4283 -c "Extra-header:"
4284
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004285# Final report
4286
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004287echo "------------------------------------------------------------------------"
4288
4289if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004290 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004291else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004292 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004293fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004294PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004295echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004296
4297exit $FAILS