blob: 8792b21c25f1e10d2b4355ceb23dbdc8ed473452 [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}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010020
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020021O_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 +010022O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020023G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010024G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010025
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010026TESTS=0
27FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020028SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010029
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000030CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020031
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010032MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010033FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020034EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010035
36print_usage() {
37 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010038 printf " -h|--help\tPrint this help.\n"
39 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
40 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
41 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010042}
43
44get_options() {
45 while [ $# -gt 0 ]; do
46 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010047 -f|--filter)
48 shift; FILTER=$1
49 ;;
50 -e|--exclude)
51 shift; EXCLUDE=$1
52 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010053 -m|--memcheck)
54 MEMCHECK=1
55 ;;
56 -h|--help)
57 print_usage
58 exit 0
59 ;;
60 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020061 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062 print_usage
63 exit 1
64 ;;
65 esac
66 shift
67 done
68}
69
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010070# skip next test if the flag is not enabled in config.h
71requires_config_enabled() {
72 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
73 SKIP_NEXT="YES"
74 fi
75}
76
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020077# skip next test if OpenSSL doesn't support FALLBACK_SCSV
78requires_openssl_with_fallback_scsv() {
79 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
80 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
81 then
82 OPENSSL_HAS_FBSCSV="YES"
83 else
84 OPENSSL_HAS_FBSCSV="NO"
85 fi
86 fi
87 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
88 SKIP_NEXT="YES"
89 fi
90}
91
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020092# skip next test if GnuTLS isn't available
93requires_gnutls() {
94 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +020095 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020096 GNUTLS_AVAILABLE="YES"
97 else
98 GNUTLS_AVAILABLE="NO"
99 fi
100 fi
101 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
102 SKIP_NEXT="YES"
103 fi
104}
105
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200106# skip next test if IPv6 isn't available on this host
107requires_ipv6() {
108 if [ -z "${HAS_IPV6:-}" ]; then
109 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
110 SRV_PID=$!
111 sleep 1
112 kill $SRV_PID >/dev/null 2>&1
113 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
114 HAS_IPV6="NO"
115 else
116 HAS_IPV6="YES"
117 fi
118 rm -r $SRV_OUT
119 fi
120
121 if [ "$HAS_IPV6" = "NO" ]; then
122 SKIP_NEXT="YES"
123 fi
124}
125
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200126# skip the next test if valgrind is in use
127not_with_valgrind() {
128 if [ "$MEMCHECK" -gt 0 ]; then
129 SKIP_NEXT="YES"
130 fi
131}
132
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200133# multiply the client timeout delay by the given factor for the next test
134needs_more_time() {
135 CLI_DELAY_FACTOR=$1
136}
137
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100138# print_name <name>
139print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100140 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200141 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100142 for i in `seq 1 $LEN`; do printf '.'; done
143 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100144
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200145 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100146}
147
148# fail <message>
149fail() {
150 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100151 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100152
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200153 mv $SRV_OUT o-srv-${TESTS}.log
154 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200155 if [ -n "$PXY_CMD" ]; then
156 mv $PXY_OUT o-pxy-${TESTS}.log
157 fi
158 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100159
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200160 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
161 echo " ! server output:"
162 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200163 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200164 echo " ! client output:"
165 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200166 if [ -n "$PXY_CMD" ]; then
167 echo " ! ========================================================"
168 echo " ! proxy output:"
169 cat o-pxy-${TESTS}.log
170 fi
171 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200172 fi
173
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200174 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100175}
176
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100177# is_polar <cmd_line>
178is_polar() {
179 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
180}
181
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200182# openssl s_server doesn't have -www with DTLS
183check_osrv_dtls() {
184 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
185 NEEDS_INPUT=1
186 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
187 else
188 NEEDS_INPUT=0
189 fi
190}
191
192# provide input to commands that need it
193provide_input() {
194 if [ $NEEDS_INPUT -eq 0 ]; then
195 return
196 fi
197
198 while true; do
199 echo "HTTP/1.0 200 OK"
200 sleep 1
201 done
202}
203
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100204# has_mem_err <log_file_name>
205has_mem_err() {
206 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
207 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
208 then
209 return 1 # false: does not have errors
210 else
211 return 0 # true: has errors
212 fi
213}
214
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200215# wait for server to start: two versions depending on lsof availability
216wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200217 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200218 START_TIME=$( date +%s )
219 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200220
221 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200222 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200223 while [ $DONE -eq 0 ]; do
224 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
225 then
226 DONE=1
227 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
228 echo "SERVERSTART TIMEOUT"
229 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
230 DONE=1
231 fi
232 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200233 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200234 while [ $DONE -eq 0 ]; do
235 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
236 then
237 DONE=1
238 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
239 echo "SERVERSTART TIMEOUT"
240 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
241 DONE=1
242 fi
243 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200244 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200245 else
246 sleep "$START_DELAY"
247 fi
248}
249
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200250# wait for client to terminate and set CLI_EXIT
251# must be called right after starting the client
252wait_client_done() {
253 CLI_PID=$!
254
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200255 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
256 CLI_DELAY_FACTOR=1
257
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200258 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200259 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200260
261 wait $CLI_PID
262 CLI_EXIT=$?
263
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200264 kill $DOG_PID >/dev/null 2>&1
265 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200266
267 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
268}
269
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200270# check if the given command uses dtls and sets global variable DTLS
271detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200272 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200273 DTLS=1
274 else
275 DTLS=0
276 fi
277}
278
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200279# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100280# Options: -s pattern pattern that must be present in server output
281# -c pattern pattern that must be present in client output
282# -S pattern pattern that must be absent in server output
283# -C pattern pattern that must be absent in client output
284run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100285 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200286 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100287
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100288 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
289 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200290 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100291 return
292 fi
293
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100294 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100295
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200296 # should we skip?
297 if [ "X$SKIP_NEXT" = "XYES" ]; then
298 SKIP_NEXT="NO"
299 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200300 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200301 return
302 fi
303
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200304 # does this test use a proxy?
305 if [ "X$1" = "X-p" ]; then
306 PXY_CMD="$2"
307 shift 2
308 else
309 PXY_CMD=""
310 fi
311
312 # get commands and client output
313 SRV_CMD="$1"
314 CLI_CMD="$2"
315 CLI_EXPECT="$3"
316 shift 3
317
318 # fix client port
319 if [ -n "$PXY_CMD" ]; then
320 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
321 else
322 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
323 fi
324
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200325 # update DTLS variable
326 detect_dtls "$SRV_CMD"
327
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100328 # prepend valgrind to our commands if active
329 if [ "$MEMCHECK" -gt 0 ]; then
330 if is_polar "$SRV_CMD"; then
331 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
332 fi
333 if is_polar "$CLI_CMD"; then
334 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
335 fi
336 fi
337
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200338 TIMES_LEFT=2
339 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200340 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200341
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200342 # run the commands
343 if [ -n "$PXY_CMD" ]; then
344 echo "$PXY_CMD" > $PXY_OUT
345 $PXY_CMD >> $PXY_OUT 2>&1 &
346 PXY_PID=$!
347 # assume proxy starts faster than server
348 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200349
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200350 check_osrv_dtls
351 echo "$SRV_CMD" > $SRV_OUT
352 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
353 SRV_PID=$!
354 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200355
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200356 echo "$CLI_CMD" > $CLI_OUT
357 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
358 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100359
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200360 # terminate the server (and the proxy)
361 kill $SRV_PID
362 wait $SRV_PID
363 if [ -n "$PXY_CMD" ]; then
364 kill $PXY_PID >/dev/null 2>&1
365 wait $PXY_PID
366 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100367
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200368 # retry only on timeouts
369 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
370 printf "RETRY "
371 else
372 TIMES_LEFT=0
373 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200374 done
375
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100376 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200377 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100378 # expected client exit to incorrectly succeed in case of catastrophic
379 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100380 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200381 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100382 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100383 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100384 return
385 fi
386 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100387 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200388 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100389 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100390 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100391 return
392 fi
393 fi
394
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100395 # check server exit code
396 if [ $? != 0 ]; then
397 fail "server fail"
398 return
399 fi
400
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100401 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100402 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
403 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100404 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200405 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100406 return
407 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100408
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100409 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200410 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100411 while [ $# -gt 0 ]
412 do
413 case $1 in
414 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200415 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100416 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100417 return
418 fi
419 ;;
420
421 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200422 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100423 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100424 return
425 fi
426 ;;
427
428 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200429 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100430 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100431 return
432 fi
433 ;;
434
435 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200436 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100437 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100438 return
439 fi
440 ;;
441
442 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200443 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100444 exit 1
445 esac
446 shift 2
447 done
448
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100449 # check valgrind's results
450 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200451 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100452 fail "Server has memory errors"
453 return
454 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200455 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100456 fail "Client has memory errors"
457 return
458 fi
459 fi
460
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100461 # if we're here, everything is ok
462 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200463 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100464}
465
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100466cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200467 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200468 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
469 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
470 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
471 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100472 exit 1
473}
474
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100475#
476# MAIN
477#
478
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000479if cd $( dirname $0 ); then :; else
480 echo "cd $( dirname $0 ) failed" >&2
481 exit 1
482fi
483
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100484get_options "$@"
485
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100486# sanity checks, avoid an avalanche of errors
487if [ ! -x "$P_SRV" ]; then
488 echo "Command '$P_SRV' is not an executable file"
489 exit 1
490fi
491if [ ! -x "$P_CLI" ]; then
492 echo "Command '$P_CLI' is not an executable file"
493 exit 1
494fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200495if [ ! -x "$P_PXY" ]; then
496 echo "Command '$P_PXY' is not an executable file"
497 exit 1
498fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100499if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
500 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100501 exit 1
502fi
503
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200504# used by watchdog
505MAIN_PID="$$"
506
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200507# be more patient with valgrind
508if [ "$MEMCHECK" -gt 0 ]; then
509 START_DELAY=3
510 DOG_DELAY=30
511else
512 START_DELAY=1
513 DOG_DELAY=10
514fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200515CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200516
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200517# Pick a "unique" server port in the range 10000-19999, and a proxy port
518PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000519PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200520SRV_PORT="1$PORT_BASE"
521PXY_PORT="2$PORT_BASE"
522unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200523
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200524# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000525# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200526P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
527P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
528P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200529O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200530O_CLI="$O_CLI -connect localhost:+SRV_PORT"
531G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000532G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200533
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200534# Also pick a unique name for intermediate files
535SRV_OUT="srv_out.$$"
536CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200537PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200538SESSION="session.$$"
539
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200540SKIP_NEXT="NO"
541
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100542trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100543
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200544# Basic test
545
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200546# Checks that:
547# - things work with all ciphersuites active (used with config-full in all.sh)
548# - the expected (highest security) parameters are selected
549# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200550run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200551 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200552 "$P_CLI" \
553 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200554 -s "Protocol is TLSv1.2" \
555 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
556 -s "client hello v3, signature_algorithm ext: 6" \
557 -s "ECDHE curve: secp521r1" \
558 -S "error" \
559 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200560
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000561run_test "Default, DTLS" \
562 "$P_SRV dtls=1" \
563 "$P_CLI dtls=1" \
564 0 \
565 -s "Protocol is DTLSv1.2" \
566 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
567
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100568# Tests for rc4 option
569
570run_test "RC4: server disabled, client enabled" \
571 "$P_SRV" \
572 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
573 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100574 -s "SSL - The server has no ciphersuites in common"
575
576run_test "RC4: server half, client enabled" \
577 "$P_SRV arc4=1" \
578 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
579 1 \
580 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100581
582run_test "RC4: server enabled, client disabled" \
583 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
584 "$P_CLI" \
585 1 \
586 -s "SSL - The server has no ciphersuites in common"
587
588run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100589 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100590 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
591 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100592 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100593 -S "SSL - The server has no ciphersuites in common"
594
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100595# Tests for Truncated HMAC extension
596
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100597run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200598 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100599 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100600 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100601 -s "dumping 'computed mac' (20 bytes)" \
602 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100603
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100604run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200605 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100606 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
607 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100608 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100609 -s "dumping 'computed mac' (20 bytes)" \
610 -S "dumping 'computed mac' (10 bytes)"
611
612run_test "Truncated HMAC: client enabled, server default" \
613 "$P_SRV debug_level=4" \
614 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
615 trunc_hmac=1" \
616 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100617 -s "dumping 'computed mac' (20 bytes)" \
618 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100619
620run_test "Truncated HMAC: client enabled, server disabled" \
621 "$P_SRV debug_level=4 trunc_hmac=0" \
622 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
623 trunc_hmac=1" \
624 0 \
625 -s "dumping 'computed mac' (20 bytes)" \
626 -S "dumping 'computed mac' (10 bytes)"
627
628run_test "Truncated HMAC: client enabled, server enabled" \
629 "$P_SRV debug_level=4 trunc_hmac=1" \
630 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
631 trunc_hmac=1" \
632 0 \
633 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100634 -s "dumping 'computed mac' (10 bytes)"
635
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100636# Tests for Encrypt-then-MAC extension
637
638run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100639 "$P_SRV debug_level=3 \
640 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100641 "$P_CLI debug_level=3" \
642 0 \
643 -c "client hello, adding encrypt_then_mac extension" \
644 -s "found encrypt then mac extension" \
645 -s "server hello, adding encrypt then mac extension" \
646 -c "found encrypt_then_mac extension" \
647 -c "using encrypt then mac" \
648 -s "using encrypt then mac"
649
650run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100651 "$P_SRV debug_level=3 etm=0 \
652 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100653 "$P_CLI debug_level=3 etm=1" \
654 0 \
655 -c "client hello, adding encrypt_then_mac extension" \
656 -s "found encrypt then mac extension" \
657 -S "server hello, adding encrypt then mac extension" \
658 -C "found encrypt_then_mac extension" \
659 -C "using encrypt then mac" \
660 -S "using encrypt then mac"
661
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100662run_test "Encrypt then MAC: client enabled, aead cipher" \
663 "$P_SRV debug_level=3 etm=1 \
664 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
665 "$P_CLI debug_level=3 etm=1" \
666 0 \
667 -c "client hello, adding encrypt_then_mac extension" \
668 -s "found encrypt then mac extension" \
669 -S "server hello, adding encrypt then mac extension" \
670 -C "found encrypt_then_mac extension" \
671 -C "using encrypt then mac" \
672 -S "using encrypt then mac"
673
674run_test "Encrypt then MAC: client enabled, stream cipher" \
675 "$P_SRV debug_level=3 etm=1 \
676 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100677 "$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 +0100678 0 \
679 -c "client hello, adding encrypt_then_mac extension" \
680 -s "found encrypt then mac extension" \
681 -S "server hello, adding encrypt then mac extension" \
682 -C "found encrypt_then_mac extension" \
683 -C "using encrypt then mac" \
684 -S "using encrypt then mac"
685
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100686run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100687 "$P_SRV debug_level=3 etm=1 \
688 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100689 "$P_CLI debug_level=3 etm=0" \
690 0 \
691 -C "client hello, adding encrypt_then_mac extension" \
692 -S "found encrypt then mac extension" \
693 -S "server hello, adding encrypt then mac extension" \
694 -C "found encrypt_then_mac extension" \
695 -C "using encrypt then mac" \
696 -S "using encrypt then mac"
697
Janos Follathe2681a42016-03-07 15:57:05 +0000698requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100699run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100700 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100701 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100702 "$P_CLI debug_level=3 force_version=ssl3" \
703 0 \
704 -C "client hello, adding encrypt_then_mac extension" \
705 -S "found encrypt then mac extension" \
706 -S "server hello, adding encrypt then mac extension" \
707 -C "found encrypt_then_mac extension" \
708 -C "using encrypt then mac" \
709 -S "using encrypt then mac"
710
Janos Follathe2681a42016-03-07 15:57:05 +0000711requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100712run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100713 "$P_SRV debug_level=3 force_version=ssl3 \
714 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100715 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100716 0 \
717 -c "client hello, adding encrypt_then_mac extension" \
718 -s "found encrypt then mac extension" \
719 -S "server hello, adding encrypt then mac extension" \
720 -C "found encrypt_then_mac extension" \
721 -C "using encrypt then mac" \
722 -S "using encrypt then mac"
723
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200724# Tests for Extended Master Secret extension
725
726run_test "Extended Master Secret: default" \
727 "$P_SRV debug_level=3" \
728 "$P_CLI debug_level=3" \
729 0 \
730 -c "client hello, adding extended_master_secret extension" \
731 -s "found extended master secret extension" \
732 -s "server hello, adding extended master secret extension" \
733 -c "found extended_master_secret extension" \
734 -c "using extended master secret" \
735 -s "using extended master secret"
736
737run_test "Extended Master Secret: client enabled, server disabled" \
738 "$P_SRV debug_level=3 extended_ms=0" \
739 "$P_CLI debug_level=3 extended_ms=1" \
740 0 \
741 -c "client hello, adding extended_master_secret extension" \
742 -s "found extended master secret extension" \
743 -S "server hello, adding extended master secret extension" \
744 -C "found extended_master_secret extension" \
745 -C "using extended master secret" \
746 -S "using extended master secret"
747
748run_test "Extended Master Secret: client disabled, server enabled" \
749 "$P_SRV debug_level=3 extended_ms=1" \
750 "$P_CLI debug_level=3 extended_ms=0" \
751 0 \
752 -C "client hello, adding extended_master_secret extension" \
753 -S "found extended master secret extension" \
754 -S "server hello, adding extended master secret extension" \
755 -C "found extended_master_secret extension" \
756 -C "using extended master secret" \
757 -S "using extended master secret"
758
Janos Follathe2681a42016-03-07 15:57:05 +0000759requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200760run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100761 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200762 "$P_CLI debug_level=3 force_version=ssl3" \
763 0 \
764 -C "client hello, adding extended_master_secret extension" \
765 -S "found extended master secret extension" \
766 -S "server hello, adding extended master secret extension" \
767 -C "found extended_master_secret extension" \
768 -C "using extended master secret" \
769 -S "using extended master secret"
770
Janos Follathe2681a42016-03-07 15:57:05 +0000771requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200772run_test "Extended Master Secret: client enabled, server SSLv3" \
773 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100774 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200775 0 \
776 -c "client hello, adding extended_master_secret extension" \
777 -s "found extended master secret extension" \
778 -S "server hello, adding extended master secret extension" \
779 -C "found extended_master_secret extension" \
780 -C "using extended master secret" \
781 -S "using extended master secret"
782
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200783# Tests for FALLBACK_SCSV
784
785run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200786 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200787 "$P_CLI debug_level=3 force_version=tls1_1" \
788 0 \
789 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200790 -S "received FALLBACK_SCSV" \
791 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200792 -C "is a fatal alert message (msg 86)"
793
794run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200795 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200796 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
797 0 \
798 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200799 -S "received FALLBACK_SCSV" \
800 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200801 -C "is a fatal alert message (msg 86)"
802
803run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200804 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200805 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200806 1 \
807 -c "adding FALLBACK_SCSV" \
808 -s "received FALLBACK_SCSV" \
809 -s "inapropriate fallback" \
810 -c "is a fatal alert message (msg 86)"
811
812run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200813 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200814 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200815 0 \
816 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200817 -s "received FALLBACK_SCSV" \
818 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200819 -C "is a fatal alert message (msg 86)"
820
821requires_openssl_with_fallback_scsv
822run_test "Fallback SCSV: default, openssl server" \
823 "$O_SRV" \
824 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
825 0 \
826 -C "adding FALLBACK_SCSV" \
827 -C "is a fatal alert message (msg 86)"
828
829requires_openssl_with_fallback_scsv
830run_test "Fallback SCSV: enabled, openssl server" \
831 "$O_SRV" \
832 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
833 1 \
834 -c "adding FALLBACK_SCSV" \
835 -c "is a fatal alert message (msg 86)"
836
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200837requires_openssl_with_fallback_scsv
838run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200839 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200840 "$O_CLI -tls1_1" \
841 0 \
842 -S "received FALLBACK_SCSV" \
843 -S "inapropriate fallback"
844
845requires_openssl_with_fallback_scsv
846run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200847 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200848 "$O_CLI -tls1_1 -fallback_scsv" \
849 1 \
850 -s "received FALLBACK_SCSV" \
851 -s "inapropriate fallback"
852
853requires_openssl_with_fallback_scsv
854run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200855 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200856 "$O_CLI -fallback_scsv" \
857 0 \
858 -s "received FALLBACK_SCSV" \
859 -S "inapropriate fallback"
860
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100861# Tests for CBC 1/n-1 record splitting
862
863run_test "CBC Record splitting: TLS 1.2, no splitting" \
864 "$P_SRV" \
865 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
866 request_size=123 force_version=tls1_2" \
867 0 \
868 -s "Read from client: 123 bytes read" \
869 -S "Read from client: 1 bytes read" \
870 -S "122 bytes read"
871
872run_test "CBC Record splitting: TLS 1.1, no splitting" \
873 "$P_SRV" \
874 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
875 request_size=123 force_version=tls1_1" \
876 0 \
877 -s "Read from client: 123 bytes read" \
878 -S "Read from client: 1 bytes read" \
879 -S "122 bytes read"
880
881run_test "CBC Record splitting: TLS 1.0, splitting" \
882 "$P_SRV" \
883 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
884 request_size=123 force_version=tls1" \
885 0 \
886 -S "Read from client: 123 bytes read" \
887 -s "Read from client: 1 bytes read" \
888 -s "122 bytes read"
889
Janos Follathe2681a42016-03-07 15:57:05 +0000890requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100891run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100892 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100893 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
894 request_size=123 force_version=ssl3" \
895 0 \
896 -S "Read from client: 123 bytes read" \
897 -s "Read from client: 1 bytes read" \
898 -s "122 bytes read"
899
900run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100901 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100902 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
903 request_size=123 force_version=tls1" \
904 0 \
905 -s "Read from client: 123 bytes read" \
906 -S "Read from client: 1 bytes read" \
907 -S "122 bytes read"
908
909run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
910 "$P_SRV" \
911 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
912 request_size=123 force_version=tls1 recsplit=0" \
913 0 \
914 -s "Read from client: 123 bytes read" \
915 -S "Read from client: 1 bytes read" \
916 -S "122 bytes read"
917
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100918run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
919 "$P_SRV nbio=2" \
920 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
921 request_size=123 force_version=tls1" \
922 0 \
923 -S "Read from client: 123 bytes read" \
924 -s "Read from client: 1 bytes read" \
925 -s "122 bytes read"
926
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100927# Tests for Session Tickets
928
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200929run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200930 "$P_SRV debug_level=3 tickets=1" \
931 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100932 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100933 -c "client hello, adding session ticket extension" \
934 -s "found session ticket extension" \
935 -s "server hello, adding session ticket extension" \
936 -c "found session_ticket extension" \
937 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100938 -S "session successfully restored from cache" \
939 -s "session successfully restored from ticket" \
940 -s "a session has been resumed" \
941 -c "a session has been resumed"
942
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200943run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200944 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
945 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100946 0 \
947 -c "client hello, adding session ticket extension" \
948 -s "found session ticket extension" \
949 -s "server hello, adding session ticket extension" \
950 -c "found session_ticket extension" \
951 -c "parse new session ticket" \
952 -S "session successfully restored from cache" \
953 -s "session successfully restored from ticket" \
954 -s "a session has been resumed" \
955 -c "a session has been resumed"
956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200957run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200958 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
959 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100960 0 \
961 -c "client hello, adding session ticket extension" \
962 -s "found session ticket extension" \
963 -s "server hello, adding session ticket extension" \
964 -c "found session_ticket extension" \
965 -c "parse new session ticket" \
966 -S "session successfully restored from cache" \
967 -S "session successfully restored from ticket" \
968 -S "a session has been resumed" \
969 -C "a session has been resumed"
970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200971run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100972 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200973 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100974 0 \
975 -c "client hello, adding session ticket extension" \
976 -c "found session_ticket extension" \
977 -c "parse new session ticket" \
978 -c "a session has been resumed"
979
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200980run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200981 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200982 "( $O_CLI -sess_out $SESSION; \
983 $O_CLI -sess_in $SESSION; \
984 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100985 0 \
986 -s "found session ticket extension" \
987 -s "server hello, adding session ticket extension" \
988 -S "session successfully restored from cache" \
989 -s "session successfully restored from ticket" \
990 -s "a session has been resumed"
991
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100992# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200994run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200995 "$P_SRV debug_level=3 tickets=0" \
996 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100997 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100998 -c "client hello, adding session ticket extension" \
999 -s "found session ticket extension" \
1000 -S "server hello, adding session ticket extension" \
1001 -C "found session_ticket extension" \
1002 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001003 -s "session successfully restored from cache" \
1004 -S "session successfully restored from ticket" \
1005 -s "a session has been resumed" \
1006 -c "a session has been resumed"
1007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001008run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001009 "$P_SRV debug_level=3 tickets=1" \
1010 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001011 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001012 -C "client hello, adding session ticket extension" \
1013 -S "found session ticket extension" \
1014 -S "server hello, adding session ticket extension" \
1015 -C "found session_ticket extension" \
1016 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001017 -s "session successfully restored from cache" \
1018 -S "session successfully restored from ticket" \
1019 -s "a session has been resumed" \
1020 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001021
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001022run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001023 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1024 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001025 0 \
1026 -S "session successfully restored from cache" \
1027 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001028 -S "a session has been resumed" \
1029 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001030
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001031run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001032 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1033 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001034 0 \
1035 -s "session successfully restored from cache" \
1036 -S "session successfully restored from ticket" \
1037 -s "a session has been resumed" \
1038 -c "a session has been resumed"
1039
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001040run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001041 "$P_SRV debug_level=3 tickets=0" \
1042 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001043 0 \
1044 -s "session successfully restored from cache" \
1045 -S "session successfully restored from ticket" \
1046 -s "a session has been resumed" \
1047 -c "a session has been resumed"
1048
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001049run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001050 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1051 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001052 0 \
1053 -S "session successfully restored from cache" \
1054 -S "session successfully restored from ticket" \
1055 -S "a session has been resumed" \
1056 -C "a session has been resumed"
1057
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001058run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001059 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1060 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001061 0 \
1062 -s "session successfully restored from cache" \
1063 -S "session successfully restored from ticket" \
1064 -s "a session has been resumed" \
1065 -c "a session has been resumed"
1066
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001067run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001068 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001069 "( $O_CLI -sess_out $SESSION; \
1070 $O_CLI -sess_in $SESSION; \
1071 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001072 0 \
1073 -s "found session ticket extension" \
1074 -S "server hello, adding session ticket extension" \
1075 -s "session successfully restored from cache" \
1076 -S "session successfully restored from ticket" \
1077 -s "a session has been resumed"
1078
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001079run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001080 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001081 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001082 0 \
1083 -C "found session_ticket extension" \
1084 -C "parse new session ticket" \
1085 -c "a session has been resumed"
1086
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001087# Tests for Max Fragment Length extension
1088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001089run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001090 "$P_SRV debug_level=3" \
1091 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001092 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001093 -c "Maximum fragment length is 16384" \
1094 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001095 -C "client hello, adding max_fragment_length extension" \
1096 -S "found max fragment length extension" \
1097 -S "server hello, max_fragment_length extension" \
1098 -C "found max_fragment_length extension"
1099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001100run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001101 "$P_SRV debug_level=3" \
1102 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001103 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001104 -c "Maximum fragment length is 4096" \
1105 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001106 -c "client hello, adding max_fragment_length extension" \
1107 -s "found max fragment length extension" \
1108 -s "server hello, max_fragment_length extension" \
1109 -c "found max_fragment_length extension"
1110
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001111run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001112 "$P_SRV debug_level=3 max_frag_len=4096" \
1113 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001114 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001115 -c "Maximum fragment length is 16384" \
1116 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001117 -C "client hello, adding max_fragment_length extension" \
1118 -S "found max fragment length extension" \
1119 -S "server hello, max_fragment_length extension" \
1120 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001122requires_gnutls
1123run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001124 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001125 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001126 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001127 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001128 -c "client hello, adding max_fragment_length extension" \
1129 -c "found max_fragment_length extension"
1130
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001131run_test "Max fragment length: client, message just fits" \
1132 "$P_SRV debug_level=3" \
1133 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1134 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001135 -c "Maximum fragment length is 2048" \
1136 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001137 -c "client hello, adding max_fragment_length extension" \
1138 -s "found max fragment length extension" \
1139 -s "server hello, max_fragment_length extension" \
1140 -c "found max_fragment_length extension" \
1141 -c "2048 bytes written in 1 fragments" \
1142 -s "2048 bytes read"
1143
1144run_test "Max fragment length: client, larger message" \
1145 "$P_SRV debug_level=3" \
1146 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1147 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001148 -c "Maximum fragment length is 2048" \
1149 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001150 -c "client hello, adding max_fragment_length extension" \
1151 -s "found max fragment length extension" \
1152 -s "server hello, max_fragment_length extension" \
1153 -c "found max_fragment_length extension" \
1154 -c "2345 bytes written in 2 fragments" \
1155 -s "2048 bytes read" \
1156 -s "297 bytes read"
1157
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001158run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001159 "$P_SRV debug_level=3 dtls=1" \
1160 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1161 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001162 -c "Maximum fragment length is 2048" \
1163 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001164 -c "client hello, adding max_fragment_length extension" \
1165 -s "found max fragment length extension" \
1166 -s "server hello, max_fragment_length extension" \
1167 -c "found max_fragment_length extension" \
1168 -c "fragment larger than.*maximum"
1169
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001170# Tests for renegotiation
1171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001172run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001173 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001174 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001175 0 \
1176 -C "client hello, adding renegotiation extension" \
1177 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1178 -S "found renegotiation extension" \
1179 -s "server hello, secure renegotiation extension" \
1180 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001181 -C "=> renegotiate" \
1182 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001183 -S "write hello request"
1184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001185run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001186 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001187 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001188 0 \
1189 -c "client hello, adding renegotiation extension" \
1190 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1191 -s "found renegotiation extension" \
1192 -s "server hello, secure renegotiation extension" \
1193 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001194 -c "=> renegotiate" \
1195 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001196 -S "write hello request"
1197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001198run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001199 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001200 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001201 0 \
1202 -c "client hello, adding renegotiation extension" \
1203 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1204 -s "found renegotiation extension" \
1205 -s "server hello, secure renegotiation extension" \
1206 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001207 -c "=> renegotiate" \
1208 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001209 -s "write hello request"
1210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001211run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001212 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001213 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001214 0 \
1215 -c "client hello, adding renegotiation extension" \
1216 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1217 -s "found renegotiation extension" \
1218 -s "server hello, secure renegotiation extension" \
1219 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001220 -c "=> renegotiate" \
1221 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001222 -s "write hello request"
1223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001224run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001225 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001226 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001227 1 \
1228 -c "client hello, adding renegotiation extension" \
1229 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1230 -S "found renegotiation extension" \
1231 -s "server hello, secure renegotiation extension" \
1232 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001233 -c "=> renegotiate" \
1234 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001235 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001236 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001237 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001238
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001239run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001240 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001241 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001242 0 \
1243 -C "client hello, adding renegotiation extension" \
1244 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1245 -S "found renegotiation extension" \
1246 -s "server hello, secure renegotiation extension" \
1247 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001248 -C "=> renegotiate" \
1249 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001250 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001251 -S "SSL - An unexpected message was received from our peer" \
1252 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001253
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001254run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001255 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001256 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001258 0 \
1259 -C "client hello, adding renegotiation extension" \
1260 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1261 -S "found renegotiation extension" \
1262 -s "server hello, secure renegotiation extension" \
1263 -c "found renegotiation extension" \
1264 -C "=> renegotiate" \
1265 -S "=> renegotiate" \
1266 -s "write hello request" \
1267 -S "SSL - An unexpected message was received from our peer" \
1268 -S "failed"
1269
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001270# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001271run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001272 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001273 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001274 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001275 0 \
1276 -C "client hello, adding renegotiation extension" \
1277 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1278 -S "found renegotiation extension" \
1279 -s "server hello, secure renegotiation extension" \
1280 -c "found renegotiation extension" \
1281 -C "=> renegotiate" \
1282 -S "=> renegotiate" \
1283 -s "write hello request" \
1284 -S "SSL - An unexpected message was received from our peer" \
1285 -S "failed"
1286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001287run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001288 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001289 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001290 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001291 0 \
1292 -C "client hello, adding renegotiation extension" \
1293 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1294 -S "found renegotiation extension" \
1295 -s "server hello, secure renegotiation extension" \
1296 -c "found renegotiation extension" \
1297 -C "=> renegotiate" \
1298 -S "=> renegotiate" \
1299 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001300 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001302run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001303 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001304 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001305 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001306 0 \
1307 -c "client hello, adding renegotiation extension" \
1308 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1309 -s "found renegotiation extension" \
1310 -s "server hello, secure renegotiation extension" \
1311 -c "found renegotiation extension" \
1312 -c "=> renegotiate" \
1313 -s "=> renegotiate" \
1314 -s "write hello request" \
1315 -S "SSL - An unexpected message was received from our peer" \
1316 -S "failed"
1317
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001318run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001319 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001320 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1321 0 \
1322 -C "client hello, adding renegotiation extension" \
1323 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1324 -S "found renegotiation extension" \
1325 -s "server hello, secure renegotiation extension" \
1326 -c "found renegotiation extension" \
1327 -S "record counter limit reached: renegotiate" \
1328 -C "=> renegotiate" \
1329 -S "=> renegotiate" \
1330 -S "write hello request" \
1331 -S "SSL - An unexpected message was received from our peer" \
1332 -S "failed"
1333
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001334# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001335run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001336 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001337 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001338 0 \
1339 -c "client hello, adding renegotiation extension" \
1340 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1341 -s "found renegotiation extension" \
1342 -s "server hello, secure renegotiation extension" \
1343 -c "found renegotiation extension" \
1344 -s "record counter limit reached: renegotiate" \
1345 -c "=> renegotiate" \
1346 -s "=> renegotiate" \
1347 -s "write hello request" \
1348 -S "SSL - An unexpected message was received from our peer" \
1349 -S "failed"
1350
1351run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001352 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001353 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001354 0 \
1355 -c "client hello, adding renegotiation extension" \
1356 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1357 -s "found renegotiation extension" \
1358 -s "server hello, secure renegotiation extension" \
1359 -c "found renegotiation extension" \
1360 -s "record counter limit reached: renegotiate" \
1361 -c "=> renegotiate" \
1362 -s "=> renegotiate" \
1363 -s "write hello request" \
1364 -S "SSL - An unexpected message was received from our peer" \
1365 -S "failed"
1366
1367run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001368 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001369 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1370 0 \
1371 -C "client hello, adding renegotiation extension" \
1372 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1373 -S "found renegotiation extension" \
1374 -s "server hello, secure renegotiation extension" \
1375 -c "found renegotiation extension" \
1376 -S "record counter limit reached: renegotiate" \
1377 -C "=> renegotiate" \
1378 -S "=> renegotiate" \
1379 -S "write hello request" \
1380 -S "SSL - An unexpected message was received from our peer" \
1381 -S "failed"
1382
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001383run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001384 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001385 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001386 0 \
1387 -c "client hello, adding renegotiation extension" \
1388 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1389 -s "found renegotiation extension" \
1390 -s "server hello, secure renegotiation extension" \
1391 -c "found renegotiation extension" \
1392 -c "=> renegotiate" \
1393 -s "=> renegotiate" \
1394 -S "write hello request"
1395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001396run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001397 "$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 +02001398 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001399 0 \
1400 -c "client hello, adding renegotiation extension" \
1401 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1402 -s "found renegotiation extension" \
1403 -s "server hello, secure renegotiation extension" \
1404 -c "found renegotiation extension" \
1405 -c "=> renegotiate" \
1406 -s "=> renegotiate" \
1407 -s "write hello request"
1408
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001409run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001410 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001411 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001412 0 \
1413 -c "client hello, adding renegotiation extension" \
1414 -c "found renegotiation extension" \
1415 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001416 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001417 -C "error" \
1418 -c "HTTP/1.0 200 [Oo][Kk]"
1419
Paul Bakker539d9722015-02-08 16:18:35 +01001420requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001421run_test "Renegotiation: gnutls server strict, client-initiated" \
1422 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001423 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001424 0 \
1425 -c "client hello, adding renegotiation extension" \
1426 -c "found renegotiation extension" \
1427 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001428 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001429 -C "error" \
1430 -c "HTTP/1.0 200 [Oo][Kk]"
1431
Paul Bakker539d9722015-02-08 16:18:35 +01001432requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001433run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1434 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1435 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1436 1 \
1437 -c "client hello, adding renegotiation extension" \
1438 -C "found renegotiation extension" \
1439 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001440 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001441 -c "error" \
1442 -C "HTTP/1.0 200 [Oo][Kk]"
1443
Paul Bakker539d9722015-02-08 16:18:35 +01001444requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001445run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1446 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1447 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1448 allow_legacy=0" \
1449 1 \
1450 -c "client hello, adding renegotiation extension" \
1451 -C "found renegotiation extension" \
1452 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001453 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001454 -c "error" \
1455 -C "HTTP/1.0 200 [Oo][Kk]"
1456
Paul Bakker539d9722015-02-08 16:18:35 +01001457requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001458run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1459 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1460 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1461 allow_legacy=1" \
1462 0 \
1463 -c "client hello, adding renegotiation extension" \
1464 -C "found renegotiation extension" \
1465 -c "=> renegotiate" \
1466 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001467 -C "error" \
1468 -c "HTTP/1.0 200 [Oo][Kk]"
1469
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001470run_test "Renegotiation: DTLS, client-initiated" \
1471 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1472 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1473 0 \
1474 -c "client hello, adding renegotiation extension" \
1475 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1476 -s "found renegotiation extension" \
1477 -s "server hello, secure renegotiation extension" \
1478 -c "found renegotiation extension" \
1479 -c "=> renegotiate" \
1480 -s "=> renegotiate" \
1481 -S "write hello request"
1482
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001483run_test "Renegotiation: DTLS, server-initiated" \
1484 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001485 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1486 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001487 0 \
1488 -c "client hello, adding renegotiation extension" \
1489 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1490 -s "found renegotiation extension" \
1491 -s "server hello, secure renegotiation extension" \
1492 -c "found renegotiation extension" \
1493 -c "=> renegotiate" \
1494 -s "=> renegotiate" \
1495 -s "write hello request"
1496
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001497requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001498run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1499 "$G_SRV -u --mtu 4096" \
1500 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1501 0 \
1502 -c "client hello, adding renegotiation extension" \
1503 -c "found renegotiation extension" \
1504 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001505 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001506 -C "error" \
1507 -s "Extra-header:"
1508
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001509# Test for the "secure renegotation" extension only (no actual renegotiation)
1510
Paul Bakker539d9722015-02-08 16:18:35 +01001511requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001512run_test "Renego ext: gnutls server strict, client default" \
1513 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1514 "$P_CLI debug_level=3" \
1515 0 \
1516 -c "found renegotiation extension" \
1517 -C "error" \
1518 -c "HTTP/1.0 200 [Oo][Kk]"
1519
Paul Bakker539d9722015-02-08 16:18:35 +01001520requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001521run_test "Renego ext: gnutls server unsafe, client default" \
1522 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1523 "$P_CLI debug_level=3" \
1524 0 \
1525 -C "found renegotiation extension" \
1526 -C "error" \
1527 -c "HTTP/1.0 200 [Oo][Kk]"
1528
Paul Bakker539d9722015-02-08 16:18:35 +01001529requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001530run_test "Renego ext: gnutls server unsafe, client break legacy" \
1531 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1532 "$P_CLI debug_level=3 allow_legacy=-1" \
1533 1 \
1534 -C "found renegotiation extension" \
1535 -c "error" \
1536 -C "HTTP/1.0 200 [Oo][Kk]"
1537
Paul Bakker539d9722015-02-08 16:18:35 +01001538requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001539run_test "Renego ext: gnutls client strict, server default" \
1540 "$P_SRV debug_level=3" \
1541 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1542 0 \
1543 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1544 -s "server hello, secure renegotiation extension"
1545
Paul Bakker539d9722015-02-08 16:18:35 +01001546requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001547run_test "Renego ext: gnutls client unsafe, server default" \
1548 "$P_SRV debug_level=3" \
1549 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1550 0 \
1551 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1552 -S "server hello, secure renegotiation extension"
1553
Paul Bakker539d9722015-02-08 16:18:35 +01001554requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001555run_test "Renego ext: gnutls client unsafe, server break legacy" \
1556 "$P_SRV debug_level=3 allow_legacy=-1" \
1557 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1558 1 \
1559 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1560 -S "server hello, secure renegotiation extension"
1561
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001562# Tests for auth_mode
1563
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001564run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001565 "$P_SRV crt_file=data_files/server5-badsign.crt \
1566 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001567 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001568 1 \
1569 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001570 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001571 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001572 -c "X509 - Certificate verification failed"
1573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001574run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001575 "$P_SRV crt_file=data_files/server5-badsign.crt \
1576 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001577 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001578 0 \
1579 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001580 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001581 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001582 -C "X509 - Certificate verification failed"
1583
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001584run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001585 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001586 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001587 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001588 0 \
1589 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001590 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001591 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001592 -C "X509 - Certificate verification failed"
1593
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001594run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001595 "$P_SRV debug_level=3 auth_mode=required" \
1596 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001597 key_file=data_files/server5.key" \
1598 1 \
1599 -S "skip write certificate request" \
1600 -C "skip parse certificate request" \
1601 -c "got a certificate request" \
1602 -C "skip write certificate" \
1603 -C "skip write certificate verify" \
1604 -S "skip parse certificate verify" \
1605 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001606 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001607 -s "! mbedtls_ssl_handshake returned" \
1608 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001609 -s "X509 - Certificate verification failed"
1610
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001611run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001612 "$P_SRV debug_level=3 auth_mode=optional" \
1613 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001614 key_file=data_files/server5.key" \
1615 0 \
1616 -S "skip write certificate request" \
1617 -C "skip parse certificate request" \
1618 -c "got a certificate request" \
1619 -C "skip write certificate" \
1620 -C "skip write certificate verify" \
1621 -S "skip parse certificate verify" \
1622 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001623 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001624 -S "! mbedtls_ssl_handshake returned" \
1625 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001626 -S "X509 - Certificate verification failed"
1627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001628run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001629 "$P_SRV debug_level=3 auth_mode=none" \
1630 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001631 key_file=data_files/server5.key" \
1632 0 \
1633 -s "skip write certificate request" \
1634 -C "skip parse certificate request" \
1635 -c "got no certificate request" \
1636 -c "skip write certificate" \
1637 -c "skip write certificate verify" \
1638 -s "skip parse certificate verify" \
1639 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001640 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001641 -S "! mbedtls_ssl_handshake returned" \
1642 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001643 -S "X509 - Certificate verification failed"
1644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001645run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001646 "$P_SRV debug_level=3 auth_mode=optional" \
1647 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001648 0 \
1649 -S "skip write certificate request" \
1650 -C "skip parse certificate request" \
1651 -c "got a certificate request" \
1652 -C "skip write certificate$" \
1653 -C "got no certificate to send" \
1654 -S "SSLv3 client has no certificate" \
1655 -c "skip write certificate verify" \
1656 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001657 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001658 -S "! mbedtls_ssl_handshake returned" \
1659 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001660 -S "X509 - Certificate verification failed"
1661
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001662run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001663 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001664 "$O_CLI" \
1665 0 \
1666 -S "skip write certificate request" \
1667 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001668 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001669 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001670 -S "X509 - Certificate verification failed"
1671
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001672run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001673 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001674 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001675 0 \
1676 -C "skip parse certificate request" \
1677 -c "got a certificate request" \
1678 -C "skip write certificate$" \
1679 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001680 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001681
Janos Follathe2681a42016-03-07 15:57:05 +00001682requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001683run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001684 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001685 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001686 0 \
1687 -S "skip write certificate request" \
1688 -C "skip parse certificate request" \
1689 -c "got a certificate request" \
1690 -C "skip write certificate$" \
1691 -c "skip write certificate verify" \
1692 -c "got no certificate to send" \
1693 -s "SSLv3 client has no certificate" \
1694 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001695 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001696 -S "! mbedtls_ssl_handshake returned" \
1697 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001698 -S "X509 - Certificate verification failed"
1699
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001700# Tests for certificate selection based on SHA verson
1701
1702run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1703 "$P_SRV crt_file=data_files/server5.crt \
1704 key_file=data_files/server5.key \
1705 crt_file2=data_files/server5-sha1.crt \
1706 key_file2=data_files/server5.key" \
1707 "$P_CLI force_version=tls1_2" \
1708 0 \
1709 -c "signed using.*ECDSA with SHA256" \
1710 -C "signed using.*ECDSA with SHA1"
1711
1712run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1713 "$P_SRV crt_file=data_files/server5.crt \
1714 key_file=data_files/server5.key \
1715 crt_file2=data_files/server5-sha1.crt \
1716 key_file2=data_files/server5.key" \
1717 "$P_CLI force_version=tls1_1" \
1718 0 \
1719 -C "signed using.*ECDSA with SHA256" \
1720 -c "signed using.*ECDSA with SHA1"
1721
1722run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1723 "$P_SRV crt_file=data_files/server5.crt \
1724 key_file=data_files/server5.key \
1725 crt_file2=data_files/server5-sha1.crt \
1726 key_file2=data_files/server5.key" \
1727 "$P_CLI force_version=tls1" \
1728 0 \
1729 -C "signed using.*ECDSA with SHA256" \
1730 -c "signed using.*ECDSA with SHA1"
1731
1732run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1733 "$P_SRV crt_file=data_files/server5.crt \
1734 key_file=data_files/server5.key \
1735 crt_file2=data_files/server6.crt \
1736 key_file2=data_files/server6.key" \
1737 "$P_CLI force_version=tls1_1" \
1738 0 \
1739 -c "serial number.*09" \
1740 -c "signed using.*ECDSA with SHA256" \
1741 -C "signed using.*ECDSA with SHA1"
1742
1743run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1744 "$P_SRV crt_file=data_files/server6.crt \
1745 key_file=data_files/server6.key \
1746 crt_file2=data_files/server5.crt \
1747 key_file2=data_files/server5.key" \
1748 "$P_CLI force_version=tls1_1" \
1749 0 \
1750 -c "serial number.*0A" \
1751 -c "signed using.*ECDSA with SHA256" \
1752 -C "signed using.*ECDSA with SHA1"
1753
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001754# tests for SNI
1755
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001756run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001757 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001758 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001759 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001760 0 \
1761 -S "parse ServerName extension" \
1762 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1763 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001764
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001765run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001766 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001767 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001768 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 +02001769 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001770 0 \
1771 -s "parse ServerName extension" \
1772 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1773 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001775run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001776 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001777 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001778 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 +02001779 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001780 0 \
1781 -s "parse ServerName extension" \
1782 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1783 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001784
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001785run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001786 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001787 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001788 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 +02001789 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001790 1 \
1791 -s "parse ServerName extension" \
1792 -s "ssl_sni_wrapper() returned" \
1793 -s "mbedtls_ssl_handshake returned" \
1794 -c "mbedtls_ssl_handshake returned" \
1795 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001796
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001797run_test "SNI: client auth no override: optional" \
1798 "$P_SRV debug_level=3 auth_mode=optional \
1799 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1800 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1801 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001802 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001803 -S "skip write certificate request" \
1804 -C "skip parse certificate request" \
1805 -c "got a certificate request" \
1806 -C "skip write certificate" \
1807 -C "skip write certificate verify" \
1808 -S "skip parse certificate verify"
1809
1810run_test "SNI: client auth override: none -> optional" \
1811 "$P_SRV debug_level=3 auth_mode=none \
1812 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1813 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1814 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001815 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001816 -S "skip write certificate request" \
1817 -C "skip parse certificate request" \
1818 -c "got a certificate request" \
1819 -C "skip write certificate" \
1820 -C "skip write certificate verify" \
1821 -S "skip parse certificate verify"
1822
1823run_test "SNI: client auth override: optional -> none" \
1824 "$P_SRV debug_level=3 auth_mode=optional \
1825 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1826 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1827 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001828 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001829 -s "skip write certificate request" \
1830 -C "skip parse certificate request" \
1831 -c "got no certificate request" \
1832 -c "skip write certificate" \
1833 -c "skip write certificate verify" \
1834 -s "skip parse certificate verify"
1835
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001836run_test "SNI: CA no override" \
1837 "$P_SRV debug_level=3 auth_mode=optional \
1838 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1839 ca_file=data_files/test-ca.crt \
1840 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1841 "$P_CLI debug_level=3 server_name=localhost \
1842 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1843 1 \
1844 -S "skip write certificate request" \
1845 -C "skip parse certificate request" \
1846 -c "got a certificate request" \
1847 -C "skip write certificate" \
1848 -C "skip write certificate verify" \
1849 -S "skip parse certificate verify" \
1850 -s "x509_verify_cert() returned" \
1851 -s "! The certificate is not correctly signed by the trusted CA" \
1852 -S "The certificate has been revoked (is on a CRL)"
1853
1854run_test "SNI: CA override" \
1855 "$P_SRV debug_level=3 auth_mode=optional \
1856 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1857 ca_file=data_files/test-ca.crt \
1858 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1859 "$P_CLI debug_level=3 server_name=localhost \
1860 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1861 0 \
1862 -S "skip write certificate request" \
1863 -C "skip parse certificate request" \
1864 -c "got a certificate request" \
1865 -C "skip write certificate" \
1866 -C "skip write certificate verify" \
1867 -S "skip parse certificate verify" \
1868 -S "x509_verify_cert() returned" \
1869 -S "! The certificate is not correctly signed by the trusted CA" \
1870 -S "The certificate has been revoked (is on a CRL)"
1871
1872run_test "SNI: CA override with CRL" \
1873 "$P_SRV debug_level=3 auth_mode=optional \
1874 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1875 ca_file=data_files/test-ca.crt \
1876 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1877 "$P_CLI debug_level=3 server_name=localhost \
1878 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1879 1 \
1880 -S "skip write certificate request" \
1881 -C "skip parse certificate request" \
1882 -c "got a certificate request" \
1883 -C "skip write certificate" \
1884 -C "skip write certificate verify" \
1885 -S "skip parse certificate verify" \
1886 -s "x509_verify_cert() returned" \
1887 -S "! The certificate is not correctly signed by the trusted CA" \
1888 -s "The certificate has been revoked (is on a CRL)"
1889
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001890# Tests for non-blocking I/O: exercise a variety of handshake flows
1891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001892run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001893 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1894 "$P_CLI nbio=2 tickets=0" \
1895 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001896 -S "mbedtls_ssl_handshake returned" \
1897 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001898 -c "Read from server: .* bytes read"
1899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001900run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001901 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1902 "$P_CLI nbio=2 tickets=0" \
1903 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001904 -S "mbedtls_ssl_handshake returned" \
1905 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001906 -c "Read from server: .* bytes read"
1907
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001908run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001909 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1910 "$P_CLI nbio=2 tickets=1" \
1911 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001912 -S "mbedtls_ssl_handshake returned" \
1913 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001914 -c "Read from server: .* bytes read"
1915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001916run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001917 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1918 "$P_CLI nbio=2 tickets=1" \
1919 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001920 -S "mbedtls_ssl_handshake returned" \
1921 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001922 -c "Read from server: .* bytes read"
1923
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001924run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001925 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1926 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1927 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001928 -S "mbedtls_ssl_handshake returned" \
1929 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001930 -c "Read from server: .* bytes read"
1931
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001932run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001933 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1934 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1935 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001936 -S "mbedtls_ssl_handshake returned" \
1937 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001938 -c "Read from server: .* bytes read"
1939
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001940run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001941 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1942 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1943 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001944 -S "mbedtls_ssl_handshake returned" \
1945 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001946 -c "Read from server: .* bytes read"
1947
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001948# Tests for version negotiation
1949
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001950run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001951 "$P_SRV" \
1952 "$P_CLI" \
1953 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001954 -S "mbedtls_ssl_handshake returned" \
1955 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001956 -s "Protocol is TLSv1.2" \
1957 -c "Protocol is TLSv1.2"
1958
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001959run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001960 "$P_SRV" \
1961 "$P_CLI max_version=tls1_1" \
1962 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001963 -S "mbedtls_ssl_handshake returned" \
1964 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001965 -s "Protocol is TLSv1.1" \
1966 -c "Protocol is TLSv1.1"
1967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001968run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001969 "$P_SRV max_version=tls1_1" \
1970 "$P_CLI" \
1971 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001972 -S "mbedtls_ssl_handshake returned" \
1973 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001974 -s "Protocol is TLSv1.1" \
1975 -c "Protocol is TLSv1.1"
1976
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001977run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001978 "$P_SRV max_version=tls1_1" \
1979 "$P_CLI max_version=tls1_1" \
1980 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001981 -S "mbedtls_ssl_handshake returned" \
1982 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001983 -s "Protocol is TLSv1.1" \
1984 -c "Protocol is TLSv1.1"
1985
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001986run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001987 "$P_SRV min_version=tls1_1" \
1988 "$P_CLI max_version=tls1_1" \
1989 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001990 -S "mbedtls_ssl_handshake returned" \
1991 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001992 -s "Protocol is TLSv1.1" \
1993 -c "Protocol is TLSv1.1"
1994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001995run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001996 "$P_SRV max_version=tls1_1" \
1997 "$P_CLI min_version=tls1_1" \
1998 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001999 -S "mbedtls_ssl_handshake returned" \
2000 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002001 -s "Protocol is TLSv1.1" \
2002 -c "Protocol is TLSv1.1"
2003
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002004run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002005 "$P_SRV max_version=tls1_1" \
2006 "$P_CLI min_version=tls1_2" \
2007 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002008 -s "mbedtls_ssl_handshake returned" \
2009 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002010 -c "SSL - Handshake protocol not within min/max boundaries"
2011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002012run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002013 "$P_SRV min_version=tls1_2" \
2014 "$P_CLI max_version=tls1_1" \
2015 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002016 -s "mbedtls_ssl_handshake returned" \
2017 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002018 -s "SSL - Handshake protocol not within min/max boundaries"
2019
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002020# Tests for ALPN extension
2021
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002022run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002023 "$P_SRV debug_level=3" \
2024 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002025 0 \
2026 -C "client hello, adding alpn extension" \
2027 -S "found alpn extension" \
2028 -C "got an alert message, type: \\[2:120]" \
2029 -S "server hello, adding alpn extension" \
2030 -C "found alpn extension " \
2031 -C "Application Layer Protocol is" \
2032 -S "Application Layer Protocol is"
2033
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002034run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002035 "$P_SRV debug_level=3" \
2036 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002037 0 \
2038 -c "client hello, adding alpn extension" \
2039 -s "found alpn extension" \
2040 -C "got an alert message, type: \\[2:120]" \
2041 -S "server hello, adding alpn extension" \
2042 -C "found alpn extension " \
2043 -c "Application Layer Protocol is (none)" \
2044 -S "Application Layer Protocol is"
2045
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002046run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002047 "$P_SRV debug_level=3 alpn=abc,1234" \
2048 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002049 0 \
2050 -C "client hello, adding alpn extension" \
2051 -S "found alpn extension" \
2052 -C "got an alert message, type: \\[2:120]" \
2053 -S "server hello, adding alpn extension" \
2054 -C "found alpn extension " \
2055 -C "Application Layer Protocol is" \
2056 -s "Application Layer Protocol is (none)"
2057
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002058run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002059 "$P_SRV debug_level=3 alpn=abc,1234" \
2060 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002061 0 \
2062 -c "client hello, adding alpn extension" \
2063 -s "found alpn extension" \
2064 -C "got an alert message, type: \\[2:120]" \
2065 -s "server hello, adding alpn extension" \
2066 -c "found alpn extension" \
2067 -c "Application Layer Protocol is abc" \
2068 -s "Application Layer Protocol is abc"
2069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002070run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002071 "$P_SRV debug_level=3 alpn=abc,1234" \
2072 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002073 0 \
2074 -c "client hello, adding alpn extension" \
2075 -s "found alpn extension" \
2076 -C "got an alert message, type: \\[2:120]" \
2077 -s "server hello, adding alpn extension" \
2078 -c "found alpn extension" \
2079 -c "Application Layer Protocol is abc" \
2080 -s "Application Layer Protocol is abc"
2081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002082run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002083 "$P_SRV debug_level=3 alpn=abc,1234" \
2084 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002085 0 \
2086 -c "client hello, adding alpn extension" \
2087 -s "found alpn extension" \
2088 -C "got an alert message, type: \\[2:120]" \
2089 -s "server hello, adding alpn extension" \
2090 -c "found alpn extension" \
2091 -c "Application Layer Protocol is 1234" \
2092 -s "Application Layer Protocol is 1234"
2093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002094run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002095 "$P_SRV debug_level=3 alpn=abc,123" \
2096 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002097 1 \
2098 -c "client hello, adding alpn extension" \
2099 -s "found alpn extension" \
2100 -c "got an alert message, type: \\[2:120]" \
2101 -S "server hello, adding alpn extension" \
2102 -C "found alpn extension" \
2103 -C "Application Layer Protocol is 1234" \
2104 -S "Application Layer Protocol is 1234"
2105
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002106
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002107# Tests for keyUsage in leaf certificates, part 1:
2108# server-side certificate/suite selection
2109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002110run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002111 "$P_SRV key_file=data_files/server2.key \
2112 crt_file=data_files/server2.ku-ds.crt" \
2113 "$P_CLI" \
2114 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002115 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002116
2117
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002118run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002119 "$P_SRV key_file=data_files/server2.key \
2120 crt_file=data_files/server2.ku-ke.crt" \
2121 "$P_CLI" \
2122 0 \
2123 -c "Ciphersuite is TLS-RSA-WITH-"
2124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002125run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002126 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002127 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002128 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002129 1 \
2130 -C "Ciphersuite is "
2131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002132run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002133 "$P_SRV key_file=data_files/server5.key \
2134 crt_file=data_files/server5.ku-ds.crt" \
2135 "$P_CLI" \
2136 0 \
2137 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2138
2139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002140run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002141 "$P_SRV key_file=data_files/server5.key \
2142 crt_file=data_files/server5.ku-ka.crt" \
2143 "$P_CLI" \
2144 0 \
2145 -c "Ciphersuite is TLS-ECDH-"
2146
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002147run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002148 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002149 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002150 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002151 1 \
2152 -C "Ciphersuite is "
2153
2154# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002155# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002157run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002158 "$O_SRV -key data_files/server2.key \
2159 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002160 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002161 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2162 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002163 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002164 -C "Processing of the Certificate handshake message failed" \
2165 -c "Ciphersuite is TLS-"
2166
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002167run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002168 "$O_SRV -key data_files/server2.key \
2169 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002170 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002171 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2172 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002173 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002174 -C "Processing of the Certificate handshake message failed" \
2175 -c "Ciphersuite is TLS-"
2176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002177run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002178 "$O_SRV -key data_files/server2.key \
2179 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002180 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002181 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2182 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002183 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002184 -C "Processing of the Certificate handshake message failed" \
2185 -c "Ciphersuite is TLS-"
2186
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002187run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002188 "$O_SRV -key data_files/server2.key \
2189 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002190 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002191 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2192 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002193 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002194 -c "Processing of the Certificate handshake message failed" \
2195 -C "Ciphersuite is TLS-"
2196
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002197run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2198 "$O_SRV -key data_files/server2.key \
2199 -cert data_files/server2.ku-ke.crt" \
2200 "$P_CLI debug_level=1 auth_mode=optional \
2201 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2202 0 \
2203 -c "bad certificate (usage extensions)" \
2204 -C "Processing of the Certificate handshake message failed" \
2205 -c "Ciphersuite is TLS-" \
2206 -c "! Usage does not match the keyUsage extension"
2207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002208run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002209 "$O_SRV -key data_files/server2.key \
2210 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002211 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002212 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2213 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002214 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002215 -C "Processing of the Certificate handshake message failed" \
2216 -c "Ciphersuite is TLS-"
2217
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002218run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002219 "$O_SRV -key data_files/server2.key \
2220 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002221 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002222 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2223 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002224 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002225 -c "Processing of the Certificate handshake message failed" \
2226 -C "Ciphersuite is TLS-"
2227
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002228run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2229 "$O_SRV -key data_files/server2.key \
2230 -cert data_files/server2.ku-ds.crt" \
2231 "$P_CLI debug_level=1 auth_mode=optional \
2232 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2233 0 \
2234 -c "bad certificate (usage extensions)" \
2235 -C "Processing of the Certificate handshake message failed" \
2236 -c "Ciphersuite is TLS-" \
2237 -c "! Usage does not match the keyUsage extension"
2238
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002239# Tests for keyUsage in leaf certificates, part 3:
2240# server-side checking of client cert
2241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002242run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002243 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002244 "$O_CLI -key data_files/server2.key \
2245 -cert data_files/server2.ku-ds.crt" \
2246 0 \
2247 -S "bad certificate (usage extensions)" \
2248 -S "Processing of the Certificate handshake message failed"
2249
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002250run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002251 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002252 "$O_CLI -key data_files/server2.key \
2253 -cert data_files/server2.ku-ke.crt" \
2254 0 \
2255 -s "bad certificate (usage extensions)" \
2256 -S "Processing of the Certificate handshake message failed"
2257
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002258run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002259 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002260 "$O_CLI -key data_files/server2.key \
2261 -cert data_files/server2.ku-ke.crt" \
2262 1 \
2263 -s "bad certificate (usage extensions)" \
2264 -s "Processing of the Certificate handshake message failed"
2265
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002266run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002267 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002268 "$O_CLI -key data_files/server5.key \
2269 -cert data_files/server5.ku-ds.crt" \
2270 0 \
2271 -S "bad certificate (usage extensions)" \
2272 -S "Processing of the Certificate handshake message failed"
2273
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002274run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002275 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002276 "$O_CLI -key data_files/server5.key \
2277 -cert data_files/server5.ku-ka.crt" \
2278 0 \
2279 -s "bad certificate (usage extensions)" \
2280 -S "Processing of the Certificate handshake message failed"
2281
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002282# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2283
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002284run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002285 "$P_SRV key_file=data_files/server5.key \
2286 crt_file=data_files/server5.eku-srv.crt" \
2287 "$P_CLI" \
2288 0
2289
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002290run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002291 "$P_SRV key_file=data_files/server5.key \
2292 crt_file=data_files/server5.eku-srv.crt" \
2293 "$P_CLI" \
2294 0
2295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002296run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002297 "$P_SRV key_file=data_files/server5.key \
2298 crt_file=data_files/server5.eku-cs_any.crt" \
2299 "$P_CLI" \
2300 0
2301
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002302run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002303 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002304 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002305 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002306 1
2307
2308# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2309
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002310run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002311 "$O_SRV -key data_files/server5.key \
2312 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002313 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002314 0 \
2315 -C "bad certificate (usage extensions)" \
2316 -C "Processing of the Certificate handshake message failed" \
2317 -c "Ciphersuite is TLS-"
2318
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002319run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002320 "$O_SRV -key data_files/server5.key \
2321 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002322 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002323 0 \
2324 -C "bad certificate (usage extensions)" \
2325 -C "Processing of the Certificate handshake message failed" \
2326 -c "Ciphersuite is TLS-"
2327
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002328run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002329 "$O_SRV -key data_files/server5.key \
2330 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002331 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002332 0 \
2333 -C "bad certificate (usage extensions)" \
2334 -C "Processing of the Certificate handshake message failed" \
2335 -c "Ciphersuite is TLS-"
2336
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002337run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002338 "$O_SRV -key data_files/server5.key \
2339 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002340 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002341 1 \
2342 -c "bad certificate (usage extensions)" \
2343 -c "Processing of the Certificate handshake message failed" \
2344 -C "Ciphersuite is TLS-"
2345
2346# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002348run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002349 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002350 "$O_CLI -key data_files/server5.key \
2351 -cert data_files/server5.eku-cli.crt" \
2352 0 \
2353 -S "bad certificate (usage extensions)" \
2354 -S "Processing of the Certificate handshake message failed"
2355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002356run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002357 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002358 "$O_CLI -key data_files/server5.key \
2359 -cert data_files/server5.eku-srv_cli.crt" \
2360 0 \
2361 -S "bad certificate (usage extensions)" \
2362 -S "Processing of the Certificate handshake message failed"
2363
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002364run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002365 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002366 "$O_CLI -key data_files/server5.key \
2367 -cert data_files/server5.eku-cs_any.crt" \
2368 0 \
2369 -S "bad certificate (usage extensions)" \
2370 -S "Processing of the Certificate handshake message failed"
2371
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002372run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002373 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002374 "$O_CLI -key data_files/server5.key \
2375 -cert data_files/server5.eku-cs.crt" \
2376 0 \
2377 -s "bad certificate (usage extensions)" \
2378 -S "Processing of the Certificate handshake message failed"
2379
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002380run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002381 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002382 "$O_CLI -key data_files/server5.key \
2383 -cert data_files/server5.eku-cs.crt" \
2384 1 \
2385 -s "bad certificate (usage extensions)" \
2386 -s "Processing of the Certificate handshake message failed"
2387
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002388# Tests for DHM parameters loading
2389
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002390run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002391 "$P_SRV" \
2392 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2393 debug_level=3" \
2394 0 \
2395 -c "value of 'DHM: P ' (2048 bits)" \
2396 -c "value of 'DHM: G ' (2048 bits)"
2397
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002398run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002399 "$P_SRV dhm_file=data_files/dhparams.pem" \
2400 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2401 debug_level=3" \
2402 0 \
2403 -c "value of 'DHM: P ' (1024 bits)" \
2404 -c "value of 'DHM: G ' (2 bits)"
2405
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002406# Tests for DHM client-side size checking
2407
2408run_test "DHM size: server default, client default, OK" \
2409 "$P_SRV" \
2410 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2411 debug_level=1" \
2412 0 \
2413 -C "DHM prime too short:"
2414
2415run_test "DHM size: server default, client 2048, OK" \
2416 "$P_SRV" \
2417 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2418 debug_level=1 dhmlen=2048" \
2419 0 \
2420 -C "DHM prime too short:"
2421
2422run_test "DHM size: server 1024, client default, OK" \
2423 "$P_SRV dhm_file=data_files/dhparams.pem" \
2424 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2425 debug_level=1" \
2426 0 \
2427 -C "DHM prime too short:"
2428
2429run_test "DHM size: server 1000, client default, rejected" \
2430 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2431 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2432 debug_level=1" \
2433 1 \
2434 -c "DHM prime too short:"
2435
2436run_test "DHM size: server default, client 2049, rejected" \
2437 "$P_SRV" \
2438 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2439 debug_level=1 dhmlen=2049" \
2440 1 \
2441 -c "DHM prime too short:"
2442
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002443# Tests for PSK callback
2444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002445run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002446 "$P_SRV psk=abc123 psk_identity=foo" \
2447 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2448 psk_identity=foo psk=abc123" \
2449 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002450 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002451 -S "SSL - Unknown identity received" \
2452 -S "SSL - Verification of the message MAC failed"
2453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002454run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002455 "$P_SRV" \
2456 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2457 psk_identity=foo psk=abc123" \
2458 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002459 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002460 -S "SSL - Unknown identity received" \
2461 -S "SSL - Verification of the message MAC failed"
2462
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002463run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002464 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2465 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2466 psk_identity=foo psk=abc123" \
2467 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002468 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002469 -s "SSL - Unknown identity received" \
2470 -S "SSL - Verification of the message MAC failed"
2471
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002472run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002473 "$P_SRV psk_list=abc,dead,def,beef" \
2474 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2475 psk_identity=abc psk=dead" \
2476 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002477 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002478 -S "SSL - Unknown identity received" \
2479 -S "SSL - Verification of the message MAC failed"
2480
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002481run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002482 "$P_SRV psk_list=abc,dead,def,beef" \
2483 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2484 psk_identity=def psk=beef" \
2485 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002486 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002487 -S "SSL - Unknown identity received" \
2488 -S "SSL - Verification of the message MAC failed"
2489
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002490run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002491 "$P_SRV psk_list=abc,dead,def,beef" \
2492 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2493 psk_identity=ghi psk=beef" \
2494 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002495 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002496 -s "SSL - Unknown identity received" \
2497 -S "SSL - Verification of the message MAC failed"
2498
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002499run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002500 "$P_SRV psk_list=abc,dead,def,beef" \
2501 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2502 psk_identity=abc psk=beef" \
2503 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002504 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002505 -S "SSL - Unknown identity received" \
2506 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002507
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002508# Tests for EC J-PAKE
2509
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002510requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002511run_test "ECJPAKE: client not configured" \
2512 "$P_SRV debug_level=3" \
2513 "$P_CLI debug_level=3" \
2514 0 \
2515 -C "add ciphersuite: c0ff" \
2516 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002517 -S "found ecjpake kkpp extension" \
2518 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002519 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002520 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002521 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002522 -S "None of the common ciphersuites is usable"
2523
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002524requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002525run_test "ECJPAKE: server not configured" \
2526 "$P_SRV debug_level=3" \
2527 "$P_CLI debug_level=3 ecjpake_pw=bla \
2528 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2529 1 \
2530 -c "add ciphersuite: c0ff" \
2531 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002532 -s "found ecjpake kkpp extension" \
2533 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002534 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002535 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002536 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002537 -s "None of the common ciphersuites is usable"
2538
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002539requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002540run_test "ECJPAKE: working, TLS" \
2541 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2542 "$P_CLI debug_level=3 ecjpake_pw=bla \
2543 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002544 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002545 -c "add ciphersuite: c0ff" \
2546 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002547 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002548 -s "found ecjpake kkpp extension" \
2549 -S "skip ecjpake kkpp extension" \
2550 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002551 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002552 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002553 -S "None of the common ciphersuites is usable" \
2554 -S "SSL - Verification of the message MAC failed"
2555
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002556requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002557run_test "ECJPAKE: password mismatch, TLS" \
2558 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2559 "$P_CLI debug_level=3 ecjpake_pw=bad \
2560 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2561 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002562 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002563 -s "SSL - Verification of the message MAC failed"
2564
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002565requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002566run_test "ECJPAKE: working, DTLS" \
2567 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2568 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2569 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2570 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002571 -c "re-using cached ecjpake parameters" \
2572 -S "SSL - Verification of the message MAC failed"
2573
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002574requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002575run_test "ECJPAKE: working, DTLS, no cookie" \
2576 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2577 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2578 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2579 0 \
2580 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002581 -S "SSL - Verification of the message MAC failed"
2582
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002583requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002584run_test "ECJPAKE: password mismatch, DTLS" \
2585 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2586 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2587 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2588 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002589 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002590 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002591
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002592# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002593requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002594run_test "ECJPAKE: working, DTLS, nolog" \
2595 "$P_SRV dtls=1 ecjpake_pw=bla" \
2596 "$P_CLI dtls=1 ecjpake_pw=bla \
2597 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2598 0
2599
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002600# Tests for ciphersuites per version
2601
Janos Follathe2681a42016-03-07 15:57:05 +00002602requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002603run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002604 "$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 +02002605 "$P_CLI force_version=ssl3" \
2606 0 \
2607 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002609run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002610 "$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 +01002611 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002612 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002613 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002615run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002616 "$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 +02002617 "$P_CLI force_version=tls1_1" \
2618 0 \
2619 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002621run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002622 "$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 +02002623 "$P_CLI force_version=tls1_2" \
2624 0 \
2625 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2626
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002627# Test for ClientHello without extensions
2628
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002629requires_gnutls
2630run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002631 "$P_SRV debug_level=3" \
2632 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2633 0 \
2634 -s "dumping 'client hello extensions' (0 bytes)"
2635
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002636# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002637
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002638run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002639 "$P_SRV" \
2640 "$P_CLI request_size=100" \
2641 0 \
2642 -s "Read from client: 100 bytes read$"
2643
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002644run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002645 "$P_SRV" \
2646 "$P_CLI request_size=500" \
2647 0 \
2648 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002649
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002650# Tests for small packets
2651
Janos Follathe2681a42016-03-07 15:57:05 +00002652requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002653run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002654 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002655 "$P_CLI request_size=1 force_version=ssl3 \
2656 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2657 0 \
2658 -s "Read from client: 1 bytes read"
2659
Janos Follathe2681a42016-03-07 15:57:05 +00002660requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002661run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002662 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002663 "$P_CLI request_size=1 force_version=ssl3 \
2664 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2665 0 \
2666 -s "Read from client: 1 bytes read"
2667
2668run_test "Small packet TLS 1.0 BlockCipher" \
2669 "$P_SRV" \
2670 "$P_CLI request_size=1 force_version=tls1 \
2671 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2672 0 \
2673 -s "Read from client: 1 bytes read"
2674
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002675run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2676 "$P_SRV" \
2677 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2678 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2679 0 \
2680 -s "Read from client: 1 bytes read"
2681
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002682run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2683 "$P_SRV" \
2684 "$P_CLI request_size=1 force_version=tls1 \
2685 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2686 trunc_hmac=1" \
2687 0 \
2688 -s "Read from client: 1 bytes read"
2689
2690run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002691 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002692 "$P_CLI request_size=1 force_version=tls1 \
2693 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2694 trunc_hmac=1" \
2695 0 \
2696 -s "Read from client: 1 bytes read"
2697
2698run_test "Small packet TLS 1.1 BlockCipher" \
2699 "$P_SRV" \
2700 "$P_CLI request_size=1 force_version=tls1_1 \
2701 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2702 0 \
2703 -s "Read from client: 1 bytes read"
2704
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002705run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2706 "$P_SRV" \
2707 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2708 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2709 0 \
2710 -s "Read from client: 1 bytes read"
2711
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002712run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002713 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002714 "$P_CLI request_size=1 force_version=tls1_1 \
2715 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2716 0 \
2717 -s "Read from client: 1 bytes read"
2718
2719run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2720 "$P_SRV" \
2721 "$P_CLI request_size=1 force_version=tls1_1 \
2722 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2723 trunc_hmac=1" \
2724 0 \
2725 -s "Read from client: 1 bytes read"
2726
2727run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002728 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002729 "$P_CLI request_size=1 force_version=tls1_1 \
2730 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2731 trunc_hmac=1" \
2732 0 \
2733 -s "Read from client: 1 bytes read"
2734
2735run_test "Small packet TLS 1.2 BlockCipher" \
2736 "$P_SRV" \
2737 "$P_CLI request_size=1 force_version=tls1_2 \
2738 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2739 0 \
2740 -s "Read from client: 1 bytes read"
2741
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002742run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2743 "$P_SRV" \
2744 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2745 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2746 0 \
2747 -s "Read from client: 1 bytes read"
2748
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002749run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2750 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002751 "$P_CLI request_size=1 force_version=tls1_2 \
2752 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002753 0 \
2754 -s "Read from client: 1 bytes read"
2755
2756run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2757 "$P_SRV" \
2758 "$P_CLI request_size=1 force_version=tls1_2 \
2759 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2760 trunc_hmac=1" \
2761 0 \
2762 -s "Read from client: 1 bytes read"
2763
2764run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002765 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002766 "$P_CLI request_size=1 force_version=tls1_2 \
2767 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2768 0 \
2769 -s "Read from client: 1 bytes read"
2770
2771run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002772 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002773 "$P_CLI request_size=1 force_version=tls1_2 \
2774 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2775 trunc_hmac=1" \
2776 0 \
2777 -s "Read from client: 1 bytes read"
2778
2779run_test "Small packet TLS 1.2 AEAD" \
2780 "$P_SRV" \
2781 "$P_CLI request_size=1 force_version=tls1_2 \
2782 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2783 0 \
2784 -s "Read from client: 1 bytes read"
2785
2786run_test "Small packet TLS 1.2 AEAD shorter tag" \
2787 "$P_SRV" \
2788 "$P_CLI request_size=1 force_version=tls1_2 \
2789 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2790 0 \
2791 -s "Read from client: 1 bytes read"
2792
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002793# Test for large packets
2794
Janos Follathe2681a42016-03-07 15:57:05 +00002795requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002796run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002797 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002798 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002799 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2800 0 \
2801 -s "Read from client: 16384 bytes read"
2802
Janos Follathe2681a42016-03-07 15:57:05 +00002803requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002804run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002805 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002806 "$P_CLI request_size=16384 force_version=ssl3 \
2807 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2808 0 \
2809 -s "Read from client: 16384 bytes read"
2810
2811run_test "Large packet TLS 1.0 BlockCipher" \
2812 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002813 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002814 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2815 0 \
2816 -s "Read from client: 16384 bytes read"
2817
2818run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2819 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002820 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002821 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2822 trunc_hmac=1" \
2823 0 \
2824 -s "Read from client: 16384 bytes read"
2825
2826run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002827 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002828 "$P_CLI request_size=16384 force_version=tls1 \
2829 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2830 trunc_hmac=1" \
2831 0 \
2832 -s "Read from client: 16384 bytes read"
2833
2834run_test "Large packet TLS 1.1 BlockCipher" \
2835 "$P_SRV" \
2836 "$P_CLI request_size=16384 force_version=tls1_1 \
2837 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2838 0 \
2839 -s "Read from client: 16384 bytes read"
2840
2841run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002842 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002843 "$P_CLI request_size=16384 force_version=tls1_1 \
2844 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2845 0 \
2846 -s "Read from client: 16384 bytes read"
2847
2848run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2849 "$P_SRV" \
2850 "$P_CLI request_size=16384 force_version=tls1_1 \
2851 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2852 trunc_hmac=1" \
2853 0 \
2854 -s "Read from client: 16384 bytes read"
2855
2856run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002857 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002858 "$P_CLI request_size=16384 force_version=tls1_1 \
2859 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2860 trunc_hmac=1" \
2861 0 \
2862 -s "Read from client: 16384 bytes read"
2863
2864run_test "Large packet TLS 1.2 BlockCipher" \
2865 "$P_SRV" \
2866 "$P_CLI request_size=16384 force_version=tls1_2 \
2867 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2868 0 \
2869 -s "Read from client: 16384 bytes read"
2870
2871run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2872 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002873 "$P_CLI request_size=16384 force_version=tls1_2 \
2874 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002875 0 \
2876 -s "Read from client: 16384 bytes read"
2877
2878run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2879 "$P_SRV" \
2880 "$P_CLI request_size=16384 force_version=tls1_2 \
2881 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2882 trunc_hmac=1" \
2883 0 \
2884 -s "Read from client: 16384 bytes read"
2885
2886run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002887 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002888 "$P_CLI request_size=16384 force_version=tls1_2 \
2889 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2890 0 \
2891 -s "Read from client: 16384 bytes read"
2892
2893run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002894 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002895 "$P_CLI request_size=16384 force_version=tls1_2 \
2896 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2897 trunc_hmac=1" \
2898 0 \
2899 -s "Read from client: 16384 bytes read"
2900
2901run_test "Large packet TLS 1.2 AEAD" \
2902 "$P_SRV" \
2903 "$P_CLI request_size=16384 force_version=tls1_2 \
2904 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2905 0 \
2906 -s "Read from client: 16384 bytes read"
2907
2908run_test "Large packet TLS 1.2 AEAD shorter tag" \
2909 "$P_SRV" \
2910 "$P_CLI request_size=16384 force_version=tls1_2 \
2911 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2912 0 \
2913 -s "Read from client: 16384 bytes read"
2914
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002915# Tests for DTLS HelloVerifyRequest
2916
2917run_test "DTLS cookie: enabled" \
2918 "$P_SRV dtls=1 debug_level=2" \
2919 "$P_CLI dtls=1 debug_level=2" \
2920 0 \
2921 -s "cookie verification failed" \
2922 -s "cookie verification passed" \
2923 -S "cookie verification skipped" \
2924 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002925 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002926 -S "SSL - The requested feature is not available"
2927
2928run_test "DTLS cookie: disabled" \
2929 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2930 "$P_CLI dtls=1 debug_level=2" \
2931 0 \
2932 -S "cookie verification failed" \
2933 -S "cookie verification passed" \
2934 -s "cookie verification skipped" \
2935 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002936 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002937 -S "SSL - The requested feature is not available"
2938
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002939run_test "DTLS cookie: default (failing)" \
2940 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2941 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2942 1 \
2943 -s "cookie verification failed" \
2944 -S "cookie verification passed" \
2945 -S "cookie verification skipped" \
2946 -C "received hello verify request" \
2947 -S "hello verification requested" \
2948 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002949
2950requires_ipv6
2951run_test "DTLS cookie: enabled, IPv6" \
2952 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2953 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2954 0 \
2955 -s "cookie verification failed" \
2956 -s "cookie verification passed" \
2957 -S "cookie verification skipped" \
2958 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002959 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002960 -S "SSL - The requested feature is not available"
2961
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002962run_test "DTLS cookie: enabled, nbio" \
2963 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2964 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2965 0 \
2966 -s "cookie verification failed" \
2967 -s "cookie verification passed" \
2968 -S "cookie verification skipped" \
2969 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002970 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002971 -S "SSL - The requested feature is not available"
2972
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002973# Tests for client reconnecting from the same port with DTLS
2974
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002975not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002976run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002977 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
2978 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002979 0 \
2980 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002981 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002982 -S "Client initiated reconnection from same port"
2983
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002984not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002985run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002986 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
2987 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002988 0 \
2989 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002990 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002991 -s "Client initiated reconnection from same port"
2992
2993run_test "DTLS client reconnect from same port: reconnect, nbio" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002994 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
2995 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002996 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02002997 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02002998 -s "Client initiated reconnection from same port"
2999
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003000run_test "DTLS client reconnect from same port: no cookies" \
3001 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003002 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3003 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003004 -s "The operation timed out" \
3005 -S "Client initiated reconnection from same port"
3006
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003007# Tests for various cases of client authentication with DTLS
3008# (focused on handshake flows and message parsing)
3009
3010run_test "DTLS client auth: required" \
3011 "$P_SRV dtls=1 auth_mode=required" \
3012 "$P_CLI dtls=1" \
3013 0 \
3014 -s "Verifying peer X.509 certificate... ok"
3015
3016run_test "DTLS client auth: optional, client has no cert" \
3017 "$P_SRV dtls=1 auth_mode=optional" \
3018 "$P_CLI dtls=1 crt_file=none key_file=none" \
3019 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003020 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003021
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003022run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003023 "$P_SRV dtls=1 auth_mode=none" \
3024 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3025 0 \
3026 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003027 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003028
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003029run_test "DTLS wrong PSK: badmac alert" \
3030 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3031 "$P_CLI dtls=1 psk=abc124" \
3032 1 \
3033 -s "SSL - Verification of the message MAC failed" \
3034 -c "SSL - A fatal alert message was received from our peer"
3035
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003036# Tests for receiving fragmented handshake messages with DTLS
3037
3038requires_gnutls
3039run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3040 "$G_SRV -u --mtu 2048 -a" \
3041 "$P_CLI dtls=1 debug_level=2" \
3042 0 \
3043 -C "found fragmented DTLS handshake message" \
3044 -C "error"
3045
3046requires_gnutls
3047run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3048 "$G_SRV -u --mtu 512" \
3049 "$P_CLI dtls=1 debug_level=2" \
3050 0 \
3051 -c "found fragmented DTLS handshake message" \
3052 -C "error"
3053
3054requires_gnutls
3055run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3056 "$G_SRV -u --mtu 128" \
3057 "$P_CLI dtls=1 debug_level=2" \
3058 0 \
3059 -c "found fragmented DTLS handshake message" \
3060 -C "error"
3061
3062requires_gnutls
3063run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3064 "$G_SRV -u --mtu 128" \
3065 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3066 0 \
3067 -c "found fragmented DTLS handshake message" \
3068 -C "error"
3069
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003070requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003071run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3072 "$G_SRV -u --mtu 256" \
3073 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3074 0 \
3075 -c "found fragmented DTLS handshake message" \
3076 -c "client hello, adding renegotiation extension" \
3077 -c "found renegotiation extension" \
3078 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003079 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003080 -C "error" \
3081 -s "Extra-header:"
3082
3083requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003084run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3085 "$G_SRV -u --mtu 256" \
3086 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3087 0 \
3088 -c "found fragmented DTLS handshake message" \
3089 -c "client hello, adding renegotiation extension" \
3090 -c "found renegotiation extension" \
3091 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003092 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003093 -C "error" \
3094 -s "Extra-header:"
3095
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003096run_test "DTLS reassembly: no fragmentation (openssl server)" \
3097 "$O_SRV -dtls1 -mtu 2048" \
3098 "$P_CLI dtls=1 debug_level=2" \
3099 0 \
3100 -C "found fragmented DTLS handshake message" \
3101 -C "error"
3102
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003103run_test "DTLS reassembly: some fragmentation (openssl server)" \
3104 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003105 "$P_CLI dtls=1 debug_level=2" \
3106 0 \
3107 -c "found fragmented DTLS handshake message" \
3108 -C "error"
3109
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003110run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003111 "$O_SRV -dtls1 -mtu 256" \
3112 "$P_CLI dtls=1 debug_level=2" \
3113 0 \
3114 -c "found fragmented DTLS handshake message" \
3115 -C "error"
3116
3117run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3118 "$O_SRV -dtls1 -mtu 256" \
3119 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3120 0 \
3121 -c "found fragmented DTLS handshake message" \
3122 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003123
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003124# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003125
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003126not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003127run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003128 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003129 "$P_SRV dtls=1 debug_level=2" \
3130 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003131 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003132 -C "replayed record" \
3133 -S "replayed record" \
3134 -C "record from another epoch" \
3135 -S "record from another epoch" \
3136 -C "discarding invalid record" \
3137 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003138 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003139 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003140 -c "HTTP/1.0 200 OK"
3141
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003142not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003143run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003144 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003145 "$P_SRV dtls=1 debug_level=2" \
3146 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003147 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003148 -c "replayed record" \
3149 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003150 -c "discarding invalid record" \
3151 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003152 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003153 -s "Extra-header:" \
3154 -c "HTTP/1.0 200 OK"
3155
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003156run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3157 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003158 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3159 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003160 0 \
3161 -c "replayed record" \
3162 -S "replayed record" \
3163 -c "discarding invalid record" \
3164 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003165 -c "resend" \
3166 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003167 -s "Extra-header:" \
3168 -c "HTTP/1.0 200 OK"
3169
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003170run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003171 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003172 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003173 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003174 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003175 -c "discarding invalid record (mac)" \
3176 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003177 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003178 -c "HTTP/1.0 200 OK" \
3179 -S "too many records with bad MAC" \
3180 -S "Verification of the message MAC failed"
3181
3182run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3183 -p "$P_PXY bad_ad=1" \
3184 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3185 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3186 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003187 -C "discarding invalid record (mac)" \
3188 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003189 -S "Extra-header:" \
3190 -C "HTTP/1.0 200 OK" \
3191 -s "too many records with bad MAC" \
3192 -s "Verification of the message MAC failed"
3193
3194run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3195 -p "$P_PXY bad_ad=1" \
3196 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3197 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3198 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003199 -c "discarding invalid record (mac)" \
3200 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003201 -s "Extra-header:" \
3202 -c "HTTP/1.0 200 OK" \
3203 -S "too many records with bad MAC" \
3204 -S "Verification of the message MAC failed"
3205
3206run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3207 -p "$P_PXY bad_ad=1" \
3208 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3209 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3210 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003211 -c "discarding invalid record (mac)" \
3212 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003213 -s "Extra-header:" \
3214 -c "HTTP/1.0 200 OK" \
3215 -s "too many records with bad MAC" \
3216 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003217
3218run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003219 -p "$P_PXY delay_ccs=1" \
3220 "$P_SRV dtls=1 debug_level=1" \
3221 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003222 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003223 -c "record from another epoch" \
3224 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003225 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003226 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003227 -s "Extra-header:" \
3228 -c "HTTP/1.0 200 OK"
3229
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003230# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003231
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003232needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003233run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003234 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003235 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3236 psk=abc123" \
3237 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003238 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3239 0 \
3240 -s "Extra-header:" \
3241 -c "HTTP/1.0 200 OK"
3242
3243needs_more_time 2
3244run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3245 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003246 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3247 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003248 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3249 0 \
3250 -s "Extra-header:" \
3251 -c "HTTP/1.0 200 OK"
3252
3253needs_more_time 2
3254run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3255 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003256 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3257 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003258 0 \
3259 -s "Extra-header:" \
3260 -c "HTTP/1.0 200 OK"
3261
3262needs_more_time 2
3263run_test "DTLS proxy: 3d, FS, client auth" \
3264 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003265 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3266 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003267 0 \
3268 -s "Extra-header:" \
3269 -c "HTTP/1.0 200 OK"
3270
3271needs_more_time 2
3272run_test "DTLS proxy: 3d, FS, ticket" \
3273 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003274 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3275 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003276 0 \
3277 -s "Extra-header:" \
3278 -c "HTTP/1.0 200 OK"
3279
3280needs_more_time 2
3281run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3282 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003283 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3284 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003285 0 \
3286 -s "Extra-header:" \
3287 -c "HTTP/1.0 200 OK"
3288
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003289needs_more_time 2
3290run_test "DTLS proxy: 3d, max handshake, nbio" \
3291 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003292 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3293 auth_mode=required" \
3294 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003295 0 \
3296 -s "Extra-header:" \
3297 -c "HTTP/1.0 200 OK"
3298
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003299needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003300run_test "DTLS proxy: 3d, min handshake, resumption" \
3301 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3302 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3303 psk=abc123 debug_level=3" \
3304 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3305 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3306 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3307 0 \
3308 -s "a session has been resumed" \
3309 -c "a session has been resumed" \
3310 -s "Extra-header:" \
3311 -c "HTTP/1.0 200 OK"
3312
3313needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003314run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3315 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3316 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3317 psk=abc123 debug_level=3 nbio=2" \
3318 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3319 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3320 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3321 0 \
3322 -s "a session has been resumed" \
3323 -c "a session has been resumed" \
3324 -s "Extra-header:" \
3325 -c "HTTP/1.0 200 OK"
3326
3327needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003328run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003329 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003330 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3331 psk=abc123 renegotiation=1 debug_level=2" \
3332 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3333 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003334 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3335 0 \
3336 -c "=> renegotiate" \
3337 -s "=> renegotiate" \
3338 -s "Extra-header:" \
3339 -c "HTTP/1.0 200 OK"
3340
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003341needs_more_time 4
3342run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3343 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003344 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3345 psk=abc123 renegotiation=1 debug_level=2" \
3346 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3347 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003348 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3349 0 \
3350 -c "=> renegotiate" \
3351 -s "=> renegotiate" \
3352 -s "Extra-header:" \
3353 -c "HTTP/1.0 200 OK"
3354
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003355needs_more_time 4
3356run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003357 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003358 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003359 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003360 debug_level=2" \
3361 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003362 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003363 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3364 0 \
3365 -c "=> renegotiate" \
3366 -s "=> renegotiate" \
3367 -s "Extra-header:" \
3368 -c "HTTP/1.0 200 OK"
3369
3370needs_more_time 4
3371run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003372 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003373 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003374 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003375 debug_level=2 nbio=2" \
3376 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003377 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003378 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3379 0 \
3380 -c "=> renegotiate" \
3381 -s "=> renegotiate" \
3382 -s "Extra-header:" \
3383 -c "HTTP/1.0 200 OK"
3384
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003385needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003386not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003387run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003388 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3389 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003390 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003391 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003392 -c "HTTP/1.0 200 OK"
3393
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003394needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003395not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003396run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3397 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3398 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003399 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003400 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003401 -c "HTTP/1.0 200 OK"
3402
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003403needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003404not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003405run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3406 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3407 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003408 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003409 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003410 -c "HTTP/1.0 200 OK"
3411
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003412requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003413needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003414not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003415run_test "DTLS proxy: 3d, gnutls server" \
3416 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3417 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003418 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003419 0 \
3420 -s "Extra-header:" \
3421 -c "Extra-header:"
3422
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003423requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003424needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003425not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003426run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3427 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3428 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003429 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003430 0 \
3431 -s "Extra-header:" \
3432 -c "Extra-header:"
3433
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003434requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003435needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003436not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003437run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3438 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3439 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003440 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003441 0 \
3442 -s "Extra-header:" \
3443 -c "Extra-header:"
3444
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003445# Final report
3446
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003447echo "------------------------------------------------------------------------"
3448
3449if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003450 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003451else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003452 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003453fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003454PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003455echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003456
3457exit $FAILS