blob: ec9e75aa31f85fff994ec4b1e6d3789f3f81abb2 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02009# Assumes a build with default options.
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010010
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020016: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010017: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020018: ${GNUTLS_CLI:=gnutls-cli}
19: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskine39e29812017-05-16 17:53:03 +020020: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020022O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010023O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020024G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010025G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskine39e29812017-05-16 17:53:03 +020026TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010027
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028TESTS=0
29FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020030SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010031
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000032CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020033
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010035FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020036EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010037
38print_usage() {
39 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010040 printf " -h|--help\tPrint this help.\n"
41 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
42 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
43 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Gilles Peskinebb4aaf12017-11-30 15:56:20 +010044 printf " --seed\tInteger seed value to use for this test run (default: random)\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045}
46
47get_options() {
48 while [ $# -gt 0 ]; do
49 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010050 -f|--filter)
51 shift; FILTER=$1
52 ;;
53 -e|--exclude)
54 shift; EXCLUDE=$1
55 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010056 -m|--memcheck)
57 MEMCHECK=1
58 ;;
Gilles Peskinebb4aaf12017-11-30 15:56:20 +010059 --seed)
60 shift; SEED="$1"
61 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062 -h|--help)
63 print_usage
64 exit 0
65 ;;
66 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020067 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010068 print_usage
69 exit 1
70 ;;
71 esac
72 shift
73 done
74}
75
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010076# skip next test if the flag is not enabled in config.h
77requires_config_enabled() {
78 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +020083# skip next test if the flag is enabled in config.h
84requires_config_disabled() {
85 if grep "^#define $1" $CONFIG_H > /dev/null; then
86 SKIP_NEXT="YES"
87 fi
88}
89
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020090# skip next test if OpenSSL doesn't support FALLBACK_SCSV
91requires_openssl_with_fallback_scsv() {
92 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
93 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
94 then
95 OPENSSL_HAS_FBSCSV="YES"
96 else
97 OPENSSL_HAS_FBSCSV="NO"
98 fi
99 fi
100 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
101 SKIP_NEXT="YES"
102 fi
103}
104
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200105# skip next test if GnuTLS isn't available
106requires_gnutls() {
107 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200108 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200109 GNUTLS_AVAILABLE="YES"
110 else
111 GNUTLS_AVAILABLE="NO"
112 fi
113 fi
114 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
115 SKIP_NEXT="YES"
116 fi
117}
118
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200119# skip next test if IPv6 isn't available on this host
120requires_ipv6() {
121 if [ -z "${HAS_IPV6:-}" ]; then
122 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
123 SRV_PID=$!
124 sleep 1
125 kill $SRV_PID >/dev/null 2>&1
126 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
127 HAS_IPV6="NO"
128 else
129 HAS_IPV6="YES"
130 fi
131 rm -r $SRV_OUT
132 fi
133
134 if [ "$HAS_IPV6" = "NO" ]; then
135 SKIP_NEXT="YES"
136 fi
137}
138
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200139# skip the next test if valgrind is in use
140not_with_valgrind() {
141 if [ "$MEMCHECK" -gt 0 ]; then
142 SKIP_NEXT="YES"
143 fi
144}
145
Paul Bakker3b224ff2016-05-13 10:33:25 +0100146# skip the next test if valgrind is NOT in use
147only_with_valgrind() {
148 if [ "$MEMCHECK" -eq 0 ]; then
149 SKIP_NEXT="YES"
150 fi
151}
152
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200153# multiply the client timeout delay by the given factor for the next test
154needs_more_time() {
155 CLI_DELAY_FACTOR=$1
156}
157
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100158# print_name <name>
159print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100160 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200161 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100162 for i in `seq 1 $LEN`; do printf '.'; done
163 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100164
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200165 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100166}
167
168# fail <message>
169fail() {
170 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100171 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100172
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200173 mv $SRV_OUT o-srv-${TESTS}.log
174 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200175 if [ -n "$PXY_CMD" ]; then
176 mv $PXY_OUT o-pxy-${TESTS}.log
177 fi
178 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100179
Azim Khan341e3782018-03-29 11:04:20 +0100180 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot -o "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200181 echo " ! server output:"
182 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200183 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200184 echo " ! client output:"
185 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200186 if [ -n "$PXY_CMD" ]; then
187 echo " ! ========================================================"
188 echo " ! proxy output:"
189 cat o-pxy-${TESTS}.log
190 fi
191 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200192 fi
193
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200194 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100195}
196
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100197# is_polar <cmd_line>
198is_polar() {
199 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
200}
201
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200202# openssl s_server doesn't have -www with DTLS
203check_osrv_dtls() {
204 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
205 NEEDS_INPUT=1
206 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
207 else
208 NEEDS_INPUT=0
209 fi
210}
211
212# provide input to commands that need it
213provide_input() {
214 if [ $NEEDS_INPUT -eq 0 ]; then
215 return
216 fi
217
218 while true; do
219 echo "HTTP/1.0 200 OK"
220 sleep 1
221 done
222}
223
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100224# has_mem_err <log_file_name>
225has_mem_err() {
226 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
227 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
228 then
229 return 1 # false: does not have errors
230 else
231 return 0 # true: has errors
232 fi
233}
234
Gilles Peskine684a5172017-12-14 18:58:42 +0100235# Wait for process $2 to be listening on port $1
236if type lsof >/dev/null 2>/dev/null; then
237 wait_server_start() {
238 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200239 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine684a5172017-12-14 18:58:42 +0100240 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200241 else
Gilles Peskine684a5172017-12-14 18:58:42 +0100242 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200243 fi
Gilles Peskine684a5172017-12-14 18:58:42 +0100244 # Make a tight loop, server normally takes less than 1s to start.
245 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
246 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
247 echo "SERVERSTART TIMEOUT"
248 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
249 break
250 fi
251 # Linux and *BSD support decimal arguments to sleep. On other
252 # OSes this may be a tight loop.
253 sleep 0.1 2>/dev/null || true
254 done
255 }
256else
Gilles Peskine2cc7ad42018-06-29 15:48:13 +0200257 echo "Warning: lsof not available, wait_server_start = sleep"
Gilles Peskine684a5172017-12-14 18:58:42 +0100258 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200259 sleep "$START_DELAY"
Gilles Peskine684a5172017-12-14 18:58:42 +0100260 }
261fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200262
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200263# wait for client to terminate and set CLI_EXIT
264# must be called right after starting the client
265wait_client_done() {
266 CLI_PID=$!
267
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200268 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
269 CLI_DELAY_FACTOR=1
270
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200271 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200272 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200273
274 wait $CLI_PID
275 CLI_EXIT=$?
276
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200277 kill $DOG_PID >/dev/null 2>&1
278 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200279
280 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
281}
282
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200283# check if the given command uses dtls and sets global variable DTLS
284detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200285 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200286 DTLS=1
287 else
288 DTLS=0
289 fi
290}
291
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200292# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100293# Options: -s pattern pattern that must be present in server output
294# -c pattern pattern that must be present in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100295# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100296# -S pattern pattern that must be absent in server output
297# -C pattern pattern that must be absent in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100298# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100299run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100300 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200301 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100302
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100303 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
304 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200305 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100306 return
307 fi
308
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100309 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100310
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200311 # should we skip?
312 if [ "X$SKIP_NEXT" = "XYES" ]; then
313 SKIP_NEXT="NO"
314 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200315 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200316 return
317 fi
318
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200319 # does this test use a proxy?
320 if [ "X$1" = "X-p" ]; then
321 PXY_CMD="$2"
322 shift 2
323 else
324 PXY_CMD=""
325 fi
326
327 # get commands and client output
328 SRV_CMD="$1"
329 CLI_CMD="$2"
330 CLI_EXPECT="$3"
331 shift 3
332
333 # fix client port
334 if [ -n "$PXY_CMD" ]; then
335 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
336 else
337 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
338 fi
339
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200340 # update DTLS variable
341 detect_dtls "$SRV_CMD"
342
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100343 # prepend valgrind to our commands if active
344 if [ "$MEMCHECK" -gt 0 ]; then
345 if is_polar "$SRV_CMD"; then
346 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
347 fi
348 if is_polar "$CLI_CMD"; then
349 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
350 fi
351 fi
352
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200353 TIMES_LEFT=2
354 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200355 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200356
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200357 # run the commands
358 if [ -n "$PXY_CMD" ]; then
359 echo "$PXY_CMD" > $PXY_OUT
360 $PXY_CMD >> $PXY_OUT 2>&1 &
361 PXY_PID=$!
362 # assume proxy starts faster than server
363 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200364
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200365 check_osrv_dtls
366 echo "$SRV_CMD" > $SRV_OUT
367 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
368 SRV_PID=$!
Gilles Peskine684a5172017-12-14 18:58:42 +0100369 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200370
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200371 echo "$CLI_CMD" > $CLI_OUT
372 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
373 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100374
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200375 # terminate the server (and the proxy)
376 kill $SRV_PID
377 wait $SRV_PID
378 if [ -n "$PXY_CMD" ]; then
379 kill $PXY_PID >/dev/null 2>&1
380 wait $PXY_PID
381 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100382
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200383 # retry only on timeouts
384 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
385 printf "RETRY "
386 else
387 TIMES_LEFT=0
388 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200389 done
390
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100391 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200392 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100393 # expected client exit to incorrectly succeed in case of catastrophic
394 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100395 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200396 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100397 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100398 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100399 return
400 fi
401 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100402 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200403 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100404 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100405 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100406 return
407 fi
408 fi
409
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100410 # check server exit code
411 if [ $? != 0 ]; then
412 fail "server fail"
413 return
414 fi
415
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100416 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100417 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
418 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100419 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200420 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100421 return
422 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100423
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100424 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200425 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100426 while [ $# -gt 0 ]
427 do
428 case $1 in
429 "-s")
Janos Follath6d3e3382016-09-07 15:48:48 +0100430 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
431 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100432 return
433 fi
434 ;;
435
436 "-c")
Janos Follath6d3e3382016-09-07 15:48:48 +0100437 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
438 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100439 return
440 fi
441 ;;
442
443 "-S")
Janos Follath6d3e3382016-09-07 15:48:48 +0100444 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
445 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100446 return
447 fi
448 ;;
449
450 "-C")
Janos Follath6d3e3382016-09-07 15:48:48 +0100451 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
452 fail "pattern '$2' MUST NOT be present in the Client output"
453 return
454 fi
455 ;;
456
457 # The filtering in the following two options (-u and -U) do the following
458 # - ignore valgrind output
459 # - filter out everything but lines right after the pattern occurances
460 # - keep one of each non-unique line
461 # - count how many lines remain
462 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
463 # if there were no duplicates.
464 "-U")
465 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
466 fail "lines following pattern '$2' must be unique in Server output"
467 return
468 fi
469 ;;
470
471 "-u")
472 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
473 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100474 return
475 fi
476 ;;
477
478 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200479 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100480 exit 1
481 esac
482 shift 2
483 done
484
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100485 # check valgrind's results
486 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200487 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100488 fail "Server has memory errors"
489 return
490 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200491 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100492 fail "Client has memory errors"
493 return
494 fi
495 fi
496
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100497 # if we're here, everything is ok
498 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200499 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100500}
501
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100502cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200503 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200504 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
505 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
506 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
507 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100508 exit 1
509}
510
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100511#
512# MAIN
513#
514
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000515if cd $( dirname $0 ); then :; else
516 echo "cd $( dirname $0 ) failed" >&2
517 exit 1
518fi
519
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100520get_options "$@"
521
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100522# sanity checks, avoid an avalanche of errors
523if [ ! -x "$P_SRV" ]; then
524 echo "Command '$P_SRV' is not an executable file"
525 exit 1
526fi
527if [ ! -x "$P_CLI" ]; then
528 echo "Command '$P_CLI' is not an executable file"
529 exit 1
530fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200531if [ ! -x "$P_PXY" ]; then
532 echo "Command '$P_PXY' is not an executable file"
533 exit 1
534fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100535if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
536 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100537 exit 1
538fi
539
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200540# used by watchdog
541MAIN_PID="$$"
542
Manuel Pégourié-Gonnard3f69e542018-01-22 10:22:09 +0100543# We use somewhat arbitrary delays for tests:
544# - how long do we wait for the server to start (when lsof not available)?
545# - how long do we allow for the client to finish?
546# (not to check performance, just to avoid waiting indefinitely)
547# Things are slower with valgrind, so give extra time here.
548#
549# Note: without lsof, there is a trade-off between the running time of this
550# script and the risk of spurious errors because we didn't wait long enough.
551# The watchdog delay on the other hand doesn't affect normal running time of
552# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200553if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard3f69e542018-01-22 10:22:09 +0100554 START_DELAY=6
555 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200556else
Manuel Pégourié-Gonnard3f69e542018-01-22 10:22:09 +0100557 START_DELAY=2
558 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200559fi
Manuel Pégourié-Gonnard3f69e542018-01-22 10:22:09 +0100560
561# some particular tests need more time:
562# - for the client, we multiply the usual watchdog limit by a factor
563# - for the server, we sleep for a number of seconds after the client exits
564# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200565CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200566
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200567# Pick a "unique" server port in the range 10000-19999, and a proxy port
568PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000569PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200570SRV_PORT="1$PORT_BASE"
571PXY_PORT="2$PORT_BASE"
572unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200573
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200574# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000575# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200576P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
577P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Gilles Peskinebb4aaf12017-11-30 15:56:20 +0100578P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200579O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200580O_CLI="$O_CLI -connect localhost:+SRV_PORT"
581G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000582G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200583
Gilles Peskine35db5ba2017-05-10 10:13:59 +0200584# Allow SHA-1, because many of our test certificates use it
585P_SRV="$P_SRV allow_sha1=1"
586P_CLI="$P_CLI allow_sha1=1"
587
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200588# Also pick a unique name for intermediate files
589SRV_OUT="srv_out.$$"
590CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200591PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200592SESSION="session.$$"
593
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200594SKIP_NEXT="NO"
595
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100596trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100597
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200598# Basic test
599
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200600# Checks that:
601# - things work with all ciphersuites active (used with config-full in all.sh)
602# - the expected (highest security) parameters are selected
603# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200604run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200605 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200606 "$P_CLI" \
607 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200608 -s "Protocol is TLSv1.2" \
609 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
610 -s "client hello v3, signature_algorithm ext: 6" \
611 -s "ECDHE curve: secp521r1" \
612 -S "error" \
613 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200614
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000615run_test "Default, DTLS" \
616 "$P_SRV dtls=1" \
617 "$P_CLI dtls=1" \
618 0 \
619 -s "Protocol is DTLSv1.2" \
620 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
621
Janos Follath6d3e3382016-09-07 15:48:48 +0100622# Test for uniqueness of IVs in AEAD ciphersuites
623run_test "Unique IV in GCM" \
624 "$P_SRV exchanges=20 debug_level=4" \
625 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
626 0 \
627 -u "IV used" \
628 -U "IV used"
629
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100630# Tests for rc4 option
631
Simon Butcher6eb066e2016-05-19 22:12:18 +0100632requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100633run_test "RC4: server disabled, client enabled" \
634 "$P_SRV" \
635 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
636 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100637 -s "SSL - The server has no ciphersuites in common"
638
Simon Butcher6eb066e2016-05-19 22:12:18 +0100639requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100640run_test "RC4: server half, client enabled" \
641 "$P_SRV arc4=1" \
642 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
643 1 \
644 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100645
646run_test "RC4: server enabled, client disabled" \
647 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
648 "$P_CLI" \
649 1 \
650 -s "SSL - The server has no ciphersuites in common"
651
652run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100653 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100654 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
655 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100656 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100657 -S "SSL - The server has no ciphersuites in common"
658
Hanno Beckera24ed192018-08-17 09:54:10 +0100659# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
660
661requires_gnutls
662requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
663run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
664 "$G_SRV"\
665 "$P_CLI force_version=tls1_1" \
666 0
667
668requires_gnutls
669requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
670run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
671 "$G_SRV"\
672 "$P_CLI force_version=tls1" \
673 0
674
Gilles Peskineae765992017-05-09 15:59:24 +0200675# Tests for SHA-1 support
676
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200677requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200678run_test "SHA-1 forbidden by default in server certificate" \
679 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
680 "$P_CLI debug_level=2 allow_sha1=0" \
681 1 \
682 -c "The certificate is signed with an unacceptable hash"
683
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200684requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
685run_test "SHA-1 forbidden by default in server certificate" \
686 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
687 "$P_CLI debug_level=2 allow_sha1=0" \
688 0
689
Gilles Peskineae765992017-05-09 15:59:24 +0200690run_test "SHA-1 explicitly allowed in server certificate" \
691 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
692 "$P_CLI allow_sha1=1" \
693 0
694
695run_test "SHA-256 allowed by default in server certificate" \
696 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
697 "$P_CLI allow_sha1=0" \
698 0
699
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200700requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200701run_test "SHA-1 forbidden by default in client certificate" \
702 "$P_SRV auth_mode=required allow_sha1=0" \
703 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
704 1 \
705 -s "The certificate is signed with an unacceptable hash"
706
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200707requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
708run_test "SHA-1 forbidden by default in client certificate" \
709 "$P_SRV auth_mode=required allow_sha1=0" \
710 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
711 0
712
Gilles Peskineae765992017-05-09 15:59:24 +0200713run_test "SHA-1 explicitly allowed in client certificate" \
714 "$P_SRV auth_mode=required allow_sha1=1" \
715 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
716 0
717
718run_test "SHA-256 allowed by default in client certificate" \
719 "$P_SRV auth_mode=required allow_sha1=0" \
720 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
721 0
722
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100723# Tests for Truncated HMAC extension
724
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100725run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200726 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100727 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +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é-Gonnard780d6712014-02-20 17:19:59 +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 disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200734 "$P_SRV debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000735 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +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
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100741run_test "Truncated HMAC: client enabled, server default" \
742 "$P_SRV debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000743 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100744 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000745 -s "dumping 'expected mac' (20 bytes)" \
746 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100747
Hanno Beckera83fafa2017-11-10 08:42:54 +0000748requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100749run_test "Truncated HMAC: client enabled, server disabled" \
750 "$P_SRV debug_level=4 trunc_hmac=0" \
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é-Gonnarde117a8f2015-01-09 12:39:35 +0100755
Hanno Beckera83fafa2017-11-10 08:42:54 +0000756requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Beckerd51bec72017-11-17 15:46:24 +0000757run_test "Truncated HMAC: client disabled, server enabled" \
758 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000759 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Beckerd51bec72017-11-17 15:46:24 +0000760 0 \
761 -s "dumping 'expected mac' (20 bytes)" \
762 -S "dumping 'expected mac' (10 bytes)"
763
764requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100765run_test "Truncated HMAC: client enabled, server enabled" \
766 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000767 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100768 0 \
Hanno Beckerce516ff2017-11-09 18:57:39 +0000769 -S "dumping 'expected mac' (20 bytes)" \
770 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100771
Hanno Becker02f632e2017-11-10 09:16:05 +0000772run_test "Truncated HMAC, DTLS: client default, server default" \
773 "$P_SRV dtls=1 debug_level=4" \
774 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
775 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 disabled, server default" \
781 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000782 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
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 enabled, server default" \
789 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000790 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
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 disabled" \
797 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000798 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000799 0 \
800 -s "dumping 'expected mac' (20 bytes)" \
801 -S "dumping 'expected mac' (10 bytes)"
802
803requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
804run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
805 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000806 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker02f632e2017-11-10 09:16:05 +0000807 0 \
808 -s "dumping 'expected mac' (20 bytes)" \
809 -S "dumping 'expected mac' (10 bytes)"
810
811requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
812run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
813 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +0000814 "$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 +0100815 0 \
816 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100817 -s "dumping 'expected mac' (10 bytes)"
818
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100819# Tests for Encrypt-then-MAC extension
820
821run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100822 "$P_SRV debug_level=3 \
823 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100824 "$P_CLI debug_level=3" \
825 0 \
826 -c "client hello, adding encrypt_then_mac extension" \
827 -s "found encrypt then mac extension" \
828 -s "server hello, adding encrypt then mac extension" \
829 -c "found encrypt_then_mac extension" \
830 -c "using encrypt then mac" \
831 -s "using encrypt then mac"
832
833run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100834 "$P_SRV debug_level=3 etm=0 \
835 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100836 "$P_CLI debug_level=3 etm=1" \
837 0 \
838 -c "client hello, adding encrypt_then_mac extension" \
839 -s "found encrypt then mac extension" \
840 -S "server hello, adding encrypt then mac extension" \
841 -C "found encrypt_then_mac extension" \
842 -C "using encrypt then mac" \
843 -S "using encrypt then mac"
844
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100845run_test "Encrypt then MAC: client enabled, aead cipher" \
846 "$P_SRV debug_level=3 etm=1 \
847 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
848 "$P_CLI debug_level=3 etm=1" \
849 0 \
850 -c "client hello, adding encrypt_then_mac extension" \
851 -s "found encrypt then mac extension" \
852 -S "server hello, adding encrypt then mac extension" \
853 -C "found encrypt_then_mac extension" \
854 -C "using encrypt then mac" \
855 -S "using encrypt then mac"
856
857run_test "Encrypt then MAC: client enabled, stream cipher" \
858 "$P_SRV debug_level=3 etm=1 \
859 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100860 "$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 +0100861 0 \
862 -c "client hello, adding encrypt_then_mac extension" \
863 -s "found encrypt then mac extension" \
864 -S "server hello, adding encrypt then mac extension" \
865 -C "found encrypt_then_mac extension" \
866 -C "using encrypt then mac" \
867 -S "using encrypt then mac"
868
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100869run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100870 "$P_SRV debug_level=3 etm=1 \
871 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100872 "$P_CLI debug_level=3 etm=0" \
873 0 \
874 -C "client hello, adding encrypt_then_mac extension" \
875 -S "found encrypt then mac extension" \
876 -S "server hello, adding encrypt then mac extension" \
877 -C "found encrypt_then_mac extension" \
878 -C "using encrypt then mac" \
879 -S "using encrypt then mac"
880
Janos Follath542ee5d2016-03-07 15:57:05 +0000881requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100882run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100883 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100884 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100885 "$P_CLI debug_level=3 force_version=ssl3" \
886 0 \
887 -C "client hello, adding encrypt_then_mac extension" \
888 -S "found encrypt then mac extension" \
889 -S "server hello, adding encrypt then mac extension" \
890 -C "found encrypt_then_mac extension" \
891 -C "using encrypt then mac" \
892 -S "using encrypt then mac"
893
Janos Follath542ee5d2016-03-07 15:57:05 +0000894requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100895run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100896 "$P_SRV debug_level=3 force_version=ssl3 \
897 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100898 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100899 0 \
900 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100901 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100902 -S "server hello, adding encrypt then mac extension" \
903 -C "found encrypt_then_mac extension" \
904 -C "using encrypt then mac" \
905 -S "using encrypt then mac"
906
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200907# Tests for Extended Master Secret extension
908
909run_test "Extended Master Secret: default" \
910 "$P_SRV debug_level=3" \
911 "$P_CLI debug_level=3" \
912 0 \
913 -c "client hello, adding extended_master_secret extension" \
914 -s "found extended master secret extension" \
915 -s "server hello, adding extended master secret extension" \
916 -c "found extended_master_secret extension" \
917 -c "using extended master secret" \
918 -s "using extended master secret"
919
920run_test "Extended Master Secret: client enabled, server disabled" \
921 "$P_SRV debug_level=3 extended_ms=0" \
922 "$P_CLI debug_level=3 extended_ms=1" \
923 0 \
924 -c "client hello, adding extended_master_secret extension" \
925 -s "found extended master secret extension" \
926 -S "server hello, adding extended master secret extension" \
927 -C "found extended_master_secret extension" \
928 -C "using extended master secret" \
929 -S "using extended master secret"
930
931run_test "Extended Master Secret: client disabled, server enabled" \
932 "$P_SRV debug_level=3 extended_ms=1" \
933 "$P_CLI debug_level=3 extended_ms=0" \
934 0 \
935 -C "client hello, adding extended_master_secret extension" \
936 -S "found extended master secret extension" \
937 -S "server hello, adding extended master secret extension" \
938 -C "found extended_master_secret extension" \
939 -C "using extended master secret" \
940 -S "using extended master secret"
941
Janos Follath542ee5d2016-03-07 15:57:05 +0000942requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200943run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100944 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200945 "$P_CLI debug_level=3 force_version=ssl3" \
946 0 \
947 -C "client hello, adding extended_master_secret extension" \
948 -S "found extended master secret extension" \
949 -S "server hello, adding extended master secret extension" \
950 -C "found extended_master_secret extension" \
951 -C "using extended master secret" \
952 -S "using extended master secret"
953
Janos Follath542ee5d2016-03-07 15:57:05 +0000954requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200955run_test "Extended Master Secret: client enabled, server SSLv3" \
956 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100957 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200958 0 \
959 -c "client hello, adding extended_master_secret extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100960 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200961 -S "server hello, adding extended master secret extension" \
962 -C "found extended_master_secret extension" \
963 -C "using extended master secret" \
964 -S "using extended master secret"
965
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200966# Tests for FALLBACK_SCSV
967
968run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200969 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200970 "$P_CLI debug_level=3 force_version=tls1_1" \
971 0 \
972 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200973 -S "received FALLBACK_SCSV" \
974 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200975 -C "is a fatal alert message (msg 86)"
976
977run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200978 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200979 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
980 0 \
981 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200982 -S "received FALLBACK_SCSV" \
983 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200984 -C "is a fatal alert message (msg 86)"
985
986run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200987 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200988 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200989 1 \
990 -c "adding FALLBACK_SCSV" \
991 -s "received FALLBACK_SCSV" \
992 -s "inapropriate fallback" \
993 -c "is a fatal alert message (msg 86)"
994
995run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200996 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200997 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200998 0 \
999 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001000 -s "received FALLBACK_SCSV" \
1001 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001002 -C "is a fatal alert message (msg 86)"
1003
1004requires_openssl_with_fallback_scsv
1005run_test "Fallback SCSV: default, openssl server" \
1006 "$O_SRV" \
1007 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1008 0 \
1009 -C "adding FALLBACK_SCSV" \
1010 -C "is a fatal alert message (msg 86)"
1011
1012requires_openssl_with_fallback_scsv
1013run_test "Fallback SCSV: enabled, openssl server" \
1014 "$O_SRV" \
1015 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1016 1 \
1017 -c "adding FALLBACK_SCSV" \
1018 -c "is a fatal alert message (msg 86)"
1019
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001020requires_openssl_with_fallback_scsv
1021run_test "Fallback SCSV: disabled, 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 -tls1_1" \
1024 0 \
1025 -S "received FALLBACK_SCSV" \
1026 -S "inapropriate fallback"
1027
1028requires_openssl_with_fallback_scsv
1029run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001030 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001031 "$O_CLI -tls1_1 -fallback_scsv" \
1032 1 \
1033 -s "received FALLBACK_SCSV" \
1034 -s "inapropriate fallback"
1035
1036requires_openssl_with_fallback_scsv
1037run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001038 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001039 "$O_CLI -fallback_scsv" \
1040 0 \
1041 -s "received FALLBACK_SCSV" \
1042 -S "inapropriate fallback"
1043
Andres Amaya Garciadc8b6df2018-07-10 20:08:04 +01001044# Test sending and receiving empty application data records
1045
1046run_test "Encrypt then MAC: empty application data record" \
1047 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1048 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1049 0 \
1050 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1051 -s "dumping 'input payload after decrypt' (0 bytes)" \
1052 -c "0 bytes written in 1 fragments"
1053
1054run_test "Default, no Encrypt then MAC: empty application data record" \
1055 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1056 "$P_CLI auth_mode=none etm=0 request_size=0" \
1057 0 \
1058 -s "dumping 'input payload after decrypt' (0 bytes)" \
1059 -c "0 bytes written in 1 fragments"
1060
1061run_test "Encrypt then MAC, DTLS: empty application data record" \
1062 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1063 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1064 0 \
1065 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1066 -s "dumping 'input payload after decrypt' (0 bytes)" \
1067 -c "0 bytes written in 1 fragments"
1068
1069run_test "Default, no Encrypt then MAC, DTLS: empty application data record" \
1070 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1071 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1072 0 \
1073 -s "dumping 'input payload after decrypt' (0 bytes)" \
1074 -c "0 bytes written in 1 fragments"
1075
Gilles Peskine39e29812017-05-16 17:53:03 +02001076## ClientHello generated with
1077## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1078## then manually twiddling the ciphersuite list.
1079## The ClientHello content is spelled out below as a hex string as
1080## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1081## The expected response is an inappropriate_fallback alert.
1082requires_openssl_with_fallback_scsv
1083run_test "Fallback SCSV: beginning of list" \
1084 "$P_SRV debug_level=2" \
1085 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1086 0 \
1087 -s "received FALLBACK_SCSV" \
1088 -s "inapropriate fallback"
1089
1090requires_openssl_with_fallback_scsv
1091run_test "Fallback SCSV: end of list" \
1092 "$P_SRV debug_level=2" \
1093 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1094 0 \
1095 -s "received FALLBACK_SCSV" \
1096 -s "inapropriate fallback"
1097
1098## Here the expected response is a valid ServerHello prefix, up to the random.
1099requires_openssl_with_fallback_scsv
1100run_test "Fallback SCSV: not in list" \
1101 "$P_SRV debug_level=2" \
1102 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1103 0 \
1104 -S "received FALLBACK_SCSV" \
1105 -S "inapropriate fallback"
1106
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001107# Tests for CBC 1/n-1 record splitting
1108
1109run_test "CBC Record splitting: TLS 1.2, no splitting" \
1110 "$P_SRV" \
1111 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1112 request_size=123 force_version=tls1_2" \
1113 0 \
1114 -s "Read from client: 123 bytes read" \
1115 -S "Read from client: 1 bytes read" \
1116 -S "122 bytes read"
1117
1118run_test "CBC Record splitting: TLS 1.1, no splitting" \
1119 "$P_SRV" \
1120 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1121 request_size=123 force_version=tls1_1" \
1122 0 \
1123 -s "Read from client: 123 bytes read" \
1124 -S "Read from client: 1 bytes read" \
1125 -S "122 bytes read"
1126
1127run_test "CBC Record splitting: TLS 1.0, splitting" \
1128 "$P_SRV" \
1129 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1130 request_size=123 force_version=tls1" \
1131 0 \
1132 -S "Read from client: 123 bytes read" \
1133 -s "Read from client: 1 bytes read" \
1134 -s "122 bytes read"
1135
Janos Follath542ee5d2016-03-07 15:57:05 +00001136requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001137run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001138 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001139 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1140 request_size=123 force_version=ssl3" \
1141 0 \
1142 -S "Read from client: 123 bytes read" \
1143 -s "Read from client: 1 bytes read" \
1144 -s "122 bytes read"
1145
1146run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001147 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001148 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1149 request_size=123 force_version=tls1" \
1150 0 \
1151 -s "Read from client: 123 bytes read" \
1152 -S "Read from client: 1 bytes read" \
1153 -S "122 bytes read"
1154
1155run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1156 "$P_SRV" \
1157 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1158 request_size=123 force_version=tls1 recsplit=0" \
1159 0 \
1160 -s "Read from client: 123 bytes read" \
1161 -S "Read from client: 1 bytes read" \
1162 -S "122 bytes read"
1163
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001164run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1165 "$P_SRV nbio=2" \
1166 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1167 request_size=123 force_version=tls1" \
1168 0 \
1169 -S "Read from client: 123 bytes read" \
1170 -s "Read from client: 1 bytes read" \
1171 -s "122 bytes read"
1172
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001173# Tests for Session Tickets
1174
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001175run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001176 "$P_SRV debug_level=3 tickets=1" \
1177 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001178 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001179 -c "client hello, adding session ticket extension" \
1180 -s "found session ticket extension" \
1181 -s "server hello, adding session ticket extension" \
1182 -c "found session_ticket extension" \
1183 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001184 -S "session successfully restored from cache" \
1185 -s "session successfully restored from ticket" \
1186 -s "a session has been resumed" \
1187 -c "a session has been resumed"
1188
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001189run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001190 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1191 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001192 0 \
1193 -c "client hello, adding session ticket extension" \
1194 -s "found session ticket extension" \
1195 -s "server hello, adding session ticket extension" \
1196 -c "found session_ticket extension" \
1197 -c "parse new session ticket" \
1198 -S "session successfully restored from cache" \
1199 -s "session successfully restored from ticket" \
1200 -s "a session has been resumed" \
1201 -c "a session has been resumed"
1202
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001203run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001204 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1205 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001206 0 \
1207 -c "client hello, adding session ticket extension" \
1208 -s "found session ticket extension" \
1209 -s "server hello, adding session ticket extension" \
1210 -c "found session_ticket extension" \
1211 -c "parse new session ticket" \
1212 -S "session successfully restored from cache" \
1213 -S "session successfully restored from ticket" \
1214 -S "a session has been resumed" \
1215 -C "a session has been resumed"
1216
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001217run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001218 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001219 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001220 0 \
1221 -c "client hello, adding session ticket extension" \
1222 -c "found session_ticket extension" \
1223 -c "parse new session ticket" \
1224 -c "a session has been resumed"
1225
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001226run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001227 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001228 "( $O_CLI -sess_out $SESSION; \
1229 $O_CLI -sess_in $SESSION; \
1230 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001231 0 \
1232 -s "found session ticket extension" \
1233 -s "server hello, adding session ticket extension" \
1234 -S "session successfully restored from cache" \
1235 -s "session successfully restored from ticket" \
1236 -s "a session has been resumed"
1237
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001238# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001239
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001240run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001241 "$P_SRV debug_level=3 tickets=0" \
1242 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001243 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001244 -c "client hello, adding session ticket extension" \
1245 -s "found session ticket extension" \
1246 -S "server hello, adding session ticket extension" \
1247 -C "found session_ticket extension" \
1248 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001249 -s "session successfully restored from cache" \
1250 -S "session successfully restored from ticket" \
1251 -s "a session has been resumed" \
1252 -c "a session has been resumed"
1253
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001254run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001255 "$P_SRV debug_level=3 tickets=1" \
1256 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001257 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001258 -C "client hello, adding session ticket extension" \
1259 -S "found session ticket extension" \
1260 -S "server hello, adding session ticket extension" \
1261 -C "found session_ticket extension" \
1262 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001263 -s "session successfully restored from cache" \
1264 -S "session successfully restored from ticket" \
1265 -s "a session has been resumed" \
1266 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001267
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001268run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001269 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1270 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001271 0 \
1272 -S "session successfully restored from cache" \
1273 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001274 -S "a session has been resumed" \
1275 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001277run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001278 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1279 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001280 0 \
1281 -s "session successfully restored from cache" \
1282 -S "session successfully restored from ticket" \
1283 -s "a session has been resumed" \
1284 -c "a session has been resumed"
1285
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001286run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001287 "$P_SRV debug_level=3 tickets=0" \
1288 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001289 0 \
1290 -s "session successfully restored from cache" \
1291 -S "session successfully restored from ticket" \
1292 -s "a session has been resumed" \
1293 -c "a session has been resumed"
1294
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001295run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001296 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1297 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001298 0 \
1299 -S "session successfully restored from cache" \
1300 -S "session successfully restored from ticket" \
1301 -S "a session has been resumed" \
1302 -C "a session has been resumed"
1303
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001304run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001305 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1306 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001307 0 \
1308 -s "session successfully restored from cache" \
1309 -S "session successfully restored from ticket" \
1310 -s "a session has been resumed" \
1311 -c "a session has been resumed"
1312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001313run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001314 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001315 "( $O_CLI -sess_out $SESSION; \
1316 $O_CLI -sess_in $SESSION; \
1317 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001318 0 \
1319 -s "found session ticket extension" \
1320 -S "server hello, adding session ticket extension" \
1321 -s "session successfully restored from cache" \
1322 -S "session successfully restored from ticket" \
1323 -s "a session has been resumed"
1324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001325run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001326 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001327 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001328 0 \
1329 -C "found session_ticket extension" \
1330 -C "parse new session ticket" \
1331 -c "a session has been resumed"
1332
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001333# Tests for Max Fragment Length extension
1334
Hanno Becker64691dc2017-09-22 16:58:50 +01001335MAX_CONTENT_LEN_EXPECT='16384'
1336MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1337
1338if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1339 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1340 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1341 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1342 printf "\n"
1343 printf "The tests assume this value and if it changes, the tests in this\n"
1344 printf "script should also be adjusted.\n"
1345 printf "\n"
1346
1347 exit 1
1348fi
1349
Hanno Becker05607782017-09-18 15:00:34 +01001350requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001351run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001352 "$P_SRV debug_level=3" \
1353 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001354 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001355 -c "Maximum fragment length is 16384" \
1356 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001357 -C "client hello, adding max_fragment_length extension" \
1358 -S "found max fragment length extension" \
1359 -S "server hello, max_fragment_length extension" \
1360 -C "found max_fragment_length extension"
1361
Hanno Becker05607782017-09-18 15:00:34 +01001362requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001363run_test "Max fragment length: enabled, default, larger message" \
1364 "$P_SRV debug_level=3" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001365 "$P_CLI debug_level=3 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001366 0 \
1367 -c "Maximum fragment length is 16384" \
1368 -s "Maximum fragment length is 16384" \
1369 -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" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001373 -c "16385 bytes written in 2 fragments" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001374 -s "16384 bytes read" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001375 -s "1 bytes read"
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001376
1377requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1378run_test "Max fragment length, DTLS: enabled, default, larger message" \
1379 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001380 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001381 1 \
1382 -c "Maximum fragment length is 16384" \
1383 -s "Maximum fragment length is 16384" \
1384 -C "client hello, adding max_fragment_length extension" \
1385 -S "found max fragment length extension" \
1386 -S "server hello, max_fragment_length extension" \
1387 -C "found max_fragment_length extension" \
1388 -c "fragment larger than.*maximum "
1389
1390requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1391run_test "Max fragment length: disabled, larger message" \
1392 "$P_SRV debug_level=3" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001393 "$P_CLI debug_level=3 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001394 0 \
1395 -C "Maximum fragment length is 16384" \
1396 -S "Maximum fragment length is 16384" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001397 -c "16385 bytes written in 2 fragments" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001398 -s "16384 bytes read" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001399 -s "1 bytes read"
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001400
1401requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1402run_test "Max fragment length DTLS: disabled, larger message" \
1403 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001404 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001405 1 \
1406 -C "Maximum fragment length is 16384" \
1407 -S "Maximum fragment length is 16384" \
1408 -c "fragment larger than.*maximum "
1409
1410requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001411run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001412 "$P_SRV debug_level=3" \
1413 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001414 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001415 -c "Maximum fragment length is 4096" \
1416 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001417 -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
Hanno Becker05607782017-09-18 15:00:34 +01001422requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001423run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001424 "$P_SRV debug_level=3 max_frag_len=4096" \
1425 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001426 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001427 -c "Maximum fragment length is 16384" \
1428 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001429 -C "client hello, adding max_fragment_length extension" \
1430 -S "found max fragment length extension" \
1431 -S "server hello, max_fragment_length extension" \
1432 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001433
Hanno Becker05607782017-09-18 15:00:34 +01001434requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001435requires_gnutls
1436run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001437 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001438 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001439 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001440 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001441 -c "client hello, adding max_fragment_length extension" \
1442 -c "found max_fragment_length extension"
1443
Hanno Becker05607782017-09-18 15:00:34 +01001444requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001445run_test "Max fragment length: client, message just fits" \
1446 "$P_SRV debug_level=3" \
1447 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1448 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001449 -c "Maximum fragment length is 2048" \
1450 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001451 -c "client hello, adding max_fragment_length extension" \
1452 -s "found max fragment length extension" \
1453 -s "server hello, max_fragment_length extension" \
1454 -c "found max_fragment_length extension" \
1455 -c "2048 bytes written in 1 fragments" \
1456 -s "2048 bytes read"
1457
Hanno Becker05607782017-09-18 15:00:34 +01001458requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001459run_test "Max fragment length: client, larger message" \
1460 "$P_SRV debug_level=3" \
1461 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1462 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001463 -c "Maximum fragment length is 2048" \
1464 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001465 -c "client hello, adding max_fragment_length extension" \
1466 -s "found max fragment length extension" \
1467 -s "server hello, max_fragment_length extension" \
1468 -c "found max_fragment_length extension" \
1469 -c "2345 bytes written in 2 fragments" \
1470 -s "2048 bytes read" \
1471 -s "297 bytes read"
1472
Hanno Becker05607782017-09-18 15:00:34 +01001473requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001474run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001475 "$P_SRV debug_level=3 dtls=1" \
1476 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1477 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001478 -c "Maximum fragment length is 2048" \
1479 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001480 -c "client hello, adding max_fragment_length extension" \
1481 -s "found max fragment length extension" \
1482 -s "server hello, max_fragment_length extension" \
1483 -c "found max_fragment_length extension" \
1484 -c "fragment larger than.*maximum"
1485
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001486# Tests for renegotiation
1487
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001488run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001489 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001490 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001491 0 \
1492 -C "client hello, adding renegotiation extension" \
1493 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1494 -S "found renegotiation extension" \
1495 -s "server hello, secure renegotiation extension" \
1496 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001497 -C "=> renegotiate" \
1498 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001499 -S "write hello request"
1500
Hanno Becker78891132017-10-24 11:54:55 +01001501requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001502run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001503 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001504 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001505 0 \
1506 -c "client hello, adding renegotiation extension" \
1507 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1508 -s "found renegotiation extension" \
1509 -s "server hello, secure renegotiation extension" \
1510 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001511 -c "=> renegotiate" \
1512 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001513 -S "write hello request"
1514
Hanno Becker78891132017-10-24 11:54:55 +01001515requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001516run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001517 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001518 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001519 0 \
1520 -c "client hello, adding renegotiation extension" \
1521 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1522 -s "found renegotiation extension" \
1523 -s "server hello, secure renegotiation extension" \
1524 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001525 -c "=> renegotiate" \
1526 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001527 -s "write hello request"
1528
Janos Follath5f1dd802017-10-05 12:29:42 +01001529# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1530# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1531# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker78891132017-10-24 11:54:55 +01001532requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follath5f1dd802017-10-05 12:29:42 +01001533run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1534 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1535 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1536 0 \
1537 -c "client hello, adding renegotiation extension" \
1538 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1539 -s "found renegotiation extension" \
1540 -s "server hello, secure renegotiation extension" \
1541 -c "found renegotiation extension" \
1542 -c "=> renegotiate" \
1543 -s "=> renegotiate" \
1544 -S "write hello request" \
1545 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1546
1547# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1548# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1549# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker78891132017-10-24 11:54:55 +01001550requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follath5f1dd802017-10-05 12:29:42 +01001551run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1552 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1553 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1554 0 \
1555 -c "client hello, adding renegotiation extension" \
1556 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1557 -s "found renegotiation extension" \
1558 -s "server hello, secure renegotiation extension" \
1559 -c "found renegotiation extension" \
1560 -c "=> renegotiate" \
1561 -s "=> renegotiate" \
1562 -s "write hello request" \
1563 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1564
Hanno Becker78891132017-10-24 11:54:55 +01001565requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001566run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001567 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001568 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001569 0 \
1570 -c "client hello, adding renegotiation extension" \
1571 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1572 -s "found renegotiation extension" \
1573 -s "server hello, secure renegotiation extension" \
1574 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001575 -c "=> renegotiate" \
1576 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001577 -s "write hello request"
1578
Hanno Becker78891132017-10-24 11:54:55 +01001579requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001580run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001581 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001582 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001583 1 \
1584 -c "client hello, adding renegotiation extension" \
1585 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1586 -S "found renegotiation extension" \
1587 -s "server hello, secure renegotiation extension" \
1588 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001589 -c "=> renegotiate" \
1590 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001591 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001592 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001593 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001594
Hanno Becker78891132017-10-24 11:54:55 +01001595requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001596run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001597 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001598 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001599 0 \
1600 -C "client hello, adding renegotiation extension" \
1601 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1602 -S "found renegotiation extension" \
1603 -s "server hello, secure renegotiation extension" \
1604 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001605 -C "=> renegotiate" \
1606 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001607 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001608 -S "SSL - An unexpected message was received from our peer" \
1609 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001610
Hanno Becker78891132017-10-24 11:54:55 +01001611requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001612run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001613 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001614 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001615 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001616 0 \
1617 -C "client hello, adding renegotiation extension" \
1618 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1619 -S "found renegotiation extension" \
1620 -s "server hello, secure renegotiation extension" \
1621 -c "found renegotiation extension" \
1622 -C "=> renegotiate" \
1623 -S "=> renegotiate" \
1624 -s "write hello request" \
1625 -S "SSL - An unexpected message was received from our peer" \
1626 -S "failed"
1627
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001628# delay 2 for 1 alert record + 1 application data record
Hanno Becker78891132017-10-24 11:54:55 +01001629requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001630run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001631 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001632 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001633 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001634 0 \
1635 -C "client hello, adding renegotiation extension" \
1636 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1637 -S "found renegotiation extension" \
1638 -s "server hello, secure renegotiation extension" \
1639 -c "found renegotiation extension" \
1640 -C "=> renegotiate" \
1641 -S "=> renegotiate" \
1642 -s "write hello request" \
1643 -S "SSL - An unexpected message was received from our peer" \
1644 -S "failed"
1645
Hanno Becker78891132017-10-24 11:54:55 +01001646requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001647run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001648 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001649 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001650 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001651 0 \
1652 -C "client hello, adding renegotiation extension" \
1653 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1654 -S "found renegotiation extension" \
1655 -s "server hello, secure renegotiation extension" \
1656 -c "found renegotiation extension" \
1657 -C "=> renegotiate" \
1658 -S "=> renegotiate" \
1659 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001660 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001661
Hanno Becker78891132017-10-24 11:54:55 +01001662requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001663run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001664 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001665 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001666 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001667 0 \
1668 -c "client hello, adding renegotiation extension" \
1669 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1670 -s "found renegotiation extension" \
1671 -s "server hello, secure renegotiation extension" \
1672 -c "found renegotiation extension" \
1673 -c "=> renegotiate" \
1674 -s "=> renegotiate" \
1675 -s "write hello request" \
1676 -S "SSL - An unexpected message was received from our peer" \
1677 -S "failed"
1678
Hanno Becker78891132017-10-24 11:54:55 +01001679requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001680run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001681 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001682 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1683 0 \
1684 -C "client hello, adding renegotiation extension" \
1685 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1686 -S "found renegotiation extension" \
1687 -s "server hello, secure renegotiation extension" \
1688 -c "found renegotiation extension" \
1689 -S "record counter limit reached: renegotiate" \
1690 -C "=> renegotiate" \
1691 -S "=> renegotiate" \
1692 -S "write hello request" \
1693 -S "SSL - An unexpected message was received from our peer" \
1694 -S "failed"
1695
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001696# one extra exchange to be able to complete renego
Hanno Becker78891132017-10-24 11:54:55 +01001697requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001698run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001699 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001700 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001701 0 \
1702 -c "client hello, adding renegotiation extension" \
1703 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1704 -s "found renegotiation extension" \
1705 -s "server hello, secure renegotiation extension" \
1706 -c "found renegotiation extension" \
1707 -s "record counter limit reached: renegotiate" \
1708 -c "=> renegotiate" \
1709 -s "=> renegotiate" \
1710 -s "write hello request" \
1711 -S "SSL - An unexpected message was received from our peer" \
1712 -S "failed"
1713
Hanno Becker78891132017-10-24 11:54:55 +01001714requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001715run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001716 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001717 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001718 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 -s "record counter limit reached: renegotiate" \
1725 -c "=> renegotiate" \
1726 -s "=> renegotiate" \
1727 -s "write hello request" \
1728 -S "SSL - An unexpected message was received from our peer" \
1729 -S "failed"
1730
Hanno Becker78891132017-10-24 11:54:55 +01001731requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001732run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001733 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001734 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1735 0 \
1736 -C "client hello, adding renegotiation extension" \
1737 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1738 -S "found renegotiation extension" \
1739 -s "server hello, secure renegotiation extension" \
1740 -c "found renegotiation extension" \
1741 -S "record counter limit reached: renegotiate" \
1742 -C "=> renegotiate" \
1743 -S "=> renegotiate" \
1744 -S "write hello request" \
1745 -S "SSL - An unexpected message was received from our peer" \
1746 -S "failed"
1747
Hanno Becker78891132017-10-24 11:54:55 +01001748requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001749run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001750 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001751 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001752 0 \
1753 -c "client hello, adding renegotiation extension" \
1754 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1755 -s "found renegotiation extension" \
1756 -s "server hello, secure renegotiation extension" \
1757 -c "found renegotiation extension" \
1758 -c "=> renegotiate" \
1759 -s "=> renegotiate" \
1760 -S "write hello request"
1761
Hanno Becker78891132017-10-24 11:54:55 +01001762requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001763run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001764 "$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 +02001765 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001766 0 \
1767 -c "client hello, adding renegotiation extension" \
1768 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1769 -s "found renegotiation extension" \
1770 -s "server hello, secure renegotiation extension" \
1771 -c "found renegotiation extension" \
1772 -c "=> renegotiate" \
1773 -s "=> renegotiate" \
1774 -s "write hello request"
1775
Hanno Becker78891132017-10-24 11:54:55 +01001776requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001777run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001778 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001779 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001780 0 \
1781 -c "client hello, adding renegotiation extension" \
1782 -c "found renegotiation extension" \
1783 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001784 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001785 -C "error" \
1786 -c "HTTP/1.0 200 [Oo][Kk]"
1787
Paul Bakker539d9722015-02-08 16:18:35 +01001788requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001789requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001790run_test "Renegotiation: gnutls server strict, client-initiated" \
1791 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001792 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001793 0 \
1794 -c "client hello, adding renegotiation extension" \
1795 -c "found renegotiation extension" \
1796 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001797 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001798 -C "error" \
1799 -c "HTTP/1.0 200 [Oo][Kk]"
1800
Paul Bakker539d9722015-02-08 16:18:35 +01001801requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001802requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001803run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1804 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1805 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1806 1 \
1807 -c "client hello, adding renegotiation extension" \
1808 -C "found renegotiation extension" \
1809 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001810 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001811 -c "error" \
1812 -C "HTTP/1.0 200 [Oo][Kk]"
1813
Paul Bakker539d9722015-02-08 16:18:35 +01001814requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001815requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001816run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1817 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1818 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1819 allow_legacy=0" \
1820 1 \
1821 -c "client hello, adding renegotiation extension" \
1822 -C "found renegotiation extension" \
1823 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001824 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001825 -c "error" \
1826 -C "HTTP/1.0 200 [Oo][Kk]"
1827
Paul Bakker539d9722015-02-08 16:18:35 +01001828requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001829requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001830run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1831 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1832 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1833 allow_legacy=1" \
1834 0 \
1835 -c "client hello, adding renegotiation extension" \
1836 -C "found renegotiation extension" \
1837 -c "=> renegotiate" \
1838 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001839 -C "error" \
1840 -c "HTTP/1.0 200 [Oo][Kk]"
1841
Hanno Becker78891132017-10-24 11:54:55 +01001842requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001843run_test "Renegotiation: DTLS, client-initiated" \
1844 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1845 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1846 0 \
1847 -c "client hello, adding renegotiation extension" \
1848 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1849 -s "found renegotiation extension" \
1850 -s "server hello, secure renegotiation extension" \
1851 -c "found renegotiation extension" \
1852 -c "=> renegotiate" \
1853 -s "=> renegotiate" \
1854 -S "write hello request"
1855
Hanno Becker78891132017-10-24 11:54:55 +01001856requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001857run_test "Renegotiation: DTLS, server-initiated" \
1858 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001859 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1860 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001861 0 \
1862 -c "client hello, adding renegotiation extension" \
1863 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1864 -s "found renegotiation extension" \
1865 -s "server hello, secure renegotiation extension" \
1866 -c "found renegotiation extension" \
1867 -c "=> renegotiate" \
1868 -s "=> renegotiate" \
1869 -s "write hello request"
1870
Hanno Becker78891132017-10-24 11:54:55 +01001871requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG9b1927b2017-01-19 16:30:57 +00001872run_test "Renegotiation: DTLS, renego_period overflow" \
1873 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1874 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1875 0 \
1876 -c "client hello, adding renegotiation extension" \
1877 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1878 -s "found renegotiation extension" \
1879 -s "server hello, secure renegotiation extension" \
1880 -s "record counter limit reached: renegotiate" \
1881 -c "=> renegotiate" \
1882 -s "=> renegotiate" \
Hanno Becker78891132017-10-24 11:54:55 +01001883 -s "write hello request"
Andres AG9b1927b2017-01-19 16:30:57 +00001884
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001885requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001886requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001887run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1888 "$G_SRV -u --mtu 4096" \
1889 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1890 0 \
1891 -c "client hello, adding renegotiation extension" \
1892 -c "found renegotiation extension" \
1893 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001894 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001895 -C "error" \
1896 -s "Extra-header:"
1897
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001898# Test for the "secure renegotation" extension only (no actual renegotiation)
1899
Paul Bakker539d9722015-02-08 16:18:35 +01001900requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001901run_test "Renego ext: gnutls server strict, client default" \
1902 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1903 "$P_CLI debug_level=3" \
1904 0 \
1905 -c "found renegotiation extension" \
1906 -C "error" \
1907 -c "HTTP/1.0 200 [Oo][Kk]"
1908
Paul Bakker539d9722015-02-08 16:18:35 +01001909requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001910run_test "Renego ext: gnutls server unsafe, client default" \
1911 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1912 "$P_CLI debug_level=3" \
1913 0 \
1914 -C "found renegotiation extension" \
1915 -C "error" \
1916 -c "HTTP/1.0 200 [Oo][Kk]"
1917
Paul Bakker539d9722015-02-08 16:18:35 +01001918requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001919run_test "Renego ext: gnutls server unsafe, client break legacy" \
1920 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1921 "$P_CLI debug_level=3 allow_legacy=-1" \
1922 1 \
1923 -C "found renegotiation extension" \
1924 -c "error" \
1925 -C "HTTP/1.0 200 [Oo][Kk]"
1926
Paul Bakker539d9722015-02-08 16:18:35 +01001927requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001928run_test "Renego ext: gnutls client strict, server default" \
1929 "$P_SRV debug_level=3" \
1930 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1931 0 \
1932 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1933 -s "server hello, secure renegotiation extension"
1934
Paul Bakker539d9722015-02-08 16:18:35 +01001935requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001936run_test "Renego ext: gnutls client unsafe, server default" \
1937 "$P_SRV debug_level=3" \
1938 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1939 0 \
1940 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1941 -S "server hello, secure renegotiation extension"
1942
Paul Bakker539d9722015-02-08 16:18:35 +01001943requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001944run_test "Renego ext: gnutls client unsafe, server break legacy" \
1945 "$P_SRV debug_level=3 allow_legacy=-1" \
1946 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1947 1 \
1948 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1949 -S "server hello, secure renegotiation extension"
1950
Janos Follath365b2262016-02-17 10:11:21 +00001951# Tests for silently dropping trailing extra bytes in .der certificates
1952
1953requires_gnutls
1954run_test "DER format: no trailing bytes" \
1955 "$P_SRV crt_file=data_files/server5-der0.crt \
1956 key_file=data_files/server5.key" \
1957 "$G_CLI " \
1958 0 \
1959 -c "Handshake was completed" \
1960
1961requires_gnutls
1962run_test "DER format: with a trailing zero byte" \
1963 "$P_SRV crt_file=data_files/server5-der1a.crt \
1964 key_file=data_files/server5.key" \
1965 "$G_CLI " \
1966 0 \
1967 -c "Handshake was completed" \
1968
1969requires_gnutls
1970run_test "DER format: with a trailing random byte" \
1971 "$P_SRV crt_file=data_files/server5-der1b.crt \
1972 key_file=data_files/server5.key" \
1973 "$G_CLI " \
1974 0 \
1975 -c "Handshake was completed" \
1976
1977requires_gnutls
1978run_test "DER format: with 2 trailing random bytes" \
1979 "$P_SRV crt_file=data_files/server5-der2.crt \
1980 key_file=data_files/server5.key" \
1981 "$G_CLI " \
1982 0 \
1983 -c "Handshake was completed" \
1984
1985requires_gnutls
1986run_test "DER format: with 4 trailing random bytes" \
1987 "$P_SRV crt_file=data_files/server5-der4.crt \
1988 key_file=data_files/server5.key" \
1989 "$G_CLI " \
1990 0 \
1991 -c "Handshake was completed" \
1992
1993requires_gnutls
1994run_test "DER format: with 8 trailing random bytes" \
1995 "$P_SRV crt_file=data_files/server5-der8.crt \
1996 key_file=data_files/server5.key" \
1997 "$G_CLI " \
1998 0 \
1999 -c "Handshake was completed" \
2000
2001requires_gnutls
2002run_test "DER format: with 9 trailing random bytes" \
2003 "$P_SRV crt_file=data_files/server5-der9.crt \
2004 key_file=data_files/server5.key" \
2005 "$G_CLI " \
2006 0 \
2007 -c "Handshake was completed" \
2008
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002009# Tests for auth_mode
2010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002011run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002012 "$P_SRV crt_file=data_files/server5-badsign.crt \
2013 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002014 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002015 1 \
2016 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002017 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002018 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002019 -c "X509 - Certificate verification failed"
2020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002021run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002022 "$P_SRV crt_file=data_files/server5-badsign.crt \
2023 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002024 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002025 0 \
2026 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002027 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002028 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002029 -C "X509 - Certificate verification failed"
2030
Hanno Becker61c0c702017-05-15 16:05:15 +01002031run_test "Authentication: server goodcert, client optional, no trusted CA" \
2032 "$P_SRV" \
2033 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2034 0 \
2035 -c "x509_verify_cert() returned" \
2036 -c "! The certificate is not correctly signed by the trusted CA" \
2037 -c "! Certificate verification flags"\
2038 -C "! mbedtls_ssl_handshake returned" \
2039 -C "X509 - Certificate verification failed" \
2040 -C "SSL - No CA Chain is set, but required to operate"
2041
2042run_test "Authentication: server goodcert, client required, no trusted CA" \
2043 "$P_SRV" \
2044 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2045 1 \
2046 -c "x509_verify_cert() returned" \
2047 -c "! The certificate is not correctly signed by the trusted CA" \
2048 -c "! Certificate verification flags"\
2049 -c "! mbedtls_ssl_handshake returned" \
2050 -c "SSL - No CA Chain is set, but required to operate"
2051
2052# The purpose of the next two tests is to test the client's behaviour when receiving a server
2053# certificate with an unsupported elliptic curve. This should usually not happen because
2054# the client informs the server about the supported curves - it does, though, in the
2055# corner case of a static ECDH suite, because the server doesn't check the curve on that
2056# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2057# different means to have the server ignoring the client's supported curve list.
2058
2059requires_config_enabled MBEDTLS_ECP_C
2060run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2061 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2062 crt_file=data_files/server5.ku-ka.crt" \
2063 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2064 1 \
2065 -c "bad certificate (EC key curve)"\
2066 -c "! Certificate verification flags"\
2067 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2068
2069requires_config_enabled MBEDTLS_ECP_C
2070run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2071 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2072 crt_file=data_files/server5.ku-ka.crt" \
2073 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2074 1 \
2075 -c "bad certificate (EC key curve)"\
2076 -c "! Certificate verification flags"\
2077 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2078
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002079run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002080 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002081 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002082 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002083 0 \
2084 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002085 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002086 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002087 -C "X509 - Certificate verification failed"
2088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002089run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002090 "$P_SRV debug_level=3 auth_mode=required" \
2091 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002092 key_file=data_files/server5.key" \
2093 1 \
2094 -S "skip write certificate request" \
2095 -C "skip parse certificate request" \
2096 -c "got a certificate request" \
2097 -C "skip write certificate" \
2098 -C "skip write certificate verify" \
2099 -S "skip parse certificate verify" \
2100 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002101 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002102 -s "! mbedtls_ssl_handshake returned" \
2103 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002104 -s "X509 - Certificate verification failed"
2105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002106run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002107 "$P_SRV debug_level=3 auth_mode=optional" \
2108 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002109 key_file=data_files/server5.key" \
2110 0 \
2111 -S "skip write certificate request" \
2112 -C "skip parse certificate request" \
2113 -c "got a certificate request" \
2114 -C "skip write certificate" \
2115 -C "skip write certificate verify" \
2116 -S "skip parse certificate verify" \
2117 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002118 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002119 -S "! mbedtls_ssl_handshake returned" \
2120 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002121 -S "X509 - Certificate verification failed"
2122
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002123run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002124 "$P_SRV debug_level=3 auth_mode=none" \
2125 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002126 key_file=data_files/server5.key" \
2127 0 \
2128 -s "skip write certificate request" \
2129 -C "skip parse certificate request" \
2130 -c "got no certificate request" \
2131 -c "skip write certificate" \
2132 -c "skip write certificate verify" \
2133 -s "skip parse certificate verify" \
2134 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002135 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002136 -S "! mbedtls_ssl_handshake returned" \
2137 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002138 -S "X509 - Certificate verification failed"
2139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002140run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002141 "$P_SRV debug_level=3 auth_mode=optional" \
2142 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002143 0 \
2144 -S "skip write certificate request" \
2145 -C "skip parse certificate request" \
2146 -c "got a certificate request" \
2147 -C "skip write certificate$" \
2148 -C "got no certificate to send" \
2149 -S "SSLv3 client has no certificate" \
2150 -c "skip write certificate verify" \
2151 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002152 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002153 -S "! mbedtls_ssl_handshake returned" \
2154 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002155 -S "X509 - Certificate verification failed"
2156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002157run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002158 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002159 "$O_CLI" \
2160 0 \
2161 -S "skip write certificate request" \
2162 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002163 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002164 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002165 -S "X509 - Certificate verification failed"
2166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002167run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002168 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002169 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002170 0 \
2171 -C "skip parse certificate request" \
2172 -c "got a certificate request" \
2173 -C "skip write certificate$" \
2174 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002175 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002176
Janos Follath542ee5d2016-03-07 15:57:05 +00002177requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002178run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002179 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002180 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002181 0 \
2182 -S "skip write certificate request" \
2183 -C "skip parse certificate request" \
2184 -c "got a certificate request" \
2185 -C "skip write certificate$" \
2186 -c "skip write certificate verify" \
2187 -c "got no certificate to send" \
2188 -s "SSLv3 client has no certificate" \
2189 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002190 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002191 -S "! mbedtls_ssl_handshake returned" \
2192 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002193 -S "X509 - Certificate verification failed"
2194
Manuel Pégourié-Gonnard591035d2017-06-26 10:45:33 +02002195run_test "Authentication: server max_int chain, client default" \
2196 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2197 key_file=data_files/dir-maxpath/09.key" \
2198 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2199 0 \
2200 -C "X509 - A fatal error occured"
2201
2202run_test "Authentication: server max_int+1 chain, client default" \
2203 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2204 key_file=data_files/dir-maxpath/10.key" \
2205 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2206 1 \
2207 -c "X509 - A fatal error occured"
2208
2209run_test "Authentication: server max_int+1 chain, client optional" \
2210 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2211 key_file=data_files/dir-maxpath/10.key" \
2212 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2213 auth_mode=optional" \
2214 1 \
2215 -c "X509 - A fatal error occured"
2216
2217run_test "Authentication: server max_int+1 chain, client none" \
2218 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2219 key_file=data_files/dir-maxpath/10.key" \
2220 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2221 auth_mode=none" \
2222 0 \
2223 -C "X509 - A fatal error occured"
2224
2225run_test "Authentication: client max_int+1 chain, server default" \
2226 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2227 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2228 key_file=data_files/dir-maxpath/10.key" \
2229 0 \
2230 -S "X509 - A fatal error occured"
2231
2232run_test "Authentication: client max_int+1 chain, server optional" \
2233 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2234 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2235 key_file=data_files/dir-maxpath/10.key" \
2236 1 \
2237 -s "X509 - A fatal error occured"
2238
2239run_test "Authentication: client max_int+1 chain, server required" \
2240 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2241 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2242 key_file=data_files/dir-maxpath/10.key" \
2243 1 \
2244 -s "X509 - A fatal error occured"
2245
2246run_test "Authentication: client max_int chain, server required" \
2247 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2248 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2249 key_file=data_files/dir-maxpath/09.key" \
2250 0 \
2251 -S "X509 - A fatal error occured"
2252
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002253# Tests for certificate selection based on SHA verson
2254
2255run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2256 "$P_SRV crt_file=data_files/server5.crt \
2257 key_file=data_files/server5.key \
2258 crt_file2=data_files/server5-sha1.crt \
2259 key_file2=data_files/server5.key" \
2260 "$P_CLI force_version=tls1_2" \
2261 0 \
2262 -c "signed using.*ECDSA with SHA256" \
2263 -C "signed using.*ECDSA with SHA1"
2264
2265run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2266 "$P_SRV crt_file=data_files/server5.crt \
2267 key_file=data_files/server5.key \
2268 crt_file2=data_files/server5-sha1.crt \
2269 key_file2=data_files/server5.key" \
2270 "$P_CLI force_version=tls1_1" \
2271 0 \
2272 -C "signed using.*ECDSA with SHA256" \
2273 -c "signed using.*ECDSA with SHA1"
2274
2275run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2276 "$P_SRV crt_file=data_files/server5.crt \
2277 key_file=data_files/server5.key \
2278 crt_file2=data_files/server5-sha1.crt \
2279 key_file2=data_files/server5.key" \
2280 "$P_CLI force_version=tls1" \
2281 0 \
2282 -C "signed using.*ECDSA with SHA256" \
2283 -c "signed using.*ECDSA with SHA1"
2284
2285run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2286 "$P_SRV crt_file=data_files/server5.crt \
2287 key_file=data_files/server5.key \
2288 crt_file2=data_files/server6.crt \
2289 key_file2=data_files/server6.key" \
2290 "$P_CLI force_version=tls1_1" \
2291 0 \
2292 -c "serial number.*09" \
2293 -c "signed using.*ECDSA with SHA256" \
2294 -C "signed using.*ECDSA with SHA1"
2295
2296run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2297 "$P_SRV crt_file=data_files/server6.crt \
2298 key_file=data_files/server6.key \
2299 crt_file2=data_files/server5.crt \
2300 key_file2=data_files/server5.key" \
2301 "$P_CLI force_version=tls1_1" \
2302 0 \
2303 -c "serial number.*0A" \
2304 -c "signed using.*ECDSA with SHA256" \
2305 -C "signed using.*ECDSA with SHA1"
2306
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002307# tests for SNI
2308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002309run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002310 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002311 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002312 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002313 0 \
2314 -S "parse ServerName extension" \
2315 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2316 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002317
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002318run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002319 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002320 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002321 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 +02002322 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002323 0 \
2324 -s "parse ServerName extension" \
2325 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2326 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002327
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002328run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002329 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002330 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002331 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 +02002332 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002333 0 \
2334 -s "parse ServerName extension" \
2335 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2336 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002338run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002339 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002340 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002341 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 +02002342 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002343 1 \
2344 -s "parse ServerName extension" \
2345 -s "ssl_sni_wrapper() returned" \
2346 -s "mbedtls_ssl_handshake returned" \
2347 -c "mbedtls_ssl_handshake returned" \
2348 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002349
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002350run_test "SNI: client auth no override: optional" \
2351 "$P_SRV debug_level=3 auth_mode=optional \
2352 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2353 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2354 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002355 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002356 -S "skip write certificate request" \
2357 -C "skip parse certificate request" \
2358 -c "got a certificate request" \
2359 -C "skip write certificate" \
2360 -C "skip write certificate verify" \
2361 -S "skip parse certificate verify"
2362
2363run_test "SNI: client auth override: none -> optional" \
2364 "$P_SRV debug_level=3 auth_mode=none \
2365 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2366 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2367 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002368 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002369 -S "skip write certificate request" \
2370 -C "skip parse certificate request" \
2371 -c "got a certificate request" \
2372 -C "skip write certificate" \
2373 -C "skip write certificate verify" \
2374 -S "skip parse certificate verify"
2375
2376run_test "SNI: client auth override: optional -> none" \
2377 "$P_SRV debug_level=3 auth_mode=optional \
2378 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2379 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2380 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002381 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002382 -s "skip write certificate request" \
2383 -C "skip parse certificate request" \
2384 -c "got no certificate request" \
2385 -c "skip write certificate" \
2386 -c "skip write certificate verify" \
2387 -s "skip parse certificate verify"
2388
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002389run_test "SNI: CA no override" \
2390 "$P_SRV debug_level=3 auth_mode=optional \
2391 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2392 ca_file=data_files/test-ca.crt \
2393 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2394 "$P_CLI debug_level=3 server_name=localhost \
2395 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2396 1 \
2397 -S "skip write certificate request" \
2398 -C "skip parse certificate request" \
2399 -c "got a certificate request" \
2400 -C "skip write certificate" \
2401 -C "skip write certificate verify" \
2402 -S "skip parse certificate verify" \
2403 -s "x509_verify_cert() returned" \
2404 -s "! The certificate is not correctly signed by the trusted CA" \
2405 -S "The certificate has been revoked (is on a CRL)"
2406
2407run_test "SNI: CA override" \
2408 "$P_SRV debug_level=3 auth_mode=optional \
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 \
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
2425run_test "SNI: CA override with CRL" \
2426 "$P_SRV debug_level=3 auth_mode=optional \
2427 crt_file=data_files/server5.crt key_file=data_files/server5.key \
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 \
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
Andres AG52142f12016-12-07 10:01:30 +00002443# Tests for SNI and DTLS
2444
Andres Amaya Garcia0b8eaa82018-05-01 20:27:37 +01002445run_test "SNI: DTLS, no SNI callback" \
2446 "$P_SRV debug_level=3 dtls=1 \
2447 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
2448 "$P_CLI server_name=localhost dtls=1" \
2449 0 \
2450 -S "parse ServerName extension" \
2451 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2452 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2453
Andres Amaya Garcia021ad3d2018-05-01 20:26:47 +01002454run_test "SNI: DTLS, matching cert 1" \
Andres AG52142f12016-12-07 10:01:30 +00002455 "$P_SRV debug_level=3 dtls=1 \
2456 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2457 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2458 "$P_CLI server_name=localhost dtls=1" \
2459 0 \
2460 -s "parse ServerName extension" \
2461 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2462 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
2463
Andres Amaya Garcia0b8eaa82018-05-01 20:27:37 +01002464run_test "SNI: DTLS, matching cert 2" \
2465 "$P_SRV debug_level=3 dtls=1 \
2466 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2467 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2468 "$P_CLI server_name=polarssl.example dtls=1" \
2469 0 \
2470 -s "parse ServerName extension" \
2471 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2472 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
2473
2474run_test "SNI: DTLS, no matching cert" \
2475 "$P_SRV debug_level=3 dtls=1 \
2476 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2477 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
2478 "$P_CLI server_name=nonesuch.example dtls=1" \
2479 1 \
2480 -s "parse ServerName extension" \
2481 -s "ssl_sni_wrapper() returned" \
2482 -s "mbedtls_ssl_handshake returned" \
2483 -c "mbedtls_ssl_handshake returned" \
2484 -c "SSL - A fatal alert message was received from our peer"
2485
2486run_test "SNI: DTLS, client auth no override: optional" \
2487 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2488 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2489 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2490 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2491 0 \
2492 -S "skip write certificate request" \
2493 -C "skip parse certificate request" \
2494 -c "got a certificate request" \
2495 -C "skip write certificate" \
2496 -C "skip write certificate verify" \
2497 -S "skip parse certificate verify"
2498
2499run_test "SNI: DTLS, client auth override: none -> optional" \
2500 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
2501 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2502 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2503 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2504 0 \
2505 -S "skip write certificate request" \
2506 -C "skip parse certificate request" \
2507 -c "got a certificate request" \
2508 -C "skip write certificate" \
2509 -C "skip write certificate verify" \
2510 -S "skip parse certificate verify"
2511
2512run_test "SNI: DTLS, client auth override: optional -> none" \
2513 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2514 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2515 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2516 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
2517 0 \
2518 -s "skip write certificate request" \
2519 -C "skip parse certificate request" \
2520 -c "got no certificate request" \
2521 -c "skip write certificate" \
2522 -c "skip write certificate verify" \
2523 -s "skip parse certificate verify"
2524
Simon Butcher12826df2018-06-16 19:46:52 +01002525needs_more_time 4
Andres Amaya Garcia0b8eaa82018-05-01 20:27:37 +01002526run_test "SNI: DTLS, CA no override" \
2527 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2528 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2529 ca_file=data_files/test-ca.crt \
2530 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2531 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2532 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2533 1 \
2534 -S "skip write certificate request" \
2535 -C "skip parse certificate request" \
2536 -c "got a certificate request" \
2537 -C "skip write certificate" \
2538 -C "skip write certificate verify" \
2539 -S "skip parse certificate verify" \
2540 -s "x509_verify_cert() returned" \
2541 -s "! The certificate is not correctly signed by the trusted CA" \
2542 -S "The certificate has been revoked (is on a CRL)"
2543
Andres Amaya Garcia021ad3d2018-05-01 20:26:47 +01002544run_test "SNI: DTLS, CA override" \
Andres AG52142f12016-12-07 10:01:30 +00002545 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
2546 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2547 ca_file=data_files/test-ca.crt \
2548 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2549 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2550 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2551 0 \
2552 -S "skip write certificate request" \
2553 -C "skip parse certificate request" \
2554 -c "got a certificate request" \
2555 -C "skip write certificate" \
2556 -C "skip write certificate verify" \
2557 -S "skip parse certificate verify" \
2558 -S "x509_verify_cert() returned" \
2559 -S "! The certificate is not correctly signed by the trusted CA" \
2560 -S "The certificate has been revoked (is on a CRL)"
2561
Simon Butcher12826df2018-06-16 19:46:52 +01002562needs_more_time 4
Andres Amaya Garcia021ad3d2018-05-01 20:26:47 +01002563run_test "SNI: DTLS, CA override with CRL" \
Andres AG52142f12016-12-07 10:01:30 +00002564 "$P_SRV debug_level=3 auth_mode=optional \
2565 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
2566 ca_file=data_files/test-ca.crt \
2567 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2568 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
2569 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2570 1 \
2571 -S "skip write certificate request" \
2572 -C "skip parse certificate request" \
2573 -c "got a certificate request" \
2574 -C "skip write certificate" \
2575 -C "skip write certificate verify" \
2576 -S "skip parse certificate verify" \
2577 -s "x509_verify_cert() returned" \
2578 -S "! The certificate is not correctly signed by the trusted CA" \
2579 -s "The certificate has been revoked (is on a CRL)"
2580
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002581# Tests for non-blocking I/O: exercise a variety of handshake flows
2582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002583run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002584 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2585 "$P_CLI nbio=2 tickets=0" \
2586 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002587 -S "mbedtls_ssl_handshake returned" \
2588 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002589 -c "Read from server: .* bytes read"
2590
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002591run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002592 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2593 "$P_CLI nbio=2 tickets=0" \
2594 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002595 -S "mbedtls_ssl_handshake returned" \
2596 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002597 -c "Read from server: .* bytes read"
2598
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002599run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002600 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2601 "$P_CLI nbio=2 tickets=1" \
2602 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002603 -S "mbedtls_ssl_handshake returned" \
2604 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002605 -c "Read from server: .* bytes read"
2606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002607run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002608 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2609 "$P_CLI nbio=2 tickets=1" \
2610 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002611 -S "mbedtls_ssl_handshake returned" \
2612 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002613 -c "Read from server: .* bytes read"
2614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002615run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002616 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2617 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2618 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002619 -S "mbedtls_ssl_handshake returned" \
2620 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002621 -c "Read from server: .* bytes read"
2622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002623run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002624 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2625 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2626 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002627 -S "mbedtls_ssl_handshake returned" \
2628 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002629 -c "Read from server: .* bytes read"
2630
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002631run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002632 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2633 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2634 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002635 -S "mbedtls_ssl_handshake returned" \
2636 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002637 -c "Read from server: .* bytes read"
2638
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002639# Tests for version negotiation
2640
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002641run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002642 "$P_SRV" \
2643 "$P_CLI" \
2644 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002645 -S "mbedtls_ssl_handshake returned" \
2646 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002647 -s "Protocol is TLSv1.2" \
2648 -c "Protocol is TLSv1.2"
2649
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002650run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002651 "$P_SRV" \
2652 "$P_CLI max_version=tls1_1" \
2653 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002654 -S "mbedtls_ssl_handshake returned" \
2655 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002656 -s "Protocol is TLSv1.1" \
2657 -c "Protocol is TLSv1.1"
2658
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002659run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002660 "$P_SRV max_version=tls1_1" \
2661 "$P_CLI" \
2662 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002663 -S "mbedtls_ssl_handshake returned" \
2664 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002665 -s "Protocol is TLSv1.1" \
2666 -c "Protocol is TLSv1.1"
2667
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002668run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002669 "$P_SRV max_version=tls1_1" \
2670 "$P_CLI max_version=tls1_1" \
2671 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002672 -S "mbedtls_ssl_handshake returned" \
2673 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002674 -s "Protocol is TLSv1.1" \
2675 -c "Protocol is TLSv1.1"
2676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002677run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002678 "$P_SRV min_version=tls1_1" \
2679 "$P_CLI max_version=tls1_1" \
2680 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002681 -S "mbedtls_ssl_handshake returned" \
2682 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002683 -s "Protocol is TLSv1.1" \
2684 -c "Protocol is TLSv1.1"
2685
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002686run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002687 "$P_SRV max_version=tls1_1" \
2688 "$P_CLI min_version=tls1_1" \
2689 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002690 -S "mbedtls_ssl_handshake returned" \
2691 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002692 -s "Protocol is TLSv1.1" \
2693 -c "Protocol is TLSv1.1"
2694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002695run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002696 "$P_SRV max_version=tls1_1" \
2697 "$P_CLI min_version=tls1_2" \
2698 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002699 -s "mbedtls_ssl_handshake returned" \
2700 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002701 -c "SSL - Handshake protocol not within min/max boundaries"
2702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002703run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002704 "$P_SRV min_version=tls1_2" \
2705 "$P_CLI max_version=tls1_1" \
2706 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002707 -s "mbedtls_ssl_handshake returned" \
2708 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002709 -s "SSL - Handshake protocol not within min/max boundaries"
2710
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002711# Tests for ALPN extension
2712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002713run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002714 "$P_SRV debug_level=3" \
2715 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002716 0 \
2717 -C "client hello, adding alpn extension" \
2718 -S "found alpn extension" \
2719 -C "got an alert message, type: \\[2:120]" \
2720 -S "server hello, adding alpn extension" \
2721 -C "found alpn extension " \
2722 -C "Application Layer Protocol is" \
2723 -S "Application Layer Protocol is"
2724
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002725run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002726 "$P_SRV debug_level=3" \
2727 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002728 0 \
2729 -c "client hello, adding alpn extension" \
2730 -s "found alpn extension" \
2731 -C "got an alert message, type: \\[2:120]" \
2732 -S "server hello, adding alpn extension" \
2733 -C "found alpn extension " \
2734 -c "Application Layer Protocol is (none)" \
2735 -S "Application Layer Protocol is"
2736
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002737run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002738 "$P_SRV debug_level=3 alpn=abc,1234" \
2739 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002740 0 \
2741 -C "client hello, adding alpn extension" \
2742 -S "found alpn extension" \
2743 -C "got an alert message, type: \\[2:120]" \
2744 -S "server hello, adding alpn extension" \
2745 -C "found alpn extension " \
2746 -C "Application Layer Protocol is" \
2747 -s "Application Layer Protocol is (none)"
2748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002749run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002750 "$P_SRV debug_level=3 alpn=abc,1234" \
2751 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002752 0 \
2753 -c "client hello, adding alpn extension" \
2754 -s "found alpn extension" \
2755 -C "got an alert message, type: \\[2:120]" \
2756 -s "server hello, adding alpn extension" \
2757 -c "found alpn extension" \
2758 -c "Application Layer Protocol is abc" \
2759 -s "Application Layer Protocol is abc"
2760
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002761run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002762 "$P_SRV debug_level=3 alpn=abc,1234" \
2763 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002764 0 \
2765 -c "client hello, adding alpn extension" \
2766 -s "found alpn extension" \
2767 -C "got an alert message, type: \\[2:120]" \
2768 -s "server hello, adding alpn extension" \
2769 -c "found alpn extension" \
2770 -c "Application Layer Protocol is abc" \
2771 -s "Application Layer Protocol is abc"
2772
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002773run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002774 "$P_SRV debug_level=3 alpn=abc,1234" \
2775 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002776 0 \
2777 -c "client hello, adding alpn extension" \
2778 -s "found alpn extension" \
2779 -C "got an alert message, type: \\[2:120]" \
2780 -s "server hello, adding alpn extension" \
2781 -c "found alpn extension" \
2782 -c "Application Layer Protocol is 1234" \
2783 -s "Application Layer Protocol is 1234"
2784
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002785run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002786 "$P_SRV debug_level=3 alpn=abc,123" \
2787 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002788 1 \
2789 -c "client hello, adding alpn extension" \
2790 -s "found alpn extension" \
2791 -c "got an alert message, type: \\[2:120]" \
2792 -S "server hello, adding alpn extension" \
2793 -C "found alpn extension" \
2794 -C "Application Layer Protocol is 1234" \
2795 -S "Application Layer Protocol is 1234"
2796
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002797
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002798# Tests for keyUsage in leaf certificates, part 1:
2799# server-side certificate/suite selection
2800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002801run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002802 "$P_SRV key_file=data_files/server2.key \
2803 crt_file=data_files/server2.ku-ds.crt" \
2804 "$P_CLI" \
2805 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002806 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002807
2808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002809run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002810 "$P_SRV key_file=data_files/server2.key \
2811 crt_file=data_files/server2.ku-ke.crt" \
2812 "$P_CLI" \
2813 0 \
2814 -c "Ciphersuite is TLS-RSA-WITH-"
2815
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002816run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002817 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002818 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002819 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002820 1 \
2821 -C "Ciphersuite is "
2822
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002823run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002824 "$P_SRV key_file=data_files/server5.key \
2825 crt_file=data_files/server5.ku-ds.crt" \
2826 "$P_CLI" \
2827 0 \
2828 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2829
2830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002831run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002832 "$P_SRV key_file=data_files/server5.key \
2833 crt_file=data_files/server5.ku-ka.crt" \
2834 "$P_CLI" \
2835 0 \
2836 -c "Ciphersuite is TLS-ECDH-"
2837
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002838run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002839 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002840 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002841 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002842 1 \
2843 -C "Ciphersuite is "
2844
2845# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002846# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002847
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002848run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002849 "$O_SRV -key data_files/server2.key \
2850 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002851 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002852 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2853 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002854 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002855 -C "Processing of the Certificate handshake message failed" \
2856 -c "Ciphersuite is TLS-"
2857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002858run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002859 "$O_SRV -key data_files/server2.key \
2860 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002861 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002862 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2863 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002864 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002865 -C "Processing of the Certificate handshake message failed" \
2866 -c "Ciphersuite is TLS-"
2867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002868run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002869 "$O_SRV -key data_files/server2.key \
2870 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002871 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002872 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2873 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002874 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002875 -C "Processing of the Certificate handshake message failed" \
2876 -c "Ciphersuite is TLS-"
2877
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002878run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002879 "$O_SRV -key data_files/server2.key \
2880 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002881 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002882 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2883 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002884 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002885 -c "Processing of the Certificate handshake message failed" \
2886 -C "Ciphersuite is TLS-"
2887
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002888run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2889 "$O_SRV -key data_files/server2.key \
2890 -cert data_files/server2.ku-ke.crt" \
2891 "$P_CLI debug_level=1 auth_mode=optional \
2892 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2893 0 \
2894 -c "bad certificate (usage extensions)" \
2895 -C "Processing of the Certificate handshake message failed" \
2896 -c "Ciphersuite is TLS-" \
2897 -c "! Usage does not match the keyUsage extension"
2898
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002899run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002900 "$O_SRV -key data_files/server2.key \
2901 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002902 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002903 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2904 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002905 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002906 -C "Processing of the Certificate handshake message failed" \
2907 -c "Ciphersuite is TLS-"
2908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002909run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002910 "$O_SRV -key data_files/server2.key \
2911 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002912 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002913 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2914 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002915 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002916 -c "Processing of the Certificate handshake message failed" \
2917 -C "Ciphersuite is TLS-"
2918
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002919run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2920 "$O_SRV -key data_files/server2.key \
2921 -cert data_files/server2.ku-ds.crt" \
2922 "$P_CLI debug_level=1 auth_mode=optional \
2923 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2924 0 \
2925 -c "bad certificate (usage extensions)" \
2926 -C "Processing of the Certificate handshake message failed" \
2927 -c "Ciphersuite is TLS-" \
2928 -c "! Usage does not match the keyUsage extension"
2929
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002930# Tests for keyUsage in leaf certificates, part 3:
2931# server-side checking of client cert
2932
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002933run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002934 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002935 "$O_CLI -key data_files/server2.key \
2936 -cert data_files/server2.ku-ds.crt" \
2937 0 \
2938 -S "bad certificate (usage extensions)" \
2939 -S "Processing of the Certificate handshake message failed"
2940
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002941run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002942 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002943 "$O_CLI -key data_files/server2.key \
2944 -cert data_files/server2.ku-ke.crt" \
2945 0 \
2946 -s "bad certificate (usage extensions)" \
2947 -S "Processing of the Certificate handshake message failed"
2948
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002949run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002950 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002951 "$O_CLI -key data_files/server2.key \
2952 -cert data_files/server2.ku-ke.crt" \
2953 1 \
2954 -s "bad certificate (usage extensions)" \
2955 -s "Processing of the Certificate handshake message failed"
2956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002957run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002958 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002959 "$O_CLI -key data_files/server5.key \
2960 -cert data_files/server5.ku-ds.crt" \
2961 0 \
2962 -S "bad certificate (usage extensions)" \
2963 -S "Processing of the Certificate handshake message failed"
2964
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002965run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002966 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002967 "$O_CLI -key data_files/server5.key \
2968 -cert data_files/server5.ku-ka.crt" \
2969 0 \
2970 -s "bad certificate (usage extensions)" \
2971 -S "Processing of the Certificate handshake message failed"
2972
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002973# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2974
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002975run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002976 "$P_SRV key_file=data_files/server5.key \
2977 crt_file=data_files/server5.eku-srv.crt" \
2978 "$P_CLI" \
2979 0
2980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002981run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002982 "$P_SRV key_file=data_files/server5.key \
2983 crt_file=data_files/server5.eku-srv.crt" \
2984 "$P_CLI" \
2985 0
2986
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002987run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002988 "$P_SRV key_file=data_files/server5.key \
2989 crt_file=data_files/server5.eku-cs_any.crt" \
2990 "$P_CLI" \
2991 0
2992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002993run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002994 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002995 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002996 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002997 1
2998
2999# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3000
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003001run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003002 "$O_SRV -key data_files/server5.key \
3003 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003004 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003005 0 \
3006 -C "bad certificate (usage extensions)" \
3007 -C "Processing of the Certificate handshake message failed" \
3008 -c "Ciphersuite is TLS-"
3009
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003010run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003011 "$O_SRV -key data_files/server5.key \
3012 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003013 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003014 0 \
3015 -C "bad certificate (usage extensions)" \
3016 -C "Processing of the Certificate handshake message failed" \
3017 -c "Ciphersuite is TLS-"
3018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003019run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003020 "$O_SRV -key data_files/server5.key \
3021 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003022 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003023 0 \
3024 -C "bad certificate (usage extensions)" \
3025 -C "Processing of the Certificate handshake message failed" \
3026 -c "Ciphersuite is TLS-"
3027
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003028run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003029 "$O_SRV -key data_files/server5.key \
3030 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003031 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003032 1 \
3033 -c "bad certificate (usage extensions)" \
3034 -c "Processing of the Certificate handshake message failed" \
3035 -C "Ciphersuite is TLS-"
3036
3037# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3038
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003039run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003040 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003041 "$O_CLI -key data_files/server5.key \
3042 -cert data_files/server5.eku-cli.crt" \
3043 0 \
3044 -S "bad certificate (usage extensions)" \
3045 -S "Processing of the Certificate handshake message failed"
3046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003047run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003048 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003049 "$O_CLI -key data_files/server5.key \
3050 -cert data_files/server5.eku-srv_cli.crt" \
3051 0 \
3052 -S "bad certificate (usage extensions)" \
3053 -S "Processing of the Certificate handshake message failed"
3054
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003055run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003056 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003057 "$O_CLI -key data_files/server5.key \
3058 -cert data_files/server5.eku-cs_any.crt" \
3059 0 \
3060 -S "bad certificate (usage extensions)" \
3061 -S "Processing of the Certificate handshake message failed"
3062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003063run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003064 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003065 "$O_CLI -key data_files/server5.key \
3066 -cert data_files/server5.eku-cs.crt" \
3067 0 \
3068 -s "bad certificate (usage extensions)" \
3069 -S "Processing of the Certificate handshake message failed"
3070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003071run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003072 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003073 "$O_CLI -key data_files/server5.key \
3074 -cert data_files/server5.eku-cs.crt" \
3075 1 \
3076 -s "bad certificate (usage extensions)" \
3077 -s "Processing of the Certificate handshake message failed"
3078
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003079# Tests for DHM parameters loading
3080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003081run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003082 "$P_SRV" \
3083 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3084 debug_level=3" \
3085 0 \
3086 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker80e0d462017-10-13 16:51:54 +01003087 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003089run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003090 "$P_SRV dhm_file=data_files/dhparams.pem" \
3091 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3092 debug_level=3" \
3093 0 \
3094 -c "value of 'DHM: P ' (1024 bits)" \
3095 -c "value of 'DHM: G ' (2 bits)"
3096
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003097# Tests for DHM client-side size checking
3098
3099run_test "DHM size: server default, client default, OK" \
3100 "$P_SRV" \
3101 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3102 debug_level=1" \
3103 0 \
3104 -C "DHM prime too short:"
3105
3106run_test "DHM size: server default, client 2048, OK" \
3107 "$P_SRV" \
3108 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3109 debug_level=1 dhmlen=2048" \
3110 0 \
3111 -C "DHM prime too short:"
3112
3113run_test "DHM size: server 1024, client default, OK" \
3114 "$P_SRV dhm_file=data_files/dhparams.pem" \
3115 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3116 debug_level=1" \
3117 0 \
3118 -C "DHM prime too short:"
3119
3120run_test "DHM size: server 1000, client default, rejected" \
3121 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3122 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3123 debug_level=1" \
3124 1 \
3125 -c "DHM prime too short:"
3126
3127run_test "DHM size: server default, client 2049, rejected" \
3128 "$P_SRV" \
3129 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3130 debug_level=1 dhmlen=2049" \
3131 1 \
3132 -c "DHM prime too short:"
3133
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003134# Tests for PSK callback
3135
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003136run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003137 "$P_SRV psk=abc123 psk_identity=foo" \
3138 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3139 psk_identity=foo psk=abc123" \
3140 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003141 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003142 -S "SSL - Unknown identity received" \
3143 -S "SSL - Verification of the message MAC failed"
3144
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003145run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003146 "$P_SRV" \
3147 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3148 psk_identity=foo psk=abc123" \
3149 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003150 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003151 -S "SSL - Unknown identity received" \
3152 -S "SSL - Verification of the message MAC failed"
3153
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003154run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003155 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3156 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3157 psk_identity=foo psk=abc123" \
3158 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003159 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003160 -s "SSL - Unknown identity received" \
3161 -S "SSL - Verification of the message MAC failed"
3162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003163run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003164 "$P_SRV psk_list=abc,dead,def,beef" \
3165 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3166 psk_identity=abc psk=dead" \
3167 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003168 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003169 -S "SSL - Unknown identity received" \
3170 -S "SSL - Verification of the message MAC failed"
3171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003172run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003173 "$P_SRV psk_list=abc,dead,def,beef" \
3174 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3175 psk_identity=def psk=beef" \
3176 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003177 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003178 -S "SSL - Unknown identity received" \
3179 -S "SSL - Verification of the message MAC failed"
3180
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003181run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003182 "$P_SRV psk_list=abc,dead,def,beef" \
3183 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3184 psk_identity=ghi psk=beef" \
3185 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003186 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003187 -s "SSL - Unknown identity received" \
3188 -S "SSL - Verification of the message MAC failed"
3189
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003190run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003191 "$P_SRV psk_list=abc,dead,def,beef" \
3192 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3193 psk_identity=abc psk=beef" \
3194 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003195 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003196 -S "SSL - Unknown identity received" \
3197 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003198
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003199# Tests for ciphersuites per version
3200
Janos Follath542ee5d2016-03-07 15:57:05 +00003201requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003202run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003203 "$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 +02003204 "$P_CLI force_version=ssl3" \
3205 0 \
3206 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003208run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003209 "$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 +01003210 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003211 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003212 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003214run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003215 "$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 +02003216 "$P_CLI force_version=tls1_1" \
3217 0 \
3218 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003220run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003221 "$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 +02003222 "$P_CLI force_version=tls1_2" \
3223 0 \
3224 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3225
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003226# Test for ClientHello without extensions
3227
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003228requires_gnutls
Gilles Peskine7344e1b2017-05-12 13:16:40 +02003229run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003230 "$P_SRV debug_level=3" \
3231 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3232 0 \
3233 -s "dumping 'client hello extensions' (0 bytes)"
3234
Gilles Peskine7344e1b2017-05-12 13:16:40 +02003235requires_gnutls
3236run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3237 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3238 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3239 0 \
3240 -s "dumping 'client hello extensions' (0 bytes)"
3241
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003242# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003243
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003244run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003245 "$P_SRV" \
3246 "$P_CLI request_size=100" \
3247 0 \
3248 -s "Read from client: 100 bytes read$"
3249
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003250run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003251 "$P_SRV" \
3252 "$P_CLI request_size=500" \
3253 0 \
3254 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003255
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003256# Tests for small packets
3257
Janos Follath542ee5d2016-03-07 15:57:05 +00003258requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003259run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003260 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003261 "$P_CLI request_size=1 force_version=ssl3 \
3262 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3263 0 \
3264 -s "Read from client: 1 bytes read"
3265
Janos Follath542ee5d2016-03-07 15:57:05 +00003266requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003267run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003268 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003269 "$P_CLI request_size=1 force_version=ssl3 \
3270 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3271 0 \
3272 -s "Read from client: 1 bytes read"
3273
3274run_test "Small packet TLS 1.0 BlockCipher" \
3275 "$P_SRV" \
3276 "$P_CLI request_size=1 force_version=tls1 \
3277 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3278 0 \
3279 -s "Read from client: 1 bytes read"
3280
Hanno Becker7aae46c2017-11-10 08:59:04 +00003281run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003282 "$P_SRV" \
3283 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3284 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3285 0 \
3286 -s "Read from client: 1 bytes read"
3287
Hanno Beckera83fafa2017-11-10 08:42:54 +00003288requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003289run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003290 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003291 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003292 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003293 0 \
3294 -s "Read from client: 1 bytes read"
3295
Hanno Beckera83fafa2017-11-10 08:42:54 +00003296requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003297run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003298 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003299 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003300 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003301 0 \
3302 -s "Read from client: 1 bytes read"
3303
3304run_test "Small packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003305 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003306 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003307 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3308 0 \
3309 -s "Read from client: 1 bytes read"
3310
3311run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
3312 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3313 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003314 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003315 0 \
3316 -s "Read from client: 1 bytes read"
3317
3318requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3319run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003320 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003321 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003322 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003323 0 \
3324 -s "Read from client: 1 bytes read"
3325
Hanno Becker7aae46c2017-11-10 08:59:04 +00003326requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3327run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003328 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
3329 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3330 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003331 0 \
3332 -s "Read from client: 1 bytes read"
3333
3334run_test "Small packet TLS 1.1 BlockCipher" \
3335 "$P_SRV" \
3336 "$P_CLI request_size=1 force_version=tls1_1 \
3337 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3338 0 \
3339 -s "Read from client: 1 bytes read"
3340
Hanno Becker7aae46c2017-11-10 08:59:04 +00003341run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003342 "$P_SRV" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003343 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003344 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003345 0 \
3346 -s "Read from client: 1 bytes read"
3347
3348requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3349run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003350 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003351 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003352 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003353 0 \
3354 -s "Read from client: 1 bytes read"
3355
3356requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3357run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003358 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003359 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003360 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003361 0 \
3362 -s "Read from client: 1 bytes read"
3363
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003364run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003365 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003366 "$P_CLI request_size=1 force_version=tls1_1 \
3367 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3368 0 \
3369 -s "Read from client: 1 bytes read"
3370
Hanno Becker7aae46c2017-11-10 08:59:04 +00003371run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
3372 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003373 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003374 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003375 0 \
3376 -s "Read from client: 1 bytes read"
3377
Hanno Becker7aae46c2017-11-10 08:59:04 +00003378requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3379run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003380 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003381 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003382 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003383 0 \
3384 -s "Read from client: 1 bytes read"
3385
Hanno Beckera83fafa2017-11-10 08:42:54 +00003386requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003387run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003388 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003389 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003390 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003391 0 \
3392 -s "Read from client: 1 bytes read"
3393
3394run_test "Small packet TLS 1.2 BlockCipher" \
3395 "$P_SRV" \
3396 "$P_CLI request_size=1 force_version=tls1_2 \
3397 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3398 0 \
3399 -s "Read from client: 1 bytes read"
3400
Hanno Becker7aae46c2017-11-10 08:59:04 +00003401run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003402 "$P_SRV" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003403 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003404 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003405 0 \
3406 -s "Read from client: 1 bytes read"
3407
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003408run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3409 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003410 "$P_CLI request_size=1 force_version=tls1_2 \
3411 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003412 0 \
3413 -s "Read from client: 1 bytes read"
3414
Hanno Beckera83fafa2017-11-10 08:42:54 +00003415requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003416run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003417 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003418 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003419 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003420 0 \
3421 -s "Read from client: 1 bytes read"
3422
Hanno Becker7aae46c2017-11-10 08:59:04 +00003423requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3424run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003425 "$P_SRV trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003426 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003427 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003428 0 \
3429 -s "Read from client: 1 bytes read"
3430
3431run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003432 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003433 "$P_CLI request_size=1 force_version=tls1_2 \
3434 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3435 0 \
3436 -s "Read from client: 1 bytes read"
3437
Hanno Becker7aae46c2017-11-10 08:59:04 +00003438run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003439 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003440 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003441 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003442 0 \
3443 -s "Read from client: 1 bytes read"
3444
Hanno Beckera83fafa2017-11-10 08:42:54 +00003445requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker7aae46c2017-11-10 08:59:04 +00003446run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003447 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003448 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003449 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003450 0 \
3451 -s "Read from client: 1 bytes read"
3452
Hanno Becker7aae46c2017-11-10 08:59:04 +00003453requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3454run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003455 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker7aae46c2017-11-10 08:59:04 +00003456 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003457 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003458 0 \
3459 -s "Read from client: 1 bytes read"
3460
3461run_test "Small packet TLS 1.2 AEAD" \
3462 "$P_SRV" \
3463 "$P_CLI request_size=1 force_version=tls1_2 \
3464 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3465 0 \
3466 -s "Read from client: 1 bytes read"
3467
3468run_test "Small packet TLS 1.2 AEAD shorter tag" \
3469 "$P_SRV" \
3470 "$P_CLI request_size=1 force_version=tls1_2 \
3471 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3472 0 \
3473 -s "Read from client: 1 bytes read"
3474
Hanno Becker461cb812017-11-10 08:59:18 +00003475# Tests for small packets in DTLS
3476
3477requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3478run_test "Small packet DTLS 1.0" \
3479 "$P_SRV dtls=1 force_version=dtls1" \
3480 "$P_CLI dtls=1 request_size=1 \
3481 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3482 0 \
3483 -s "Read from client: 1 bytes read"
3484
3485requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3486run_test "Small packet DTLS 1.0, without EtM" \
3487 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
3488 "$P_CLI dtls=1 request_size=1 \
3489 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3490 0 \
3491 -s "Read from client: 1 bytes read"
3492
3493requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3494requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3495run_test "Small packet DTLS 1.0, truncated hmac" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003496 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
3497 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Becker461cb812017-11-10 08:59:18 +00003498 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3499 0 \
3500 -s "Read from client: 1 bytes read"
3501
3502requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3503requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3504run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003505 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Becker461cb812017-11-10 08:59:18 +00003506 "$P_CLI dtls=1 request_size=1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003507 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Becker461cb812017-11-10 08:59:18 +00003508 0 \
3509 -s "Read from client: 1 bytes read"
3510
3511requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3512run_test "Small packet DTLS 1.2" \
3513 "$P_SRV dtls=1 force_version=dtls1_2" \
3514 "$P_CLI dtls=1 request_size=1 \
3515 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3516 0 \
3517 -s "Read from client: 1 bytes read"
3518
3519requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3520run_test "Small packet DTLS 1.2, without EtM" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003521 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Becker461cb812017-11-10 08:59:18 +00003522 "$P_CLI dtls=1 request_size=1 \
3523 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3524 0 \
3525 -s "Read from client: 1 bytes read"
3526
3527requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3528requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3529run_test "Small packet DTLS 1.2, truncated hmac" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003530 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Becker461cb812017-11-10 08:59:18 +00003531 "$P_CLI dtls=1 request_size=1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003532 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker461cb812017-11-10 08:59:18 +00003533 0 \
3534 -s "Read from client: 1 bytes read"
3535
3536requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
3537requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3538run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003539 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Becker461cb812017-11-10 08:59:18 +00003540 "$P_CLI dtls=1 request_size=1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003541 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Becker461cb812017-11-10 08:59:18 +00003542 0 \
3543 -s "Read from client: 1 bytes read"
3544
Janos Follathb700c462016-05-06 13:48:23 +01003545# A test for extensions in SSLv3
3546
3547requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3548run_test "SSLv3 with extensions, server side" \
3549 "$P_SRV min_version=ssl3 debug_level=3" \
3550 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3551 0 \
3552 -S "dumping 'client hello extensions'" \
3553 -S "server hello, total extension length:"
3554
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003555# Test for large packets
3556
Janos Follath542ee5d2016-03-07 15:57:05 +00003557requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003558run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003559 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003560 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003561 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3562 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003563 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003564 -s "Read from client: 16384 bytes read"
3565
Janos Follath542ee5d2016-03-07 15:57:05 +00003566requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003567run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003568 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003569 "$P_CLI request_size=16384 force_version=ssl3 \
3570 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3571 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003572 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003573 -s "Read from client: 16384 bytes read"
3574
3575run_test "Large packet TLS 1.0 BlockCipher" \
3576 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003577 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003578 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3579 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003580 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003581 -s "Read from client: 16384 bytes read"
3582
Hanno Becker0b9d9132017-11-10 09:16:28 +00003583run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003584 "$P_SRV" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003585 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
3586 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3587 0 \
3588 -s "Read from client: 16384 bytes read"
3589
Hanno Beckera83fafa2017-11-10 08:42:54 +00003590requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003591run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003592 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003593 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003594 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003595 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003596 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003597 -s "Read from client: 16384 bytes read"
3598
Hanno Beckera83fafa2017-11-10 08:42:54 +00003599requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003600run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003601 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003602 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003603 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003604 0 \
3605 -s "Read from client: 16384 bytes read"
3606
3607run_test "Large packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003608 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003609 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003610 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3611 0 \
3612 -s "Read from client: 16384 bytes read"
3613
3614run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
3615 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3616 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003617 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003618 0 \
3619 -s "Read from client: 16384 bytes read"
3620
3621requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3622run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003623 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003624 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003625 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003626 0 \
3627 -s "Read from client: 16384 bytes read"
3628
Hanno Becker0b9d9132017-11-10 09:16:28 +00003629requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3630run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003631 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003632 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003633 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003634 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003635 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003636 -s "Read from client: 16384 bytes read"
3637
3638run_test "Large packet TLS 1.1 BlockCipher" \
3639 "$P_SRV" \
3640 "$P_CLI request_size=16384 force_version=tls1_1 \
3641 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3642 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003643 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003644 -s "Read from client: 16384 bytes read"
3645
Hanno Becker0b9d9132017-11-10 09:16:28 +00003646run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
3647 "$P_SRV" \
3648 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
3649 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003650 0 \
3651 -s "Read from client: 16384 bytes read"
3652
Hanno Beckera83fafa2017-11-10 08:42:54 +00003653requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003654run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003655 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003656 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003657 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003658 0 \
3659 -s "Read from client: 16384 bytes read"
3660
Hanno Beckera83fafa2017-11-10 08:42:54 +00003661requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003662run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003663 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003664 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003665 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003666 0 \
3667 -s "Read from client: 16384 bytes read"
3668
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003669run_test "Large packet TLS 1.1 StreamCipher" \
3670 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3671 "$P_CLI request_size=16384 force_version=tls1_1 \
3672 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3673 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003674 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003675 -s "Read from client: 16384 bytes read"
3676
Hanno Becker0b9d9132017-11-10 09:16:28 +00003677run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
3678 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003679 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003680 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003681 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003682 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003683 -s "Read from client: 16384 bytes read"
3684
Hanno Becker0b9d9132017-11-10 09:16:28 +00003685requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3686run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003687 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003688 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003689 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003690 0 \
3691 -s "Read from client: 16384 bytes read"
3692
Hanno Becker0b9d9132017-11-10 09:16:28 +00003693requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3694run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003695 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003696 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003697 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003698 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003699 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003700 -s "Read from client: 16384 bytes read"
3701
3702run_test "Large packet TLS 1.2 BlockCipher" \
3703 "$P_SRV" \
3704 "$P_CLI request_size=16384 force_version=tls1_2 \
3705 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3706 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003707 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003708 -s "Read from client: 16384 bytes read"
3709
Hanno Becker0b9d9132017-11-10 09:16:28 +00003710run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
3711 "$P_SRV" \
3712 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
3713 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3714 0 \
3715 -s "Read from client: 16384 bytes read"
3716
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003717run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3718 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003719 "$P_CLI request_size=16384 force_version=tls1_2 \
3720 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003721 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003722 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003723 -s "Read from client: 16384 bytes read"
3724
Hanno Beckera83fafa2017-11-10 08:42:54 +00003725requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003726run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003727 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003728 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003729 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003730 0 \
3731 -s "Read from client: 16384 bytes read"
3732
Hanno Becker0b9d9132017-11-10 09:16:28 +00003733requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3734run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003735 "$P_SRV trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003736 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003737 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003738 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003739 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003740 -s "Read from client: 16384 bytes read"
3741
3742run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003743 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003744 "$P_CLI request_size=16384 force_version=tls1_2 \
3745 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3746 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003747 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003748 -s "Read from client: 16384 bytes read"
3749
Hanno Becker0b9d9132017-11-10 09:16:28 +00003750run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003751 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003752 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003753 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
3754 0 \
3755 -s "Read from client: 16384 bytes read"
3756
Hanno Beckera83fafa2017-11-10 08:42:54 +00003757requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker0b9d9132017-11-10 09:16:28 +00003758run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003759 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003760 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003761 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003762 0 \
3763 -s "Read from client: 16384 bytes read"
3764
Hanno Becker0b9d9132017-11-10 09:16:28 +00003765requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
3766run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003767 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker0b9d9132017-11-10 09:16:28 +00003768 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker8e75b6c2017-11-21 17:10:12 +00003769 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003770 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003771 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003772 -s "Read from client: 16384 bytes read"
3773
3774run_test "Large packet TLS 1.2 AEAD" \
3775 "$P_SRV" \
3776 "$P_CLI request_size=16384 force_version=tls1_2 \
3777 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3778 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003779 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003780 -s "Read from client: 16384 bytes read"
3781
3782run_test "Large packet TLS 1.2 AEAD shorter tag" \
3783 "$P_SRV" \
3784 "$P_CLI request_size=16384 force_version=tls1_2 \
3785 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3786 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003787 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003788 -s "Read from client: 16384 bytes read"
3789
Ron Eldorb27a1ab2018-06-28 13:22:05 +03003790# Tests for ECC extensions (rfc 4492)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003791
Ron Eldor2eee2e62018-06-28 16:17:00 +03003792requires_config_enabled MBEDTLS_AES_C
3793requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
3794requires_config_enabled MBEDTLS_SHA256_C
3795requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorb27a1ab2018-06-28 13:22:05 +03003796run_test "Force a non ECC ciphersuite in the client side" \
3797 "$P_SRV debug_level=3" \
Ron Eldor2eee2e62018-06-28 16:17:00 +03003798 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003799 0 \
Ron Eldorb27a1ab2018-06-28 13:22:05 +03003800 -C "client hello, adding supported_elliptic_curves extension" \
3801 -C "client hello, adding supported_point_formats extension" \
3802 -S "found supported elliptic curves extension" \
3803 -S "found supported point formats extension"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003804
Ron Eldor2eee2e62018-06-28 16:17:00 +03003805requires_config_enabled MBEDTLS_AES_C
3806requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
3807requires_config_enabled MBEDTLS_SHA256_C
3808requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldorb27a1ab2018-06-28 13:22:05 +03003809run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor2eee2e62018-06-28 16:17:00 +03003810 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldorb27a1ab2018-06-28 13:22:05 +03003811 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003812 0 \
Ron Eldorb27a1ab2018-06-28 13:22:05 +03003813 -C "found supported_point_formats extension" \
3814 -S "server hello, supported_point_formats extension"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003815
Ron Eldor2eee2e62018-06-28 16:17:00 +03003816requires_config_enabled MBEDTLS_AES_C
3817requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
3818requires_config_enabled MBEDTLS_SHA256_C
3819requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorb27a1ab2018-06-28 13:22:05 +03003820run_test "Force an ECC ciphersuite in the client side" \
3821 "$P_SRV debug_level=3" \
3822 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003823 0 \
Ron Eldorb27a1ab2018-06-28 13:22:05 +03003824 -c "client hello, adding supported_elliptic_curves extension" \
3825 -c "client hello, adding supported_point_formats extension" \
3826 -s "found supported elliptic curves extension" \
3827 -s "found supported point formats extension"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003828
Ron Eldor2eee2e62018-06-28 16:17:00 +03003829requires_config_enabled MBEDTLS_AES_C
3830requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
3831requires_config_enabled MBEDTLS_SHA256_C
3832requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldorb27a1ab2018-06-28 13:22:05 +03003833run_test "Force an ECC ciphersuite in the server side" \
3834 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
3835 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003836 0 \
Ron Eldorb27a1ab2018-06-28 13:22:05 +03003837 -c "found supported_point_formats extension" \
3838 -s "server hello, supported_point_formats extension"
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003839
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01003840# Tests for DTLS HelloVerifyRequest
3841
3842run_test "DTLS cookie: enabled" \
3843 "$P_SRV dtls=1 debug_level=2" \
3844 "$P_CLI dtls=1 debug_level=2" \
3845 0 \
3846 -s "cookie verification failed" \
3847 -s "cookie verification passed" \
3848 -S "cookie verification skipped" \
3849 -c "received hello verify request" \
3850 -s "hello verification requested" \
3851 -S "SSL - The requested feature is not available"
3852
3853run_test "DTLS cookie: disabled" \
3854 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3855 "$P_CLI dtls=1 debug_level=2" \
3856 0 \
3857 -S "cookie verification failed" \
3858 -S "cookie verification passed" \
3859 -s "cookie verification skipped" \
3860 -C "received hello verify request" \
3861 -S "hello verification requested" \
3862 -S "SSL - The requested feature is not available"
3863
3864run_test "DTLS cookie: default (failing)" \
3865 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3866 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3867 1 \
3868 -s "cookie verification failed" \
3869 -S "cookie verification passed" \
3870 -S "cookie verification skipped" \
3871 -C "received hello verify request" \
3872 -S "hello verification requested" \
3873 -s "SSL - The requested feature is not available"
3874
3875requires_ipv6
3876run_test "DTLS cookie: enabled, IPv6" \
3877 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3878 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3879 0 \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003880 -s "cookie verification failed" \
3881 -s "cookie verification passed" \
3882 -S "cookie verification skipped" \
3883 -c "received hello verify request" \
3884 -s "hello verification requested" \
3885 -S "SSL - The requested feature is not available"
3886
3887run_test "DTLS cookie: enabled, nbio" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003888 "$P_SRV dtls=1 nbio=2 debug_level=2" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003889 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3890 0 \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003891 -s "cookie verification failed" \
3892 -s "cookie verification passed" \
3893 -S "cookie verification skipped" \
3894 -c "received hello verify request" \
3895 -s "hello verification requested" \
3896 -S "SSL - The requested feature is not available"
3897
3898# Tests for client reconnecting from the same port with DTLS
3899
3900not_with_valgrind # spurious resend
3901run_test "DTLS client reconnect from same port: reference" \
3902 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3903 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
3904 0 \
3905 -C "resend" \
3906 -S "The operation timed out" \
3907 -S "Client initiated reconnection from same port"
3908
3909not_with_valgrind # spurious resend
3910run_test "DTLS client reconnect from same port: reconnect" \
3911 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3912 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003913 0 \
3914 -C "resend" \
3915 -S "The operation timed out" \
3916 -s "Client initiated reconnection from same port"
3917
3918not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3919run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
3920 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3921 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
3922 0 \
3923 -S "The operation timed out" \
3924 -s "Client initiated reconnection from same port"
3925
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003926only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003927run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003928 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003929 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3930 0 \
3931 -S "The operation timed out" \
3932 -s "Client initiated reconnection from same port"
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003933
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003934run_test "DTLS client reconnect from same port: no cookies" \
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003935 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
3936 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3937 0 \
3938 -s "The operation timed out" \
3939 -S "Client initiated reconnection from same port"
3940
3941# Tests for various cases of client authentication with DTLS
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003942# (focused on handshake flows and message parsing)
3943
3944run_test "DTLS client auth: required" \
3945 "$P_SRV dtls=1 auth_mode=required" \
3946 "$P_CLI dtls=1" \
3947 0 \
3948 -s "Verifying peer X.509 certificate... ok"
3949
3950run_test "DTLS client auth: optional, client has no cert" \
3951 "$P_SRV dtls=1 auth_mode=optional" \
3952 "$P_CLI dtls=1 crt_file=none key_file=none" \
3953 0 \
3954 -s "! Certificate was missing"
3955
3956run_test "DTLS client auth: none, client has no cert" \
3957 "$P_SRV dtls=1 auth_mode=none" \
3958 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3959 0 \
3960 -c "skip write certificate$" \
3961 -s "! Certificate verification was skipped"
3962
3963run_test "DTLS wrong PSK: badmac alert" \
3964 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3965 "$P_CLI dtls=1 psk=abc124" \
3966 1 \
3967 -s "SSL - Verification of the message MAC failed" \
3968 -c "SSL - A fatal alert message was received from our peer"
3969
3970# Tests for receiving fragmented handshake messages with DTLS
3971
3972requires_gnutls
3973run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3974 "$G_SRV -u --mtu 2048 -a" \
3975 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003976 0 \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003977 -C "found fragmented DTLS handshake message" \
3978 -C "error"
3979
3980requires_gnutls
3981run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3982 "$G_SRV -u --mtu 512" \
3983 "$P_CLI dtls=1 debug_level=2" \
3984 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003985 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003986 -C "error"
3987
3988requires_gnutls
3989run_test "DTLS reassembly: more fragmentation (gnutls server)" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003990 "$G_SRV -u --mtu 128" \
3991 "$P_CLI dtls=1 debug_level=2" \
3992 0 \
3993 -c "found fragmented DTLS handshake message" \
3994 -C "error"
3995
3996requires_gnutls
3997run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003998 "$G_SRV -u --mtu 128" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003999 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4000 0 \
4001 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004002 -C "error"
4003
4004requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01004005requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004006run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
4007 "$G_SRV -u --mtu 256" \
4008 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
4009 0 \
4010 -c "found fragmented DTLS handshake message" \
4011 -c "client hello, adding renegotiation extension" \
4012 -c "found renegotiation extension" \
4013 -c "=> renegotiate" \
4014 -C "mbedtls_ssl_handshake returned" \
4015 -C "error" \
4016 -s "Extra-header:"
4017
4018requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01004019requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004020run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
4021 "$G_SRV -u --mtu 256" \
4022 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
4023 0 \
4024 -c "found fragmented DTLS handshake message" \
4025 -c "client hello, adding renegotiation extension" \
4026 -c "found renegotiation extension" \
4027 -c "=> renegotiate" \
4028 -C "mbedtls_ssl_handshake returned" \
4029 -C "error" \
4030 -s "Extra-header:"
4031
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004032run_test "DTLS reassembly: no fragmentation (openssl server)" \
4033 "$O_SRV -dtls1 -mtu 2048" \
4034 "$P_CLI dtls=1 debug_level=2" \
4035 0 \
4036 -C "found fragmented DTLS handshake message" \
4037 -C "error"
4038
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004039run_test "DTLS reassembly: some fragmentation (openssl server)" \
4040 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004041 "$P_CLI dtls=1 debug_level=2" \
4042 0 \
4043 -c "found fragmented DTLS handshake message" \
4044 -C "error"
4045
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004046run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02004047 "$O_SRV -dtls1 -mtu 256" \
4048 "$P_CLI dtls=1 debug_level=2" \
4049 0 \
4050 -c "found fragmented DTLS handshake message" \
4051 -C "error"
4052
4053run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
4054 "$O_SRV -dtls1 -mtu 256" \
4055 "$P_CLI dtls=1 nbio=2 debug_level=2" \
4056 0 \
4057 -c "found fragmented DTLS handshake message" \
4058 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02004059
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004060# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004061
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004062not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004063run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02004064 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004065 "$P_SRV dtls=1 debug_level=2" \
4066 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004067 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004068 -C "replayed record" \
4069 -S "replayed record" \
4070 -C "record from another epoch" \
4071 -S "record from another epoch" \
4072 -C "discarding invalid record" \
4073 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004074 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004075 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004076 -c "HTTP/1.0 200 OK"
4077
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004078not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004079run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004080 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004081 "$P_SRV dtls=1 debug_level=2" \
4082 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02004083 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02004084 -c "replayed record" \
4085 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004086 -c "discarding invalid record" \
4087 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004088 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004089 -s "Extra-header:" \
4090 -c "HTTP/1.0 200 OK"
4091
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004092run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
4093 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004094 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
4095 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004096 0 \
4097 -c "replayed record" \
4098 -S "replayed record" \
4099 -c "discarding invalid record" \
4100 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02004101 -c "resend" \
4102 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02004103 -s "Extra-header:" \
4104 -c "HTTP/1.0 200 OK"
4105
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004106run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02004107 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004108 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004109 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004110 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004111 -c "discarding invalid record (mac)" \
4112 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004113 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004114 -c "HTTP/1.0 200 OK" \
4115 -S "too many records with bad MAC" \
4116 -S "Verification of the message MAC failed"
4117
4118run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
4119 -p "$P_PXY bad_ad=1" \
4120 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
4121 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4122 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004123 -C "discarding invalid record (mac)" \
4124 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004125 -S "Extra-header:" \
4126 -C "HTTP/1.0 200 OK" \
4127 -s "too many records with bad MAC" \
4128 -s "Verification of the message MAC failed"
4129
4130run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
4131 -p "$P_PXY bad_ad=1" \
4132 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
4133 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
4134 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004135 -c "discarding invalid record (mac)" \
4136 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004137 -s "Extra-header:" \
4138 -c "HTTP/1.0 200 OK" \
4139 -S "too many records with bad MAC" \
4140 -S "Verification of the message MAC failed"
4141
4142run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
4143 -p "$P_PXY bad_ad=1" \
4144 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
4145 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
4146 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02004147 -c "discarding invalid record (mac)" \
4148 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02004149 -s "Extra-header:" \
4150 -c "HTTP/1.0 200 OK" \
4151 -s "too many records with bad MAC" \
4152 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004153
4154run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004155 -p "$P_PXY delay_ccs=1" \
4156 "$P_SRV dtls=1 debug_level=1" \
4157 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004158 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004159 -c "record from another epoch" \
4160 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004161 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02004162 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004163 -s "Extra-header:" \
4164 -c "HTTP/1.0 200 OK"
4165
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02004166# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004167
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004168needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004169run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004170 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004171 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4172 psk=abc123" \
4173 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004174 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4175 0 \
4176 -s "Extra-header:" \
4177 -c "HTTP/1.0 200 OK"
4178
4179needs_more_time 2
4180run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
4181 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004182 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4183 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004184 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4185 0 \
4186 -s "Extra-header:" \
4187 -c "HTTP/1.0 200 OK"
4188
4189needs_more_time 2
4190run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
4191 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004192 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
4193 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004194 0 \
4195 -s "Extra-header:" \
4196 -c "HTTP/1.0 200 OK"
4197
4198needs_more_time 2
4199run_test "DTLS proxy: 3d, FS, client auth" \
4200 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004201 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4202 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004203 0 \
4204 -s "Extra-header:" \
4205 -c "HTTP/1.0 200 OK"
4206
4207needs_more_time 2
4208run_test "DTLS proxy: 3d, FS, ticket" \
4209 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004210 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4211 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004212 0 \
4213 -s "Extra-header:" \
4214 -c "HTTP/1.0 200 OK"
4215
4216needs_more_time 2
4217run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
4218 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004219 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
4220 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004221 0 \
4222 -s "Extra-header:" \
4223 -c "HTTP/1.0 200 OK"
4224
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004225needs_more_time 2
4226run_test "DTLS proxy: 3d, max handshake, nbio" \
4227 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004228 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4229 auth_mode=required" \
4230 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004231 0 \
4232 -s "Extra-header:" \
4233 -c "HTTP/1.0 200 OK"
4234
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004235needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004236run_test "DTLS proxy: 3d, min handshake, resumption" \
4237 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4238 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4239 psk=abc123 debug_level=3" \
4240 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4241 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4242 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4243 0 \
4244 -s "a session has been resumed" \
4245 -c "a session has been resumed" \
4246 -s "Extra-header:" \
4247 -c "HTTP/1.0 200 OK"
4248
4249needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004250run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4251 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4252 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4253 psk=abc123 debug_level=3 nbio=2" \
4254 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4255 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4256 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4257 0 \
4258 -s "a session has been resumed" \
4259 -c "a session has been resumed" \
4260 -s "Extra-header:" \
4261 -c "HTTP/1.0 200 OK"
4262
4263needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004264requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004265run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004266 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004267 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4268 psk=abc123 renegotiation=1 debug_level=2" \
4269 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4270 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004271 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4272 0 \
4273 -c "=> renegotiate" \
4274 -s "=> renegotiate" \
4275 -s "Extra-header:" \
4276 -c "HTTP/1.0 200 OK"
4277
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004278needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004279requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004280run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4281 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004282 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4283 psk=abc123 renegotiation=1 debug_level=2" \
4284 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4285 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004286 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4287 0 \
4288 -c "=> renegotiate" \
4289 -s "=> renegotiate" \
4290 -s "Extra-header:" \
4291 -c "HTTP/1.0 200 OK"
4292
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004293needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004294requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004295run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004296 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004297 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004298 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004299 debug_level=2" \
4300 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004301 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004302 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4303 0 \
4304 -c "=> renegotiate" \
4305 -s "=> renegotiate" \
4306 -s "Extra-header:" \
4307 -c "HTTP/1.0 200 OK"
4308
4309needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01004310requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004311run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004312 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004313 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004314 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004315 debug_level=2 nbio=2" \
4316 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004317 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004318 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4319 0 \
4320 -c "=> renegotiate" \
4321 -s "=> renegotiate" \
4322 -s "Extra-header:" \
4323 -c "HTTP/1.0 200 OK"
4324
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02004325needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004326not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004327run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004328 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4329 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004330 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004331 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004332 -c "HTTP/1.0 200 OK"
4333
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004334needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004335not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004336run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4337 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4338 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004339 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004340 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004341 -c "HTTP/1.0 200 OK"
4342
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004343needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004344not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004345run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4346 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4347 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004348 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004349 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004350 -c "HTTP/1.0 200 OK"
4351
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004352requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02004353needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004354not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004355run_test "DTLS proxy: 3d, gnutls server" \
4356 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4357 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004358 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004359 0 \
4360 -s "Extra-header:" \
4361 -c "Extra-header:"
4362
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004363requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004364needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004365not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004366run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4367 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4368 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004369 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004370 0 \
4371 -s "Extra-header:" \
4372 -c "Extra-header:"
4373
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004374requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02004375needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004376not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004377run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4378 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4379 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004380 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004381 0 \
4382 -s "Extra-header:" \
4383 -c "Extra-header:"
4384
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004385# Final report
4386
4387echo "------------------------------------------------------------------------"
4388
4389if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004390 printf "PASSED"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004391else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004392 printf "FAILED"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004393fi
4394PASSES=$(( $TESTS - $FAILS ))
4395echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
4396
4397exit $FAILS