blob: b126d677fd079af33124590c88d98dd827540520 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02009# Assumes a build with default options.
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010010
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020016: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010017: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020018: ${GNUTLS_CLI:=gnutls-cli}
19: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskine39e29812017-05-16 17:53:03 +020020: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020022O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010023O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020024G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010025G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskine39e29812017-05-16 17:53:03 +020026TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010027
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028TESTS=0
29FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020030SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010031
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000032CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020033
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010035FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020036EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010037
38print_usage() {
39 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010040 printf " -h|--help\tPrint this help.\n"
41 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
42 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
43 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Gilles Peskinebb4aaf12017-11-30 15:56:20 +010044 printf " --seed\tInteger seed value to use for this test run (default: random)\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045}
46
47get_options() {
48 while [ $# -gt 0 ]; do
49 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010050 -f|--filter)
51 shift; FILTER=$1
52 ;;
53 -e|--exclude)
54 shift; EXCLUDE=$1
55 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010056 -m|--memcheck)
57 MEMCHECK=1
58 ;;
Gilles Peskinebb4aaf12017-11-30 15:56:20 +010059 --seed)
60 shift; SEED="$1"
61 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062 -h|--help)
63 print_usage
64 exit 0
65 ;;
66 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020067 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010068 print_usage
69 exit 1
70 ;;
71 esac
72 shift
73 done
74}
75
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010076# skip next test if the flag is not enabled in config.h
77requires_config_enabled() {
78 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +020083# skip next test if the flag is enabled in config.h
84requires_config_disabled() {
85 if grep "^#define $1" $CONFIG_H > /dev/null; then
86 SKIP_NEXT="YES"
87 fi
88}
89
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020090# skip next test if OpenSSL doesn't support FALLBACK_SCSV
91requires_openssl_with_fallback_scsv() {
92 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
93 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
94 then
95 OPENSSL_HAS_FBSCSV="YES"
96 else
97 OPENSSL_HAS_FBSCSV="NO"
98 fi
99 fi
100 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
101 SKIP_NEXT="YES"
102 fi
103}
104
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200105# skip next test if GnuTLS isn't available
106requires_gnutls() {
107 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200108 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200109 GNUTLS_AVAILABLE="YES"
110 else
111 GNUTLS_AVAILABLE="NO"
112 fi
113 fi
114 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
115 SKIP_NEXT="YES"
116 fi
117}
118
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200119# skip next test if IPv6 isn't available on this host
120requires_ipv6() {
121 if [ -z "${HAS_IPV6:-}" ]; then
122 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
123 SRV_PID=$!
124 sleep 1
125 kill $SRV_PID >/dev/null 2>&1
126 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
127 HAS_IPV6="NO"
128 else
129 HAS_IPV6="YES"
130 fi
131 rm -r $SRV_OUT
132 fi
133
134 if [ "$HAS_IPV6" = "NO" ]; then
135 SKIP_NEXT="YES"
136 fi
137}
138
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200139# skip the next test if valgrind is in use
140not_with_valgrind() {
141 if [ "$MEMCHECK" -gt 0 ]; then
142 SKIP_NEXT="YES"
143 fi
144}
145
Paul Bakker3b224ff2016-05-13 10:33:25 +0100146# skip the next test if valgrind is NOT in use
147only_with_valgrind() {
148 if [ "$MEMCHECK" -eq 0 ]; then
149 SKIP_NEXT="YES"
150 fi
151}
152
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200153# multiply the client timeout delay by the given factor for the next test
154needs_more_time() {
155 CLI_DELAY_FACTOR=$1
156}
157
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100158# print_name <name>
159print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100160 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200161 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100162 for i in `seq 1 $LEN`; do printf '.'; done
163 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100164
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200165 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100166}
167
168# fail <message>
169fail() {
170 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100171 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100172
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200173 mv $SRV_OUT o-srv-${TESTS}.log
174 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200175 if [ -n "$PXY_CMD" ]; then
176 mv $PXY_OUT o-pxy-${TESTS}.log
177 fi
178 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100179
Azim Khan341e3782018-03-29 11:04:20 +0100180 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot -o "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200181 echo " ! server output:"
182 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200183 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200184 echo " ! client output:"
185 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200186 if [ -n "$PXY_CMD" ]; then
187 echo " ! ========================================================"
188 echo " ! proxy output:"
189 cat o-pxy-${TESTS}.log
190 fi
191 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200192 fi
193
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200194 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100195}
196
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100197# is_polar <cmd_line>
198is_polar() {
199 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
200}
201
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200202# openssl s_server doesn't have -www with DTLS
203check_osrv_dtls() {
204 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
205 NEEDS_INPUT=1
206 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
207 else
208 NEEDS_INPUT=0
209 fi
210}
211
212# provide input to commands that need it
213provide_input() {
214 if [ $NEEDS_INPUT -eq 0 ]; then
215 return
216 fi
217
218 while true; do
219 echo "HTTP/1.0 200 OK"
220 sleep 1
221 done
222}
223
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100224# has_mem_err <log_file_name>
225has_mem_err() {
226 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
227 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
228 then
229 return 1 # false: does not have errors
230 else
231 return 0 # true: has errors
232 fi
233}
234
Gilles Peskine684a5172017-12-14 18:58:42 +0100235# Wait for process $2 to be listening on port $1
236if type lsof >/dev/null 2>/dev/null; then
237 wait_server_start() {
238 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200239 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine684a5172017-12-14 18:58:42 +0100240 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200241 else
Gilles Peskine684a5172017-12-14 18:58:42 +0100242 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200243 fi
Gilles Peskine684a5172017-12-14 18:58:42 +0100244 # Make a tight loop, server normally takes less than 1s to start.
245 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
246 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
247 echo "SERVERSTART TIMEOUT"
248 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
249 break
250 fi
251 # Linux and *BSD support decimal arguments to sleep. On other
252 # OSes this may be a tight loop.
253 sleep 0.1 2>/dev/null || true
254 done
255 }
256else
Gilles Peskine784f41c2018-01-08 12:38:15 +0100257 echo "Warning: lsof not available, wait_server_start = sleep $START_DELAY"
Gilles Peskine684a5172017-12-14 18:58:42 +0100258 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200259 sleep "$START_DELAY"
Gilles Peskine684a5172017-12-14 18:58:42 +0100260 }
261fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200262
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200263# wait for client to terminate and set CLI_EXIT
264# must be called right after starting the client
265wait_client_done() {
266 CLI_PID=$!
267
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200268 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
269 CLI_DELAY_FACTOR=1
270
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200271 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200272 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200273
274 wait $CLI_PID
275 CLI_EXIT=$?
276
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200277 kill $DOG_PID >/dev/null 2>&1
278 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200279
280 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
281}
282
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200283# check if the given command uses dtls and sets global variable DTLS
284detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200285 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200286 DTLS=1
287 else
288 DTLS=0
289 fi
290}
291
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200292# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100293# Options: -s pattern pattern that must be present in server output
294# -c pattern pattern that must be present in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100295# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100296# -S pattern pattern that must be absent in server output
297# -C pattern pattern that must be absent in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100298# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100299run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100300 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200301 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100302
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100303 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
304 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200305 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100306 return
307 fi
308
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100309 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100310
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200311 # should we skip?
312 if [ "X$SKIP_NEXT" = "XYES" ]; then
313 SKIP_NEXT="NO"
314 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200315 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200316 return
317 fi
318
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200319 # does this test use a proxy?
320 if [ "X$1" = "X-p" ]; then
321 PXY_CMD="$2"
322 shift 2
323 else
324 PXY_CMD=""
325 fi
326
327 # get commands and client output
328 SRV_CMD="$1"
329 CLI_CMD="$2"
330 CLI_EXPECT="$3"
331 shift 3
332
333 # fix client port
334 if [ -n "$PXY_CMD" ]; then
335 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
336 else
337 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
338 fi
339
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200340 # update DTLS variable
341 detect_dtls "$SRV_CMD"
342
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100343 # prepend valgrind to our commands if active
344 if [ "$MEMCHECK" -gt 0 ]; then
345 if is_polar "$SRV_CMD"; then
346 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
347 fi
348 if is_polar "$CLI_CMD"; then
349 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
350 fi
351 fi
352
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200353 TIMES_LEFT=2
354 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200355 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200356
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200357 # run the commands
358 if [ -n "$PXY_CMD" ]; then
359 echo "$PXY_CMD" > $PXY_OUT
360 $PXY_CMD >> $PXY_OUT 2>&1 &
361 PXY_PID=$!
362 # assume proxy starts faster than server
363 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200364
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200365 check_osrv_dtls
366 echo "$SRV_CMD" > $SRV_OUT
367 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
368 SRV_PID=$!
Gilles Peskine684a5172017-12-14 18:58:42 +0100369 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200370
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200371 echo "$CLI_CMD" > $CLI_OUT
372 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
373 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100374
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200375 # terminate the server (and the proxy)
376 kill $SRV_PID
377 wait $SRV_PID
378 if [ -n "$PXY_CMD" ]; then
379 kill $PXY_PID >/dev/null 2>&1
380 wait $PXY_PID
381 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100382
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200383 # retry only on timeouts
384 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
385 printf "RETRY "
386 else
387 TIMES_LEFT=0
388 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200389 done
390
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100391 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200392 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100393 # expected client exit to incorrectly succeed in case of catastrophic
394 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100395 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200396 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100397 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100398 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100399 return
400 fi
401 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100402 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200403 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100404 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100405 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100406 return
407 fi
408 fi
409
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100410 # check server exit code
411 if [ $? != 0 ]; then
412 fail "server fail"
413 return
414 fi
415
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100416 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100417 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
418 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100419 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200420 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100421 return
422 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100423
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100424 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200425 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100426 while [ $# -gt 0 ]
427 do
428 case $1 in
429 "-s")
Janos Follath6d3e3382016-09-07 15:48:48 +0100430 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
431 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100432 return
433 fi
434 ;;
435
436 "-c")
Janos Follath6d3e3382016-09-07 15:48:48 +0100437 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
438 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100439 return
440 fi
441 ;;
442
443 "-S")
Janos Follath6d3e3382016-09-07 15:48:48 +0100444 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
445 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100446 return
447 fi
448 ;;
449
450 "-C")
Janos Follath6d3e3382016-09-07 15:48:48 +0100451 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
452 fail "pattern '$2' MUST NOT be present in the Client output"
453 return
454 fi
455 ;;
456
457 # The filtering in the following two options (-u and -U) do the following
458 # - ignore valgrind output
459 # - filter out everything but lines right after the pattern occurances
460 # - keep one of each non-unique line
461 # - count how many lines remain
462 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
463 # if there were no duplicates.
464 "-U")
465 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
466 fail "lines following pattern '$2' must be unique in Server output"
467 return
468 fi
469 ;;
470
471 "-u")
472 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
473 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100474 return
475 fi
476 ;;
477
478 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200479 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100480 exit 1
481 esac
482 shift 2
483 done
484
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100485 # check valgrind's results
486 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200487 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100488 fail "Server has memory errors"
489 return
490 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200491 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100492 fail "Client has memory errors"
493 return
494 fi
495 fi
496
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100497 # if we're here, everything is ok
498 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200499 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100500}
501
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100502cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200503 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200504 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
505 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
506 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
507 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100508 exit 1
509}
510
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100511#
512# MAIN
513#
514
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000515if cd $( dirname $0 ); then :; else
516 echo "cd $( dirname $0 ) failed" >&2
517 exit 1
518fi
519
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100520get_options "$@"
521
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100522# sanity checks, avoid an avalanche of errors
523if [ ! -x "$P_SRV" ]; then
524 echo "Command '$P_SRV' is not an executable file"
525 exit 1
526fi
527if [ ! -x "$P_CLI" ]; then
528 echo "Command '$P_CLI' is not an executable file"
529 exit 1
530fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200531if [ ! -x "$P_PXY" ]; then
532 echo "Command '$P_PXY' is not an executable file"
533 exit 1
534fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100535if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
536 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100537 exit 1
538fi
539
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200540# used by watchdog
541MAIN_PID="$$"
542
Manuel Pégourié-Gonnard3f69e542018-01-22 10:22:09 +0100543# We use somewhat arbitrary delays for tests:
544# - how long do we wait for the server to start (when lsof not available)?
545# - how long do we allow for the client to finish?
546# (not to check performance, just to avoid waiting indefinitely)
547# Things are slower with valgrind, so give extra time here.
548#
549# Note: without lsof, there is a trade-off between the running time of this
550# script and the risk of spurious errors because we didn't wait long enough.
551# The watchdog delay on the other hand doesn't affect normal running time of
552# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200553if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard3f69e542018-01-22 10:22:09 +0100554 START_DELAY=6
555 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200556else
Manuel Pégourié-Gonnard3f69e542018-01-22 10:22:09 +0100557 START_DELAY=2
558 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200559fi
Manuel Pégourié-Gonnard3f69e542018-01-22 10:22:09 +0100560
561# some particular tests need more time:
562# - for the client, we multiply the usual watchdog limit by a factor
563# - for the server, we sleep for a number of seconds after the client exits
564# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200565CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200566
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200567# Pick a "unique" server port in the range 10000-19999, and a proxy port
568PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000569PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200570SRV_PORT="1$PORT_BASE"
571PXY_PORT="2$PORT_BASE"
572unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200573
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200574# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000575# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200576P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
577P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Gilles Peskinebb4aaf12017-11-30 15:56:20 +0100578P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200579O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200580O_CLI="$O_CLI -connect localhost:+SRV_PORT"
581G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000582G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200583
Gilles Peskine35db5ba2017-05-10 10:13:59 +0200584# Allow SHA-1, because many of our test certificates use it
585P_SRV="$P_SRV allow_sha1=1"
586P_CLI="$P_CLI allow_sha1=1"
587
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200588# Also pick a unique name for intermediate files
589SRV_OUT="srv_out.$$"
590CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200591PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200592SESSION="session.$$"
593
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200594SKIP_NEXT="NO"
595
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100596trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100597
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200598# Basic test
599
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200600# Checks that:
601# - things work with all ciphersuites active (used with config-full in all.sh)
602# - the expected (highest security) parameters are selected
603# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200604run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200605 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200606 "$P_CLI" \
607 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200608 -s "Protocol is TLSv1.2" \
609 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
610 -s "client hello v3, signature_algorithm ext: 6" \
611 -s "ECDHE curve: secp521r1" \
612 -S "error" \
613 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200614
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000615run_test "Default, DTLS" \
616 "$P_SRV dtls=1" \
617 "$P_CLI dtls=1" \
618 0 \
619 -s "Protocol is DTLSv1.2" \
620 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
621
Janos Follath6d3e3382016-09-07 15:48:48 +0100622# Test for uniqueness of IVs in AEAD ciphersuites
623run_test "Unique IV in GCM" \
624 "$P_SRV exchanges=20 debug_level=4" \
625 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
626 0 \
627 -u "IV used" \
628 -U "IV used"
629
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100630# Tests for rc4 option
631
Simon Butcher6eb066e2016-05-19 22:12:18 +0100632requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100633run_test "RC4: server disabled, client enabled" \
634 "$P_SRV" \
635 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
636 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100637 -s "SSL - The server has no ciphersuites in common"
638
Simon Butcher6eb066e2016-05-19 22:12:18 +0100639requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100640run_test "RC4: server half, client enabled" \
641 "$P_SRV arc4=1" \
642 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
643 1 \
644 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100645
646run_test "RC4: server enabled, client disabled" \
647 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
648 "$P_CLI" \
649 1 \
650 -s "SSL - The server has no ciphersuites in common"
651
652run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100653 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100654 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
655 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100656 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100657 -S "SSL - The server has no ciphersuites in common"
658
Gilles Peskineae765992017-05-09 15:59:24 +0200659# Tests for SHA-1 support
660
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200661requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200662run_test "SHA-1 forbidden by default in server certificate" \
663 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
664 "$P_CLI debug_level=2 allow_sha1=0" \
665 1 \
666 -c "The certificate is signed with an unacceptable hash"
667
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200668requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
669run_test "SHA-1 forbidden by default in server certificate" \
670 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
671 "$P_CLI debug_level=2 allow_sha1=0" \
672 0
673
Gilles Peskineae765992017-05-09 15:59:24 +0200674run_test "SHA-1 explicitly allowed in server certificate" \
675 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
676 "$P_CLI allow_sha1=1" \
677 0
678
679run_test "SHA-256 allowed by default in server certificate" \
680 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
681 "$P_CLI allow_sha1=0" \
682 0
683
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200684requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200685run_test "SHA-1 forbidden by default in client certificate" \
686 "$P_SRV auth_mode=required allow_sha1=0" \
687 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
688 1 \
689 -s "The certificate is signed with an unacceptable hash"
690
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200691requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
692run_test "SHA-1 forbidden by default in client certificate" \
693 "$P_SRV auth_mode=required allow_sha1=0" \
694 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
695 0
696
Gilles Peskineae765992017-05-09 15:59:24 +0200697run_test "SHA-1 explicitly allowed in client certificate" \
698 "$P_SRV auth_mode=required allow_sha1=1" \
699 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
700 0
701
702run_test "SHA-256 allowed by default in client certificate" \
703 "$P_SRV auth_mode=required allow_sha1=0" \
704 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
705 0
706
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100707# Tests for Truncated HMAC extension
708
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100709run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200710 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100711 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100712 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000713 -s "dumping 'expected mac' (20 bytes)" \
714 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100715
Hanno Beckera83fafa2017-11-10 08:42:54 +0000716requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100717run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200718 "$P_SRV debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000719 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100720 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000721 -s "dumping 'expected mac' (20 bytes)" \
722 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100723
Hanno Beckera83fafa2017-11-10 08:42:54 +0000724requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100725run_test "Truncated HMAC: client enabled, server default" \
726 "$P_SRV debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000727 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100728 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000729 -s "dumping 'expected mac' (20 bytes)" \
730 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100731
Hanno Beckera83fafa2017-11-10 08:42:54 +0000732requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100733run_test "Truncated HMAC: client enabled, server disabled" \
734 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000735 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100736 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000737 -s "dumping 'expected mac' (20 bytes)" \
738 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100739
Hanno Beckera83fafa2017-11-10 08:42:54 +0000740requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Beckerd51bec72017-11-17 15:46:24 +0000741run_test "Truncated HMAC: client disabled, server enabled" \
742 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000743 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Beckerd51bec72017-11-17 15:46:24 +0000744 0 \
745 -s "dumping 'expected mac' (20 bytes)" \
746 -S "dumping 'expected mac' (10 bytes)"
747
748requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100749run_test "Truncated HMAC: client enabled, server enabled" \
750 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000751 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100752 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000753 -S "dumping 'expected mac' (20 bytes)" \
754 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100755
Hanno Becker02f632e2017-11-10 09:16:05 +0000756run_test "Truncated HMAC, DTLS: client default, server default" \
757 "$P_SRV dtls=1 debug_level=4" \
758 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
759 0 \
760 -s "dumping 'expected mac' (20 bytes)" \
761 -S "dumping 'expected mac' (10 bytes)"
762
763requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
764run_test "Truncated HMAC, DTLS: client disabled, server default" \
765 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000766 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000767 0 \
768 -s "dumping 'expected mac' (20 bytes)" \
769 -S "dumping 'expected mac' (10 bytes)"
770
771requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
772run_test "Truncated HMAC, DTLS: client enabled, server default" \
773 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000774 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000775 0 \
776 -s "dumping 'expected mac' (20 bytes)" \
777 -S "dumping 'expected mac' (10 bytes)"
778
779requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
780run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
781 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000782 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000783 0 \
784 -s "dumping 'expected mac' (20 bytes)" \
785 -S "dumping 'expected mac' (10 bytes)"
786
787requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
788run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
789 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000790 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000791 0 \
792 -s "dumping 'expected mac' (20 bytes)" \
793 -S "dumping 'expected mac' (10 bytes)"
794
795requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
796run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
797 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000798 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100799 0 \
800 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100801 -s "dumping 'expected mac' (10 bytes)"
802
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100803# Tests for Encrypt-then-MAC extension
804
805run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100806 "$P_SRV debug_level=3 \
807 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100808 "$P_CLI debug_level=3" \
809 0 \
810 -c "client hello, adding encrypt_then_mac extension" \
811 -s "found encrypt then mac extension" \
812 -s "server hello, adding encrypt then mac extension" \
813 -c "found encrypt_then_mac extension" \
814 -c "using encrypt then mac" \
815 -s "using encrypt then mac"
816
817run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100818 "$P_SRV debug_level=3 etm=0 \
819 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100820 "$P_CLI debug_level=3 etm=1" \
821 0 \
822 -c "client hello, adding encrypt_then_mac extension" \
823 -s "found encrypt then mac extension" \
824 -S "server hello, adding encrypt then mac extension" \
825 -C "found encrypt_then_mac extension" \
826 -C "using encrypt then mac" \
827 -S "using encrypt then mac"
828
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100829run_test "Encrypt then MAC: client enabled, aead cipher" \
830 "$P_SRV debug_level=3 etm=1 \
831 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
832 "$P_CLI debug_level=3 etm=1" \
833 0 \
834 -c "client hello, adding encrypt_then_mac extension" \
835 -s "found encrypt then mac extension" \
836 -S "server hello, adding encrypt then mac extension" \
837 -C "found encrypt_then_mac extension" \
838 -C "using encrypt then mac" \
839 -S "using encrypt then mac"
840
841run_test "Encrypt then MAC: client enabled, stream cipher" \
842 "$P_SRV debug_level=3 etm=1 \
843 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100844 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100845 0 \
846 -c "client hello, adding encrypt_then_mac extension" \
847 -s "found encrypt then mac extension" \
848 -S "server hello, adding encrypt then mac extension" \
849 -C "found encrypt_then_mac extension" \
850 -C "using encrypt then mac" \
851 -S "using encrypt then mac"
852
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100853run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100854 "$P_SRV debug_level=3 etm=1 \
855 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100856 "$P_CLI debug_level=3 etm=0" \
857 0 \
858 -C "client hello, adding encrypt_then_mac extension" \
859 -S "found encrypt then mac extension" \
860 -S "server hello, adding encrypt then mac extension" \
861 -C "found encrypt_then_mac extension" \
862 -C "using encrypt then mac" \
863 -S "using encrypt then mac"
864
Janos Follath542ee5d2016-03-07 15:57:05 +0000865requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100866run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100867 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100868 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100869 "$P_CLI debug_level=3 force_version=ssl3" \
870 0 \
871 -C "client hello, adding encrypt_then_mac extension" \
872 -S "found encrypt then mac extension" \
873 -S "server hello, adding encrypt then mac extension" \
874 -C "found encrypt_then_mac extension" \
875 -C "using encrypt then mac" \
876 -S "using encrypt then mac"
877
Janos Follath542ee5d2016-03-07 15:57:05 +0000878requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100879run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100880 "$P_SRV debug_level=3 force_version=ssl3 \
881 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100882 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100883 0 \
884 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100885 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100886 -S "server hello, adding encrypt then mac extension" \
887 -C "found encrypt_then_mac extension" \
888 -C "using encrypt then mac" \
889 -S "using encrypt then mac"
890
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200891# Tests for Extended Master Secret extension
892
893run_test "Extended Master Secret: default" \
894 "$P_SRV debug_level=3" \
895 "$P_CLI debug_level=3" \
896 0 \
897 -c "client hello, adding extended_master_secret extension" \
898 -s "found extended master secret extension" \
899 -s "server hello, adding extended master secret extension" \
900 -c "found extended_master_secret extension" \
901 -c "using extended master secret" \
902 -s "using extended master secret"
903
904run_test "Extended Master Secret: client enabled, server disabled" \
905 "$P_SRV debug_level=3 extended_ms=0" \
906 "$P_CLI debug_level=3 extended_ms=1" \
907 0 \
908 -c "client hello, adding extended_master_secret extension" \
909 -s "found extended master secret extension" \
910 -S "server hello, adding extended master secret extension" \
911 -C "found extended_master_secret extension" \
912 -C "using extended master secret" \
913 -S "using extended master secret"
914
915run_test "Extended Master Secret: client disabled, server enabled" \
916 "$P_SRV debug_level=3 extended_ms=1" \
917 "$P_CLI debug_level=3 extended_ms=0" \
918 0 \
919 -C "client hello, adding extended_master_secret extension" \
920 -S "found extended master secret extension" \
921 -S "server hello, adding extended master secret extension" \
922 -C "found extended_master_secret extension" \
923 -C "using extended master secret" \
924 -S "using extended master secret"
925
Janos Follath542ee5d2016-03-07 15:57:05 +0000926requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200927run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100928 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200929 "$P_CLI debug_level=3 force_version=ssl3" \
930 0 \
931 -C "client hello, adding extended_master_secret extension" \
932 -S "found extended master secret extension" \
933 -S "server hello, adding extended master secret extension" \
934 -C "found extended_master_secret extension" \
935 -C "using extended master secret" \
936 -S "using extended master secret"
937
Janos Follath542ee5d2016-03-07 15:57:05 +0000938requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200939run_test "Extended Master Secret: client enabled, server SSLv3" \
940 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100941 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200942 0 \
943 -c "client hello, adding extended_master_secret extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100944 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200945 -S "server hello, adding extended master secret extension" \
946 -C "found extended_master_secret extension" \
947 -C "using extended master secret" \
948 -S "using extended master secret"
949
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200950# Tests for FALLBACK_SCSV
951
952run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200953 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200954 "$P_CLI debug_level=3 force_version=tls1_1" \
955 0 \
956 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200957 -S "received FALLBACK_SCSV" \
958 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200959 -C "is a fatal alert message (msg 86)"
960
961run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200962 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200963 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
964 0 \
965 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200966 -S "received FALLBACK_SCSV" \
967 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200968 -C "is a fatal alert message (msg 86)"
969
970run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200971 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200972 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200973 1 \
974 -c "adding FALLBACK_SCSV" \
975 -s "received FALLBACK_SCSV" \
976 -s "inapropriate fallback" \
977 -c "is a fatal alert message (msg 86)"
978
979run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200980 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200981 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200982 0 \
983 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200984 -s "received FALLBACK_SCSV" \
985 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200986 -C "is a fatal alert message (msg 86)"
987
988requires_openssl_with_fallback_scsv
989run_test "Fallback SCSV: default, openssl server" \
990 "$O_SRV" \
991 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
992 0 \
993 -C "adding FALLBACK_SCSV" \
994 -C "is a fatal alert message (msg 86)"
995
996requires_openssl_with_fallback_scsv
997run_test "Fallback SCSV: enabled, openssl server" \
998 "$O_SRV" \
999 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1000 1 \
1001 -c "adding FALLBACK_SCSV" \
1002 -c "is a fatal alert message (msg 86)"
1003
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001004requires_openssl_with_fallback_scsv
1005run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001006 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001007 "$O_CLI -tls1_1" \
1008 0 \
1009 -S "received FALLBACK_SCSV" \
1010 -S "inapropriate fallback"
1011
1012requires_openssl_with_fallback_scsv
1013run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001014 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001015 "$O_CLI -tls1_1 -fallback_scsv" \
1016 1 \
1017 -s "received FALLBACK_SCSV" \
1018 -s "inapropriate fallback"
1019
1020requires_openssl_with_fallback_scsv
1021run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001022 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001023 "$O_CLI -fallback_scsv" \
1024 0 \
1025 -s "received FALLBACK_SCSV" \
1026 -S "inapropriate fallback"
1027
Gilles Peskine39e29812017-05-16 17:53:03 +02001028## ClientHello generated with
1029## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1030## then manually twiddling the ciphersuite list.
1031## The ClientHello content is spelled out below as a hex string as
1032## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1033## The expected response is an inappropriate_fallback alert.
1034requires_openssl_with_fallback_scsv
1035run_test "Fallback SCSV: beginning of list" \
1036 "$P_SRV debug_level=2" \
1037 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1038 0 \
1039 -s "received FALLBACK_SCSV" \
1040 -s "inapropriate fallback"
1041
1042requires_openssl_with_fallback_scsv
1043run_test "Fallback SCSV: end of list" \
1044 "$P_SRV debug_level=2" \
1045 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1046 0 \
1047 -s "received FALLBACK_SCSV" \
1048 -s "inapropriate fallback"
1049
1050## Here the expected response is a valid ServerHello prefix, up to the random.
1051requires_openssl_with_fallback_scsv
1052run_test "Fallback SCSV: not in list" \
1053 "$P_SRV debug_level=2" \
1054 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1055 0 \
1056 -S "received FALLBACK_SCSV" \
1057 -S "inapropriate fallback"
1058
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001059# Tests for CBC 1/n-1 record splitting
1060
1061run_test "CBC Record splitting: TLS 1.2, no splitting" \
1062 "$P_SRV" \
1063 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1064 request_size=123 force_version=tls1_2" \
1065 0 \
1066 -s "Read from client: 123 bytes read" \
1067 -S "Read from client: 1 bytes read" \
1068 -S "122 bytes read"
1069
1070run_test "CBC Record splitting: TLS 1.1, no splitting" \
1071 "$P_SRV" \
1072 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1073 request_size=123 force_version=tls1_1" \
1074 0 \
1075 -s "Read from client: 123 bytes read" \
1076 -S "Read from client: 1 bytes read" \
1077 -S "122 bytes read"
1078
1079run_test "CBC Record splitting: TLS 1.0, splitting" \
1080 "$P_SRV" \
1081 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1082 request_size=123 force_version=tls1" \
1083 0 \
1084 -S "Read from client: 123 bytes read" \
1085 -s "Read from client: 1 bytes read" \
1086 -s "122 bytes read"
1087
Janos Follath542ee5d2016-03-07 15:57:05 +00001088requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001089run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001090 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001091 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1092 request_size=123 force_version=ssl3" \
1093 0 \
1094 -S "Read from client: 123 bytes read" \
1095 -s "Read from client: 1 bytes read" \
1096 -s "122 bytes read"
1097
1098run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001099 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001100 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1101 request_size=123 force_version=tls1" \
1102 0 \
1103 -s "Read from client: 123 bytes read" \
1104 -S "Read from client: 1 bytes read" \
1105 -S "122 bytes read"
1106
1107run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1108 "$P_SRV" \
1109 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1110 request_size=123 force_version=tls1 recsplit=0" \
1111 0 \
1112 -s "Read from client: 123 bytes read" \
1113 -S "Read from client: 1 bytes read" \
1114 -S "122 bytes read"
1115
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001116run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1117 "$P_SRV nbio=2" \
1118 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1119 request_size=123 force_version=tls1" \
1120 0 \
1121 -S "Read from client: 123 bytes read" \
1122 -s "Read from client: 1 bytes read" \
1123 -s "122 bytes read"
1124
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001125# Tests for Session Tickets
1126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001127run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001128 "$P_SRV debug_level=3 tickets=1" \
1129 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001130 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001131 -c "client hello, adding session ticket extension" \
1132 -s "found session ticket extension" \
1133 -s "server hello, adding session ticket extension" \
1134 -c "found session_ticket extension" \
1135 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001136 -S "session successfully restored from cache" \
1137 -s "session successfully restored from ticket" \
1138 -s "a session has been resumed" \
1139 -c "a session has been resumed"
1140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001141run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001142 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1143 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001144 0 \
1145 -c "client hello, adding session ticket extension" \
1146 -s "found session ticket extension" \
1147 -s "server hello, adding session ticket extension" \
1148 -c "found session_ticket extension" \
1149 -c "parse new session ticket" \
1150 -S "session successfully restored from cache" \
1151 -s "session successfully restored from ticket" \
1152 -s "a session has been resumed" \
1153 -c "a session has been resumed"
1154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001155run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001156 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1157 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001158 0 \
1159 -c "client hello, adding session ticket extension" \
1160 -s "found session ticket extension" \
1161 -s "server hello, adding session ticket extension" \
1162 -c "found session_ticket extension" \
1163 -c "parse new session ticket" \
1164 -S "session successfully restored from cache" \
1165 -S "session successfully restored from ticket" \
1166 -S "a session has been resumed" \
1167 -C "a session has been resumed"
1168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001169run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001170 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001171 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001172 0 \
1173 -c "client hello, adding session ticket extension" \
1174 -c "found session_ticket extension" \
1175 -c "parse new session ticket" \
1176 -c "a session has been resumed"
1177
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001178run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001179 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001180 "( $O_CLI -sess_out $SESSION; \
1181 $O_CLI -sess_in $SESSION; \
1182 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001183 0 \
1184 -s "found session ticket extension" \
1185 -s "server hello, adding session ticket extension" \
1186 -S "session successfully restored from cache" \
1187 -s "session successfully restored from ticket" \
1188 -s "a session has been resumed"
1189
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001190# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001191
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001192run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001193 "$P_SRV debug_level=3 tickets=0" \
1194 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001195 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001196 -c "client hello, adding session ticket extension" \
1197 -s "found session ticket extension" \
1198 -S "server hello, adding session ticket extension" \
1199 -C "found session_ticket extension" \
1200 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001201 -s "session successfully restored from cache" \
1202 -S "session successfully restored from ticket" \
1203 -s "a session has been resumed" \
1204 -c "a session has been resumed"
1205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001206run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001207 "$P_SRV debug_level=3 tickets=1" \
1208 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001209 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001210 -C "client hello, adding session ticket extension" \
1211 -S "found session ticket extension" \
1212 -S "server hello, adding session ticket extension" \
1213 -C "found session_ticket extension" \
1214 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001215 -s "session successfully restored from cache" \
1216 -S "session successfully restored from ticket" \
1217 -s "a session has been resumed" \
1218 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001220run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001221 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1222 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001223 0 \
1224 -S "session successfully restored from cache" \
1225 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001226 -S "a session has been resumed" \
1227 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001228
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001229run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001230 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1231 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001232 0 \
1233 -s "session successfully restored from cache" \
1234 -S "session successfully restored from ticket" \
1235 -s "a session has been resumed" \
1236 -c "a session has been resumed"
1237
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001238run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001239 "$P_SRV debug_level=3 tickets=0" \
1240 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001241 0 \
1242 -s "session successfully restored from cache" \
1243 -S "session successfully restored from ticket" \
1244 -s "a session has been resumed" \
1245 -c "a session has been resumed"
1246
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001247run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001248 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1249 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001250 0 \
1251 -S "session successfully restored from cache" \
1252 -S "session successfully restored from ticket" \
1253 -S "a session has been resumed" \
1254 -C "a session has been resumed"
1255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001256run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1258 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001259 0 \
1260 -s "session successfully restored from cache" \
1261 -S "session successfully restored from ticket" \
1262 -s "a session has been resumed" \
1263 -c "a session has been resumed"
1264
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001265run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001266 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001267 "( $O_CLI -sess_out $SESSION; \
1268 $O_CLI -sess_in $SESSION; \
1269 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001270 0 \
1271 -s "found session ticket extension" \
1272 -S "server hello, adding session ticket extension" \
1273 -s "session successfully restored from cache" \
1274 -S "session successfully restored from ticket" \
1275 -s "a session has been resumed"
1276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001277run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001278 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001279 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001280 0 \
1281 -C "found session_ticket extension" \
1282 -C "parse new session ticket" \
1283 -c "a session has been resumed"
1284
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001285# Tests for Max Fragment Length extension
1286
Hanno Becker64691dc2017-09-22 16:58:50 +01001287MAX_CONTENT_LEN_EXPECT='16384'
1288MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1289
1290if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1291 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1292 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1293 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1294 printf "\n"
1295 printf "The tests assume this value and if it changes, the tests in this\n"
1296 printf "script should also be adjusted.\n"
1297 printf "\n"
1298
1299 exit 1
1300fi
1301
Hanno Becker05607782017-09-18 15:00:34 +01001302requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001303run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001304 "$P_SRV debug_level=3" \
1305 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001306 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001307 -c "Maximum fragment length is 16384" \
1308 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001309 -C "client hello, adding max_fragment_length extension" \
1310 -S "found max fragment length extension" \
1311 -S "server hello, max_fragment_length extension" \
1312 -C "found max_fragment_length extension"
1313
Hanno Becker05607782017-09-18 15:00:34 +01001314requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001315run_test "Max fragment length: enabled, default, larger message" \
1316 "$P_SRV debug_level=3" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001317 "$P_CLI debug_level=3 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001318 0 \
1319 -c "Maximum fragment length is 16384" \
1320 -s "Maximum fragment length is 16384" \
1321 -C "client hello, adding max_fragment_length extension" \
1322 -S "found max fragment length extension" \
1323 -S "server hello, max_fragment_length extension" \
1324 -C "found max_fragment_length extension" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001325 -c "16385 bytes written in 2 fragments" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001326 -s "16384 bytes read" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001327 -s "1 bytes read"
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001328
1329requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1330run_test "Max fragment length, DTLS: enabled, default, larger message" \
1331 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001332 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001333 1 \
1334 -c "Maximum fragment length is 16384" \
1335 -s "Maximum fragment length is 16384" \
1336 -C "client hello, adding max_fragment_length extension" \
1337 -S "found max fragment length extension" \
1338 -S "server hello, max_fragment_length extension" \
1339 -C "found max_fragment_length extension" \
1340 -c "fragment larger than.*maximum "
1341
1342requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1343run_test "Max fragment length: disabled, larger message" \
1344 "$P_SRV debug_level=3" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001345 "$P_CLI debug_level=3 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001346 0 \
1347 -C "Maximum fragment length is 16384" \
1348 -S "Maximum fragment length is 16384" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001349 -c "16385 bytes written in 2 fragments" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001350 -s "16384 bytes read" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001351 -s "1 bytes read"
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001352
1353requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1354run_test "Max fragment length DTLS: disabled, larger message" \
1355 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001356 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001357 1 \
1358 -C "Maximum fragment length is 16384" \
1359 -S "Maximum fragment length is 16384" \
1360 -c "fragment larger than.*maximum "
1361
1362requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001363run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001364 "$P_SRV debug_level=3" \
1365 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001366 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001367 -c "Maximum fragment length is 4096" \
1368 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001369 -c "client hello, adding max_fragment_length extension" \
1370 -s "found max fragment length extension" \
1371 -s "server hello, max_fragment_length extension" \
1372 -c "found max_fragment_length extension"
1373
Hanno Becker05607782017-09-18 15:00:34 +01001374requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001375run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001376 "$P_SRV debug_level=3 max_frag_len=4096" \
1377 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001378 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001379 -c "Maximum fragment length is 16384" \
1380 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001381 -C "client hello, adding max_fragment_length extension" \
1382 -S "found max fragment length extension" \
1383 -S "server hello, max_fragment_length extension" \
1384 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001385
Hanno Becker05607782017-09-18 15:00:34 +01001386requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001387requires_gnutls
1388run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001389 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001390 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001391 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001392 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001393 -c "client hello, adding max_fragment_length extension" \
1394 -c "found max_fragment_length extension"
1395
Hanno Becker05607782017-09-18 15:00:34 +01001396requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001397run_test "Max fragment length: client, message just fits" \
1398 "$P_SRV debug_level=3" \
1399 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1400 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001401 -c "Maximum fragment length is 2048" \
1402 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001403 -c "client hello, adding max_fragment_length extension" \
1404 -s "found max fragment length extension" \
1405 -s "server hello, max_fragment_length extension" \
1406 -c "found max_fragment_length extension" \
1407 -c "2048 bytes written in 1 fragments" \
1408 -s "2048 bytes read"
1409
Hanno Becker05607782017-09-18 15:00:34 +01001410requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001411run_test "Max fragment length: client, larger message" \
1412 "$P_SRV debug_level=3" \
1413 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1414 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001415 -c "Maximum fragment length is 2048" \
1416 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001417 -c "client hello, adding max_fragment_length extension" \
1418 -s "found max fragment length extension" \
1419 -s "server hello, max_fragment_length extension" \
1420 -c "found max_fragment_length extension" \
1421 -c "2345 bytes written in 2 fragments" \
1422 -s "2048 bytes read" \
1423 -s "297 bytes read"
1424
Hanno Becker05607782017-09-18 15:00:34 +01001425requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001426run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001427 "$P_SRV debug_level=3 dtls=1" \
1428 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1429 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001430 -c "Maximum fragment length is 2048" \
1431 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001432 -c "client hello, adding max_fragment_length extension" \
1433 -s "found max fragment length extension" \
1434 -s "server hello, max_fragment_length extension" \
1435 -c "found max_fragment_length extension" \
1436 -c "fragment larger than.*maximum"
1437
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001438# Tests for renegotiation
1439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001440run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001441 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001442 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001443 0 \
1444 -C "client hello, adding renegotiation extension" \
1445 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1446 -S "found renegotiation extension" \
1447 -s "server hello, secure renegotiation extension" \
1448 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001449 -C "=> renegotiate" \
1450 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001451 -S "write hello request"
1452
Hanno Becker78891132017-10-24 11:54:55 +01001453requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001454run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001455 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001456 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001457 0 \
1458 -c "client hello, adding renegotiation extension" \
1459 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1460 -s "found renegotiation extension" \
1461 -s "server hello, secure renegotiation extension" \
1462 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001463 -c "=> renegotiate" \
1464 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001465 -S "write hello request"
1466
Hanno Becker78891132017-10-24 11:54:55 +01001467requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001468run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001469 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001470 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001471 0 \
1472 -c "client hello, adding renegotiation extension" \
1473 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1474 -s "found renegotiation extension" \
1475 -s "server hello, secure renegotiation extension" \
1476 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001477 -c "=> renegotiate" \
1478 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001479 -s "write hello request"
1480
Janos Follath5f1dd802017-10-05 12:29:42 +01001481# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1482# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1483# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker78891132017-10-24 11:54:55 +01001484requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follath5f1dd802017-10-05 12:29:42 +01001485run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1486 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1487 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1488 0 \
1489 -c "client hello, adding renegotiation extension" \
1490 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1491 -s "found renegotiation extension" \
1492 -s "server hello, secure renegotiation extension" \
1493 -c "found renegotiation extension" \
1494 -c "=> renegotiate" \
1495 -s "=> renegotiate" \
1496 -S "write hello request" \
1497 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1498
1499# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1500# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1501# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker78891132017-10-24 11:54:55 +01001502requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follath5f1dd802017-10-05 12:29:42 +01001503run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1504 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1505 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1506 0 \
1507 -c "client hello, adding renegotiation extension" \
1508 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1509 -s "found renegotiation extension" \
1510 -s "server hello, secure renegotiation extension" \
1511 -c "found renegotiation extension" \
1512 -c "=> renegotiate" \
1513 -s "=> renegotiate" \
1514 -s "write hello request" \
1515 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1516
Hanno Becker78891132017-10-24 11:54:55 +01001517requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001518run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001519 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001520 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001521 0 \
1522 -c "client hello, adding renegotiation extension" \
1523 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1524 -s "found renegotiation extension" \
1525 -s "server hello, secure renegotiation extension" \
1526 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001527 -c "=> renegotiate" \
1528 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001529 -s "write hello request"
1530
Hanno Becker78891132017-10-24 11:54:55 +01001531requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001532run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001533 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001534 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001535 1 \
1536 -c "client hello, adding renegotiation extension" \
1537 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1538 -S "found renegotiation extension" \
1539 -s "server hello, secure renegotiation extension" \
1540 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001541 -c "=> renegotiate" \
1542 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001543 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001544 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001545 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001546
Hanno Becker78891132017-10-24 11:54:55 +01001547requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001548run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001549 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001550 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001551 0 \
1552 -C "client hello, adding renegotiation extension" \
1553 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1554 -S "found renegotiation extension" \
1555 -s "server hello, secure renegotiation extension" \
1556 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001557 -C "=> renegotiate" \
1558 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001559 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001560 -S "SSL - An unexpected message was received from our peer" \
1561 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001562
Hanno Becker78891132017-10-24 11:54:55 +01001563requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001564run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001565 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001566 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001567 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001568 0 \
1569 -C "client hello, adding renegotiation extension" \
1570 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1571 -S "found renegotiation extension" \
1572 -s "server hello, secure renegotiation extension" \
1573 -c "found renegotiation extension" \
1574 -C "=> renegotiate" \
1575 -S "=> renegotiate" \
1576 -s "write hello request" \
1577 -S "SSL - An unexpected message was received from our peer" \
1578 -S "failed"
1579
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001580# delay 2 for 1 alert record + 1 application data record
Hanno Becker78891132017-10-24 11:54:55 +01001581requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001582run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001583 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001584 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001585 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001586 0 \
1587 -C "client hello, adding renegotiation extension" \
1588 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1589 -S "found renegotiation extension" \
1590 -s "server hello, secure renegotiation extension" \
1591 -c "found renegotiation extension" \
1592 -C "=> renegotiate" \
1593 -S "=> renegotiate" \
1594 -s "write hello request" \
1595 -S "SSL - An unexpected message was received from our peer" \
1596 -S "failed"
1597
Hanno Becker78891132017-10-24 11:54:55 +01001598requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001599run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001600 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001601 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001602 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001603 0 \
1604 -C "client hello, adding renegotiation extension" \
1605 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1606 -S "found renegotiation extension" \
1607 -s "server hello, secure renegotiation extension" \
1608 -c "found renegotiation extension" \
1609 -C "=> renegotiate" \
1610 -S "=> renegotiate" \
1611 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001612 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001613
Hanno Becker78891132017-10-24 11:54:55 +01001614requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001615run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001616 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001617 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001618 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001619 0 \
1620 -c "client hello, adding renegotiation extension" \
1621 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1622 -s "found renegotiation extension" \
1623 -s "server hello, secure renegotiation extension" \
1624 -c "found renegotiation extension" \
1625 -c "=> renegotiate" \
1626 -s "=> renegotiate" \
1627 -s "write hello request" \
1628 -S "SSL - An unexpected message was received from our peer" \
1629 -S "failed"
1630
Hanno Becker78891132017-10-24 11:54:55 +01001631requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001632run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001633 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001634 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1635 0 \
1636 -C "client hello, adding renegotiation extension" \
1637 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1638 -S "found renegotiation extension" \
1639 -s "server hello, secure renegotiation extension" \
1640 -c "found renegotiation extension" \
1641 -S "record counter limit reached: renegotiate" \
1642 -C "=> renegotiate" \
1643 -S "=> renegotiate" \
1644 -S "write hello request" \
1645 -S "SSL - An unexpected message was received from our peer" \
1646 -S "failed"
1647
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001648# one extra exchange to be able to complete renego
Hanno Becker78891132017-10-24 11:54:55 +01001649requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001650run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001651 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001652 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001653 0 \
1654 -c "client hello, adding renegotiation extension" \
1655 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1656 -s "found renegotiation extension" \
1657 -s "server hello, secure renegotiation extension" \
1658 -c "found renegotiation extension" \
1659 -s "record counter limit reached: renegotiate" \
1660 -c "=> renegotiate" \
1661 -s "=> renegotiate" \
1662 -s "write hello request" \
1663 -S "SSL - An unexpected message was received from our peer" \
1664 -S "failed"
1665
Hanno Becker78891132017-10-24 11:54:55 +01001666requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001667run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001668 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001669 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001670 0 \
1671 -c "client hello, adding renegotiation extension" \
1672 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1673 -s "found renegotiation extension" \
1674 -s "server hello, secure renegotiation extension" \
1675 -c "found renegotiation extension" \
1676 -s "record counter limit reached: renegotiate" \
1677 -c "=> renegotiate" \
1678 -s "=> renegotiate" \
1679 -s "write hello request" \
1680 -S "SSL - An unexpected message was received from our peer" \
1681 -S "failed"
1682
Hanno Becker78891132017-10-24 11:54:55 +01001683requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001684run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001685 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001686 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1687 0 \
1688 -C "client hello, adding renegotiation extension" \
1689 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1690 -S "found renegotiation extension" \
1691 -s "server hello, secure renegotiation extension" \
1692 -c "found renegotiation extension" \
1693 -S "record counter limit reached: renegotiate" \
1694 -C "=> renegotiate" \
1695 -S "=> renegotiate" \
1696 -S "write hello request" \
1697 -S "SSL - An unexpected message was received from our peer" \
1698 -S "failed"
1699
Hanno Becker78891132017-10-24 11:54:55 +01001700requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001701run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001702 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001703 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001704 0 \
1705 -c "client hello, adding renegotiation extension" \
1706 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1707 -s "found renegotiation extension" \
1708 -s "server hello, secure renegotiation extension" \
1709 -c "found renegotiation extension" \
1710 -c "=> renegotiate" \
1711 -s "=> renegotiate" \
1712 -S "write hello request"
1713
Hanno Becker78891132017-10-24 11:54:55 +01001714requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001715run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001716 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001717 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001718 0 \
1719 -c "client hello, adding renegotiation extension" \
1720 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1721 -s "found renegotiation extension" \
1722 -s "server hello, secure renegotiation extension" \
1723 -c "found renegotiation extension" \
1724 -c "=> renegotiate" \
1725 -s "=> renegotiate" \
1726 -s "write hello request"
1727
Hanno Becker78891132017-10-24 11:54:55 +01001728requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001729run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001730 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001731 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001732 0 \
1733 -c "client hello, adding renegotiation extension" \
1734 -c "found renegotiation extension" \
1735 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001736 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001737 -C "error" \
1738 -c "HTTP/1.0 200 [Oo][Kk]"
1739
Paul Bakker539d9722015-02-08 16:18:35 +01001740requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001741requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001742run_test "Renegotiation: gnutls server strict, client-initiated" \
1743 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001744 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001745 0 \
1746 -c "client hello, adding renegotiation extension" \
1747 -c "found renegotiation extension" \
1748 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001749 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001750 -C "error" \
1751 -c "HTTP/1.0 200 [Oo][Kk]"
1752
Paul Bakker539d9722015-02-08 16:18:35 +01001753requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001754requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001755run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1756 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1757 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1758 1 \
1759 -c "client hello, adding renegotiation extension" \
1760 -C "found renegotiation extension" \
1761 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001762 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001763 -c "error" \
1764 -C "HTTP/1.0 200 [Oo][Kk]"
1765
Paul Bakker539d9722015-02-08 16:18:35 +01001766requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001767requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001768run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1769 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1770 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1771 allow_legacy=0" \
1772 1 \
1773 -c "client hello, adding renegotiation extension" \
1774 -C "found renegotiation extension" \
1775 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001776 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001777 -c "error" \
1778 -C "HTTP/1.0 200 [Oo][Kk]"
1779
Paul Bakker539d9722015-02-08 16:18:35 +01001780requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001781requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001782run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1783 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1784 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1785 allow_legacy=1" \
1786 0 \
1787 -c "client hello, adding renegotiation extension" \
1788 -C "found renegotiation extension" \
1789 -c "=> renegotiate" \
1790 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001791 -C "error" \
1792 -c "HTTP/1.0 200 [Oo][Kk]"
1793
Hanno Becker78891132017-10-24 11:54:55 +01001794requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001795run_test "Renegotiation: DTLS, client-initiated" \
1796 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1797 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1798 0 \
1799 -c "client hello, adding renegotiation extension" \
1800 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1801 -s "found renegotiation extension" \
1802 -s "server hello, secure renegotiation extension" \
1803 -c "found renegotiation extension" \
1804 -c "=> renegotiate" \
1805 -s "=> renegotiate" \
1806 -S "write hello request"
1807
Hanno Becker78891132017-10-24 11:54:55 +01001808requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001809run_test "Renegotiation: DTLS, server-initiated" \
1810 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001811 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1812 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001813 0 \
1814 -c "client hello, adding renegotiation extension" \
1815 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1816 -s "found renegotiation extension" \
1817 -s "server hello, secure renegotiation extension" \
1818 -c "found renegotiation extension" \
1819 -c "=> renegotiate" \
1820 -s "=> renegotiate" \
1821 -s "write hello request"
1822
Hanno Becker78891132017-10-24 11:54:55 +01001823requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG9b1927b2017-01-19 16:30:57 +00001824run_test "Renegotiation: DTLS, renego_period overflow" \
1825 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1826 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1827 0 \
1828 -c "client hello, adding renegotiation extension" \
1829 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1830 -s "found renegotiation extension" \
1831 -s "server hello, secure renegotiation extension" \
1832 -s "record counter limit reached: renegotiate" \
1833 -c "=> renegotiate" \
1834 -s "=> renegotiate" \
Hanno Becker78891132017-10-24 11:54:55 +01001835 -s "write hello request"
Andres AG9b1927b2017-01-19 16:30:57 +00001836
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001837requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001838requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001839run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1840 "$G_SRV -u --mtu 4096" \
1841 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1842 0 \
1843 -c "client hello, adding renegotiation extension" \
1844 -c "found renegotiation extension" \
1845 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001846 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001847 -C "error" \
1848 -s "Extra-header:"
1849
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001850# Test for the "secure renegotation" extension only (no actual renegotiation)
1851
Paul Bakker539d9722015-02-08 16:18:35 +01001852requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001853run_test "Renego ext: gnutls server strict, client default" \
1854 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1855 "$P_CLI debug_level=3" \
1856 0 \
1857 -c "found renegotiation extension" \
1858 -C "error" \
1859 -c "HTTP/1.0 200 [Oo][Kk]"
1860
Paul Bakker539d9722015-02-08 16:18:35 +01001861requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001862run_test "Renego ext: gnutls server unsafe, client default" \
1863 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1864 "$P_CLI debug_level=3" \
1865 0 \
1866 -C "found renegotiation extension" \
1867 -C "error" \
1868 -c "HTTP/1.0 200 [Oo][Kk]"
1869
Paul Bakker539d9722015-02-08 16:18:35 +01001870requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001871run_test "Renego ext: gnutls server unsafe, client break legacy" \
1872 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1873 "$P_CLI debug_level=3 allow_legacy=-1" \
1874 1 \
1875 -C "found renegotiation extension" \
1876 -c "error" \
1877 -C "HTTP/1.0 200 [Oo][Kk]"
1878
Paul Bakker539d9722015-02-08 16:18:35 +01001879requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001880run_test "Renego ext: gnutls client strict, server default" \
1881 "$P_SRV debug_level=3" \
1882 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1883 0 \
1884 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1885 -s "server hello, secure renegotiation extension"
1886
Paul Bakker539d9722015-02-08 16:18:35 +01001887requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001888run_test "Renego ext: gnutls client unsafe, server default" \
1889 "$P_SRV debug_level=3" \
1890 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1891 0 \
1892 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1893 -S "server hello, secure renegotiation extension"
1894
Paul Bakker539d9722015-02-08 16:18:35 +01001895requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001896run_test "Renego ext: gnutls client unsafe, server break legacy" \
1897 "$P_SRV debug_level=3 allow_legacy=-1" \
1898 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1899 1 \
1900 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1901 -S "server hello, secure renegotiation extension"
1902
Janos Follath365b2262016-02-17 10:11:21 +00001903# Tests for silently dropping trailing extra bytes in .der certificates
1904
1905requires_gnutls
1906run_test "DER format: no trailing bytes" \
1907 "$P_SRV crt_file=data_files/server5-der0.crt \
1908 key_file=data_files/server5.key" \
1909 "$G_CLI " \
1910 0 \
1911 -c "Handshake was completed" \
1912
1913requires_gnutls
1914run_test "DER format: with a trailing zero byte" \
1915 "$P_SRV crt_file=data_files/server5-der1a.crt \
1916 key_file=data_files/server5.key" \
1917 "$G_CLI " \
1918 0 \
1919 -c "Handshake was completed" \
1920
1921requires_gnutls
1922run_test "DER format: with a trailing random byte" \
1923 "$P_SRV crt_file=data_files/server5-der1b.crt \
1924 key_file=data_files/server5.key" \
1925 "$G_CLI " \
1926 0 \
1927 -c "Handshake was completed" \
1928
1929requires_gnutls
1930run_test "DER format: with 2 trailing random bytes" \
1931 "$P_SRV crt_file=data_files/server5-der2.crt \
1932 key_file=data_files/server5.key" \
1933 "$G_CLI " \
1934 0 \
1935 -c "Handshake was completed" \
1936
1937requires_gnutls
1938run_test "DER format: with 4 trailing random bytes" \
1939 "$P_SRV crt_file=data_files/server5-der4.crt \
1940 key_file=data_files/server5.key" \
1941 "$G_CLI " \
1942 0 \
1943 -c "Handshake was completed" \
1944
1945requires_gnutls
1946run_test "DER format: with 8 trailing random bytes" \
1947 "$P_SRV crt_file=data_files/server5-der8.crt \
1948 key_file=data_files/server5.key" \
1949 "$G_CLI " \
1950 0 \
1951 -c "Handshake was completed" \
1952
1953requires_gnutls
1954run_test "DER format: with 9 trailing random bytes" \
1955 "$P_SRV crt_file=data_files/server5-der9.crt \
1956 key_file=data_files/server5.key" \
1957 "$G_CLI " \
1958 0 \
1959 -c "Handshake was completed" \
1960
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001961# Tests for auth_mode
1962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001963run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001964 "$P_SRV crt_file=data_files/server5-badsign.crt \
1965 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001966 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001967 1 \
1968 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001969 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001970 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001971 -c "X509 - Certificate verification failed"
1972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001973run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001974 "$P_SRV crt_file=data_files/server5-badsign.crt \
1975 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001976 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001977 0 \
1978 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001979 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001980 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001981 -C "X509 - Certificate verification failed"
1982
Hanno Becker61c0c702017-05-15 16:05:15 +01001983run_test "Authentication: server goodcert, client optional, no trusted CA" \
1984 "$P_SRV" \
1985 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1986 0 \
1987 -c "x509_verify_cert() returned" \
1988 -c "! The certificate is not correctly signed by the trusted CA" \
1989 -c "! Certificate verification flags"\
1990 -C "! mbedtls_ssl_handshake returned" \
1991 -C "X509 - Certificate verification failed" \
1992 -C "SSL - No CA Chain is set, but required to operate"
1993
1994run_test "Authentication: server goodcert, client required, no trusted CA" \
1995 "$P_SRV" \
1996 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1997 1 \
1998 -c "x509_verify_cert() returned" \
1999 -c "! The certificate is not correctly signed by the trusted CA" \
2000 -c "! Certificate verification flags"\
2001 -c "! mbedtls_ssl_handshake returned" \
2002 -c "SSL - No CA Chain is set, but required to operate"
2003
2004# The purpose of the next two tests is to test the client's behaviour when receiving a server
2005# certificate with an unsupported elliptic curve. This should usually not happen because
2006# the client informs the server about the supported curves - it does, though, in the
2007# corner case of a static ECDH suite, because the server doesn't check the curve on that
2008# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2009# different means to have the server ignoring the client's supported curve list.
2010
2011requires_config_enabled MBEDTLS_ECP_C
2012run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2013 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2014 crt_file=data_files/server5.ku-ka.crt" \
2015 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2016 1 \
2017 -c "bad certificate (EC key curve)"\
2018 -c "! Certificate verification flags"\
2019 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2020
2021requires_config_enabled MBEDTLS_ECP_C
2022run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2023 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2024 crt_file=data_files/server5.ku-ka.crt" \
2025 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2026 1 \
2027 -c "bad certificate (EC key curve)"\
2028 -c "! Certificate verification flags"\
2029 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002031run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002032 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002033 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002034 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002035 0 \
2036 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002037 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002038 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002039 -C "X509 - Certificate verification failed"
2040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002041run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002042 "$P_SRV debug_level=3 auth_mode=required" \
2043 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002044 key_file=data_files/server5.key" \
2045 1 \
2046 -S "skip write certificate request" \
2047 -C "skip parse certificate request" \
2048 -c "got a certificate request" \
2049 -C "skip write certificate" \
2050 -C "skip write certificate verify" \
2051 -S "skip parse certificate verify" \
2052 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002053 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002054 -s "! mbedtls_ssl_handshake returned" \
2055 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002056 -s "X509 - Certificate verification failed"
2057
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002058run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002059 "$P_SRV debug_level=3 auth_mode=optional" \
2060 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002061 key_file=data_files/server5.key" \
2062 0 \
2063 -S "skip write certificate request" \
2064 -C "skip parse certificate request" \
2065 -c "got a certificate request" \
2066 -C "skip write certificate" \
2067 -C "skip write certificate verify" \
2068 -S "skip parse certificate verify" \
2069 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002070 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002071 -S "! mbedtls_ssl_handshake returned" \
2072 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002073 -S "X509 - Certificate verification failed"
2074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002075run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002076 "$P_SRV debug_level=3 auth_mode=none" \
2077 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002078 key_file=data_files/server5.key" \
2079 0 \
2080 -s "skip write certificate request" \
2081 -C "skip parse certificate request" \
2082 -c "got no certificate request" \
2083 -c "skip write certificate" \
2084 -c "skip write certificate verify" \
2085 -s "skip parse certificate verify" \
2086 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002087 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002088 -S "! mbedtls_ssl_handshake returned" \
2089 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002090 -S "X509 - Certificate verification failed"
2091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002092run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002093 "$P_SRV debug_level=3 auth_mode=optional" \
2094 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002095 0 \
2096 -S "skip write certificate request" \
2097 -C "skip parse certificate request" \
2098 -c "got a certificate request" \
2099 -C "skip write certificate$" \
2100 -C "got no certificate to send" \
2101 -S "SSLv3 client has no certificate" \
2102 -c "skip write certificate verify" \
2103 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002104 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002105 -S "! mbedtls_ssl_handshake returned" \
2106 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002107 -S "X509 - Certificate verification failed"
2108
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002109run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002110 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002111 "$O_CLI" \
2112 0 \
2113 -S "skip write certificate request" \
2114 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002115 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002116 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002117 -S "X509 - Certificate verification failed"
2118
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002119run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002120 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002121 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002122 0 \
2123 -C "skip parse certificate request" \
2124 -c "got a certificate request" \
2125 -C "skip write certificate$" \
2126 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002127 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002128
Janos Follath542ee5d2016-03-07 15:57:05 +00002129requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002130run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002131 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002132 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002133 0 \
2134 -S "skip write certificate request" \
2135 -C "skip parse certificate request" \
2136 -c "got a certificate request" \
2137 -C "skip write certificate$" \
2138 -c "skip write certificate verify" \
2139 -c "got no certificate to send" \
2140 -s "SSLv3 client has no certificate" \
2141 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002142 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002143 -S "! mbedtls_ssl_handshake returned" \
2144 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002145 -S "X509 - Certificate verification failed"
2146
Manuel Pégourié-Gonnard591035d2017-06-26 10:45:33 +02002147run_test "Authentication: server max_int chain, client default" \
2148 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2149 key_file=data_files/dir-maxpath/09.key" \
2150 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2151 0 \
2152 -C "X509 - A fatal error occured"
2153
2154run_test "Authentication: server max_int+1 chain, client default" \
2155 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2156 key_file=data_files/dir-maxpath/10.key" \
2157 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2158 1 \
2159 -c "X509 - A fatal error occured"
2160
2161run_test "Authentication: server max_int+1 chain, client optional" \
2162 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2163 key_file=data_files/dir-maxpath/10.key" \
2164 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2165 auth_mode=optional" \
2166 1 \
2167 -c "X509 - A fatal error occured"
2168
2169run_test "Authentication: server max_int+1 chain, client none" \
2170 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2171 key_file=data_files/dir-maxpath/10.key" \
2172 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2173 auth_mode=none" \
2174 0 \
2175 -C "X509 - A fatal error occured"
2176
2177run_test "Authentication: client max_int+1 chain, server default" \
2178 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2179 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2180 key_file=data_files/dir-maxpath/10.key" \
2181 0 \
2182 -S "X509 - A fatal error occured"
2183
2184run_test "Authentication: client max_int+1 chain, server optional" \
2185 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2186 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2187 key_file=data_files/dir-maxpath/10.key" \
2188 1 \
2189 -s "X509 - A fatal error occured"
2190
2191run_test "Authentication: client max_int+1 chain, server required" \
2192 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2193 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2194 key_file=data_files/dir-maxpath/10.key" \
2195 1 \
2196 -s "X509 - A fatal error occured"
2197
2198run_test "Authentication: client max_int chain, server required" \
2199 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2200 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2201 key_file=data_files/dir-maxpath/09.key" \
2202 0 \
2203 -S "X509 - A fatal error occured"
2204
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002205# Tests for certificate selection based on SHA verson
2206
2207run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2208 "$P_SRV crt_file=data_files/server5.crt \
2209 key_file=data_files/server5.key \
2210 crt_file2=data_files/server5-sha1.crt \
2211 key_file2=data_files/server5.key" \
2212 "$P_CLI force_version=tls1_2" \
2213 0 \
2214 -c "signed using.*ECDSA with SHA256" \
2215 -C "signed using.*ECDSA with SHA1"
2216
2217run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2218 "$P_SRV crt_file=data_files/server5.crt \
2219 key_file=data_files/server5.key \
2220 crt_file2=data_files/server5-sha1.crt \
2221 key_file2=data_files/server5.key" \
2222 "$P_CLI force_version=tls1_1" \
2223 0 \
2224 -C "signed using.*ECDSA with SHA256" \
2225 -c "signed using.*ECDSA with SHA1"
2226
2227run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2228 "$P_SRV crt_file=data_files/server5.crt \
2229 key_file=data_files/server5.key \
2230 crt_file2=data_files/server5-sha1.crt \
2231 key_file2=data_files/server5.key" \
2232 "$P_CLI force_version=tls1" \
2233 0 \
2234 -C "signed using.*ECDSA with SHA256" \
2235 -c "signed using.*ECDSA with SHA1"
2236
2237run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2238 "$P_SRV crt_file=data_files/server5.crt \
2239 key_file=data_files/server5.key \
2240 crt_file2=data_files/server6.crt \
2241 key_file2=data_files/server6.key" \
2242 "$P_CLI force_version=tls1_1" \
2243 0 \
2244 -c "serial number.*09" \
2245 -c "signed using.*ECDSA with SHA256" \
2246 -C "signed using.*ECDSA with SHA1"
2247
2248run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2249 "$P_SRV crt_file=data_files/server6.crt \
2250 key_file=data_files/server6.key \
2251 crt_file2=data_files/server5.crt \
2252 key_file2=data_files/server5.key" \
2253 "$P_CLI force_version=tls1_1" \
2254 0 \
2255 -c "serial number.*0A" \
2256 -c "signed using.*ECDSA with SHA256" \
2257 -C "signed using.*ECDSA with SHA1"
2258
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002259# tests for SNI
2260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002261run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002262 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002263 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002264 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002265 0 \
2266 -S "parse ServerName extension" \
2267 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2268 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002270run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002271 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002272 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002273 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002274 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002275 0 \
2276 -s "parse ServerName extension" \
2277 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2278 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002279
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002280run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002281 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002282 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002283 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002284 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002285 0 \
2286 -s "parse ServerName extension" \
2287 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2288 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002289
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002290run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002291 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002292 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002293 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002294 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002295 1 \
2296 -s "parse ServerName extension" \
2297 -s "ssl_sni_wrapper() returned" \
2298 -s "mbedtls_ssl_handshake returned" \
2299 -c "mbedtls_ssl_handshake returned" \
2300 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002301
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002302run_test "SNI: client auth no override: optional" \
2303 "$P_SRV debug_level=3 auth_mode=optional \
2304 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2305 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2306 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002307 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002308 -S "skip write certificate request" \
2309 -C "skip parse certificate request" \
2310 -c "got a certificate request" \
2311 -C "skip write certificate" \
2312 -C "skip write certificate verify" \
2313 -S "skip parse certificate verify"
2314
2315run_test "SNI: client auth override: none -> optional" \
2316 "$P_SRV debug_level=3 auth_mode=none \
2317 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2318 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2319 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002320 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002321 -S "skip write certificate request" \
2322 -C "skip parse certificate request" \
2323 -c "got a certificate request" \
2324 -C "skip write certificate" \
2325 -C "skip write certificate verify" \
2326 -S "skip parse certificate verify"
2327
2328run_test "SNI: client auth override: optional -> none" \
2329 "$P_SRV debug_level=3 auth_mode=optional \
2330 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2331 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2332 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002333 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002334 -s "skip write certificate request" \
2335 -C "skip parse certificate request" \
2336 -c "got no certificate request" \
2337 -c "skip write certificate" \
2338 -c "skip write certificate verify" \
2339 -s "skip parse certificate verify"
2340
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002341run_test "SNI: CA no override" \
2342 "$P_SRV debug_level=3 auth_mode=optional \
2343 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2344 ca_file=data_files/test-ca.crt \
2345 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2346 "$P_CLI debug_level=3 server_name=localhost \
2347 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2348 1 \
2349 -S "skip write certificate request" \
2350 -C "skip parse certificate request" \
2351 -c "got a certificate request" \
2352 -C "skip write certificate" \
2353 -C "skip write certificate verify" \
2354 -S "skip parse certificate verify" \
2355 -s "x509_verify_cert() returned" \
2356 -s "! The certificate is not correctly signed by the trusted CA" \
2357 -S "The certificate has been revoked (is on a CRL)"
2358
2359run_test "SNI: CA override" \
2360 "$P_SRV debug_level=3 auth_mode=optional \
2361 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2362 ca_file=data_files/test-ca.crt \
2363 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2364 "$P_CLI debug_level=3 server_name=localhost \
2365 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2366 0 \
2367 -S "skip write certificate request" \
2368 -C "skip parse certificate request" \
2369 -c "got a certificate request" \
2370 -C "skip write certificate" \
2371 -C "skip write certificate verify" \
2372 -S "skip parse certificate verify" \
2373 -S "x509_verify_cert() returned" \
2374 -S "! The certificate is not correctly signed by the trusted CA" \
2375 -S "The certificate has been revoked (is on a CRL)"
2376
2377run_test "SNI: CA override with CRL" \
2378 "$P_SRV debug_level=3 auth_mode=optional \
2379 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2380 ca_file=data_files/test-ca.crt \
2381 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2382 "$P_CLI debug_level=3 server_name=localhost \
2383 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2384 1 \
2385 -S "skip write certificate request" \
2386 -C "skip parse certificate request" \
2387 -c "got a certificate request" \
2388 -C "skip write certificate" \
2389 -C "skip write certificate verify" \
2390 -S "skip parse certificate verify" \
2391 -s "x509_verify_cert() returned" \
2392 -S "! The certificate is not correctly signed by the trusted CA" \
2393 -s "The certificate has been revoked (is on a CRL)"
2394
Andres AG52142f12016-12-07 10:01:30 +00002395# Tests for SNI and DTLS
2396
Andres Amaya Garcia021ad3d2018-05-01 20:26:47 +01002397run_test "SNI: DTLS, matching cert 1" \
Andres AG52142f12016-12-07 10:01:30 +00002398 "$P_SRV debug_level=3 dtls=1 \
2399 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2400 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2401 "$P_CLI server_name=localhost dtls=1" \
2402 0 \
2403 -s "parse ServerName extension" \
2404 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2405 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2406
Andres Amaya Garcia021ad3d2018-05-01 20:26:47 +01002407run_test "SNI: DTLS, CA override" \
Andres AG52142f12016-12-07 10:01:30 +00002408 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2409 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2410 ca_file=data_files/test-ca.crt \
2411 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2412 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2413 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2414 0 \
2415 -S "skip write certificate request" \
2416 -C "skip parse certificate request" \
2417 -c "got a certificate request" \
2418 -C "skip write certificate" \
2419 -C "skip write certificate verify" \
2420 -S "skip parse certificate verify" \
2421 -S "x509_verify_cert() returned" \
2422 -S "! The certificate is not correctly signed by the trusted CA" \
2423 -S "The certificate has been revoked (is on a CRL)"
2424
Andres Amaya Garcia021ad3d2018-05-01 20:26:47 +01002425run_test "SNI: DTLS, CA override with CRL" \
Andres AG52142f12016-12-07 10:01:30 +00002426 "$P_SRV debug_level=3 auth_mode=optional \
2427 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2428 ca_file=data_files/test-ca.crt \
2429 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2430 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2431 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2432 1 \
2433 -S "skip write certificate request" \
2434 -C "skip parse certificate request" \
2435 -c "got a certificate request" \
2436 -C "skip write certificate" \
2437 -C "skip write certificate verify" \
2438 -S "skip parse certificate verify" \
2439 -s "x509_verify_cert() returned" \
2440 -S "! The certificate is not correctly signed by the trusted CA" \
2441 -s "The certificate has been revoked (is on a CRL)"
2442
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002443# Tests for non-blocking I/O: exercise a variety of handshake flows
2444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002445run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002446 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2447 "$P_CLI nbio=2 tickets=0" \
2448 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002449 -S "mbedtls_ssl_handshake returned" \
2450 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002451 -c "Read from server: .* bytes read"
2452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002453run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002454 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2455 "$P_CLI nbio=2 tickets=0" \
2456 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002457 -S "mbedtls_ssl_handshake returned" \
2458 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002459 -c "Read from server: .* bytes read"
2460
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002461run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002462 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2463 "$P_CLI nbio=2 tickets=1" \
2464 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002465 -S "mbedtls_ssl_handshake returned" \
2466 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002467 -c "Read from server: .* bytes read"
2468
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002469run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002470 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2471 "$P_CLI nbio=2 tickets=1" \
2472 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002473 -S "mbedtls_ssl_handshake returned" \
2474 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002475 -c "Read from server: .* bytes read"
2476
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002477run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002478 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2479 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2480 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002481 -S "mbedtls_ssl_handshake returned" \
2482 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002483 -c "Read from server: .* bytes read"
2484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002485run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002486 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2487 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2488 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002489 -S "mbedtls_ssl_handshake returned" \
2490 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002491 -c "Read from server: .* bytes read"
2492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002493run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002494 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2495 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2496 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002497 -S "mbedtls_ssl_handshake returned" \
2498 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002499 -c "Read from server: .* bytes read"
2500
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002501# Tests for version negotiation
2502
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002503run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002504 "$P_SRV" \
2505 "$P_CLI" \
2506 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002507 -S "mbedtls_ssl_handshake returned" \
2508 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002509 -s "Protocol is TLSv1.2" \
2510 -c "Protocol is TLSv1.2"
2511
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002512run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002513 "$P_SRV" \
2514 "$P_CLI max_version=tls1_1" \
2515 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002516 -S "mbedtls_ssl_handshake returned" \
2517 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002518 -s "Protocol is TLSv1.1" \
2519 -c "Protocol is TLSv1.1"
2520
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002521run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002522 "$P_SRV max_version=tls1_1" \
2523 "$P_CLI" \
2524 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002525 -S "mbedtls_ssl_handshake returned" \
2526 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002527 -s "Protocol is TLSv1.1" \
2528 -c "Protocol is TLSv1.1"
2529
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002530run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002531 "$P_SRV max_version=tls1_1" \
2532 "$P_CLI max_version=tls1_1" \
2533 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002534 -S "mbedtls_ssl_handshake returned" \
2535 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002536 -s "Protocol is TLSv1.1" \
2537 -c "Protocol is TLSv1.1"
2538
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002539run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002540 "$P_SRV min_version=tls1_1" \
2541 "$P_CLI max_version=tls1_1" \
2542 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002543 -S "mbedtls_ssl_handshake returned" \
2544 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002545 -s "Protocol is TLSv1.1" \
2546 -c "Protocol is TLSv1.1"
2547
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002548run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002549 "$P_SRV max_version=tls1_1" \
2550 "$P_CLI min_version=tls1_1" \
2551 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002552 -S "mbedtls_ssl_handshake returned" \
2553 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002554 -s "Protocol is TLSv1.1" \
2555 -c "Protocol is TLSv1.1"
2556
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002557run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002558 "$P_SRV max_version=tls1_1" \
2559 "$P_CLI min_version=tls1_2" \
2560 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002561 -s "mbedtls_ssl_handshake returned" \
2562 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002563 -c "SSL - Handshake protocol not within min/max boundaries"
2564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002565run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002566 "$P_SRV min_version=tls1_2" \
2567 "$P_CLI max_version=tls1_1" \
2568 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002569 -s "mbedtls_ssl_handshake returned" \
2570 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002571 -s "SSL - Handshake protocol not within min/max boundaries"
2572
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002573# Tests for ALPN extension
2574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002575run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002576 "$P_SRV debug_level=3" \
2577 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002578 0 \
2579 -C "client hello, adding alpn extension" \
2580 -S "found alpn extension" \
2581 -C "got an alert message, type: \\[2:120]" \
2582 -S "server hello, adding alpn extension" \
2583 -C "found alpn extension " \
2584 -C "Application Layer Protocol is" \
2585 -S "Application Layer Protocol is"
2586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002587run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002588 "$P_SRV debug_level=3" \
2589 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002590 0 \
2591 -c "client hello, adding alpn extension" \
2592 -s "found alpn extension" \
2593 -C "got an alert message, type: \\[2:120]" \
2594 -S "server hello, adding alpn extension" \
2595 -C "found alpn extension " \
2596 -c "Application Layer Protocol is (none)" \
2597 -S "Application Layer Protocol is"
2598
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002599run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002600 "$P_SRV debug_level=3 alpn=abc,1234" \
2601 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002602 0 \
2603 -C "client hello, adding alpn extension" \
2604 -S "found alpn extension" \
2605 -C "got an alert message, type: \\[2:120]" \
2606 -S "server hello, adding alpn extension" \
2607 -C "found alpn extension " \
2608 -C "Application Layer Protocol is" \
2609 -s "Application Layer Protocol is (none)"
2610
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002611run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002612 "$P_SRV debug_level=3 alpn=abc,1234" \
2613 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002614 0 \
2615 -c "client hello, adding alpn extension" \
2616 -s "found alpn extension" \
2617 -C "got an alert message, type: \\[2:120]" \
2618 -s "server hello, adding alpn extension" \
2619 -c "found alpn extension" \
2620 -c "Application Layer Protocol is abc" \
2621 -s "Application Layer Protocol is abc"
2622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002623run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002624 "$P_SRV debug_level=3 alpn=abc,1234" \
2625 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002626 0 \
2627 -c "client hello, adding alpn extension" \
2628 -s "found alpn extension" \
2629 -C "got an alert message, type: \\[2:120]" \
2630 -s "server hello, adding alpn extension" \
2631 -c "found alpn extension" \
2632 -c "Application Layer Protocol is abc" \
2633 -s "Application Layer Protocol is abc"
2634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002635run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002636 "$P_SRV debug_level=3 alpn=abc,1234" \
2637 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002638 0 \
2639 -c "client hello, adding alpn extension" \
2640 -s "found alpn extension" \
2641 -C "got an alert message, type: \\[2:120]" \
2642 -s "server hello, adding alpn extension" \
2643 -c "found alpn extension" \
2644 -c "Application Layer Protocol is 1234" \
2645 -s "Application Layer Protocol is 1234"
2646
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002647run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002648 "$P_SRV debug_level=3 alpn=abc,123" \
2649 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002650 1 \
2651 -c "client hello, adding alpn extension" \
2652 -s "found alpn extension" \
2653 -c "got an alert message, type: \\[2:120]" \
2654 -S "server hello, adding alpn extension" \
2655 -C "found alpn extension" \
2656 -C "Application Layer Protocol is 1234" \
2657 -S "Application Layer Protocol is 1234"
2658
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002659
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002660# Tests for keyUsage in leaf certificates, part 1:
2661# server-side certificate/suite selection
2662
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002663run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002664 "$P_SRV key_file=data_files/server2.key \
2665 crt_file=data_files/server2.ku-ds.crt" \
2666 "$P_CLI" \
2667 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002668 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002669
2670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002671run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002672 "$P_SRV key_file=data_files/server2.key \
2673 crt_file=data_files/server2.ku-ke.crt" \
2674 "$P_CLI" \
2675 0 \
2676 -c "Ciphersuite is TLS-RSA-WITH-"
2677
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002678run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002679 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002680 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002681 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002682 1 \
2683 -C "Ciphersuite is "
2684
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002685run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002686 "$P_SRV key_file=data_files/server5.key \
2687 crt_file=data_files/server5.ku-ds.crt" \
2688 "$P_CLI" \
2689 0 \
2690 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2691
2692
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002693run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002694 "$P_SRV key_file=data_files/server5.key \
2695 crt_file=data_files/server5.ku-ka.crt" \
2696 "$P_CLI" \
2697 0 \
2698 -c "Ciphersuite is TLS-ECDH-"
2699
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002700run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002701 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002702 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002703 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002704 1 \
2705 -C "Ciphersuite is "
2706
2707# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002708# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002709
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002710run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002711 "$O_SRV -key data_files/server2.key \
2712 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002713 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002714 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2715 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002716 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002717 -C "Processing of the Certificate handshake message failed" \
2718 -c "Ciphersuite is TLS-"
2719
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002720run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002721 "$O_SRV -key data_files/server2.key \
2722 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002723 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002724 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2725 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002726 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002727 -C "Processing of the Certificate handshake message failed" \
2728 -c "Ciphersuite is TLS-"
2729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002730run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002731 "$O_SRV -key data_files/server2.key \
2732 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002733 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002734 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2735 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002736 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002737 -C "Processing of the Certificate handshake message failed" \
2738 -c "Ciphersuite is TLS-"
2739
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002740run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002741 "$O_SRV -key data_files/server2.key \
2742 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002743 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002744 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2745 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002746 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002747 -c "Processing of the Certificate handshake message failed" \
2748 -C "Ciphersuite is TLS-"
2749
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002750run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2751 "$O_SRV -key data_files/server2.key \
2752 -cert data_files/server2.ku-ke.crt" \
2753 "$P_CLI debug_level=1 auth_mode=optional \
2754 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2755 0 \
2756 -c "bad certificate (usage extensions)" \
2757 -C "Processing of the Certificate handshake message failed" \
2758 -c "Ciphersuite is TLS-" \
2759 -c "! Usage does not match the keyUsage extension"
2760
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002761run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002762 "$O_SRV -key data_files/server2.key \
2763 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002764 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002765 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2766 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002767 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002768 -C "Processing of the Certificate handshake message failed" \
2769 -c "Ciphersuite is TLS-"
2770
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002771run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002772 "$O_SRV -key data_files/server2.key \
2773 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002774 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002775 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2776 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002777 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002778 -c "Processing of the Certificate handshake message failed" \
2779 -C "Ciphersuite is TLS-"
2780
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002781run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2782 "$O_SRV -key data_files/server2.key \
2783 -cert data_files/server2.ku-ds.crt" \
2784 "$P_CLI debug_level=1 auth_mode=optional \
2785 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2786 0 \
2787 -c "bad certificate (usage extensions)" \
2788 -C "Processing of the Certificate handshake message failed" \
2789 -c "Ciphersuite is TLS-" \
2790 -c "! Usage does not match the keyUsage extension"
2791
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002792# Tests for keyUsage in leaf certificates, part 3:
2793# server-side checking of client cert
2794
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002795run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002796 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002797 "$O_CLI -key data_files/server2.key \
2798 -cert data_files/server2.ku-ds.crt" \
2799 0 \
2800 -S "bad certificate (usage extensions)" \
2801 -S "Processing of the Certificate handshake message failed"
2802
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002803run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002804 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002805 "$O_CLI -key data_files/server2.key \
2806 -cert data_files/server2.ku-ke.crt" \
2807 0 \
2808 -s "bad certificate (usage extensions)" \
2809 -S "Processing of the Certificate handshake message failed"
2810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002811run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002812 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002813 "$O_CLI -key data_files/server2.key \
2814 -cert data_files/server2.ku-ke.crt" \
2815 1 \
2816 -s "bad certificate (usage extensions)" \
2817 -s "Processing of the Certificate handshake message failed"
2818
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002819run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002820 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002821 "$O_CLI -key data_files/server5.key \
2822 -cert data_files/server5.ku-ds.crt" \
2823 0 \
2824 -S "bad certificate (usage extensions)" \
2825 -S "Processing of the Certificate handshake message failed"
2826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002827run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002828 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002829 "$O_CLI -key data_files/server5.key \
2830 -cert data_files/server5.ku-ka.crt" \
2831 0 \
2832 -s "bad certificate (usage extensions)" \
2833 -S "Processing of the Certificate handshake message failed"
2834
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002835# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2836
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002837run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002838 "$P_SRV key_file=data_files/server5.key \
2839 crt_file=data_files/server5.eku-srv.crt" \
2840 "$P_CLI" \
2841 0
2842
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002843run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002844 "$P_SRV key_file=data_files/server5.key \
2845 crt_file=data_files/server5.eku-srv.crt" \
2846 "$P_CLI" \
2847 0
2848
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002849run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002850 "$P_SRV key_file=data_files/server5.key \
2851 crt_file=data_files/server5.eku-cs_any.crt" \
2852 "$P_CLI" \
2853 0
2854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002855run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002856 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002857 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002858 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002859 1
2860
2861# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2862
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002863run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002864 "$O_SRV -key data_files/server5.key \
2865 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002866 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002867 0 \
2868 -C "bad certificate (usage extensions)" \
2869 -C "Processing of the Certificate handshake message failed" \
2870 -c "Ciphersuite is TLS-"
2871
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002872run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002873 "$O_SRV -key data_files/server5.key \
2874 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002875 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002876 0 \
2877 -C "bad certificate (usage extensions)" \
2878 -C "Processing of the Certificate handshake message failed" \
2879 -c "Ciphersuite is TLS-"
2880
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002881run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002882 "$O_SRV -key data_files/server5.key \
2883 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002884 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002885 0 \
2886 -C "bad certificate (usage extensions)" \
2887 -C "Processing of the Certificate handshake message failed" \
2888 -c "Ciphersuite is TLS-"
2889
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002890run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002891 "$O_SRV -key data_files/server5.key \
2892 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002893 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002894 1 \
2895 -c "bad certificate (usage extensions)" \
2896 -c "Processing of the Certificate handshake message failed" \
2897 -C "Ciphersuite is TLS-"
2898
2899# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2900
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002901run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002902 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002903 "$O_CLI -key data_files/server5.key \
2904 -cert data_files/server5.eku-cli.crt" \
2905 0 \
2906 -S "bad certificate (usage extensions)" \
2907 -S "Processing of the Certificate handshake message failed"
2908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002909run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002910 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002911 "$O_CLI -key data_files/server5.key \
2912 -cert data_files/server5.eku-srv_cli.crt" \
2913 0 \
2914 -S "bad certificate (usage extensions)" \
2915 -S "Processing of the Certificate handshake message failed"
2916
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002917run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002918 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002919 "$O_CLI -key data_files/server5.key \
2920 -cert data_files/server5.eku-cs_any.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 "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002926 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002927 "$O_CLI -key data_files/server5.key \
2928 -cert data_files/server5.eku-cs.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 "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002934 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002935 "$O_CLI -key data_files/server5.key \
2936 -cert data_files/server5.eku-cs.crt" \
2937 1 \
2938 -s "bad certificate (usage extensions)" \
2939 -s "Processing of the Certificate handshake message failed"
2940
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002941# Tests for DHM parameters loading
2942
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002943run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002944 "$P_SRV" \
2945 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2946 debug_level=3" \
2947 0 \
2948 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker80e0d462017-10-13 16:51:54 +01002949 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002951run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002952 "$P_SRV dhm_file=data_files/dhparams.pem" \
2953 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2954 debug_level=3" \
2955 0 \
2956 -c "value of 'DHM: P ' (1024 bits)" \
2957 -c "value of 'DHM: G ' (2 bits)"
2958
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002959# Tests for DHM client-side size checking
2960
2961run_test "DHM size: server default, client default, OK" \
2962 "$P_SRV" \
2963 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2964 debug_level=1" \
2965 0 \
2966 -C "DHM prime too short:"
2967
2968run_test "DHM size: server default, client 2048, OK" \
2969 "$P_SRV" \
2970 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2971 debug_level=1 dhmlen=2048" \
2972 0 \
2973 -C "DHM prime too short:"
2974
2975run_test "DHM size: server 1024, client default, OK" \
2976 "$P_SRV dhm_file=data_files/dhparams.pem" \
2977 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2978 debug_level=1" \
2979 0 \
2980 -C "DHM prime too short:"
2981
2982run_test "DHM size: server 1000, client default, rejected" \
2983 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2984 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2985 debug_level=1" \
2986 1 \
2987 -c "DHM prime too short:"
2988
2989run_test "DHM size: server default, client 2049, rejected" \
2990 "$P_SRV" \
2991 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2992 debug_level=1 dhmlen=2049" \
2993 1 \
2994 -c "DHM prime too short:"
2995
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002996# Tests for PSK callback
2997
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002998run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002999 "$P_SRV psk=abc123 psk_identity=foo" \
3000 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3001 psk_identity=foo psk=abc123" \
3002 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003003 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003004 -S "SSL - Unknown identity received" \
3005 -S "SSL - Verification of the message MAC failed"
3006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003007run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003008 "$P_SRV" \
3009 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3010 psk_identity=foo psk=abc123" \
3011 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003012 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003013 -S "SSL - Unknown identity received" \
3014 -S "SSL - Verification of the message MAC failed"
3015
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003016run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003017 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3018 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3019 psk_identity=foo psk=abc123" \
3020 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003021 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003022 -s "SSL - Unknown identity received" \
3023 -S "SSL - Verification of the message MAC failed"
3024
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003025run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003026 "$P_SRV psk_list=abc,dead,def,beef" \
3027 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3028 psk_identity=abc psk=dead" \
3029 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003030 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003031 -S "SSL - Unknown identity received" \
3032 -S "SSL - Verification of the message MAC failed"
3033
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003034run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003035 "$P_SRV psk_list=abc,dead,def,beef" \
3036 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3037 psk_identity=def psk=beef" \
3038 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003039 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003040 -S "SSL - Unknown identity received" \
3041 -S "SSL - Verification of the message MAC failed"
3042
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003043run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003044 "$P_SRV psk_list=abc,dead,def,beef" \
3045 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3046 psk_identity=ghi psk=beef" \
3047 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003048 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003049 -s "SSL - Unknown identity received" \
3050 -S "SSL - Verification of the message MAC failed"
3051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003052run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003053 "$P_SRV psk_list=abc,dead,def,beef" \
3054 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3055 psk_identity=abc psk=beef" \
3056 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003057 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003058 -S "SSL - Unknown identity received" \
3059 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003060
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003061# Tests for ciphersuites per version
3062
Janos Follath542ee5d2016-03-07 15:57:05 +00003063requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003064run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003065 "$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 +02003066 "$P_CLI force_version=ssl3" \
3067 0 \
3068 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003070run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003071 "$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 +01003072 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003073 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003074 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003075
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003076run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003077 "$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 +02003078 "$P_CLI force_version=tls1_1" \
3079 0 \
3080 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003082run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003083 "$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 +02003084 "$P_CLI force_version=tls1_2" \
3085 0 \
3086 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3087
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003088# Test for ClientHello without extensions
3089
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003090requires_gnutls
Gilles Peskine7344e1b2017-05-12 13:16:40 +02003091run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003092 "$P_SRV debug_level=3" \
3093 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3094 0 \
3095 -s "dumping 'client hello extensions' (0 bytes)"
3096
Gilles Peskine7344e1b2017-05-12 13:16:40 +02003097requires_gnutls
3098run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3099 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3100 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3101 0 \
3102 -s "dumping 'client hello extensions' (0 bytes)"
3103
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003104# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003105
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003106run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003107 "$P_SRV" \
3108 "$P_CLI request_size=100" \
3109 0 \
3110 -s "Read from client: 100 bytes read$"
3111
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003112run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003113 "$P_SRV" \
3114 "$P_CLI request_size=500" \
3115 0 \
3116 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003117
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003118# Tests for small packets
3119
Janos Follath542ee5d2016-03-07 15:57:05 +00003120requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003121run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003122 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003123 "$P_CLI request_size=1 force_version=ssl3 \
3124 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3125 0 \
3126 -s "Read from client: 1 bytes read"
3127
Janos Follath542ee5d2016-03-07 15:57:05 +00003128requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003129run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003130 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003131 "$P_CLI request_size=1 force_version=ssl3 \
3132 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3133 0 \
3134 -s "Read from client: 1 bytes read"
3135
3136run_test "Small packet TLS 1.0 BlockCipher" \
3137 "$P_SRV" \
3138 "$P_CLI request_size=1 force_version=tls1 \
3139 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3140 0 \
3141 -s "Read from client: 1 bytes read"
3142
Hanno Becker7aae46c2017-11-10 08:59:04 +00003143run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003144 "$P_SRV" \
3145 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3146 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3147 0 \
3148 -s "Read from client: 1 bytes read"
3149
Hanno Beckera83fafa2017-11-10 08:42:54 +00003150requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003151run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003152 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003153 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003154 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003155 0 \
3156 -s "Read from client: 1 bytes read"
3157
Hanno Beckera83fafa2017-11-10 08:42:54 +00003158requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003159run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003160 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003161 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003162 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003163 0 \
3164 -s "Read from client: 1 bytes read"
3165
3166run_test "Small packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003167 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003168 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003169 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3170 0 \
3171 -s "Read from client: 1 bytes read"
3172
3173run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3174 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3175 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003176 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003177 0 \
3178 -s "Read from client: 1 bytes read"
3179
3180requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3181run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003182 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003183 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003184 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003185 0 \
3186 -s "Read from client: 1 bytes read"
3187
Hanno Becker7aae46c2017-11-10 08:59:04 +00003188requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3189run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003190 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3191 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3192 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003193 0 \
3194 -s "Read from client: 1 bytes read"
3195
3196run_test "Small packet TLS 1.1 BlockCipher" \
3197 "$P_SRV" \
3198 "$P_CLI request_size=1 force_version=tls1_1 \
3199 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3200 0 \
3201 -s "Read from client: 1 bytes read"
3202
Hanno Becker7aae46c2017-11-10 08:59:04 +00003203run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003204 "$P_SRV" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003205 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003206 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003207 0 \
3208 -s "Read from client: 1 bytes read"
3209
3210requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3211run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003212 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003213 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003214 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003215 0 \
3216 -s "Read from client: 1 bytes read"
3217
3218requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3219run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003220 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003221 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003222 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003223 0 \
3224 -s "Read from client: 1 bytes read"
3225
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003226run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003227 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003228 "$P_CLI request_size=1 force_version=tls1_1 \
3229 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3230 0 \
3231 -s "Read from client: 1 bytes read"
3232
Hanno Becker7aae46c2017-11-10 08:59:04 +00003233run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3234 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003235 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003236 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003237 0 \
3238 -s "Read from client: 1 bytes read"
3239
Hanno Becker7aae46c2017-11-10 08:59:04 +00003240requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3241run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003242 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003243 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003244 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003245 0 \
3246 -s "Read from client: 1 bytes read"
3247
Hanno Beckera83fafa2017-11-10 08:42:54 +00003248requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003249run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003250 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003251 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003252 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003253 0 \
3254 -s "Read from client: 1 bytes read"
3255
3256run_test "Small packet TLS 1.2 BlockCipher" \
3257 "$P_SRV" \
3258 "$P_CLI request_size=1 force_version=tls1_2 \
3259 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3260 0 \
3261 -s "Read from client: 1 bytes read"
3262
Hanno Becker7aae46c2017-11-10 08:59:04 +00003263run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003264 "$P_SRV" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003265 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003266 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003267 0 \
3268 -s "Read from client: 1 bytes read"
3269
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003270run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3271 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003272 "$P_CLI request_size=1 force_version=tls1_2 \
3273 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003274 0 \
3275 -s "Read from client: 1 bytes read"
3276
Hanno Beckera83fafa2017-11-10 08:42:54 +00003277requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003278run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003279 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003280 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003281 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003282 0 \
3283 -s "Read from client: 1 bytes read"
3284
Hanno Becker7aae46c2017-11-10 08:59:04 +00003285requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3286run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003287 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003288 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003289 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003290 0 \
3291 -s "Read from client: 1 bytes read"
3292
3293run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003294 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003295 "$P_CLI request_size=1 force_version=tls1_2 \
3296 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3297 0 \
3298 -s "Read from client: 1 bytes read"
3299
Hanno Becker7aae46c2017-11-10 08:59:04 +00003300run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003301 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003302 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003303 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003304 0 \
3305 -s "Read from client: 1 bytes read"
3306
Hanno Beckera83fafa2017-11-10 08:42:54 +00003307requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003308run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003309 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003310 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003311 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003312 0 \
3313 -s "Read from client: 1 bytes read"
3314
Hanno Becker7aae46c2017-11-10 08:59:04 +00003315requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3316run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003317 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003318 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003319 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003320 0 \
3321 -s "Read from client: 1 bytes read"
3322
3323run_test "Small packet TLS 1.2 AEAD" \
3324 "$P_SRV" \
3325 "$P_CLI request_size=1 force_version=tls1_2 \
3326 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3327 0 \
3328 -s "Read from client: 1 bytes read"
3329
3330run_test "Small packet TLS 1.2 AEAD shorter tag" \
3331 "$P_SRV" \
3332 "$P_CLI request_size=1 force_version=tls1_2 \
3333 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3334 0 \
3335 -s "Read from client: 1 bytes read"
3336
Hanno Becker461cb812017-11-10 08:59:18 +00003337# Tests for small packets in DTLS
3338
3339requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3340run_test "Small packet DTLS 1.0" \
3341 "$P_SRV dtls=1 force_version=dtls1" \
3342 "$P_CLI dtls=1 request_size=1 \
3343 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3344 0 \
3345 -s "Read from client: 1 bytes read"
3346
3347requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3348run_test "Small packet DTLS 1.0, without EtM" \
3349 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3350 "$P_CLI dtls=1 request_size=1 \
3351 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3352 0 \
3353 -s "Read from client: 1 bytes read"
3354
3355requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3356requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3357run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003358 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3359 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Becker461cb812017-11-10 08:59:18 +00003360 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3361 0 \
3362 -s "Read from client: 1 bytes read"
3363
3364requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3365requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3366run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003367 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Becker461cb812017-11-10 08:59:18 +00003368 "$P_CLI dtls=1 request_size=1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003369 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Becker461cb812017-11-10 08:59:18 +00003370 0 \
3371 -s "Read from client: 1 bytes read"
3372
3373requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3374run_test "Small packet DTLS 1.2" \
3375 "$P_SRV dtls=1 force_version=dtls1_2" \
3376 "$P_CLI dtls=1 request_size=1 \
3377 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3378 0 \
3379 -s "Read from client: 1 bytes read"
3380
3381requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3382run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003383 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Becker461cb812017-11-10 08:59:18 +00003384 "$P_CLI dtls=1 request_size=1 \
3385 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3386 0 \
3387 -s "Read from client: 1 bytes read"
3388
3389requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3390requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3391run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003392 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Becker461cb812017-11-10 08:59:18 +00003393 "$P_CLI dtls=1 request_size=1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003394 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker461cb812017-11-10 08:59:18 +00003395 0 \
3396 -s "Read from client: 1 bytes read"
3397
3398requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3399requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3400run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003401 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Becker461cb812017-11-10 08:59:18 +00003402 "$P_CLI dtls=1 request_size=1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003403 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Becker461cb812017-11-10 08:59:18 +00003404 0 \
3405 -s "Read from client: 1 bytes read"
3406
Janos Follathb700c462016-05-06 13:48:23 +01003407# A test for extensions in SSLv3
3408
3409requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3410run_test "SSLv3 with extensions, server side" \
3411 "$P_SRV min_version=ssl3 debug_level=3" \
3412 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3413 0 \
3414 -S "dumping 'client hello extensions'" \
3415 -S "server hello, total extension length:"
3416
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003417# Test for large packets
3418
Janos Follath542ee5d2016-03-07 15:57:05 +00003419requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003420run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003421 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003422 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003423 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3424 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003425 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003426 -s "Read from client: 16384 bytes read"
3427
Janos Follath542ee5d2016-03-07 15:57:05 +00003428requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003429run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003430 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003431 "$P_CLI request_size=16384 force_version=ssl3 \
3432 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3433 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003434 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003435 -s "Read from client: 16384 bytes read"
3436
3437run_test "Large packet TLS 1.0 BlockCipher" \
3438 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003439 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003440 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3441 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003442 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003443 -s "Read from client: 16384 bytes read"
3444
Hanno Becker0b9d9132017-11-10 09:16:28 +00003445run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003446 "$P_SRV" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003447 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3448 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3449 0 \
3450 -s "Read from client: 16384 bytes read"
3451
Hanno Beckera83fafa2017-11-10 08:42:54 +00003452requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003453run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003454 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003455 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003456 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003457 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003458 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003459 -s "Read from client: 16384 bytes read"
3460
Hanno Beckera83fafa2017-11-10 08:42:54 +00003461requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003462run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003463 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003464 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003465 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003466 0 \
3467 -s "Read from client: 16384 bytes read"
3468
3469run_test "Large packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003470 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003471 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003472 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3473 0 \
3474 -s "Read from client: 16384 bytes read"
3475
3476run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
3477 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3478 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003479 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003480 0 \
3481 -s "Read from client: 16384 bytes read"
3482
3483requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3484run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003485 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003486 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003487 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003488 0 \
3489 -s "Read from client: 16384 bytes read"
3490
Hanno Becker0b9d9132017-11-10 09:16:28 +00003491requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3492run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003493 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003494 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003495 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003496 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003497 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003498 -s "Read from client: 16384 bytes read"
3499
3500run_test "Large packet TLS 1.1 BlockCipher" \
3501 "$P_SRV" \
3502 "$P_CLI request_size=16384 force_version=tls1_1 \
3503 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3504 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003505 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003506 -s "Read from client: 16384 bytes read"
3507
Hanno Becker0b9d9132017-11-10 09:16:28 +00003508run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
3509 "$P_SRV" \
3510 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
3511 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003512 0 \
3513 -s "Read from client: 16384 bytes read"
3514
Hanno Beckera83fafa2017-11-10 08:42:54 +00003515requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003516run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003517 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003518 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003519 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003520 0 \
3521 -s "Read from client: 16384 bytes read"
3522
Hanno Beckera83fafa2017-11-10 08:42:54 +00003523requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003524run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003525 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003526 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003527 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003528 0 \
3529 -s "Read from client: 16384 bytes read"
3530
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003531run_test "Large packet TLS 1.1 StreamCipher" \
3532 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3533 "$P_CLI request_size=16384 force_version=tls1_1 \
3534 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3535 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003536 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003537 -s "Read from client: 16384 bytes read"
3538
Hanno Becker0b9d9132017-11-10 09:16:28 +00003539run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
3540 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003541 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003542 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003543 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003544 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003545 -s "Read from client: 16384 bytes read"
3546
Hanno Becker0b9d9132017-11-10 09:16:28 +00003547requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3548run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003549 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003550 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003551 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003552 0 \
3553 -s "Read from client: 16384 bytes read"
3554
Hanno Becker0b9d9132017-11-10 09:16:28 +00003555requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3556run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003557 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003558 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003559 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003560 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003561 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003562 -s "Read from client: 16384 bytes read"
3563
3564run_test "Large packet TLS 1.2 BlockCipher" \
3565 "$P_SRV" \
3566 "$P_CLI request_size=16384 force_version=tls1_2 \
3567 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3568 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003569 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003570 -s "Read from client: 16384 bytes read"
3571
Hanno Becker0b9d9132017-11-10 09:16:28 +00003572run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
3573 "$P_SRV" \
3574 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
3575 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3576 0 \
3577 -s "Read from client: 16384 bytes read"
3578
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003579run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3580 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003581 "$P_CLI request_size=16384 force_version=tls1_2 \
3582 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003583 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003584 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003585 -s "Read from client: 16384 bytes read"
3586
Hanno Beckera83fafa2017-11-10 08:42:54 +00003587requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003588run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003589 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003590 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003591 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003592 0 \
3593 -s "Read from client: 16384 bytes read"
3594
Hanno Becker0b9d9132017-11-10 09:16:28 +00003595requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3596run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003597 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003598 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003599 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003600 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003601 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003602 -s "Read from client: 16384 bytes read"
3603
3604run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003605 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003606 "$P_CLI request_size=16384 force_version=tls1_2 \
3607 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3608 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003609 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003610 -s "Read from client: 16384 bytes read"
3611
Hanno Becker0b9d9132017-11-10 09:16:28 +00003612run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003613 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003614 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003615 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
3616 0 \
3617 -s "Read from client: 16384 bytes read"
3618
Hanno Beckera83fafa2017-11-10 08:42:54 +00003619requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003620run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003621 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003622 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003623 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003624 0 \
3625 -s "Read from client: 16384 bytes read"
3626
Hanno Becker0b9d9132017-11-10 09:16:28 +00003627requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3628run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003629 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003630 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003631 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003632 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003633 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003634 -s "Read from client: 16384 bytes read"
3635
3636run_test "Large packet TLS 1.2 AEAD" \
3637 "$P_SRV" \
3638 "$P_CLI request_size=16384 force_version=tls1_2 \
3639 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3640 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003641 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003642 -s "Read from client: 16384 bytes read"
3643
3644run_test "Large packet TLS 1.2 AEAD shorter tag" \
3645 "$P_SRV" \
3646 "$P_CLI request_size=16384 force_version=tls1_2 \
3647 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3648 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003649 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003650 -s "Read from client: 16384 bytes read"
3651
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003652# Tests for DTLS HelloVerifyRequest
3653
3654run_test "DTLS cookie: enabled" \
3655 "$P_SRV dtls=1 debug_level=2" \
3656 "$P_CLI dtls=1 debug_level=2" \
3657 0 \
3658 -s "cookie verification failed" \
3659 -s "cookie verification passed" \
3660 -S "cookie verification skipped" \
3661 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003662 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003663 -S "SSL - The requested feature is not available"
3664
3665run_test "DTLS cookie: disabled" \
3666 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3667 "$P_CLI dtls=1 debug_level=2" \
3668 0 \
3669 -S "cookie verification failed" \
3670 -S "cookie verification passed" \
3671 -s "cookie verification skipped" \
3672 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003673 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003674 -S "SSL - The requested feature is not available"
3675
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003676run_test "DTLS cookie: default (failing)" \
3677 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3678 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3679 1 \
3680 -s "cookie verification failed" \
3681 -S "cookie verification passed" \
3682 -S "cookie verification skipped" \
3683 -C "received hello verify request" \
3684 -S "hello verification requested" \
3685 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003686
3687requires_ipv6
3688run_test "DTLS cookie: enabled, IPv6" \
3689 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3690 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3691 0 \
3692 -s "cookie verification failed" \
3693 -s "cookie verification passed" \
3694 -S "cookie verification skipped" \
3695 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003696 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003697 -S "SSL - The requested feature is not available"
3698
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003699run_test "DTLS cookie: enabled, nbio" \
3700 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3701 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3702 0 \
3703 -s "cookie verification failed" \
3704 -s "cookie verification passed" \
3705 -S "cookie verification skipped" \
3706 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003707 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003708 -S "SSL - The requested feature is not available"
3709
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003710# Tests for client reconnecting from the same port with DTLS
3711
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003712not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003713run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003714 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3715 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003716 0 \
3717 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003718 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003719 -S "Client initiated reconnection from same port"
3720
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003721not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003722run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003723 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3724 "$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 +02003725 0 \
3726 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003727 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003728 -s "Client initiated reconnection from same port"
3729
Paul Bakker3b224ff2016-05-13 10:33:25 +01003730not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3731run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003732 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3733 "$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 +02003734 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003735 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003736 -s "Client initiated reconnection from same port"
3737
Paul Bakker3b224ff2016-05-13 10:33:25 +01003738only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3739run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3740 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3741 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3742 0 \
3743 -S "The operation timed out" \
3744 -s "Client initiated reconnection from same port"
3745
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003746run_test "DTLS client reconnect from same port: no cookies" \
3747 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003748 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3749 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003750 -s "The operation timed out" \
3751 -S "Client initiated reconnection from same port"
3752
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003753# Tests for various cases of client authentication with DTLS
3754# (focused on handshake flows and message parsing)
3755
3756run_test "DTLS client auth: required" \
3757 "$P_SRV dtls=1 auth_mode=required" \
3758 "$P_CLI dtls=1" \
3759 0 \
3760 -s "Verifying peer X.509 certificate... ok"
3761
3762run_test "DTLS client auth: optional, client has no cert" \
3763 "$P_SRV dtls=1 auth_mode=optional" \
3764 "$P_CLI dtls=1 crt_file=none key_file=none" \
3765 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003766 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003767
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003768run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003769 "$P_SRV dtls=1 auth_mode=none" \
3770 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3771 0 \
3772 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003773 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003774
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003775run_test "DTLS wrong PSK: badmac alert" \
3776 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3777 "$P_CLI dtls=1 psk=abc124" \
3778 1 \
3779 -s "SSL - Verification of the message MAC failed" \
3780 -c "SSL - A fatal alert message was received from our peer"
3781
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003782# Tests for receiving fragmented handshake messages with DTLS
3783
3784requires_gnutls
3785run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3786 "$G_SRV -u --mtu 2048 -a" \
3787 "$P_CLI dtls=1 debug_level=2" \
3788 0 \
3789 -C "found fragmented DTLS handshake message" \
3790 -C "error"
3791
3792requires_gnutls
3793run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3794 "$G_SRV -u --mtu 512" \
3795 "$P_CLI dtls=1 debug_level=2" \
3796 0 \
3797 -c "found fragmented DTLS handshake message" \
3798 -C "error"
3799
3800requires_gnutls
3801run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3802 "$G_SRV -u --mtu 128" \
3803 "$P_CLI dtls=1 debug_level=2" \
3804 0 \
3805 -c "found fragmented DTLS handshake message" \
3806 -C "error"
3807
3808requires_gnutls
3809run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3810 "$G_SRV -u --mtu 128" \
3811 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3812 0 \
3813 -c "found fragmented DTLS handshake message" \
3814 -C "error"
3815
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003816requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01003817requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003818run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3819 "$G_SRV -u --mtu 256" \
3820 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3821 0 \
3822 -c "found fragmented DTLS handshake message" \
3823 -c "client hello, adding renegotiation extension" \
3824 -c "found renegotiation extension" \
3825 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003826 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003827 -C "error" \
3828 -s "Extra-header:"
3829
3830requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01003831requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003832run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3833 "$G_SRV -u --mtu 256" \
3834 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3835 0 \
3836 -c "found fragmented DTLS handshake message" \
3837 -c "client hello, adding renegotiation extension" \
3838 -c "found renegotiation extension" \
3839 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003840 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003841 -C "error" \
3842 -s "Extra-header:"
3843
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003844run_test "DTLS reassembly: no fragmentation (openssl server)" \
3845 "$O_SRV -dtls1 -mtu 2048" \
3846 "$P_CLI dtls=1 debug_level=2" \
3847 0 \
3848 -C "found fragmented DTLS handshake message" \
3849 -C "error"
3850
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003851run_test "DTLS reassembly: some fragmentation (openssl server)" \
3852 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003853 "$P_CLI dtls=1 debug_level=2" \
3854 0 \
3855 -c "found fragmented DTLS handshake message" \
3856 -C "error"
3857
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003858run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003859 "$O_SRV -dtls1 -mtu 256" \
3860 "$P_CLI dtls=1 debug_level=2" \
3861 0 \
3862 -c "found fragmented DTLS handshake message" \
3863 -C "error"
3864
3865run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3866 "$O_SRV -dtls1 -mtu 256" \
3867 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3868 0 \
3869 -c "found fragmented DTLS handshake message" \
3870 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003871
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003872# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003873
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003874not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003875run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003876 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003877 "$P_SRV dtls=1 debug_level=2" \
3878 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003879 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003880 -C "replayed record" \
3881 -S "replayed record" \
3882 -C "record from another epoch" \
3883 -S "record from another epoch" \
3884 -C "discarding invalid record" \
3885 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003886 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003887 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003888 -c "HTTP/1.0 200 OK"
3889
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003890not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003891run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003892 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003893 "$P_SRV dtls=1 debug_level=2" \
3894 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003895 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003896 -c "replayed record" \
3897 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003898 -c "discarding invalid record" \
3899 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003900 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003901 -s "Extra-header:" \
3902 -c "HTTP/1.0 200 OK"
3903
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003904run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3905 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003906 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3907 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003908 0 \
3909 -c "replayed record" \
3910 -S "replayed record" \
3911 -c "discarding invalid record" \
3912 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003913 -c "resend" \
3914 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003915 -s "Extra-header:" \
3916 -c "HTTP/1.0 200 OK"
3917
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003918run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003919 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003920 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003921 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003922 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003923 -c "discarding invalid record (mac)" \
3924 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003925 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003926 -c "HTTP/1.0 200 OK" \
3927 -S "too many records with bad MAC" \
3928 -S "Verification of the message MAC failed"
3929
3930run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3931 -p "$P_PXY bad_ad=1" \
3932 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3933 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3934 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003935 -C "discarding invalid record (mac)" \
3936 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003937 -S "Extra-header:" \
3938 -C "HTTP/1.0 200 OK" \
3939 -s "too many records with bad MAC" \
3940 -s "Verification of the message MAC failed"
3941
3942run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3943 -p "$P_PXY bad_ad=1" \
3944 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3945 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3946 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003947 -c "discarding invalid record (mac)" \
3948 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003949 -s "Extra-header:" \
3950 -c "HTTP/1.0 200 OK" \
3951 -S "too many records with bad MAC" \
3952 -S "Verification of the message MAC failed"
3953
3954run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3955 -p "$P_PXY bad_ad=1" \
3956 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3957 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3958 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003959 -c "discarding invalid record (mac)" \
3960 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003961 -s "Extra-header:" \
3962 -c "HTTP/1.0 200 OK" \
3963 -s "too many records with bad MAC" \
3964 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003965
3966run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003967 -p "$P_PXY delay_ccs=1" \
3968 "$P_SRV dtls=1 debug_level=1" \
3969 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003970 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003971 -c "record from another epoch" \
3972 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003973 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003974 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003975 -s "Extra-header:" \
3976 -c "HTTP/1.0 200 OK"
3977
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003978# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003979
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003980needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003981run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003982 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003983 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3984 psk=abc123" \
3985 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003986 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3987 0 \
3988 -s "Extra-header:" \
3989 -c "HTTP/1.0 200 OK"
3990
3991needs_more_time 2
3992run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3993 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003994 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3995 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003996 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3997 0 \
3998 -s "Extra-header:" \
3999 -c "HTTP/1.0 200 OK"
4000
4001needs_more_time 2
4002run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4003 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004004 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4005 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004006 0 \
4007 -s "Extra-header:" \
4008 -c "HTTP/1.0 200 OK"
4009
4010needs_more_time 2
4011run_test "DTLS proxy: 3d, FS, client auth" \
4012 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004013 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4014 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004015 0 \
4016 -s "Extra-header:" \
4017 -c "HTTP/1.0 200 OK"
4018
4019needs_more_time 2
4020run_test "DTLS proxy: 3d, FS, ticket" \
4021 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004022 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4023 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004024 0 \
4025 -s "Extra-header:" \
4026 -c "HTTP/1.0 200 OK"
4027
4028needs_more_time 2
4029run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
4030 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004031 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
4032 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004033 0 \
4034 -s "Extra-header:" \
4035 -c "HTTP/1.0 200 OK"
4036
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004037needs_more_time 2
4038run_test "DTLS proxy: 3d, max handshake, nbio" \
4039 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004040 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4041 auth_mode=required" \
4042 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004043 0 \
4044 -s "Extra-header:" \
4045 -c "HTTP/1.0 200 OK"
4046
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004047needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004048run_test "DTLS proxy: 3d, min handshake, resumption" \
4049 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4050 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4051 psk=abc123 debug_level=3" \
4052 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4053 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4054 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4055 0 \
4056 -s "a session has been resumed" \
4057 -c "a session has been resumed" \
4058 -s "Extra-header:" \
4059 -c "HTTP/1.0 200 OK"
4060
4061needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004062run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4063 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4064 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4065 psk=abc123 debug_level=3 nbio=2" \
4066 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4067 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4068 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4069 0 \
4070 -s "a session has been resumed" \
4071 -c "a session has been resumed" \
4072 -s "Extra-header:" \
4073 -c "HTTP/1.0 200 OK"
4074
4075needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004076requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004077run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004078 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004079 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4080 psk=abc123 renegotiation=1 debug_level=2" \
4081 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4082 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004083 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4084 0 \
4085 -c "=> renegotiate" \
4086 -s "=> renegotiate" \
4087 -s "Extra-header:" \
4088 -c "HTTP/1.0 200 OK"
4089
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004090needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004091requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004092run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4093 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004094 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4095 psk=abc123 renegotiation=1 debug_level=2" \
4096 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4097 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004098 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4099 0 \
4100 -c "=> renegotiate" \
4101 -s "=> renegotiate" \
4102 -s "Extra-header:" \
4103 -c "HTTP/1.0 200 OK"
4104
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004105needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004106requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004107run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004108 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004109 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004110 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004111 debug_level=2" \
4112 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004113 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004114 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4115 0 \
4116 -c "=> renegotiate" \
4117 -s "=> renegotiate" \
4118 -s "Extra-header:" \
4119 -c "HTTP/1.0 200 OK"
4120
4121needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004122requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004123run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004124 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004125 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004126 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004127 debug_level=2 nbio=2" \
4128 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004129 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004130 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4131 0 \
4132 -c "=> renegotiate" \
4133 -s "=> renegotiate" \
4134 -s "Extra-header:" \
4135 -c "HTTP/1.0 200 OK"
4136
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02004137needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004138not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004139run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004140 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4141 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004142 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004143 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004144 -c "HTTP/1.0 200 OK"
4145
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004146needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004147not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004148run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4149 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4150 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004151 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004152 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004153 -c "HTTP/1.0 200 OK"
4154
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004155needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004156not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004157run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4158 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4159 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004160 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004161 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004162 -c "HTTP/1.0 200 OK"
4163
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004164requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02004165needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004166not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004167run_test "DTLS proxy: 3d, gnutls server" \
4168 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4169 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004170 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004171 0 \
4172 -s "Extra-header:" \
4173 -c "Extra-header:"
4174
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004175requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004176needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004177not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004178run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4179 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4180 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004181 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004182 0 \
4183 -s "Extra-header:" \
4184 -c "Extra-header:"
4185
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004186requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004187needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004188not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004189run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4190 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4191 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004192 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004193 0 \
4194 -s "Extra-header:" \
4195 -c "Extra-header:"
4196
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004197# Final report
4198
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004199echo "------------------------------------------------------------------------"
4200
4201if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004202 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004203else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004204 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004205fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004206PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004207echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004208
4209exit $FAILS