blob: 3f0ace49bdeeb844e3defe17262e4005cda1d4f2 [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 Peskine2cc7ad42018-06-29 15:48:13 +0200257 echo "Warning: lsof not available, wait_server_start = sleep"
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
Andres Amaya Garciadc8b6df2018-07-10 20:08:04 +01001028# Test sending and receiving empty application data records
1029
1030run_test "Encrypt then MAC: empty application data record" \
1031 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1032 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1033 0 \
1034 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1035 -s "dumping 'input payload after decrypt' (0 bytes)" \
1036 -c "0 bytes written in 1 fragments"
1037
1038run_test "Default, no Encrypt then MAC: empty application data record" \
1039 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1040 "$P_CLI auth_mode=none etm=0 request_size=0" \
1041 0 \
1042 -s "dumping 'input payload after decrypt' (0 bytes)" \
1043 -c "0 bytes written in 1 fragments"
1044
1045run_test "Encrypt then MAC, DTLS: empty application data record" \
1046 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1047 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1048 0 \
1049 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1050 -s "dumping 'input payload after decrypt' (0 bytes)" \
1051 -c "0 bytes written in 1 fragments"
1052
1053run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
1054 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1055 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1056 0 \
1057 -s "dumping 'input payload after decrypt' (0 bytes)" \
1058 -c "0 bytes written in 1 fragments"
1059
Gilles Peskine39e29812017-05-16 17:53:03 +02001060## ClientHello generated with
1061## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1062## then manually twiddling the ciphersuite list.
1063## The ClientHello content is spelled out below as a hex string as
1064## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1065## The expected response is an inappropriate_fallback alert.
1066requires_openssl_with_fallback_scsv
1067run_test "Fallback SCSV: beginning of list" \
1068 "$P_SRV debug_level=2" \
1069 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1070 0 \
1071 -s "received FALLBACK_SCSV" \
1072 -s "inapropriate fallback"
1073
1074requires_openssl_with_fallback_scsv
1075run_test "Fallback SCSV: end of list" \
1076 "$P_SRV debug_level=2" \
1077 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1078 0 \
1079 -s "received FALLBACK_SCSV" \
1080 -s "inapropriate fallback"
1081
1082## Here the expected response is a valid ServerHello prefix, up to the random.
1083requires_openssl_with_fallback_scsv
1084run_test "Fallback SCSV: not in list" \
1085 "$P_SRV debug_level=2" \
1086 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1087 0 \
1088 -S "received FALLBACK_SCSV" \
1089 -S "inapropriate fallback"
1090
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001091# Tests for CBC 1/n-1 record splitting
1092
1093run_test "CBC Record splitting: TLS 1.2, no splitting" \
1094 "$P_SRV" \
1095 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1096 request_size=123 force_version=tls1_2" \
1097 0 \
1098 -s "Read from client: 123 bytes read" \
1099 -S "Read from client: 1 bytes read" \
1100 -S "122 bytes read"
1101
1102run_test "CBC Record splitting: TLS 1.1, no splitting" \
1103 "$P_SRV" \
1104 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1105 request_size=123 force_version=tls1_1" \
1106 0 \
1107 -s "Read from client: 123 bytes read" \
1108 -S "Read from client: 1 bytes read" \
1109 -S "122 bytes read"
1110
1111run_test "CBC Record splitting: TLS 1.0, splitting" \
1112 "$P_SRV" \
1113 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1114 request_size=123 force_version=tls1" \
1115 0 \
1116 -S "Read from client: 123 bytes read" \
1117 -s "Read from client: 1 bytes read" \
1118 -s "122 bytes read"
1119
Janos Follath542ee5d2016-03-07 15:57:05 +00001120requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001121run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001122 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001123 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1124 request_size=123 force_version=ssl3" \
1125 0 \
1126 -S "Read from client: 123 bytes read" \
1127 -s "Read from client: 1 bytes read" \
1128 -s "122 bytes read"
1129
1130run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001131 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001132 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1133 request_size=123 force_version=tls1" \
1134 0 \
1135 -s "Read from client: 123 bytes read" \
1136 -S "Read from client: 1 bytes read" \
1137 -S "122 bytes read"
1138
1139run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1140 "$P_SRV" \
1141 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1142 request_size=123 force_version=tls1 recsplit=0" \
1143 0 \
1144 -s "Read from client: 123 bytes read" \
1145 -S "Read from client: 1 bytes read" \
1146 -S "122 bytes read"
1147
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001148run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1149 "$P_SRV nbio=2" \
1150 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1151 request_size=123 force_version=tls1" \
1152 0 \
1153 -S "Read from client: 123 bytes read" \
1154 -s "Read from client: 1 bytes read" \
1155 -s "122 bytes read"
1156
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001157# Tests for Session Tickets
1158
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001159run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001160 "$P_SRV debug_level=3 tickets=1" \
1161 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001162 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001163 -c "client hello, adding session ticket extension" \
1164 -s "found session ticket extension" \
1165 -s "server hello, adding session ticket extension" \
1166 -c "found session_ticket extension" \
1167 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001168 -S "session successfully restored from cache" \
1169 -s "session successfully restored from ticket" \
1170 -s "a session has been resumed" \
1171 -c "a session has been resumed"
1172
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001173run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001174 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1175 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001176 0 \
1177 -c "client hello, adding session ticket extension" \
1178 -s "found session ticket extension" \
1179 -s "server hello, adding session ticket extension" \
1180 -c "found session_ticket extension" \
1181 -c "parse new session ticket" \
1182 -S "session successfully restored from cache" \
1183 -s "session successfully restored from ticket" \
1184 -s "a session has been resumed" \
1185 -c "a session has been resumed"
1186
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001187run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001188 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1189 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001190 0 \
1191 -c "client hello, adding session ticket extension" \
1192 -s "found session ticket extension" \
1193 -s "server hello, adding session ticket extension" \
1194 -c "found session_ticket extension" \
1195 -c "parse new session ticket" \
1196 -S "session successfully restored from cache" \
1197 -S "session successfully restored from ticket" \
1198 -S "a session has been resumed" \
1199 -C "a session has been resumed"
1200
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001201run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001202 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001203 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001204 0 \
1205 -c "client hello, adding session ticket extension" \
1206 -c "found session_ticket extension" \
1207 -c "parse new session ticket" \
1208 -c "a session has been resumed"
1209
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001210run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001211 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001212 "( $O_CLI -sess_out $SESSION; \
1213 $O_CLI -sess_in $SESSION; \
1214 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001215 0 \
1216 -s "found session ticket extension" \
1217 -s "server hello, adding session ticket extension" \
1218 -S "session successfully restored from cache" \
1219 -s "session successfully restored from ticket" \
1220 -s "a session has been resumed"
1221
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001222# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001224run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001225 "$P_SRV debug_level=3 tickets=0" \
1226 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001227 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001228 -c "client hello, adding session ticket extension" \
1229 -s "found session ticket extension" \
1230 -S "server hello, adding session ticket extension" \
1231 -C "found session_ticket extension" \
1232 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001233 -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é-Gonnard8e03c712014-08-30 21:42:40 +02001238run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001239 "$P_SRV debug_level=3 tickets=1" \
1240 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001241 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001242 -C "client hello, adding session ticket extension" \
1243 -S "found session ticket extension" \
1244 -S "server hello, adding session ticket extension" \
1245 -C "found session_ticket extension" \
1246 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001247 -s "session successfully restored from cache" \
1248 -S "session successfully restored from ticket" \
1249 -s "a session has been resumed" \
1250 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001251
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001252run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001253 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1254 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001255 0 \
1256 -S "session successfully restored from cache" \
1257 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001258 -S "a session has been resumed" \
1259 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001261run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001262 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1263 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001264 0 \
1265 -s "session successfully restored from cache" \
1266 -S "session successfully restored from ticket" \
1267 -s "a session has been resumed" \
1268 -c "a session has been resumed"
1269
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001270run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001271 "$P_SRV debug_level=3 tickets=0" \
1272 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001273 0 \
1274 -s "session successfully restored from cache" \
1275 -S "session successfully restored from ticket" \
1276 -s "a session has been resumed" \
1277 -c "a session has been resumed"
1278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001279run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001280 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1281 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001282 0 \
1283 -S "session successfully restored from cache" \
1284 -S "session successfully restored from ticket" \
1285 -S "a session has been resumed" \
1286 -C "a session has been resumed"
1287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001288run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001289 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1290 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001291 0 \
1292 -s "session successfully restored from cache" \
1293 -S "session successfully restored from ticket" \
1294 -s "a session has been resumed" \
1295 -c "a session has been resumed"
1296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001297run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001298 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001299 "( $O_CLI -sess_out $SESSION; \
1300 $O_CLI -sess_in $SESSION; \
1301 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001302 0 \
1303 -s "found session ticket extension" \
1304 -S "server hello, adding session ticket extension" \
1305 -s "session successfully restored from cache" \
1306 -S "session successfully restored from ticket" \
1307 -s "a session has been resumed"
1308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001309run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001310 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001311 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001312 0 \
1313 -C "found session_ticket extension" \
1314 -C "parse new session ticket" \
1315 -c "a session has been resumed"
1316
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001317# Tests for Max Fragment Length extension
1318
Hanno Becker64691dc2017-09-22 16:58:50 +01001319MAX_CONTENT_LEN_EXPECT='16384'
1320MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1321
1322if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1323 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1324 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1325 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1326 printf "\n"
1327 printf "The tests assume this value and if it changes, the tests in this\n"
1328 printf "script should also be adjusted.\n"
1329 printf "\n"
1330
1331 exit 1
1332fi
1333
Hanno Becker05607782017-09-18 15:00:34 +01001334requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001335run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001336 "$P_SRV debug_level=3" \
1337 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001338 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001339 -c "Maximum fragment length is 16384" \
1340 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001341 -C "client hello, adding max_fragment_length extension" \
1342 -S "found max fragment length extension" \
1343 -S "server hello, max_fragment_length extension" \
1344 -C "found max_fragment_length extension"
1345
Hanno Becker05607782017-09-18 15:00:34 +01001346requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001347run_test "Max fragment length: enabled, default, larger message" \
1348 "$P_SRV debug_level=3" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001349 "$P_CLI debug_level=3 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001350 0 \
1351 -c "Maximum fragment length is 16384" \
1352 -s "Maximum fragment length is 16384" \
1353 -C "client hello, adding max_fragment_length extension" \
1354 -S "found max fragment length extension" \
1355 -S "server hello, max_fragment_length extension" \
1356 -C "found max_fragment_length extension" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001357 -c "16385 bytes written in 2 fragments" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001358 -s "16384 bytes read" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001359 -s "1 bytes read"
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001360
1361requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1362run_test "Max fragment length, DTLS: enabled, default, larger message" \
1363 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001364 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001365 1 \
1366 -c "Maximum fragment length is 16384" \
1367 -s "Maximum fragment length is 16384" \
1368 -C "client hello, adding max_fragment_length extension" \
1369 -S "found max fragment length extension" \
1370 -S "server hello, max_fragment_length extension" \
1371 -C "found max_fragment_length extension" \
1372 -c "fragment larger than.*maximum "
1373
1374requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1375run_test "Max fragment length: disabled, larger message" \
1376 "$P_SRV debug_level=3" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001377 "$P_CLI debug_level=3 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001378 0 \
1379 -C "Maximum fragment length is 16384" \
1380 -S "Maximum fragment length is 16384" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001381 -c "16385 bytes written in 2 fragments" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001382 -s "16384 bytes read" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001383 -s "1 bytes read"
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001384
1385requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1386run_test "Max fragment length DTLS: disabled, larger message" \
1387 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001388 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001389 1 \
1390 -C "Maximum fragment length is 16384" \
1391 -S "Maximum fragment length is 16384" \
1392 -c "fragment larger than.*maximum "
1393
1394requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001395run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001396 "$P_SRV debug_level=3" \
1397 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001398 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001399 -c "Maximum fragment length is 4096" \
1400 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001401 -c "client hello, adding max_fragment_length extension" \
1402 -s "found max fragment length extension" \
1403 -s "server hello, max_fragment_length extension" \
1404 -c "found max_fragment_length extension"
1405
Hanno Becker05607782017-09-18 15:00:34 +01001406requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001407run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001408 "$P_SRV debug_level=3 max_frag_len=4096" \
1409 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001410 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001411 -c "Maximum fragment length is 16384" \
1412 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001413 -C "client hello, adding max_fragment_length extension" \
1414 -S "found max fragment length extension" \
1415 -S "server hello, max_fragment_length extension" \
1416 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001417
Hanno Becker05607782017-09-18 15:00:34 +01001418requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001419requires_gnutls
1420run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001421 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001422 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001423 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001424 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001425 -c "client hello, adding max_fragment_length extension" \
1426 -c "found max_fragment_length extension"
1427
Hanno Becker05607782017-09-18 15:00:34 +01001428requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001429run_test "Max fragment length: client, message just fits" \
1430 "$P_SRV debug_level=3" \
1431 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1432 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001433 -c "Maximum fragment length is 2048" \
1434 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001435 -c "client hello, adding max_fragment_length extension" \
1436 -s "found max fragment length extension" \
1437 -s "server hello, max_fragment_length extension" \
1438 -c "found max_fragment_length extension" \
1439 -c "2048 bytes written in 1 fragments" \
1440 -s "2048 bytes read"
1441
Hanno Becker05607782017-09-18 15:00:34 +01001442requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001443run_test "Max fragment length: client, larger message" \
1444 "$P_SRV debug_level=3" \
1445 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1446 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001447 -c "Maximum fragment length is 2048" \
1448 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001449 -c "client hello, adding max_fragment_length extension" \
1450 -s "found max fragment length extension" \
1451 -s "server hello, max_fragment_length extension" \
1452 -c "found max_fragment_length extension" \
1453 -c "2345 bytes written in 2 fragments" \
1454 -s "2048 bytes read" \
1455 -s "297 bytes read"
1456
Hanno Becker05607782017-09-18 15:00:34 +01001457requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001458run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001459 "$P_SRV debug_level=3 dtls=1" \
1460 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1461 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001462 -c "Maximum fragment length is 2048" \
1463 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001464 -c "client hello, adding max_fragment_length extension" \
1465 -s "found max fragment length extension" \
1466 -s "server hello, max_fragment_length extension" \
1467 -c "found max_fragment_length extension" \
1468 -c "fragment larger than.*maximum"
1469
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001470# Tests for renegotiation
1471
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001472run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001473 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001474 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001475 0 \
1476 -C "client hello, adding renegotiation extension" \
1477 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1478 -S "found renegotiation extension" \
1479 -s "server hello, secure renegotiation extension" \
1480 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001481 -C "=> renegotiate" \
1482 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001483 -S "write hello request"
1484
Hanno Becker78891132017-10-24 11:54:55 +01001485requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001486run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001487 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001488 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001489 0 \
1490 -c "client hello, adding renegotiation extension" \
1491 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1492 -s "found renegotiation extension" \
1493 -s "server hello, secure renegotiation extension" \
1494 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001495 -c "=> renegotiate" \
1496 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001497 -S "write hello request"
1498
Hanno Becker78891132017-10-24 11:54:55 +01001499requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001500run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001501 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001502 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001503 0 \
1504 -c "client hello, adding renegotiation extension" \
1505 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1506 -s "found renegotiation extension" \
1507 -s "server hello, secure renegotiation extension" \
1508 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001509 -c "=> renegotiate" \
1510 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001511 -s "write hello request"
1512
Janos Follath5f1dd802017-10-05 12:29:42 +01001513# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1514# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1515# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker78891132017-10-24 11:54:55 +01001516requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follath5f1dd802017-10-05 12:29:42 +01001517run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1518 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1519 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1520 0 \
1521 -c "client hello, adding renegotiation extension" \
1522 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1523 -s "found renegotiation extension" \
1524 -s "server hello, secure renegotiation extension" \
1525 -c "found renegotiation extension" \
1526 -c "=> renegotiate" \
1527 -s "=> renegotiate" \
1528 -S "write hello request" \
1529 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1530
1531# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1532# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1533# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker78891132017-10-24 11:54:55 +01001534requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follath5f1dd802017-10-05 12:29:42 +01001535run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1536 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1537 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1538 0 \
1539 -c "client hello, adding renegotiation extension" \
1540 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1541 -s "found renegotiation extension" \
1542 -s "server hello, secure renegotiation extension" \
1543 -c "found renegotiation extension" \
1544 -c "=> renegotiate" \
1545 -s "=> renegotiate" \
1546 -s "write hello request" \
1547 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1548
Hanno Becker78891132017-10-24 11:54:55 +01001549requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001550run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001551 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001552 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001553 0 \
1554 -c "client hello, adding renegotiation extension" \
1555 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1556 -s "found renegotiation extension" \
1557 -s "server hello, secure renegotiation extension" \
1558 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001559 -c "=> renegotiate" \
1560 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001561 -s "write hello request"
1562
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: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001565 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001566 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001567 1 \
1568 -c "client hello, adding renegotiation extension" \
1569 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1570 -S "found renegotiation extension" \
1571 -s "server hello, secure renegotiation extension" \
1572 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001573 -c "=> renegotiate" \
1574 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001575 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001576 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001577 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001578
Hanno Becker78891132017-10-24 11:54:55 +01001579requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001580run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001581 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001582 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001583 0 \
1584 -C "client hello, adding renegotiation extension" \
1585 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1586 -S "found renegotiation extension" \
1587 -s "server hello, secure renegotiation extension" \
1588 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001589 -C "=> renegotiate" \
1590 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001591 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001592 -S "SSL - An unexpected message was received from our peer" \
1593 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001594
Hanno Becker78891132017-10-24 11:54:55 +01001595requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001596run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001597 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001598 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001599 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001600 0 \
1601 -C "client hello, adding renegotiation extension" \
1602 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1603 -S "found renegotiation extension" \
1604 -s "server hello, secure renegotiation extension" \
1605 -c "found renegotiation extension" \
1606 -C "=> renegotiate" \
1607 -S "=> renegotiate" \
1608 -s "write hello request" \
1609 -S "SSL - An unexpected message was received from our peer" \
1610 -S "failed"
1611
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001612# delay 2 for 1 alert record + 1 application data record
Hanno Becker78891132017-10-24 11:54:55 +01001613requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001614run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001615 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001616 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001617 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001618 0 \
1619 -C "client hello, adding renegotiation extension" \
1620 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1621 -S "found renegotiation extension" \
1622 -s "server hello, secure renegotiation extension" \
1623 -c "found renegotiation extension" \
1624 -C "=> renegotiate" \
1625 -S "=> renegotiate" \
1626 -s "write hello request" \
1627 -S "SSL - An unexpected message was received from our peer" \
1628 -S "failed"
1629
Hanno Becker78891132017-10-24 11:54:55 +01001630requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001631run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001632 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001633 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001634 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001635 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 -C "=> renegotiate" \
1642 -S "=> renegotiate" \
1643 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001644 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001645
Hanno Becker78891132017-10-24 11:54:55 +01001646requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001647run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001648 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001649 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001650 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001651 0 \
1652 -c "client hello, adding renegotiation extension" \
1653 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1654 -s "found renegotiation extension" \
1655 -s "server hello, secure renegotiation extension" \
1656 -c "found renegotiation extension" \
1657 -c "=> renegotiate" \
1658 -s "=> renegotiate" \
1659 -s "write hello request" \
1660 -S "SSL - An unexpected message was received from our peer" \
1661 -S "failed"
1662
Hanno Becker78891132017-10-24 11:54:55 +01001663requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001664run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001665 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001666 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1667 0 \
1668 -C "client hello, adding renegotiation extension" \
1669 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1670 -S "found renegotiation extension" \
1671 -s "server hello, secure renegotiation extension" \
1672 -c "found renegotiation extension" \
1673 -S "record counter limit reached: renegotiate" \
1674 -C "=> renegotiate" \
1675 -S "=> renegotiate" \
1676 -S "write hello request" \
1677 -S "SSL - An unexpected message was received from our peer" \
1678 -S "failed"
1679
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001680# one extra exchange to be able to complete renego
Hanno Becker78891132017-10-24 11:54:55 +01001681requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001682run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001683 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001684 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001685 0 \
1686 -c "client hello, adding renegotiation extension" \
1687 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1688 -s "found renegotiation extension" \
1689 -s "server hello, secure renegotiation extension" \
1690 -c "found renegotiation extension" \
1691 -s "record counter limit reached: renegotiate" \
1692 -c "=> renegotiate" \
1693 -s "=> renegotiate" \
1694 -s "write hello request" \
1695 -S "SSL - An unexpected message was received from our peer" \
1696 -S "failed"
1697
Hanno Becker78891132017-10-24 11:54:55 +01001698requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001699run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001700 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001701 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001702 0 \
1703 -c "client hello, adding renegotiation extension" \
1704 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1705 -s "found renegotiation extension" \
1706 -s "server hello, secure renegotiation extension" \
1707 -c "found renegotiation extension" \
1708 -s "record counter limit reached: renegotiate" \
1709 -c "=> renegotiate" \
1710 -s "=> renegotiate" \
1711 -s "write hello request" \
1712 -S "SSL - An unexpected message was received from our peer" \
1713 -S "failed"
1714
Hanno Becker78891132017-10-24 11:54:55 +01001715requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001716run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001717 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001718 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1719 0 \
1720 -C "client hello, adding renegotiation extension" \
1721 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1722 -S "found renegotiation extension" \
1723 -s "server hello, secure renegotiation extension" \
1724 -c "found renegotiation extension" \
1725 -S "record counter limit reached: renegotiate" \
1726 -C "=> renegotiate" \
1727 -S "=> renegotiate" \
1728 -S "write hello request" \
1729 -S "SSL - An unexpected message was received from our peer" \
1730 -S "failed"
1731
Hanno Becker78891132017-10-24 11:54:55 +01001732requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001733run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001734 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001735 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001736 0 \
1737 -c "client hello, adding renegotiation extension" \
1738 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1739 -s "found renegotiation extension" \
1740 -s "server hello, secure renegotiation extension" \
1741 -c "found renegotiation extension" \
1742 -c "=> renegotiate" \
1743 -s "=> renegotiate" \
1744 -S "write hello request"
1745
Hanno Becker78891132017-10-24 11:54:55 +01001746requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001747run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001748 "$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 +02001749 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001750 0 \
1751 -c "client hello, adding renegotiation extension" \
1752 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1753 -s "found renegotiation extension" \
1754 -s "server hello, secure renegotiation extension" \
1755 -c "found renegotiation extension" \
1756 -c "=> renegotiate" \
1757 -s "=> renegotiate" \
1758 -s "write hello request"
1759
Hanno Becker78891132017-10-24 11:54:55 +01001760requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001761run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001762 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001763 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001764 0 \
1765 -c "client hello, adding renegotiation extension" \
1766 -c "found renegotiation extension" \
1767 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001768 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001769 -C "error" \
1770 -c "HTTP/1.0 200 [Oo][Kk]"
1771
Paul Bakker539d9722015-02-08 16:18:35 +01001772requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001773requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001774run_test "Renegotiation: gnutls server strict, client-initiated" \
1775 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001776 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001777 0 \
1778 -c "client hello, adding renegotiation extension" \
1779 -c "found renegotiation extension" \
1780 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001781 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001782 -C "error" \
1783 -c "HTTP/1.0 200 [Oo][Kk]"
1784
Paul Bakker539d9722015-02-08 16:18:35 +01001785requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001786requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001787run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1788 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1789 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1790 1 \
1791 -c "client hello, adding renegotiation extension" \
1792 -C "found renegotiation extension" \
1793 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001794 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001795 -c "error" \
1796 -C "HTTP/1.0 200 [Oo][Kk]"
1797
Paul Bakker539d9722015-02-08 16:18:35 +01001798requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001799requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001800run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1801 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1802 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1803 allow_legacy=0" \
1804 1 \
1805 -c "client hello, adding renegotiation extension" \
1806 -C "found renegotiation extension" \
1807 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001808 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001809 -c "error" \
1810 -C "HTTP/1.0 200 [Oo][Kk]"
1811
Paul Bakker539d9722015-02-08 16:18:35 +01001812requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001813requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001814run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1815 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1816 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1817 allow_legacy=1" \
1818 0 \
1819 -c "client hello, adding renegotiation extension" \
1820 -C "found renegotiation extension" \
1821 -c "=> renegotiate" \
1822 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001823 -C "error" \
1824 -c "HTTP/1.0 200 [Oo][Kk]"
1825
Hanno Becker78891132017-10-24 11:54:55 +01001826requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001827run_test "Renegotiation: DTLS, client-initiated" \
1828 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1829 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1830 0 \
1831 -c "client hello, adding renegotiation extension" \
1832 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1833 -s "found renegotiation extension" \
1834 -s "server hello, secure renegotiation extension" \
1835 -c "found renegotiation extension" \
1836 -c "=> renegotiate" \
1837 -s "=> renegotiate" \
1838 -S "write hello request"
1839
Hanno Becker78891132017-10-24 11:54:55 +01001840requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001841run_test "Renegotiation: DTLS, server-initiated" \
1842 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001843 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1844 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001845 0 \
1846 -c "client hello, adding renegotiation extension" \
1847 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1848 -s "found renegotiation extension" \
1849 -s "server hello, secure renegotiation extension" \
1850 -c "found renegotiation extension" \
1851 -c "=> renegotiate" \
1852 -s "=> renegotiate" \
1853 -s "write hello request"
1854
Hanno Becker78891132017-10-24 11:54:55 +01001855requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG9b1927b2017-01-19 16:30:57 +00001856run_test "Renegotiation: DTLS, renego_period overflow" \
1857 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1858 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1859 0 \
1860 -c "client hello, adding renegotiation extension" \
1861 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1862 -s "found renegotiation extension" \
1863 -s "server hello, secure renegotiation extension" \
1864 -s "record counter limit reached: renegotiate" \
1865 -c "=> renegotiate" \
1866 -s "=> renegotiate" \
Hanno Becker78891132017-10-24 11:54:55 +01001867 -s "write hello request"
Andres AG9b1927b2017-01-19 16:30:57 +00001868
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001869requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001870requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001871run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1872 "$G_SRV -u --mtu 4096" \
1873 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1874 0 \
1875 -c "client hello, adding renegotiation extension" \
1876 -c "found renegotiation extension" \
1877 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001878 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001879 -C "error" \
1880 -s "Extra-header:"
1881
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001882# Test for the "secure renegotation" extension only (no actual renegotiation)
1883
Paul Bakker539d9722015-02-08 16:18:35 +01001884requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001885run_test "Renego ext: gnutls server strict, client default" \
1886 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1887 "$P_CLI debug_level=3" \
1888 0 \
1889 -c "found renegotiation extension" \
1890 -C "error" \
1891 -c "HTTP/1.0 200 [Oo][Kk]"
1892
Paul Bakker539d9722015-02-08 16:18:35 +01001893requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001894run_test "Renego ext: gnutls server unsafe, client default" \
1895 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1896 "$P_CLI debug_level=3" \
1897 0 \
1898 -C "found renegotiation extension" \
1899 -C "error" \
1900 -c "HTTP/1.0 200 [Oo][Kk]"
1901
Paul Bakker539d9722015-02-08 16:18:35 +01001902requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001903run_test "Renego ext: gnutls server unsafe, client break legacy" \
1904 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1905 "$P_CLI debug_level=3 allow_legacy=-1" \
1906 1 \
1907 -C "found renegotiation extension" \
1908 -c "error" \
1909 -C "HTTP/1.0 200 [Oo][Kk]"
1910
Paul Bakker539d9722015-02-08 16:18:35 +01001911requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001912run_test "Renego ext: gnutls client strict, server default" \
1913 "$P_SRV debug_level=3" \
1914 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1915 0 \
1916 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1917 -s "server hello, secure renegotiation extension"
1918
Paul Bakker539d9722015-02-08 16:18:35 +01001919requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001920run_test "Renego ext: gnutls client unsafe, server default" \
1921 "$P_SRV debug_level=3" \
1922 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1923 0 \
1924 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1925 -S "server hello, secure renegotiation extension"
1926
Paul Bakker539d9722015-02-08 16:18:35 +01001927requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001928run_test "Renego ext: gnutls client unsafe, server break legacy" \
1929 "$P_SRV debug_level=3 allow_legacy=-1" \
1930 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1931 1 \
1932 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1933 -S "server hello, secure renegotiation extension"
1934
Janos Follath365b2262016-02-17 10:11:21 +00001935# Tests for silently dropping trailing extra bytes in .der certificates
1936
1937requires_gnutls
1938run_test "DER format: no trailing bytes" \
1939 "$P_SRV crt_file=data_files/server5-der0.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 a trailing zero byte" \
1947 "$P_SRV crt_file=data_files/server5-der1a.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 a trailing random byte" \
1955 "$P_SRV crt_file=data_files/server5-der1b.crt \
1956 key_file=data_files/server5.key" \
1957 "$G_CLI " \
1958 0 \
1959 -c "Handshake was completed" \
1960
1961requires_gnutls
1962run_test "DER format: with 2 trailing random bytes" \
1963 "$P_SRV crt_file=data_files/server5-der2.crt \
1964 key_file=data_files/server5.key" \
1965 "$G_CLI " \
1966 0 \
1967 -c "Handshake was completed" \
1968
1969requires_gnutls
1970run_test "DER format: with 4 trailing random bytes" \
1971 "$P_SRV crt_file=data_files/server5-der4.crt \
1972 key_file=data_files/server5.key" \
1973 "$G_CLI " \
1974 0 \
1975 -c "Handshake was completed" \
1976
1977requires_gnutls
1978run_test "DER format: with 8 trailing random bytes" \
1979 "$P_SRV crt_file=data_files/server5-der8.crt \
1980 key_file=data_files/server5.key" \
1981 "$G_CLI " \
1982 0 \
1983 -c "Handshake was completed" \
1984
1985requires_gnutls
1986run_test "DER format: with 9 trailing random bytes" \
1987 "$P_SRV crt_file=data_files/server5-der9.crt \
1988 key_file=data_files/server5.key" \
1989 "$G_CLI " \
1990 0 \
1991 -c "Handshake was completed" \
1992
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001993# Tests for auth_mode
1994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001995run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001996 "$P_SRV crt_file=data_files/server5-badsign.crt \
1997 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001998 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001999 1 \
2000 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002001 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002002 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002003 -c "X509 - Certificate verification failed"
2004
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002005run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002006 "$P_SRV crt_file=data_files/server5-badsign.crt \
2007 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002008 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002009 0 \
2010 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002011 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002012 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002013 -C "X509 - Certificate verification failed"
2014
Hanno Becker61c0c702017-05-15 16:05:15 +01002015run_test "Authentication: server goodcert, client optional, no trusted CA" \
2016 "$P_SRV" \
2017 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2018 0 \
2019 -c "x509_verify_cert() returned" \
2020 -c "! The certificate is not correctly signed by the trusted CA" \
2021 -c "! Certificate verification flags"\
2022 -C "! mbedtls_ssl_handshake returned" \
2023 -C "X509 - Certificate verification failed" \
2024 -C "SSL - No CA Chain is set, but required to operate"
2025
2026run_test "Authentication: server goodcert, client required, no trusted CA" \
2027 "$P_SRV" \
2028 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2029 1 \
2030 -c "x509_verify_cert() returned" \
2031 -c "! The certificate is not correctly signed by the trusted CA" \
2032 -c "! Certificate verification flags"\
2033 -c "! mbedtls_ssl_handshake returned" \
2034 -c "SSL - No CA Chain is set, but required to operate"
2035
2036# The purpose of the next two tests is to test the client's behaviour when receiving a server
2037# certificate with an unsupported elliptic curve. This should usually not happen because
2038# the client informs the server about the supported curves - it does, though, in the
2039# corner case of a static ECDH suite, because the server doesn't check the curve on that
2040# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2041# different means to have the server ignoring the client's supported curve list.
2042
2043requires_config_enabled MBEDTLS_ECP_C
2044run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2045 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2046 crt_file=data_files/server5.ku-ka.crt" \
2047 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2048 1 \
2049 -c "bad certificate (EC key curve)"\
2050 -c "! Certificate verification flags"\
2051 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2052
2053requires_config_enabled MBEDTLS_ECP_C
2054run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2055 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2056 crt_file=data_files/server5.ku-ka.crt" \
2057 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2058 1 \
2059 -c "bad certificate (EC key curve)"\
2060 -c "! Certificate verification flags"\
2061 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002063run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002064 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002065 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002066 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002067 0 \
2068 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002069 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002070 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002071 -C "X509 - Certificate verification failed"
2072
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002073run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002074 "$P_SRV debug_level=3 auth_mode=required" \
2075 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002076 key_file=data_files/server5.key" \
2077 1 \
2078 -S "skip write certificate request" \
2079 -C "skip parse certificate request" \
2080 -c "got a certificate request" \
2081 -C "skip write certificate" \
2082 -C "skip write certificate verify" \
2083 -S "skip parse certificate verify" \
2084 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002085 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002086 -s "! mbedtls_ssl_handshake returned" \
2087 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002088 -s "X509 - Certificate verification failed"
2089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002090run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002091 "$P_SRV debug_level=3 auth_mode=optional" \
2092 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002093 key_file=data_files/server5.key" \
2094 0 \
2095 -S "skip write certificate request" \
2096 -C "skip parse certificate request" \
2097 -c "got a certificate request" \
2098 -C "skip write certificate" \
2099 -C "skip write certificate verify" \
2100 -S "skip parse certificate verify" \
2101 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002102 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002103 -S "! mbedtls_ssl_handshake returned" \
2104 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002105 -S "X509 - Certificate verification failed"
2106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002107run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002108 "$P_SRV debug_level=3 auth_mode=none" \
2109 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002110 key_file=data_files/server5.key" \
2111 0 \
2112 -s "skip write certificate request" \
2113 -C "skip parse certificate request" \
2114 -c "got no certificate request" \
2115 -c "skip write certificate" \
2116 -c "skip write certificate verify" \
2117 -s "skip parse certificate verify" \
2118 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002119 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002120 -S "! mbedtls_ssl_handshake returned" \
2121 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002122 -S "X509 - Certificate verification failed"
2123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002124run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002125 "$P_SRV debug_level=3 auth_mode=optional" \
2126 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002127 0 \
2128 -S "skip write certificate request" \
2129 -C "skip parse certificate request" \
2130 -c "got a certificate request" \
2131 -C "skip write certificate$" \
2132 -C "got no certificate to send" \
2133 -S "SSLv3 client has no certificate" \
2134 -c "skip write certificate verify" \
2135 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002136 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002137 -S "! mbedtls_ssl_handshake returned" \
2138 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002139 -S "X509 - Certificate verification failed"
2140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002141run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002142 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002143 "$O_CLI" \
2144 0 \
2145 -S "skip write certificate request" \
2146 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002147 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002148 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002149 -S "X509 - Certificate verification failed"
2150
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002151run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002152 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002153 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002154 0 \
2155 -C "skip parse certificate request" \
2156 -c "got a certificate request" \
2157 -C "skip write certificate$" \
2158 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002159 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002160
Janos Follath542ee5d2016-03-07 15:57:05 +00002161requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002162run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002163 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002164 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002165 0 \
2166 -S "skip write certificate request" \
2167 -C "skip parse certificate request" \
2168 -c "got a certificate request" \
2169 -C "skip write certificate$" \
2170 -c "skip write certificate verify" \
2171 -c "got no certificate to send" \
2172 -s "SSLv3 client has no certificate" \
2173 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002174 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002175 -S "! mbedtls_ssl_handshake returned" \
2176 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002177 -S "X509 - Certificate verification failed"
2178
Manuel Pégourié-Gonnard591035d2017-06-26 10:45:33 +02002179run_test "Authentication: server max_int chain, client default" \
2180 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2181 key_file=data_files/dir-maxpath/09.key" \
2182 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2183 0 \
2184 -C "X509 - A fatal error occured"
2185
2186run_test "Authentication: server max_int+1 chain, client default" \
2187 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2188 key_file=data_files/dir-maxpath/10.key" \
2189 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2190 1 \
2191 -c "X509 - A fatal error occured"
2192
2193run_test "Authentication: server max_int+1 chain, client optional" \
2194 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2195 key_file=data_files/dir-maxpath/10.key" \
2196 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2197 auth_mode=optional" \
2198 1 \
2199 -c "X509 - A fatal error occured"
2200
2201run_test "Authentication: server max_int+1 chain, client none" \
2202 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2203 key_file=data_files/dir-maxpath/10.key" \
2204 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2205 auth_mode=none" \
2206 0 \
2207 -C "X509 - A fatal error occured"
2208
2209run_test "Authentication: client max_int+1 chain, server default" \
2210 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2211 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2212 key_file=data_files/dir-maxpath/10.key" \
2213 0 \
2214 -S "X509 - A fatal error occured"
2215
2216run_test "Authentication: client max_int+1 chain, server optional" \
2217 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2218 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2219 key_file=data_files/dir-maxpath/10.key" \
2220 1 \
2221 -s "X509 - A fatal error occured"
2222
2223run_test "Authentication: client max_int+1 chain, server required" \
2224 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2225 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2226 key_file=data_files/dir-maxpath/10.key" \
2227 1 \
2228 -s "X509 - A fatal error occured"
2229
2230run_test "Authentication: client max_int chain, server required" \
2231 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2232 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2233 key_file=data_files/dir-maxpath/09.key" \
2234 0 \
2235 -S "X509 - A fatal error occured"
2236
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002237# Tests for certificate selection based on SHA verson
2238
2239run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2240 "$P_SRV crt_file=data_files/server5.crt \
2241 key_file=data_files/server5.key \
2242 crt_file2=data_files/server5-sha1.crt \
2243 key_file2=data_files/server5.key" \
2244 "$P_CLI force_version=tls1_2" \
2245 0 \
2246 -c "signed using.*ECDSA with SHA256" \
2247 -C "signed using.*ECDSA with SHA1"
2248
2249run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2250 "$P_SRV crt_file=data_files/server5.crt \
2251 key_file=data_files/server5.key \
2252 crt_file2=data_files/server5-sha1.crt \
2253 key_file2=data_files/server5.key" \
2254 "$P_CLI force_version=tls1_1" \
2255 0 \
2256 -C "signed using.*ECDSA with SHA256" \
2257 -c "signed using.*ECDSA with SHA1"
2258
2259run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2260 "$P_SRV crt_file=data_files/server5.crt \
2261 key_file=data_files/server5.key \
2262 crt_file2=data_files/server5-sha1.crt \
2263 key_file2=data_files/server5.key" \
2264 "$P_CLI force_version=tls1" \
2265 0 \
2266 -C "signed using.*ECDSA with SHA256" \
2267 -c "signed using.*ECDSA with SHA1"
2268
2269run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2270 "$P_SRV crt_file=data_files/server5.crt \
2271 key_file=data_files/server5.key \
2272 crt_file2=data_files/server6.crt \
2273 key_file2=data_files/server6.key" \
2274 "$P_CLI force_version=tls1_1" \
2275 0 \
2276 -c "serial number.*09" \
2277 -c "signed using.*ECDSA with SHA256" \
2278 -C "signed using.*ECDSA with SHA1"
2279
2280run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2281 "$P_SRV crt_file=data_files/server6.crt \
2282 key_file=data_files/server6.key \
2283 crt_file2=data_files/server5.crt \
2284 key_file2=data_files/server5.key" \
2285 "$P_CLI force_version=tls1_1" \
2286 0 \
2287 -c "serial number.*0A" \
2288 -c "signed using.*ECDSA with SHA256" \
2289 -C "signed using.*ECDSA with SHA1"
2290
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002291# tests for SNI
2292
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002293run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002294 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002295 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002296 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002297 0 \
2298 -S "parse ServerName extension" \
2299 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2300 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002302run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002303 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002304 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002305 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 +02002306 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002307 0 \
2308 -s "parse ServerName extension" \
2309 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2310 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002312run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002313 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002314 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002315 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 +02002316 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002317 0 \
2318 -s "parse ServerName extension" \
2319 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2320 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002322run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002323 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002324 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002325 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 +02002326 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002327 1 \
2328 -s "parse ServerName extension" \
2329 -s "ssl_sni_wrapper() returned" \
2330 -s "mbedtls_ssl_handshake returned" \
2331 -c "mbedtls_ssl_handshake returned" \
2332 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002333
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002334run_test "SNI: client auth no override: optional" \
2335 "$P_SRV debug_level=3 auth_mode=optional \
2336 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2337 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2338 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002339 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002340 -S "skip write certificate request" \
2341 -C "skip parse certificate request" \
2342 -c "got a certificate request" \
2343 -C "skip write certificate" \
2344 -C "skip write certificate verify" \
2345 -S "skip parse certificate verify"
2346
2347run_test "SNI: client auth override: none -> optional" \
2348 "$P_SRV debug_level=3 auth_mode=none \
2349 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2350 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2351 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002352 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002353 -S "skip write certificate request" \
2354 -C "skip parse certificate request" \
2355 -c "got a certificate request" \
2356 -C "skip write certificate" \
2357 -C "skip write certificate verify" \
2358 -S "skip parse certificate verify"
2359
2360run_test "SNI: client auth override: optional -> none" \
2361 "$P_SRV debug_level=3 auth_mode=optional \
2362 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2363 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2364 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002365 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002366 -s "skip write certificate request" \
2367 -C "skip parse certificate request" \
2368 -c "got no certificate request" \
2369 -c "skip write certificate" \
2370 -c "skip write certificate verify" \
2371 -s "skip parse certificate verify"
2372
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002373run_test "SNI: CA no override" \
2374 "$P_SRV debug_level=3 auth_mode=optional \
2375 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2376 ca_file=data_files/test-ca.crt \
2377 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2378 "$P_CLI debug_level=3 server_name=localhost \
2379 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2380 1 \
2381 -S "skip write certificate request" \
2382 -C "skip parse certificate request" \
2383 -c "got a certificate request" \
2384 -C "skip write certificate" \
2385 -C "skip write certificate verify" \
2386 -S "skip parse certificate verify" \
2387 -s "x509_verify_cert() returned" \
2388 -s "! The certificate is not correctly signed by the trusted CA" \
2389 -S "The certificate has been revoked (is on a CRL)"
2390
2391run_test "SNI: CA override" \
2392 "$P_SRV debug_level=3 auth_mode=optional \
2393 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2394 ca_file=data_files/test-ca.crt \
2395 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2396 "$P_CLI debug_level=3 server_name=localhost \
2397 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2398 0 \
2399 -S "skip write certificate request" \
2400 -C "skip parse certificate request" \
2401 -c "got a certificate request" \
2402 -C "skip write certificate" \
2403 -C "skip write certificate verify" \
2404 -S "skip parse certificate verify" \
2405 -S "x509_verify_cert() returned" \
2406 -S "! The certificate is not correctly signed by the trusted CA" \
2407 -S "The certificate has been revoked (is on a CRL)"
2408
2409run_test "SNI: CA override with CRL" \
2410 "$P_SRV debug_level=3 auth_mode=optional \
2411 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2412 ca_file=data_files/test-ca.crt \
2413 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2414 "$P_CLI debug_level=3 server_name=localhost \
2415 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2416 1 \
2417 -S "skip write certificate request" \
2418 -C "skip parse certificate request" \
2419 -c "got a certificate request" \
2420 -C "skip write certificate" \
2421 -C "skip write certificate verify" \
2422 -S "skip parse certificate verify" \
2423 -s "x509_verify_cert() returned" \
2424 -S "! The certificate is not correctly signed by the trusted CA" \
2425 -s "The certificate has been revoked (is on a CRL)"
2426
Andres AG52142f12016-12-07 10:01:30 +00002427# Tests for SNI and DTLS
2428
Andres Amaya Garcia0b8eaa82018-05-01 20:27:37 +01002429run_test "SNI: DTLS, no SNI callback" \
2430 "$P_SRV debug_level=3 dtls=1 \
2431 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2432 "$P_CLI server_name=localhost dtls=1" \
2433 0 \
2434 -S "parse ServerName extension" \
2435 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2436 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2437
Andres Amaya Garcia021ad3d2018-05-01 20:26:47 +01002438run_test "SNI: DTLS, matching cert 1" \
Andres AG52142f12016-12-07 10:01:30 +00002439 "$P_SRV debug_level=3 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,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2442 "$P_CLI server_name=localhost dtls=1" \
2443 0 \
2444 -s "parse ServerName extension" \
2445 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2446 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2447
Andres Amaya Garcia0b8eaa82018-05-01 20:27:37 +01002448run_test "SNI: DTLS, matching cert 2" \
2449 "$P_SRV debug_level=3 dtls=1 \
2450 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2451 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2452 "$P_CLI server_name=polarssl.example dtls=1" \
2453 0 \
2454 -s "parse ServerName extension" \
2455 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2456 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2457
2458run_test "SNI: DTLS, no matching cert" \
2459 "$P_SRV debug_level=3 dtls=1 \
2460 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2461 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2462 "$P_CLI server_name=nonesuch.example dtls=1" \
2463 1 \
2464 -s "parse ServerName extension" \
2465 -s "ssl_sni_wrapper() returned" \
2466 -s "mbedtls_ssl_handshake returned" \
2467 -c "mbedtls_ssl_handshake returned" \
2468 -c "SSL - A fatal alert message was received from our peer"
2469
2470run_test "SNI: DTLS, client auth no override: optional" \
2471 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2472 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2473 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2474 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2475 0 \
2476 -S "skip write certificate request" \
2477 -C "skip parse certificate request" \
2478 -c "got a certificate request" \
2479 -C "skip write certificate" \
2480 -C "skip write certificate verify" \
2481 -S "skip parse certificate verify"
2482
2483run_test "SNI: DTLS, client auth override: none -> optional" \
2484 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2485 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2486 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2487 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2488 0 \
2489 -S "skip write certificate request" \
2490 -C "skip parse certificate request" \
2491 -c "got a certificate request" \
2492 -C "skip write certificate" \
2493 -C "skip write certificate verify" \
2494 -S "skip parse certificate verify"
2495
2496run_test "SNI: DTLS, client auth override: optional -> none" \
2497 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2498 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2499 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2500 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2501 0 \
2502 -s "skip write certificate request" \
2503 -C "skip parse certificate request" \
2504 -c "got no certificate request" \
2505 -c "skip write certificate" \
2506 -c "skip write certificate verify" \
2507 -s "skip parse certificate verify"
2508
Simon Butcher12826df2018-06-16 19:46:52 +01002509needs_more_time 4
Andres Amaya Garcia0b8eaa82018-05-01 20:27:37 +01002510run_test "SNI: DTLS, CA no override" \
2511 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2512 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2513 ca_file=data_files/test-ca.crt \
2514 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2515 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2516 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2517 1 \
2518 -S "skip write certificate request" \
2519 -C "skip parse certificate request" \
2520 -c "got a certificate request" \
2521 -C "skip write certificate" \
2522 -C "skip write certificate verify" \
2523 -S "skip parse certificate verify" \
2524 -s "x509_verify_cert() returned" \
2525 -s "! The certificate is not correctly signed by the trusted CA" \
2526 -S "The certificate has been revoked (is on a CRL)"
2527
Andres Amaya Garcia021ad3d2018-05-01 20:26:47 +01002528run_test "SNI: DTLS, CA override" \
Andres AG52142f12016-12-07 10:01:30 +00002529 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2530 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2531 ca_file=data_files/test-ca.crt \
2532 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2533 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2534 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2535 0 \
2536 -S "skip write certificate request" \
2537 -C "skip parse certificate request" \
2538 -c "got a certificate request" \
2539 -C "skip write certificate" \
2540 -C "skip write certificate verify" \
2541 -S "skip parse certificate verify" \
2542 -S "x509_verify_cert() returned" \
2543 -S "! The certificate is not correctly signed by the trusted CA" \
2544 -S "The certificate has been revoked (is on a CRL)"
2545
Simon Butcher12826df2018-06-16 19:46:52 +01002546needs_more_time 4
Andres Amaya Garcia021ad3d2018-05-01 20:26:47 +01002547run_test "SNI: DTLS, CA override with CRL" \
Andres AG52142f12016-12-07 10:01:30 +00002548 "$P_SRV debug_level=3 auth_mode=optional \
2549 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2550 ca_file=data_files/test-ca.crt \
2551 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2552 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2553 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2554 1 \
2555 -S "skip write certificate request" \
2556 -C "skip parse certificate request" \
2557 -c "got a certificate request" \
2558 -C "skip write certificate" \
2559 -C "skip write certificate verify" \
2560 -S "skip parse certificate verify" \
2561 -s "x509_verify_cert() returned" \
2562 -S "! The certificate is not correctly signed by the trusted CA" \
2563 -s "The certificate has been revoked (is on a CRL)"
2564
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002565# Tests for non-blocking I/O: exercise a variety of handshake flows
2566
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002567run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002568 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2569 "$P_CLI nbio=2 tickets=0" \
2570 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002571 -S "mbedtls_ssl_handshake returned" \
2572 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002573 -c "Read from server: .* bytes read"
2574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002575run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002576 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2577 "$P_CLI nbio=2 tickets=0" \
2578 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002579 -S "mbedtls_ssl_handshake returned" \
2580 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002581 -c "Read from server: .* bytes read"
2582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002583run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002584 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2585 "$P_CLI nbio=2 tickets=1" \
2586 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002587 -S "mbedtls_ssl_handshake returned" \
2588 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002589 -c "Read from server: .* bytes read"
2590
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002591run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002592 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2593 "$P_CLI nbio=2 tickets=1" \
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é-Gonnard0b6609b2014-02-26 14:45:12 +01002597 -c "Read from server: .* bytes read"
2598
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002599run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002600 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2601 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2602 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002603 -S "mbedtls_ssl_handshake returned" \
2604 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002605 -c "Read from server: .* bytes read"
2606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002607run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002608 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2609 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2610 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002611 -S "mbedtls_ssl_handshake returned" \
2612 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002613 -c "Read from server: .* bytes read"
2614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002615run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002616 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2617 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2618 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002619 -S "mbedtls_ssl_handshake returned" \
2620 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002621 -c "Read from server: .* bytes read"
2622
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002623# Tests for version negotiation
2624
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002625run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002626 "$P_SRV" \
2627 "$P_CLI" \
2628 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002629 -S "mbedtls_ssl_handshake returned" \
2630 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002631 -s "Protocol is TLSv1.2" \
2632 -c "Protocol is TLSv1.2"
2633
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002634run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002635 "$P_SRV" \
2636 "$P_CLI max_version=tls1_1" \
2637 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002638 -S "mbedtls_ssl_handshake returned" \
2639 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002640 -s "Protocol is TLSv1.1" \
2641 -c "Protocol is TLSv1.1"
2642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002643run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002644 "$P_SRV max_version=tls1_1" \
2645 "$P_CLI" \
2646 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002647 -S "mbedtls_ssl_handshake returned" \
2648 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002649 -s "Protocol is TLSv1.1" \
2650 -c "Protocol is TLSv1.1"
2651
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002652run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002653 "$P_SRV max_version=tls1_1" \
2654 "$P_CLI max_version=tls1_1" \
2655 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002656 -S "mbedtls_ssl_handshake returned" \
2657 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002658 -s "Protocol is TLSv1.1" \
2659 -c "Protocol is TLSv1.1"
2660
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002661run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002662 "$P_SRV min_version=tls1_1" \
2663 "$P_CLI max_version=tls1_1" \
2664 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002665 -S "mbedtls_ssl_handshake returned" \
2666 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002667 -s "Protocol is TLSv1.1" \
2668 -c "Protocol is TLSv1.1"
2669
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002670run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002671 "$P_SRV max_version=tls1_1" \
2672 "$P_CLI min_version=tls1_1" \
2673 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002674 -S "mbedtls_ssl_handshake returned" \
2675 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002676 -s "Protocol is TLSv1.1" \
2677 -c "Protocol is TLSv1.1"
2678
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002679run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002680 "$P_SRV max_version=tls1_1" \
2681 "$P_CLI min_version=tls1_2" \
2682 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002683 -s "mbedtls_ssl_handshake returned" \
2684 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002685 -c "SSL - Handshake protocol not within min/max boundaries"
2686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002687run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002688 "$P_SRV min_version=tls1_2" \
2689 "$P_CLI max_version=tls1_1" \
2690 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002691 -s "mbedtls_ssl_handshake returned" \
2692 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002693 -s "SSL - Handshake protocol not within min/max boundaries"
2694
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002695# Tests for ALPN extension
2696
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002697run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002698 "$P_SRV debug_level=3" \
2699 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002700 0 \
2701 -C "client hello, adding alpn extension" \
2702 -S "found alpn extension" \
2703 -C "got an alert message, type: \\[2:120]" \
2704 -S "server hello, adding alpn extension" \
2705 -C "found alpn extension " \
2706 -C "Application Layer Protocol is" \
2707 -S "Application Layer Protocol is"
2708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002709run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002710 "$P_SRV debug_level=3" \
2711 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002712 0 \
2713 -c "client hello, adding alpn extension" \
2714 -s "found alpn extension" \
2715 -C "got an alert message, type: \\[2:120]" \
2716 -S "server hello, adding alpn extension" \
2717 -C "found alpn extension " \
2718 -c "Application Layer Protocol is (none)" \
2719 -S "Application Layer Protocol is"
2720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002721run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002722 "$P_SRV debug_level=3 alpn=abc,1234" \
2723 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002724 0 \
2725 -C "client hello, adding alpn extension" \
2726 -S "found alpn extension" \
2727 -C "got an alert message, type: \\[2:120]" \
2728 -S "server hello, adding alpn extension" \
2729 -C "found alpn extension " \
2730 -C "Application Layer Protocol is" \
2731 -s "Application Layer Protocol is (none)"
2732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002733run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002734 "$P_SRV debug_level=3 alpn=abc,1234" \
2735 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002736 0 \
2737 -c "client hello, adding alpn extension" \
2738 -s "found alpn extension" \
2739 -C "got an alert message, type: \\[2:120]" \
2740 -s "server hello, adding alpn extension" \
2741 -c "found alpn extension" \
2742 -c "Application Layer Protocol is abc" \
2743 -s "Application Layer Protocol is abc"
2744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002745run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002746 "$P_SRV debug_level=3 alpn=abc,1234" \
2747 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002748 0 \
2749 -c "client hello, adding alpn extension" \
2750 -s "found alpn extension" \
2751 -C "got an alert message, type: \\[2:120]" \
2752 -s "server hello, adding alpn extension" \
2753 -c "found alpn extension" \
2754 -c "Application Layer Protocol is abc" \
2755 -s "Application Layer Protocol is abc"
2756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002757run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002758 "$P_SRV debug_level=3 alpn=abc,1234" \
2759 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002760 0 \
2761 -c "client hello, adding alpn extension" \
2762 -s "found alpn extension" \
2763 -C "got an alert message, type: \\[2:120]" \
2764 -s "server hello, adding alpn extension" \
2765 -c "found alpn extension" \
2766 -c "Application Layer Protocol is 1234" \
2767 -s "Application Layer Protocol is 1234"
2768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002769run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002770 "$P_SRV debug_level=3 alpn=abc,123" \
2771 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002772 1 \
2773 -c "client hello, adding alpn extension" \
2774 -s "found alpn extension" \
2775 -c "got an alert message, type: \\[2:120]" \
2776 -S "server hello, adding alpn extension" \
2777 -C "found alpn extension" \
2778 -C "Application Layer Protocol is 1234" \
2779 -S "Application Layer Protocol is 1234"
2780
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002781
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002782# Tests for keyUsage in leaf certificates, part 1:
2783# server-side certificate/suite selection
2784
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002785run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002786 "$P_SRV key_file=data_files/server2.key \
2787 crt_file=data_files/server2.ku-ds.crt" \
2788 "$P_CLI" \
2789 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002790 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002791
2792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002793run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002794 "$P_SRV key_file=data_files/server2.key \
2795 crt_file=data_files/server2.ku-ke.crt" \
2796 "$P_CLI" \
2797 0 \
2798 -c "Ciphersuite is TLS-RSA-WITH-"
2799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002800run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002801 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002802 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002803 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002804 1 \
2805 -C "Ciphersuite is "
2806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002807run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002808 "$P_SRV key_file=data_files/server5.key \
2809 crt_file=data_files/server5.ku-ds.crt" \
2810 "$P_CLI" \
2811 0 \
2812 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2813
2814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002815run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002816 "$P_SRV key_file=data_files/server5.key \
2817 crt_file=data_files/server5.ku-ka.crt" \
2818 "$P_CLI" \
2819 0 \
2820 -c "Ciphersuite is TLS-ECDH-"
2821
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002822run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002823 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002824 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002825 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002826 1 \
2827 -C "Ciphersuite is "
2828
2829# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002830# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002831
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002832run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002833 "$O_SRV -key data_files/server2.key \
2834 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002835 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002836 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2837 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002838 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002839 -C "Processing of the Certificate handshake message failed" \
2840 -c "Ciphersuite is TLS-"
2841
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002842run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002843 "$O_SRV -key data_files/server2.key \
2844 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002845 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002846 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2847 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002848 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002849 -C "Processing of the Certificate handshake message failed" \
2850 -c "Ciphersuite is TLS-"
2851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002852run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002853 "$O_SRV -key data_files/server2.key \
2854 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002855 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002856 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2857 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002858 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002859 -C "Processing of the Certificate handshake message failed" \
2860 -c "Ciphersuite is TLS-"
2861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002862run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002863 "$O_SRV -key data_files/server2.key \
2864 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002865 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002866 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2867 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002868 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002869 -c "Processing of the Certificate handshake message failed" \
2870 -C "Ciphersuite is TLS-"
2871
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002872run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2873 "$O_SRV -key data_files/server2.key \
2874 -cert data_files/server2.ku-ke.crt" \
2875 "$P_CLI debug_level=1 auth_mode=optional \
2876 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2877 0 \
2878 -c "bad certificate (usage extensions)" \
2879 -C "Processing of the Certificate handshake message failed" \
2880 -c "Ciphersuite is TLS-" \
2881 -c "! Usage does not match the keyUsage extension"
2882
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002883run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002884 "$O_SRV -key data_files/server2.key \
2885 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002886 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002887 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2888 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002889 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002890 -C "Processing of the Certificate handshake message failed" \
2891 -c "Ciphersuite is TLS-"
2892
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002893run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002894 "$O_SRV -key data_files/server2.key \
2895 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002896 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002897 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2898 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002899 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002900 -c "Processing of the Certificate handshake message failed" \
2901 -C "Ciphersuite is TLS-"
2902
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002903run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2904 "$O_SRV -key data_files/server2.key \
2905 -cert data_files/server2.ku-ds.crt" \
2906 "$P_CLI debug_level=1 auth_mode=optional \
2907 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2908 0 \
2909 -c "bad certificate (usage extensions)" \
2910 -C "Processing of the Certificate handshake message failed" \
2911 -c "Ciphersuite is TLS-" \
2912 -c "! Usage does not match the keyUsage extension"
2913
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002914# Tests for keyUsage in leaf certificates, part 3:
2915# server-side checking of client cert
2916
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002917run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002918 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002919 "$O_CLI -key data_files/server2.key \
2920 -cert data_files/server2.ku-ds.crt" \
2921 0 \
2922 -S "bad certificate (usage extensions)" \
2923 -S "Processing of the Certificate handshake message failed"
2924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002925run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002926 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002927 "$O_CLI -key data_files/server2.key \
2928 -cert data_files/server2.ku-ke.crt" \
2929 0 \
2930 -s "bad certificate (usage extensions)" \
2931 -S "Processing of the Certificate handshake message failed"
2932
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002933run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002934 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002935 "$O_CLI -key data_files/server2.key \
2936 -cert data_files/server2.ku-ke.crt" \
2937 1 \
2938 -s "bad certificate (usage extensions)" \
2939 -s "Processing of the Certificate handshake message failed"
2940
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002941run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002942 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002943 "$O_CLI -key data_files/server5.key \
2944 -cert data_files/server5.ku-ds.crt" \
2945 0 \
2946 -S "bad certificate (usage extensions)" \
2947 -S "Processing of the Certificate handshake message failed"
2948
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002949run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002950 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002951 "$O_CLI -key data_files/server5.key \
2952 -cert data_files/server5.ku-ka.crt" \
2953 0 \
2954 -s "bad certificate (usage extensions)" \
2955 -S "Processing of the Certificate handshake message failed"
2956
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002957# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2958
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002959run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002960 "$P_SRV key_file=data_files/server5.key \
2961 crt_file=data_files/server5.eku-srv.crt" \
2962 "$P_CLI" \
2963 0
2964
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002965run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002966 "$P_SRV key_file=data_files/server5.key \
2967 crt_file=data_files/server5.eku-srv.crt" \
2968 "$P_CLI" \
2969 0
2970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002971run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002972 "$P_SRV key_file=data_files/server5.key \
2973 crt_file=data_files/server5.eku-cs_any.crt" \
2974 "$P_CLI" \
2975 0
2976
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002977run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002978 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002979 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002980 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002981 1
2982
2983# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2984
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002985run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002986 "$O_SRV -key data_files/server5.key \
2987 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002988 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002989 0 \
2990 -C "bad certificate (usage extensions)" \
2991 -C "Processing of the Certificate handshake message failed" \
2992 -c "Ciphersuite is TLS-"
2993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002994run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002995 "$O_SRV -key data_files/server5.key \
2996 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002997 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002998 0 \
2999 -C "bad certificate (usage extensions)" \
3000 -C "Processing of the Certificate handshake message failed" \
3001 -c "Ciphersuite is TLS-"
3002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003003run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003004 "$O_SRV -key data_files/server5.key \
3005 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003006 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003007 0 \
3008 -C "bad certificate (usage extensions)" \
3009 -C "Processing of the Certificate handshake message failed" \
3010 -c "Ciphersuite is TLS-"
3011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003012run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003013 "$O_SRV -key data_files/server5.key \
3014 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003015 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003016 1 \
3017 -c "bad certificate (usage extensions)" \
3018 -c "Processing of the Certificate handshake message failed" \
3019 -C "Ciphersuite is TLS-"
3020
3021# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003023run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003024 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003025 "$O_CLI -key data_files/server5.key \
3026 -cert data_files/server5.eku-cli.crt" \
3027 0 \
3028 -S "bad certificate (usage extensions)" \
3029 -S "Processing of the Certificate handshake message failed"
3030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003031run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003032 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003033 "$O_CLI -key data_files/server5.key \
3034 -cert data_files/server5.eku-srv_cli.crt" \
3035 0 \
3036 -S "bad certificate (usage extensions)" \
3037 -S "Processing of the Certificate handshake message failed"
3038
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003039run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003040 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003041 "$O_CLI -key data_files/server5.key \
3042 -cert data_files/server5.eku-cs_any.crt" \
3043 0 \
3044 -S "bad certificate (usage extensions)" \
3045 -S "Processing of the Certificate handshake message failed"
3046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003047run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003048 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003049 "$O_CLI -key data_files/server5.key \
3050 -cert data_files/server5.eku-cs.crt" \
3051 0 \
3052 -s "bad certificate (usage extensions)" \
3053 -S "Processing of the Certificate handshake message failed"
3054
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003055run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003056 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003057 "$O_CLI -key data_files/server5.key \
3058 -cert data_files/server5.eku-cs.crt" \
3059 1 \
3060 -s "bad certificate (usage extensions)" \
3061 -s "Processing of the Certificate handshake message failed"
3062
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003063# Tests for DHM parameters loading
3064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003065run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003066 "$P_SRV" \
3067 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3068 debug_level=3" \
3069 0 \
3070 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker80e0d462017-10-13 16:51:54 +01003071 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003072
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003073run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003074 "$P_SRV dhm_file=data_files/dhparams.pem" \
3075 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3076 debug_level=3" \
3077 0 \
3078 -c "value of 'DHM: P ' (1024 bits)" \
3079 -c "value of 'DHM: G ' (2 bits)"
3080
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003081# Tests for DHM client-side size checking
3082
3083run_test "DHM size: server default, client default, OK" \
3084 "$P_SRV" \
3085 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3086 debug_level=1" \
3087 0 \
3088 -C "DHM prime too short:"
3089
3090run_test "DHM size: server default, client 2048, OK" \
3091 "$P_SRV" \
3092 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3093 debug_level=1 dhmlen=2048" \
3094 0 \
3095 -C "DHM prime too short:"
3096
3097run_test "DHM size: server 1024, client default, OK" \
3098 "$P_SRV dhm_file=data_files/dhparams.pem" \
3099 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3100 debug_level=1" \
3101 0 \
3102 -C "DHM prime too short:"
3103
3104run_test "DHM size: server 1000, client default, rejected" \
3105 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3106 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3107 debug_level=1" \
3108 1 \
3109 -c "DHM prime too short:"
3110
3111run_test "DHM size: server default, client 2049, rejected" \
3112 "$P_SRV" \
3113 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3114 debug_level=1 dhmlen=2049" \
3115 1 \
3116 -c "DHM prime too short:"
3117
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003118# Tests for PSK callback
3119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003120run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003121 "$P_SRV psk=abc123 psk_identity=foo" \
3122 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3123 psk_identity=foo psk=abc123" \
3124 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003125 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003126 -S "SSL - Unknown identity received" \
3127 -S "SSL - Verification of the message MAC failed"
3128
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003129run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003130 "$P_SRV" \
3131 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3132 psk_identity=foo psk=abc123" \
3133 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003134 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003135 -S "SSL - Unknown identity received" \
3136 -S "SSL - Verification of the message MAC failed"
3137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003138run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003139 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3140 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3141 psk_identity=foo psk=abc123" \
3142 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003143 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003144 -s "SSL - Unknown identity received" \
3145 -S "SSL - Verification of the message MAC failed"
3146
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003147run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003148 "$P_SRV psk_list=abc,dead,def,beef" \
3149 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3150 psk_identity=abc psk=dead" \
3151 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003152 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003153 -S "SSL - Unknown identity received" \
3154 -S "SSL - Verification of the message MAC failed"
3155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003156run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003157 "$P_SRV psk_list=abc,dead,def,beef" \
3158 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3159 psk_identity=def psk=beef" \
3160 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003161 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003162 -S "SSL - Unknown identity received" \
3163 -S "SSL - Verification of the message MAC failed"
3164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003165run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003166 "$P_SRV psk_list=abc,dead,def,beef" \
3167 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3168 psk_identity=ghi psk=beef" \
3169 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003170 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003171 -s "SSL - Unknown identity received" \
3172 -S "SSL - Verification of the message MAC failed"
3173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003174run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003175 "$P_SRV psk_list=abc,dead,def,beef" \
3176 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3177 psk_identity=abc psk=beef" \
3178 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003179 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003180 -S "SSL - Unknown identity received" \
3181 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003182
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003183# Tests for ciphersuites per version
3184
Janos Follath542ee5d2016-03-07 15:57:05 +00003185requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003186run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003187 "$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 +02003188 "$P_CLI force_version=ssl3" \
3189 0 \
3190 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003192run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003193 "$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 +01003194 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003195 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003196 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003198run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003199 "$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 +02003200 "$P_CLI force_version=tls1_1" \
3201 0 \
3202 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3203
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003204run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003205 "$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 +02003206 "$P_CLI force_version=tls1_2" \
3207 0 \
3208 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3209
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003210# Test for ClientHello without extensions
3211
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003212requires_gnutls
Gilles Peskine7344e1b2017-05-12 13:16:40 +02003213run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003214 "$P_SRV debug_level=3" \
3215 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3216 0 \
3217 -s "dumping 'client hello extensions' (0 bytes)"
3218
Gilles Peskine7344e1b2017-05-12 13:16:40 +02003219requires_gnutls
3220run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3221 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3222 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3223 0 \
3224 -s "dumping 'client hello extensions' (0 bytes)"
3225
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003226# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003227
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003228run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003229 "$P_SRV" \
3230 "$P_CLI request_size=100" \
3231 0 \
3232 -s "Read from client: 100 bytes read$"
3233
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003234run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003235 "$P_SRV" \
3236 "$P_CLI request_size=500" \
3237 0 \
3238 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003239
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003240# Tests for small packets
3241
Janos Follath542ee5d2016-03-07 15:57:05 +00003242requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003243run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003244 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003245 "$P_CLI request_size=1 force_version=ssl3 \
3246 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3247 0 \
3248 -s "Read from client: 1 bytes read"
3249
Janos Follath542ee5d2016-03-07 15:57:05 +00003250requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003251run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003252 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003253 "$P_CLI request_size=1 force_version=ssl3 \
3254 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3255 0 \
3256 -s "Read from client: 1 bytes read"
3257
3258run_test "Small packet TLS 1.0 BlockCipher" \
3259 "$P_SRV" \
3260 "$P_CLI request_size=1 force_version=tls1 \
3261 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3262 0 \
3263 -s "Read from client: 1 bytes read"
3264
Hanno Becker7aae46c2017-11-10 08:59:04 +00003265run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003266 "$P_SRV" \
3267 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3268 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3269 0 \
3270 -s "Read from client: 1 bytes read"
3271
Hanno Beckera83fafa2017-11-10 08:42:54 +00003272requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003273run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003274 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003275 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003276 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003277 0 \
3278 -s "Read from client: 1 bytes read"
3279
Hanno Beckera83fafa2017-11-10 08:42:54 +00003280requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003281run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003282 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003283 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003284 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003285 0 \
3286 -s "Read from client: 1 bytes read"
3287
3288run_test "Small packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003289 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003290 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003291 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3292 0 \
3293 -s "Read from client: 1 bytes read"
3294
3295run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3296 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3297 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003298 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003299 0 \
3300 -s "Read from client: 1 bytes read"
3301
3302requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3303run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003304 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003305 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003306 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003307 0 \
3308 -s "Read from client: 1 bytes read"
3309
Hanno Becker7aae46c2017-11-10 08:59:04 +00003310requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3311run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003312 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3313 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3314 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003315 0 \
3316 -s "Read from client: 1 bytes read"
3317
3318run_test "Small packet TLS 1.1 BlockCipher" \
3319 "$P_SRV" \
3320 "$P_CLI request_size=1 force_version=tls1_1 \
3321 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3322 0 \
3323 -s "Read from client: 1 bytes read"
3324
Hanno Becker7aae46c2017-11-10 08:59:04 +00003325run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003326 "$P_SRV" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003327 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003328 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003329 0 \
3330 -s "Read from client: 1 bytes read"
3331
3332requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3333run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003334 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003335 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003336 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003337 0 \
3338 -s "Read from client: 1 bytes read"
3339
3340requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3341run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003342 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003343 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003344 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003345 0 \
3346 -s "Read from client: 1 bytes read"
3347
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003348run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003349 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003350 "$P_CLI request_size=1 force_version=tls1_1 \
3351 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3352 0 \
3353 -s "Read from client: 1 bytes read"
3354
Hanno Becker7aae46c2017-11-10 08:59:04 +00003355run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3356 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003357 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003358 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003359 0 \
3360 -s "Read from client: 1 bytes read"
3361
Hanno Becker7aae46c2017-11-10 08:59:04 +00003362requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3363run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003364 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003365 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003366 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003367 0 \
3368 -s "Read from client: 1 bytes read"
3369
Hanno Beckera83fafa2017-11-10 08:42:54 +00003370requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003371run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003372 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003373 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003374 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003375 0 \
3376 -s "Read from client: 1 bytes read"
3377
3378run_test "Small packet TLS 1.2 BlockCipher" \
3379 "$P_SRV" \
3380 "$P_CLI request_size=1 force_version=tls1_2 \
3381 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3382 0 \
3383 -s "Read from client: 1 bytes read"
3384
Hanno Becker7aae46c2017-11-10 08:59:04 +00003385run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003386 "$P_SRV" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003387 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003388 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003389 0 \
3390 -s "Read from client: 1 bytes read"
3391
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003392run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3393 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003394 "$P_CLI request_size=1 force_version=tls1_2 \
3395 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003396 0 \
3397 -s "Read from client: 1 bytes read"
3398
Hanno Beckera83fafa2017-11-10 08:42:54 +00003399requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003400run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003401 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003402 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003403 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003404 0 \
3405 -s "Read from client: 1 bytes read"
3406
Hanno Becker7aae46c2017-11-10 08:59:04 +00003407requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3408run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003409 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003410 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003411 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003412 0 \
3413 -s "Read from client: 1 bytes read"
3414
3415run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003416 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003417 "$P_CLI request_size=1 force_version=tls1_2 \
3418 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3419 0 \
3420 -s "Read from client: 1 bytes read"
3421
Hanno Becker7aae46c2017-11-10 08:59:04 +00003422run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003423 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003424 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003425 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003426 0 \
3427 -s "Read from client: 1 bytes read"
3428
Hanno Beckera83fafa2017-11-10 08:42:54 +00003429requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003430run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003431 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003432 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003433 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003434 0 \
3435 -s "Read from client: 1 bytes read"
3436
Hanno Becker7aae46c2017-11-10 08:59:04 +00003437requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3438run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003439 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003440 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003441 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003442 0 \
3443 -s "Read from client: 1 bytes read"
3444
3445run_test "Small packet TLS 1.2 AEAD" \
3446 "$P_SRV" \
3447 "$P_CLI request_size=1 force_version=tls1_2 \
3448 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3449 0 \
3450 -s "Read from client: 1 bytes read"
3451
3452run_test "Small packet TLS 1.2 AEAD shorter tag" \
3453 "$P_SRV" \
3454 "$P_CLI request_size=1 force_version=tls1_2 \
3455 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3456 0 \
3457 -s "Read from client: 1 bytes read"
3458
Hanno Becker461cb812017-11-10 08:59:18 +00003459# Tests for small packets in DTLS
3460
3461requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3462run_test "Small packet DTLS 1.0" \
3463 "$P_SRV dtls=1 force_version=dtls1" \
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.0, without EtM" \
3471 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3472 "$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.0, truncated hmac" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003480 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3481 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Becker461cb812017-11-10 08:59:18 +00003482 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3483 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.0, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003489 "$P_SRV dtls=1 force_version=dtls1 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
3495requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3496run_test "Small packet DTLS 1.2" \
3497 "$P_SRV dtls=1 force_version=dtls1_2" \
3498 "$P_CLI dtls=1 request_size=1 \
3499 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3500 0 \
3501 -s "Read from client: 1 bytes read"
3502
3503requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3504run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003505 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Becker461cb812017-11-10 08:59:18 +00003506 "$P_CLI dtls=1 request_size=1 \
3507 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3508 0 \
3509 -s "Read from client: 1 bytes read"
3510
3511requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3512requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3513run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003514 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Becker461cb812017-11-10 08:59:18 +00003515 "$P_CLI dtls=1 request_size=1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003516 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker461cb812017-11-10 08:59:18 +00003517 0 \
3518 -s "Read from client: 1 bytes read"
3519
3520requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3521requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3522run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003523 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Becker461cb812017-11-10 08:59:18 +00003524 "$P_CLI dtls=1 request_size=1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003525 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Becker461cb812017-11-10 08:59:18 +00003526 0 \
3527 -s "Read from client: 1 bytes read"
3528
Janos Follathb700c462016-05-06 13:48:23 +01003529# A test for extensions in SSLv3
3530
3531requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3532run_test "SSLv3 with extensions, server side" \
3533 "$P_SRV min_version=ssl3 debug_level=3" \
3534 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3535 0 \
3536 -S "dumping 'client hello extensions'" \
3537 -S "server hello, total extension length:"
3538
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003539# Test for large packets
3540
Janos Follath542ee5d2016-03-07 15:57:05 +00003541requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003542run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003543 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003544 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003545 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3546 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003547 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003548 -s "Read from client: 16384 bytes read"
3549
Janos Follath542ee5d2016-03-07 15:57:05 +00003550requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003551run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003552 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003553 "$P_CLI request_size=16384 force_version=ssl3 \
3554 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3555 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003556 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003557 -s "Read from client: 16384 bytes read"
3558
3559run_test "Large packet TLS 1.0 BlockCipher" \
3560 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003561 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003562 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3563 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003564 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003565 -s "Read from client: 16384 bytes read"
3566
Hanno Becker0b9d9132017-11-10 09:16:28 +00003567run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003568 "$P_SRV" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003569 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3570 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3571 0 \
3572 -s "Read from client: 16384 bytes read"
3573
Hanno Beckera83fafa2017-11-10 08:42:54 +00003574requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003575run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003576 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003577 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003578 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003579 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003580 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003581 -s "Read from client: 16384 bytes read"
3582
Hanno Beckera83fafa2017-11-10 08:42:54 +00003583requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003584run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003585 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003586 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003587 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003588 0 \
3589 -s "Read from client: 16384 bytes read"
3590
3591run_test "Large packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003592 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003593 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003594 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3595 0 \
3596 -s "Read from client: 16384 bytes read"
3597
3598run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
3599 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3600 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003601 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003602 0 \
3603 -s "Read from client: 16384 bytes read"
3604
3605requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3606run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003607 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003608 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003609 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003610 0 \
3611 -s "Read from client: 16384 bytes read"
3612
Hanno Becker0b9d9132017-11-10 09:16:28 +00003613requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3614run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003615 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003616 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003617 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003618 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003619 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003620 -s "Read from client: 16384 bytes read"
3621
3622run_test "Large packet TLS 1.1 BlockCipher" \
3623 "$P_SRV" \
3624 "$P_CLI request_size=16384 force_version=tls1_1 \
3625 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3626 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003627 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003628 -s "Read from client: 16384 bytes read"
3629
Hanno Becker0b9d9132017-11-10 09:16:28 +00003630run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
3631 "$P_SRV" \
3632 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
3633 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003634 0 \
3635 -s "Read from client: 16384 bytes read"
3636
Hanno Beckera83fafa2017-11-10 08:42:54 +00003637requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003638run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003639 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003640 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003641 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003642 0 \
3643 -s "Read from client: 16384 bytes read"
3644
Hanno Beckera83fafa2017-11-10 08:42:54 +00003645requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003646run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003647 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003648 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003649 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003650 0 \
3651 -s "Read from client: 16384 bytes read"
3652
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003653run_test "Large packet TLS 1.1 StreamCipher" \
3654 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3655 "$P_CLI request_size=16384 force_version=tls1_1 \
3656 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3657 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003658 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003659 -s "Read from client: 16384 bytes read"
3660
Hanno Becker0b9d9132017-11-10 09:16:28 +00003661run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
3662 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003663 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003664 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003665 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003666 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003667 -s "Read from client: 16384 bytes read"
3668
Hanno Becker0b9d9132017-11-10 09:16:28 +00003669requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3670run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003671 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003672 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003673 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003674 0 \
3675 -s "Read from client: 16384 bytes read"
3676
Hanno Becker0b9d9132017-11-10 09:16:28 +00003677requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3678run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003679 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003680 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003681 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003682 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003683 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003684 -s "Read from client: 16384 bytes read"
3685
3686run_test "Large packet TLS 1.2 BlockCipher" \
3687 "$P_SRV" \
3688 "$P_CLI request_size=16384 force_version=tls1_2 \
3689 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3690 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003691 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003692 -s "Read from client: 16384 bytes read"
3693
Hanno Becker0b9d9132017-11-10 09:16:28 +00003694run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
3695 "$P_SRV" \
3696 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
3697 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3698 0 \
3699 -s "Read from client: 16384 bytes read"
3700
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003701run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3702 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003703 "$P_CLI request_size=16384 force_version=tls1_2 \
3704 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003705 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003706 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003707 -s "Read from client: 16384 bytes read"
3708
Hanno Beckera83fafa2017-11-10 08:42:54 +00003709requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003710run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003711 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003712 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003713 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003714 0 \
3715 -s "Read from client: 16384 bytes read"
3716
Hanno Becker0b9d9132017-11-10 09:16:28 +00003717requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3718run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003719 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003720 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003721 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003722 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003723 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003724 -s "Read from client: 16384 bytes read"
3725
3726run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003727 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003728 "$P_CLI request_size=16384 force_version=tls1_2 \
3729 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3730 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003731 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003732 -s "Read from client: 16384 bytes read"
3733
Hanno Becker0b9d9132017-11-10 09:16:28 +00003734run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003735 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003736 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003737 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
3738 0 \
3739 -s "Read from client: 16384 bytes read"
3740
Hanno Beckera83fafa2017-11-10 08:42:54 +00003741requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003742run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003743 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003744 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003745 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003746 0 \
3747 -s "Read from client: 16384 bytes read"
3748
Hanno Becker0b9d9132017-11-10 09:16:28 +00003749requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3750run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003751 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003752 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003753 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003754 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003755 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003756 -s "Read from client: 16384 bytes read"
3757
3758run_test "Large packet TLS 1.2 AEAD" \
3759 "$P_SRV" \
3760 "$P_CLI request_size=16384 force_version=tls1_2 \
3761 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3762 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003763 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003764 -s "Read from client: 16384 bytes read"
3765
3766run_test "Large packet TLS 1.2 AEAD shorter tag" \
3767 "$P_SRV" \
3768 "$P_CLI request_size=16384 force_version=tls1_2 \
3769 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3770 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003771 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003772 -s "Read from client: 16384 bytes read"
3773
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003774# Tests for DTLS HelloVerifyRequest
3775
3776run_test "DTLS cookie: enabled" \
3777 "$P_SRV dtls=1 debug_level=2" \
3778 "$P_CLI dtls=1 debug_level=2" \
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
3787run_test "DTLS cookie: disabled" \
3788 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3789 "$P_CLI dtls=1 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é-Gonnard0eb6cab2014-07-23 20:17:47 +02003796 -S "SSL - The requested feature is not available"
3797
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003798run_test "DTLS cookie: default (failing)" \
3799 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3800 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3801 1 \
3802 -s "cookie verification failed" \
3803 -S "cookie verification passed" \
3804 -S "cookie verification skipped" \
3805 -C "received hello verify request" \
3806 -S "hello verification requested" \
3807 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003808
3809requires_ipv6
3810run_test "DTLS cookie: enabled, IPv6" \
3811 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3812 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3813 0 \
3814 -s "cookie verification failed" \
3815 -s "cookie verification passed" \
3816 -S "cookie verification skipped" \
3817 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003818 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003819 -S "SSL - The requested feature is not available"
3820
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003821run_test "DTLS cookie: enabled, nbio" \
3822 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3823 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3824 0 \
3825 -s "cookie verification failed" \
3826 -s "cookie verification passed" \
3827 -S "cookie verification skipped" \
3828 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003829 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003830 -S "SSL - The requested feature is not available"
3831
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003832# Tests for client reconnecting from the same port with DTLS
3833
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003834not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003835run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003836 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3837 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003838 0 \
3839 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003840 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003841 -S "Client initiated reconnection from same port"
3842
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003843not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003844run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003845 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3846 "$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 +02003847 0 \
3848 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003849 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003850 -s "Client initiated reconnection from same port"
3851
Paul Bakker3b224ff2016-05-13 10:33:25 +01003852not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3853run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003854 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3855 "$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 +02003856 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003857 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003858 -s "Client initiated reconnection from same port"
3859
Paul Bakker3b224ff2016-05-13 10:33:25 +01003860only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3861run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3862 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3863 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3864 0 \
3865 -S "The operation timed out" \
3866 -s "Client initiated reconnection from same port"
3867
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003868run_test "DTLS client reconnect from same port: no cookies" \
3869 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003870 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3871 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003872 -s "The operation timed out" \
3873 -S "Client initiated reconnection from same port"
3874
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003875# Tests for various cases of client authentication with DTLS
3876# (focused on handshake flows and message parsing)
3877
3878run_test "DTLS client auth: required" \
3879 "$P_SRV dtls=1 auth_mode=required" \
3880 "$P_CLI dtls=1" \
3881 0 \
3882 -s "Verifying peer X.509 certificate... ok"
3883
3884run_test "DTLS client auth: optional, client has no cert" \
3885 "$P_SRV dtls=1 auth_mode=optional" \
3886 "$P_CLI dtls=1 crt_file=none key_file=none" \
3887 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003888 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003889
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003890run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003891 "$P_SRV dtls=1 auth_mode=none" \
3892 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3893 0 \
3894 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003895 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003896
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003897run_test "DTLS wrong PSK: badmac alert" \
3898 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3899 "$P_CLI dtls=1 psk=abc124" \
3900 1 \
3901 -s "SSL - Verification of the message MAC failed" \
3902 -c "SSL - A fatal alert message was received from our peer"
3903
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003904# Tests for receiving fragmented handshake messages with DTLS
3905
3906requires_gnutls
3907run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3908 "$G_SRV -u --mtu 2048 -a" \
3909 "$P_CLI dtls=1 debug_level=2" \
3910 0 \
3911 -C "found fragmented DTLS handshake message" \
3912 -C "error"
3913
3914requires_gnutls
3915run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3916 "$G_SRV -u --mtu 512" \
3917 "$P_CLI dtls=1 debug_level=2" \
3918 0 \
3919 -c "found fragmented DTLS handshake message" \
3920 -C "error"
3921
3922requires_gnutls
3923run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3924 "$G_SRV -u --mtu 128" \
3925 "$P_CLI dtls=1 debug_level=2" \
3926 0 \
3927 -c "found fragmented DTLS handshake message" \
3928 -C "error"
3929
3930requires_gnutls
3931run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3932 "$G_SRV -u --mtu 128" \
3933 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3934 0 \
3935 -c "found fragmented DTLS handshake message" \
3936 -C "error"
3937
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003938requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01003939requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003940run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3941 "$G_SRV -u --mtu 256" \
3942 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3943 0 \
3944 -c "found fragmented DTLS handshake message" \
3945 -c "client hello, adding renegotiation extension" \
3946 -c "found renegotiation extension" \
3947 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003948 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003949 -C "error" \
3950 -s "Extra-header:"
3951
3952requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01003953requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003954run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3955 "$G_SRV -u --mtu 256" \
3956 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3957 0 \
3958 -c "found fragmented DTLS handshake message" \
3959 -c "client hello, adding renegotiation extension" \
3960 -c "found renegotiation extension" \
3961 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003962 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003963 -C "error" \
3964 -s "Extra-header:"
3965
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003966run_test "DTLS reassembly: no fragmentation (openssl server)" \
3967 "$O_SRV -dtls1 -mtu 2048" \
3968 "$P_CLI dtls=1 debug_level=2" \
3969 0 \
3970 -C "found fragmented DTLS handshake message" \
3971 -C "error"
3972
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003973run_test "DTLS reassembly: some fragmentation (openssl server)" \
3974 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003975 "$P_CLI dtls=1 debug_level=2" \
3976 0 \
3977 -c "found fragmented DTLS handshake message" \
3978 -C "error"
3979
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003980run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003981 "$O_SRV -dtls1 -mtu 256" \
3982 "$P_CLI dtls=1 debug_level=2" \
3983 0 \
3984 -c "found fragmented DTLS handshake message" \
3985 -C "error"
3986
3987run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3988 "$O_SRV -dtls1 -mtu 256" \
3989 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3990 0 \
3991 -c "found fragmented DTLS handshake message" \
3992 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003993
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003994# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003995
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003996not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003997run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003998 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003999 "$P_SRV dtls=1 debug_level=2" \
4000 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004001 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004002 -C "replayed record" \
4003 -S "replayed record" \
4004 -C "record from another epoch" \
4005 -S "record from another epoch" \
4006 -C "discarding invalid record" \
4007 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004008 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004009 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004010 -c "HTTP/1.0 200 OK"
4011
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004012not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004013run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004014 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004015 "$P_SRV dtls=1 debug_level=2" \
4016 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004017 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004018 -c "replayed record" \
4019 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004020 -c "discarding invalid record" \
4021 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004022 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004023 -s "Extra-header:" \
4024 -c "HTTP/1.0 200 OK"
4025
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004026run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4027 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004028 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4029 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004030 0 \
4031 -c "replayed record" \
4032 -S "replayed record" \
4033 -c "discarding invalid record" \
4034 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004035 -c "resend" \
4036 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004037 -s "Extra-header:" \
4038 -c "HTTP/1.0 200 OK"
4039
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004040run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004041 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004042 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004043 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004044 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004045 -c "discarding invalid record (mac)" \
4046 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004047 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004048 -c "HTTP/1.0 200 OK" \
4049 -S "too many records with bad MAC" \
4050 -S "Verification of the message MAC failed"
4051
4052run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4053 -p "$P_PXY bad_ad=1" \
4054 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4055 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4056 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004057 -C "discarding invalid record (mac)" \
4058 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004059 -S "Extra-header:" \
4060 -C "HTTP/1.0 200 OK" \
4061 -s "too many records with bad MAC" \
4062 -s "Verification of the message MAC failed"
4063
4064run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4065 -p "$P_PXY bad_ad=1" \
4066 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4067 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4068 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004069 -c "discarding invalid record (mac)" \
4070 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004071 -s "Extra-header:" \
4072 -c "HTTP/1.0 200 OK" \
4073 -S "too many records with bad MAC" \
4074 -S "Verification of the message MAC failed"
4075
4076run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4077 -p "$P_PXY bad_ad=1" \
4078 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4079 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4080 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004081 -c "discarding invalid record (mac)" \
4082 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004083 -s "Extra-header:" \
4084 -c "HTTP/1.0 200 OK" \
4085 -s "too many records with bad MAC" \
4086 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004087
4088run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004089 -p "$P_PXY delay_ccs=1" \
4090 "$P_SRV dtls=1 debug_level=1" \
4091 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004092 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004093 -c "record from another epoch" \
4094 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004095 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004096 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004097 -s "Extra-header:" \
4098 -c "HTTP/1.0 200 OK"
4099
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004100# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004101
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004102needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004103run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004104 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004105 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4106 psk=abc123" \
4107 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004108 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4109 0 \
4110 -s "Extra-header:" \
4111 -c "HTTP/1.0 200 OK"
4112
4113needs_more_time 2
4114run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4115 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004116 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4117 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004118 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4119 0 \
4120 -s "Extra-header:" \
4121 -c "HTTP/1.0 200 OK"
4122
4123needs_more_time 2
4124run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4125 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004126 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4127 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004128 0 \
4129 -s "Extra-header:" \
4130 -c "HTTP/1.0 200 OK"
4131
4132needs_more_time 2
4133run_test "DTLS proxy: 3d, FS, client auth" \
4134 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004135 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4136 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004137 0 \
4138 -s "Extra-header:" \
4139 -c "HTTP/1.0 200 OK"
4140
4141needs_more_time 2
4142run_test "DTLS proxy: 3d, FS, ticket" \
4143 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004144 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4145 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004146 0 \
4147 -s "Extra-header:" \
4148 -c "HTTP/1.0 200 OK"
4149
4150needs_more_time 2
4151run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
4152 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004153 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
4154 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004155 0 \
4156 -s "Extra-header:" \
4157 -c "HTTP/1.0 200 OK"
4158
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004159needs_more_time 2
4160run_test "DTLS proxy: 3d, max handshake, nbio" \
4161 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004162 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4163 auth_mode=required" \
4164 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004165 0 \
4166 -s "Extra-header:" \
4167 -c "HTTP/1.0 200 OK"
4168
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004169needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004170run_test "DTLS proxy: 3d, min handshake, resumption" \
4171 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4172 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4173 psk=abc123 debug_level=3" \
4174 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4175 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4176 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4177 0 \
4178 -s "a session has been resumed" \
4179 -c "a session has been resumed" \
4180 -s "Extra-header:" \
4181 -c "HTTP/1.0 200 OK"
4182
4183needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004184run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4185 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4186 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4187 psk=abc123 debug_level=3 nbio=2" \
4188 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4189 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4190 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4191 0 \
4192 -s "a session has been resumed" \
4193 -c "a session has been resumed" \
4194 -s "Extra-header:" \
4195 -c "HTTP/1.0 200 OK"
4196
4197needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004198requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004199run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004200 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004201 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4202 psk=abc123 renegotiation=1 debug_level=2" \
4203 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4204 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004205 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4206 0 \
4207 -c "=> renegotiate" \
4208 -s "=> renegotiate" \
4209 -s "Extra-header:" \
4210 -c "HTTP/1.0 200 OK"
4211
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004212needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004213requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004214run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4215 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004216 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4217 psk=abc123 renegotiation=1 debug_level=2" \
4218 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4219 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004220 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4221 0 \
4222 -c "=> renegotiate" \
4223 -s "=> renegotiate" \
4224 -s "Extra-header:" \
4225 -c "HTTP/1.0 200 OK"
4226
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004227needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004228requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004229run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004230 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004231 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004232 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004233 debug_level=2" \
4234 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004235 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004236 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4237 0 \
4238 -c "=> renegotiate" \
4239 -s "=> renegotiate" \
4240 -s "Extra-header:" \
4241 -c "HTTP/1.0 200 OK"
4242
4243needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004244requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004245run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004246 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004247 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004248 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004249 debug_level=2 nbio=2" \
4250 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004251 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004252 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4253 0 \
4254 -c "=> renegotiate" \
4255 -s "=> renegotiate" \
4256 -s "Extra-header:" \
4257 -c "HTTP/1.0 200 OK"
4258
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02004259needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004260not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004261run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004262 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4263 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004264 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004265 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004266 -c "HTTP/1.0 200 OK"
4267
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004268needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004269not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004270run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4271 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4272 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004273 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004274 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004275 -c "HTTP/1.0 200 OK"
4276
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004277needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004278not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004279run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4280 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4281 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004282 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004283 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004284 -c "HTTP/1.0 200 OK"
4285
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004286requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02004287needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004288not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004289run_test "DTLS proxy: 3d, gnutls server" \
4290 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4291 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004292 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004293 0 \
4294 -s "Extra-header:" \
4295 -c "Extra-header:"
4296
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004297requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004298needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004299not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004300run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4301 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4302 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004303 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004304 0 \
4305 -s "Extra-header:" \
4306 -c "Extra-header:"
4307
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004308requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004309needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004310not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004311run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4312 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4313 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004314 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004315 0 \
4316 -s "Extra-header:" \
4317 -c "Extra-header:"
4318
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004319# Final report
4320
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004321echo "------------------------------------------------------------------------"
4322
4323if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004324 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004325else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004326 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004327fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004328PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004329echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004330
4331exit $FAILS