blob: 09a947e654b6037ae6fa2b9117564028ab56f90d [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010031
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020032O_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 +010033O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020034G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010035G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010036
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010037TESTS=0
38FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020039SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010040
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000041CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020042
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010043MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010044FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020045EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010046
Paul Bakkere20310a2016-05-10 11:18:17 +010047SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010048RUN_TEST_NUMBER=''
49
Paul Bakkeracaac852016-05-10 11:47:13 +010050PRESERVE_LOGS=0
51
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052print_usage() {
53 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010054 printf " -h|--help\tPrint this help.\n"
55 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
56 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
57 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010058 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010059 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010060 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Andres AGf04f54d2016-10-10 15:46:20 +010061 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062}
63
64get_options() {
65 while [ $# -gt 0 ]; do
66 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010067 -f|--filter)
68 shift; FILTER=$1
69 ;;
70 -e|--exclude)
71 shift; EXCLUDE=$1
72 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010073 -m|--memcheck)
74 MEMCHECK=1
75 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010076 -n|--number)
77 shift; RUN_TEST_NUMBER=$1
78 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010079 -s|--show-numbers)
80 SHOW_TEST_NUMBER=1
81 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010082 -p|--preserve-logs)
83 PRESERVE_LOGS=1
84 ;;
Andres AGf04f54d2016-10-10 15:46:20 +010085 --seed)
86 shift; SEED="$1"
87 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010088 -h|--help)
89 print_usage
90 exit 0
91 ;;
92 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020093 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010094 print_usage
95 exit 1
96 ;;
97 esac
98 shift
99 done
100}
101
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100102# skip next test if the flag is not enabled in config.h
103requires_config_enabled() {
104 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
105 SKIP_NEXT="YES"
106 fi
107}
108
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200109# skip next test if OpenSSL doesn't support FALLBACK_SCSV
110requires_openssl_with_fallback_scsv() {
111 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
112 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
113 then
114 OPENSSL_HAS_FBSCSV="YES"
115 else
116 OPENSSL_HAS_FBSCSV="NO"
117 fi
118 fi
119 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
120 SKIP_NEXT="YES"
121 fi
122}
123
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200124# skip next test if GnuTLS isn't available
125requires_gnutls() {
126 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200127 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200128 GNUTLS_AVAILABLE="YES"
129 else
130 GNUTLS_AVAILABLE="NO"
131 fi
132 fi
133 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
134 SKIP_NEXT="YES"
135 fi
136}
137
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200138# skip next test if IPv6 isn't available on this host
139requires_ipv6() {
140 if [ -z "${HAS_IPV6:-}" ]; then
141 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
142 SRV_PID=$!
143 sleep 1
144 kill $SRV_PID >/dev/null 2>&1
145 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
146 HAS_IPV6="NO"
147 else
148 HAS_IPV6="YES"
149 fi
150 rm -r $SRV_OUT
151 fi
152
153 if [ "$HAS_IPV6" = "NO" ]; then
154 SKIP_NEXT="YES"
155 fi
156}
157
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200158# skip the next test if valgrind is in use
159not_with_valgrind() {
160 if [ "$MEMCHECK" -gt 0 ]; then
161 SKIP_NEXT="YES"
162 fi
163}
164
Paul Bakker362689d2016-05-13 10:33:25 +0100165# skip the next test if valgrind is NOT in use
166only_with_valgrind() {
167 if [ "$MEMCHECK" -eq 0 ]; then
168 SKIP_NEXT="YES"
169 fi
170}
171
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200172# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100173client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200174 CLI_DELAY_FACTOR=$1
175}
176
Janos Follath74537a62016-09-02 13:45:28 +0100177# wait for the given seconds after the client finished in the next test
178server_needs_more_time() {
179 SRV_DELAY_SECONDS=$1
180}
181
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100182# print_name <name>
183print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100184 TESTS=$(( $TESTS + 1 ))
185 LINE=""
186
187 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
188 LINE="$TESTS "
189 fi
190
191 LINE="$LINE$1"
192 printf "$LINE "
193 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100194 for i in `seq 1 $LEN`; do printf '.'; done
195 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100196
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100197}
198
199# fail <message>
200fail() {
201 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100202 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100203
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200204 mv $SRV_OUT o-srv-${TESTS}.log
205 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200206 if [ -n "$PXY_CMD" ]; then
207 mv $PXY_OUT o-pxy-${TESTS}.log
208 fi
209 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100210
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200211 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
212 echo " ! server output:"
213 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200214 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200215 echo " ! client output:"
216 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200217 if [ -n "$PXY_CMD" ]; then
218 echo " ! ========================================================"
219 echo " ! proxy output:"
220 cat o-pxy-${TESTS}.log
221 fi
222 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200223 fi
224
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200225 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100226}
227
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100228# is_polar <cmd_line>
229is_polar() {
230 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
231}
232
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200233# openssl s_server doesn't have -www with DTLS
234check_osrv_dtls() {
235 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
236 NEEDS_INPUT=1
237 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
238 else
239 NEEDS_INPUT=0
240 fi
241}
242
243# provide input to commands that need it
244provide_input() {
245 if [ $NEEDS_INPUT -eq 0 ]; then
246 return
247 fi
248
249 while true; do
250 echo "HTTP/1.0 200 OK"
251 sleep 1
252 done
253}
254
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100255# has_mem_err <log_file_name>
256has_mem_err() {
257 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
258 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
259 then
260 return 1 # false: does not have errors
261 else
262 return 0 # true: has errors
263 fi
264}
265
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200266# wait for server to start: two versions depending on lsof availability
267wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200268 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200269 START_TIME=$( date +%s )
270 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200271
272 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200273 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200274 while [ $DONE -eq 0 ]; do
275 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
276 then
277 DONE=1
278 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
279 echo "SERVERSTART TIMEOUT"
280 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
281 DONE=1
282 fi
283 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200284 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200285 while [ $DONE -eq 0 ]; do
286 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
287 then
288 DONE=1
289 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
290 echo "SERVERSTART TIMEOUT"
291 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
292 DONE=1
293 fi
294 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200295 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200296 else
297 sleep "$START_DELAY"
298 fi
299}
300
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200301# wait for client to terminate and set CLI_EXIT
302# must be called right after starting the client
303wait_client_done() {
304 CLI_PID=$!
305
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200306 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
307 CLI_DELAY_FACTOR=1
308
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200309 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200310 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200311
312 wait $CLI_PID
313 CLI_EXIT=$?
314
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200315 kill $DOG_PID >/dev/null 2>&1
316 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200317
318 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100319
320 sleep $SRV_DELAY_SECONDS
321 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200322}
323
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200324# check if the given command uses dtls and sets global variable DTLS
325detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200326 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200327 DTLS=1
328 else
329 DTLS=0
330 fi
331}
332
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200333# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100334# Options: -s pattern pattern that must be present in server output
335# -c pattern pattern that must be present in client output
336# -S pattern pattern that must be absent in server output
337# -C pattern pattern that must be absent in client output
338run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100339 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200340 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100341
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100342 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
343 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200344 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100345 return
346 fi
347
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100348 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100349
Paul Bakkerb7584a52016-05-10 10:50:43 +0100350 # Do we only run numbered tests?
351 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
352 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
353 else
354 SKIP_NEXT="YES"
355 fi
356
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200357 # should we skip?
358 if [ "X$SKIP_NEXT" = "XYES" ]; then
359 SKIP_NEXT="NO"
360 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200361 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200362 return
363 fi
364
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200365 # does this test use a proxy?
366 if [ "X$1" = "X-p" ]; then
367 PXY_CMD="$2"
368 shift 2
369 else
370 PXY_CMD=""
371 fi
372
373 # get commands and client output
374 SRV_CMD="$1"
375 CLI_CMD="$2"
376 CLI_EXPECT="$3"
377 shift 3
378
379 # fix client port
380 if [ -n "$PXY_CMD" ]; then
381 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
382 else
383 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
384 fi
385
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200386 # update DTLS variable
387 detect_dtls "$SRV_CMD"
388
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100389 # prepend valgrind to our commands if active
390 if [ "$MEMCHECK" -gt 0 ]; then
391 if is_polar "$SRV_CMD"; then
392 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
393 fi
394 if is_polar "$CLI_CMD"; then
395 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
396 fi
397 fi
398
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200399 TIMES_LEFT=2
400 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200401 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200402
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200403 # run the commands
404 if [ -n "$PXY_CMD" ]; then
405 echo "$PXY_CMD" > $PXY_OUT
406 $PXY_CMD >> $PXY_OUT 2>&1 &
407 PXY_PID=$!
408 # assume proxy starts faster than server
409 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200410
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200411 check_osrv_dtls
412 echo "$SRV_CMD" > $SRV_OUT
413 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
414 SRV_PID=$!
415 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200416
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200417 echo "$CLI_CMD" > $CLI_OUT
418 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
419 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100420
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200421 # terminate the server (and the proxy)
422 kill $SRV_PID
423 wait $SRV_PID
424 if [ -n "$PXY_CMD" ]; then
425 kill $PXY_PID >/dev/null 2>&1
426 wait $PXY_PID
427 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100428
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200429 # retry only on timeouts
430 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
431 printf "RETRY "
432 else
433 TIMES_LEFT=0
434 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200435 done
436
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100437 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200438 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100439 # expected client exit to incorrectly succeed in case of catastrophic
440 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100441 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200442 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100443 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100444 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100445 return
446 fi
447 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100448 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200449 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100450 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100451 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100452 return
453 fi
454 fi
455
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100456 # check server exit code
457 if [ $? != 0 ]; then
458 fail "server fail"
459 return
460 fi
461
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100462 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100463 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
464 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100465 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200466 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100467 return
468 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100469
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100470 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200471 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100472 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100473 while [ $# -gt 0 ]
474 do
475 case $1 in
476 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100477 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100478 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100479 return
480 fi
481 ;;
482
483 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100484 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100485 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100486 return
487 fi
488 ;;
489
490 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100491 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100492 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100493 return
494 fi
495 ;;
496
497 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100498 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100499 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100500 return
501 fi
502 ;;
503
504 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200505 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100506 exit 1
507 esac
508 shift 2
509 done
510
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100511 # check valgrind's results
512 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200513 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100514 fail "Server has memory errors"
515 return
516 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200517 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100518 fail "Client has memory errors"
519 return
520 fi
521 fi
522
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100523 # if we're here, everything is ok
524 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100525 if [ "$PRESERVE_LOGS" -gt 0 ]; then
526 mv $SRV_OUT o-srv-${TESTS}.log
527 mv $CLI_OUT o-cli-${TESTS}.log
528 fi
529
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200530 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100531}
532
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100533cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200534 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200535 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
536 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
537 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
538 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100539 exit 1
540}
541
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100542#
543# MAIN
544#
545
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000546if cd $( dirname $0 ); then :; else
547 echo "cd $( dirname $0 ) failed" >&2
548 exit 1
549fi
550
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100551get_options "$@"
552
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100553# sanity checks, avoid an avalanche of errors
554if [ ! -x "$P_SRV" ]; then
555 echo "Command '$P_SRV' is not an executable file"
556 exit 1
557fi
558if [ ! -x "$P_CLI" ]; then
559 echo "Command '$P_CLI' is not an executable file"
560 exit 1
561fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200562if [ ! -x "$P_PXY" ]; then
563 echo "Command '$P_PXY' is not an executable file"
564 exit 1
565fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100566if [ "$MEMCHECK" -gt 0 ]; then
567 if which valgrind >/dev/null 2>&1; then :; else
568 echo "Memcheck not possible. Valgrind not found"
569 exit 1
570 fi
571fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100572if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
573 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100574 exit 1
575fi
576
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200577# used by watchdog
578MAIN_PID="$$"
579
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200580# be more patient with valgrind
581if [ "$MEMCHECK" -gt 0 ]; then
582 START_DELAY=3
583 DOG_DELAY=30
584else
585 START_DELAY=1
586 DOG_DELAY=10
587fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200588CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100589SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200590
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200591# Pick a "unique" server port in the range 10000-19999, and a proxy port
592PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000593PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200594SRV_PORT="1$PORT_BASE"
595PXY_PORT="2$PORT_BASE"
596unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200597
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200598# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000599# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200600P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
601P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100602P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200603O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200604O_CLI="$O_CLI -connect localhost:+SRV_PORT"
605G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000606G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200607
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200608# Also pick a unique name for intermediate files
609SRV_OUT="srv_out.$$"
610CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200611PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200612SESSION="session.$$"
613
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200614SKIP_NEXT="NO"
615
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100616trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100617
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200618# Basic test
619
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200620# Checks that:
621# - things work with all ciphersuites active (used with config-full in all.sh)
622# - the expected (highest security) parameters are selected
623# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200624run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200625 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200626 "$P_CLI" \
627 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200628 -s "Protocol is TLSv1.2" \
629 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
630 -s "client hello v3, signature_algorithm ext: 6" \
631 -s "ECDHE curve: secp521r1" \
632 -S "error" \
633 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200634
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000635run_test "Default, DTLS" \
636 "$P_SRV dtls=1" \
637 "$P_CLI dtls=1" \
638 0 \
639 -s "Protocol is DTLSv1.2" \
640 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
641
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100642# Tests for rc4 option
643
Simon Butchera410af52016-05-19 22:12:18 +0100644requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100645run_test "RC4: server disabled, client enabled" \
646 "$P_SRV" \
647 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
648 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100649 -s "SSL - The server has no ciphersuites in common"
650
Simon Butchera410af52016-05-19 22:12:18 +0100651requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100652run_test "RC4: server half, client enabled" \
653 "$P_SRV arc4=1" \
654 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
655 1 \
656 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100657
658run_test "RC4: server enabled, client disabled" \
659 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
660 "$P_CLI" \
661 1 \
662 -s "SSL - The server has no ciphersuites in common"
663
664run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100665 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100666 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
667 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100668 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100669 -S "SSL - The server has no ciphersuites in common"
670
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100671# Tests for Truncated HMAC extension
672
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100673run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200674 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100675 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100676 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100677 -s "dumping 'computed mac' (20 bytes)" \
678 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100679
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100680run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200681 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100682 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
683 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100684 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100685 -s "dumping 'computed mac' (20 bytes)" \
686 -S "dumping 'computed mac' (10 bytes)"
687
688run_test "Truncated HMAC: client enabled, server default" \
689 "$P_SRV debug_level=4" \
690 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
691 trunc_hmac=1" \
692 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100693 -s "dumping 'computed mac' (20 bytes)" \
694 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100695
696run_test "Truncated HMAC: client enabled, server disabled" \
697 "$P_SRV debug_level=4 trunc_hmac=0" \
698 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
699 trunc_hmac=1" \
700 0 \
701 -s "dumping 'computed mac' (20 bytes)" \
702 -S "dumping 'computed mac' (10 bytes)"
703
704run_test "Truncated HMAC: client enabled, server enabled" \
705 "$P_SRV debug_level=4 trunc_hmac=1" \
706 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
707 trunc_hmac=1" \
708 0 \
709 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100710 -s "dumping 'computed mac' (10 bytes)"
711
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100712# Tests for Encrypt-then-MAC extension
713
714run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100715 "$P_SRV debug_level=3 \
716 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100717 "$P_CLI debug_level=3" \
718 0 \
719 -c "client hello, adding encrypt_then_mac extension" \
720 -s "found encrypt then mac extension" \
721 -s "server hello, adding encrypt then mac extension" \
722 -c "found encrypt_then_mac extension" \
723 -c "using encrypt then mac" \
724 -s "using encrypt then mac"
725
726run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100727 "$P_SRV debug_level=3 etm=0 \
728 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100729 "$P_CLI debug_level=3 etm=1" \
730 0 \
731 -c "client hello, adding encrypt_then_mac extension" \
732 -s "found encrypt then mac extension" \
733 -S "server hello, adding encrypt then mac extension" \
734 -C "found encrypt_then_mac extension" \
735 -C "using encrypt then mac" \
736 -S "using encrypt then mac"
737
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100738run_test "Encrypt then MAC: client enabled, aead cipher" \
739 "$P_SRV debug_level=3 etm=1 \
740 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
741 "$P_CLI debug_level=3 etm=1" \
742 0 \
743 -c "client hello, adding encrypt_then_mac extension" \
744 -s "found encrypt then mac extension" \
745 -S "server hello, adding encrypt then mac extension" \
746 -C "found encrypt_then_mac extension" \
747 -C "using encrypt then mac" \
748 -S "using encrypt then mac"
749
750run_test "Encrypt then MAC: client enabled, stream cipher" \
751 "$P_SRV debug_level=3 etm=1 \
752 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100753 "$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 +0100754 0 \
755 -c "client hello, adding encrypt_then_mac extension" \
756 -s "found encrypt then mac extension" \
757 -S "server hello, adding encrypt then mac extension" \
758 -C "found encrypt_then_mac extension" \
759 -C "using encrypt then mac" \
760 -S "using encrypt then mac"
761
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100762run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100763 "$P_SRV debug_level=3 etm=1 \
764 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100765 "$P_CLI debug_level=3 etm=0" \
766 0 \
767 -C "client hello, adding encrypt_then_mac extension" \
768 -S "found encrypt then mac extension" \
769 -S "server hello, adding encrypt then mac extension" \
770 -C "found encrypt_then_mac extension" \
771 -C "using encrypt then mac" \
772 -S "using encrypt then mac"
773
Janos Follathe2681a42016-03-07 15:57:05 +0000774requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100775run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100776 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100777 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100778 "$P_CLI debug_level=3 force_version=ssl3" \
779 0 \
780 -C "client hello, adding encrypt_then_mac extension" \
781 -S "found encrypt then mac extension" \
782 -S "server hello, adding encrypt then mac extension" \
783 -C "found encrypt_then_mac extension" \
784 -C "using encrypt then mac" \
785 -S "using encrypt then mac"
786
Janos Follathe2681a42016-03-07 15:57:05 +0000787requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100788run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100789 "$P_SRV debug_level=3 force_version=ssl3 \
790 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100791 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100792 0 \
793 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100794 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100795 -S "server hello, adding encrypt then mac extension" \
796 -C "found encrypt_then_mac extension" \
797 -C "using encrypt then mac" \
798 -S "using encrypt then mac"
799
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200800# Tests for Extended Master Secret extension
801
802run_test "Extended Master Secret: default" \
803 "$P_SRV debug_level=3" \
804 "$P_CLI debug_level=3" \
805 0 \
806 -c "client hello, adding extended_master_secret extension" \
807 -s "found extended master secret extension" \
808 -s "server hello, adding extended master secret extension" \
809 -c "found extended_master_secret extension" \
810 -c "using extended master secret" \
811 -s "using extended master secret"
812
813run_test "Extended Master Secret: client enabled, server disabled" \
814 "$P_SRV debug_level=3 extended_ms=0" \
815 "$P_CLI debug_level=3 extended_ms=1" \
816 0 \
817 -c "client hello, adding extended_master_secret extension" \
818 -s "found extended master secret extension" \
819 -S "server hello, adding extended master secret extension" \
820 -C "found extended_master_secret extension" \
821 -C "using extended master secret" \
822 -S "using extended master secret"
823
824run_test "Extended Master Secret: client disabled, server enabled" \
825 "$P_SRV debug_level=3 extended_ms=1" \
826 "$P_CLI debug_level=3 extended_ms=0" \
827 0 \
828 -C "client hello, adding extended_master_secret extension" \
829 -S "found extended master secret extension" \
830 -S "server hello, adding extended master secret extension" \
831 -C "found extended_master_secret extension" \
832 -C "using extended master secret" \
833 -S "using extended master secret"
834
Janos Follathe2681a42016-03-07 15:57:05 +0000835requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200836run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100837 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200838 "$P_CLI debug_level=3 force_version=ssl3" \
839 0 \
840 -C "client hello, adding extended_master_secret extension" \
841 -S "found extended master secret extension" \
842 -S "server hello, adding extended master secret extension" \
843 -C "found extended_master_secret extension" \
844 -C "using extended master secret" \
845 -S "using extended master secret"
846
Janos Follathe2681a42016-03-07 15:57:05 +0000847requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200848run_test "Extended Master Secret: client enabled, server SSLv3" \
849 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100850 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200851 0 \
852 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100853 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200854 -S "server hello, adding extended master secret extension" \
855 -C "found extended_master_secret extension" \
856 -C "using extended master secret" \
857 -S "using extended master secret"
858
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200859# Tests for FALLBACK_SCSV
860
861run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200862 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200863 "$P_CLI debug_level=3 force_version=tls1_1" \
864 0 \
865 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200866 -S "received FALLBACK_SCSV" \
867 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200868 -C "is a fatal alert message (msg 86)"
869
870run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200871 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200872 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
873 0 \
874 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200875 -S "received FALLBACK_SCSV" \
876 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200877 -C "is a fatal alert message (msg 86)"
878
879run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200880 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200881 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200882 1 \
883 -c "adding FALLBACK_SCSV" \
884 -s "received FALLBACK_SCSV" \
885 -s "inapropriate fallback" \
886 -c "is a fatal alert message (msg 86)"
887
888run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200889 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200890 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200891 0 \
892 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200893 -s "received FALLBACK_SCSV" \
894 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200895 -C "is a fatal alert message (msg 86)"
896
897requires_openssl_with_fallback_scsv
898run_test "Fallback SCSV: default, openssl server" \
899 "$O_SRV" \
900 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
901 0 \
902 -C "adding FALLBACK_SCSV" \
903 -C "is a fatal alert message (msg 86)"
904
905requires_openssl_with_fallback_scsv
906run_test "Fallback SCSV: enabled, openssl server" \
907 "$O_SRV" \
908 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
909 1 \
910 -c "adding FALLBACK_SCSV" \
911 -c "is a fatal alert message (msg 86)"
912
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200913requires_openssl_with_fallback_scsv
914run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200915 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200916 "$O_CLI -tls1_1" \
917 0 \
918 -S "received FALLBACK_SCSV" \
919 -S "inapropriate fallback"
920
921requires_openssl_with_fallback_scsv
922run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200923 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200924 "$O_CLI -tls1_1 -fallback_scsv" \
925 1 \
926 -s "received FALLBACK_SCSV" \
927 -s "inapropriate fallback"
928
929requires_openssl_with_fallback_scsv
930run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200931 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200932 "$O_CLI -fallback_scsv" \
933 0 \
934 -s "received FALLBACK_SCSV" \
935 -S "inapropriate fallback"
936
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100937# Tests for CBC 1/n-1 record splitting
938
939run_test "CBC Record splitting: TLS 1.2, no splitting" \
940 "$P_SRV" \
941 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
942 request_size=123 force_version=tls1_2" \
943 0 \
944 -s "Read from client: 123 bytes read" \
945 -S "Read from client: 1 bytes read" \
946 -S "122 bytes read"
947
948run_test "CBC Record splitting: TLS 1.1, no splitting" \
949 "$P_SRV" \
950 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
951 request_size=123 force_version=tls1_1" \
952 0 \
953 -s "Read from client: 123 bytes read" \
954 -S "Read from client: 1 bytes read" \
955 -S "122 bytes read"
956
957run_test "CBC Record splitting: TLS 1.0, splitting" \
958 "$P_SRV" \
959 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
960 request_size=123 force_version=tls1" \
961 0 \
962 -S "Read from client: 123 bytes read" \
963 -s "Read from client: 1 bytes read" \
964 -s "122 bytes read"
965
Janos Follathe2681a42016-03-07 15:57:05 +0000966requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100967run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100968 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100969 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
970 request_size=123 force_version=ssl3" \
971 0 \
972 -S "Read from client: 123 bytes read" \
973 -s "Read from client: 1 bytes read" \
974 -s "122 bytes read"
975
976run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100977 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100978 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
979 request_size=123 force_version=tls1" \
980 0 \
981 -s "Read from client: 123 bytes read" \
982 -S "Read from client: 1 bytes read" \
983 -S "122 bytes read"
984
985run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
986 "$P_SRV" \
987 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
988 request_size=123 force_version=tls1 recsplit=0" \
989 0 \
990 -s "Read from client: 123 bytes read" \
991 -S "Read from client: 1 bytes read" \
992 -S "122 bytes read"
993
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100994run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
995 "$P_SRV nbio=2" \
996 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
997 request_size=123 force_version=tls1" \
998 0 \
999 -S "Read from client: 123 bytes read" \
1000 -s "Read from client: 1 bytes read" \
1001 -s "122 bytes read"
1002
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001003# Tests for Session Tickets
1004
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001005run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001006 "$P_SRV debug_level=3 tickets=1" \
1007 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001008 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001009 -c "client hello, adding session ticket extension" \
1010 -s "found session ticket extension" \
1011 -s "server hello, adding session ticket extension" \
1012 -c "found session_ticket extension" \
1013 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001014 -S "session successfully restored from cache" \
1015 -s "session successfully restored from ticket" \
1016 -s "a session has been resumed" \
1017 -c "a session has been resumed"
1018
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001019run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001020 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1021 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001022 0 \
1023 -c "client hello, adding session ticket extension" \
1024 -s "found session ticket extension" \
1025 -s "server hello, adding session ticket extension" \
1026 -c "found session_ticket extension" \
1027 -c "parse new session ticket" \
1028 -S "session successfully restored from cache" \
1029 -s "session successfully restored from ticket" \
1030 -s "a session has been resumed" \
1031 -c "a session has been resumed"
1032
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001033run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001034 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1035 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001036 0 \
1037 -c "client hello, adding session ticket extension" \
1038 -s "found session ticket extension" \
1039 -s "server hello, adding session ticket extension" \
1040 -c "found session_ticket extension" \
1041 -c "parse new session ticket" \
1042 -S "session successfully restored from cache" \
1043 -S "session successfully restored from ticket" \
1044 -S "a session has been resumed" \
1045 -C "a session has been resumed"
1046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001047run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001048 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001049 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001050 0 \
1051 -c "client hello, adding session ticket extension" \
1052 -c "found session_ticket extension" \
1053 -c "parse new session ticket" \
1054 -c "a session has been resumed"
1055
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001056run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001057 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001058 "( $O_CLI -sess_out $SESSION; \
1059 $O_CLI -sess_in $SESSION; \
1060 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001061 0 \
1062 -s "found session ticket extension" \
1063 -s "server hello, adding session ticket extension" \
1064 -S "session successfully restored from cache" \
1065 -s "session successfully restored from ticket" \
1066 -s "a session has been resumed"
1067
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001068# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001070run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001071 "$P_SRV debug_level=3 tickets=0" \
1072 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001073 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001074 -c "client hello, adding session ticket extension" \
1075 -s "found session ticket extension" \
1076 -S "server hello, adding session ticket extension" \
1077 -C "found session_ticket extension" \
1078 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001079 -s "session successfully restored from cache" \
1080 -S "session successfully restored from ticket" \
1081 -s "a session has been resumed" \
1082 -c "a session has been resumed"
1083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001084run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001085 "$P_SRV debug_level=3 tickets=1" \
1086 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001087 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001088 -C "client hello, adding session ticket extension" \
1089 -S "found session ticket extension" \
1090 -S "server hello, adding session ticket extension" \
1091 -C "found session_ticket extension" \
1092 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001093 -s "session successfully restored from cache" \
1094 -S "session successfully restored from ticket" \
1095 -s "a session has been resumed" \
1096 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001098run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001099 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1100 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001101 0 \
1102 -S "session successfully restored from cache" \
1103 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001104 -S "a session has been resumed" \
1105 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001107run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001108 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1109 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001110 0 \
1111 -s "session successfully restored from cache" \
1112 -S "session successfully restored from ticket" \
1113 -s "a session has been resumed" \
1114 -c "a session has been resumed"
1115
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001116run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001117 "$P_SRV debug_level=3 tickets=0" \
1118 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001119 0 \
1120 -s "session successfully restored from cache" \
1121 -S "session successfully restored from ticket" \
1122 -s "a session has been resumed" \
1123 -c "a session has been resumed"
1124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001125run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001126 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1127 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001128 0 \
1129 -S "session successfully restored from cache" \
1130 -S "session successfully restored from ticket" \
1131 -S "a session has been resumed" \
1132 -C "a session has been resumed"
1133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001134run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001135 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1136 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001137 0 \
1138 -s "session successfully restored from cache" \
1139 -S "session successfully restored from ticket" \
1140 -s "a session has been resumed" \
1141 -c "a session has been resumed"
1142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001143run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001144 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001145 "( $O_CLI -sess_out $SESSION; \
1146 $O_CLI -sess_in $SESSION; \
1147 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001148 0 \
1149 -s "found session ticket extension" \
1150 -S "server hello, adding session ticket extension" \
1151 -s "session successfully restored from cache" \
1152 -S "session successfully restored from ticket" \
1153 -s "a session has been resumed"
1154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001155run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001156 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001157 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001158 0 \
1159 -C "found session_ticket extension" \
1160 -C "parse new session ticket" \
1161 -c "a session has been resumed"
1162
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001163# Tests for Max Fragment Length extension
1164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001165run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001166 "$P_SRV debug_level=3" \
1167 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001168 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001169 -c "Maximum fragment length is 16384" \
1170 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001171 -C "client hello, adding max_fragment_length extension" \
1172 -S "found max fragment length extension" \
1173 -S "server hello, max_fragment_length extension" \
1174 -C "found max_fragment_length extension"
1175
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001176run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001177 "$P_SRV debug_level=3" \
1178 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001179 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001180 -c "Maximum fragment length is 4096" \
1181 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001182 -c "client hello, adding max_fragment_length extension" \
1183 -s "found max fragment length extension" \
1184 -s "server hello, max_fragment_length extension" \
1185 -c "found max_fragment_length extension"
1186
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001187run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001188 "$P_SRV debug_level=3 max_frag_len=4096" \
1189 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001190 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001191 -c "Maximum fragment length is 16384" \
1192 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001193 -C "client hello, adding max_fragment_length extension" \
1194 -S "found max fragment length extension" \
1195 -S "server hello, max_fragment_length extension" \
1196 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001198requires_gnutls
1199run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001200 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001201 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001202 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001203 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001204 -c "client hello, adding max_fragment_length extension" \
1205 -c "found max_fragment_length extension"
1206
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001207run_test "Max fragment length: client, message just fits" \
1208 "$P_SRV debug_level=3" \
1209 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1210 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001211 -c "Maximum fragment length is 2048" \
1212 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001213 -c "client hello, adding max_fragment_length extension" \
1214 -s "found max fragment length extension" \
1215 -s "server hello, max_fragment_length extension" \
1216 -c "found max_fragment_length extension" \
1217 -c "2048 bytes written in 1 fragments" \
1218 -s "2048 bytes read"
1219
1220run_test "Max fragment length: client, larger message" \
1221 "$P_SRV debug_level=3" \
1222 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1223 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001224 -c "Maximum fragment length is 2048" \
1225 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001226 -c "client hello, adding max_fragment_length extension" \
1227 -s "found max fragment length extension" \
1228 -s "server hello, max_fragment_length extension" \
1229 -c "found max_fragment_length extension" \
1230 -c "2345 bytes written in 2 fragments" \
1231 -s "2048 bytes read" \
1232 -s "297 bytes read"
1233
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001234run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001235 "$P_SRV debug_level=3 dtls=1" \
1236 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1237 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001238 -c "Maximum fragment length is 2048" \
1239 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001240 -c "client hello, adding max_fragment_length extension" \
1241 -s "found max fragment length extension" \
1242 -s "server hello, max_fragment_length extension" \
1243 -c "found max_fragment_length extension" \
1244 -c "fragment larger than.*maximum"
1245
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001246# Tests for renegotiation
1247
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001248run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001249 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001250 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001251 0 \
1252 -C "client hello, adding renegotiation extension" \
1253 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1254 -S "found renegotiation extension" \
1255 -s "server hello, secure renegotiation extension" \
1256 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001257 -C "=> renegotiate" \
1258 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001259 -S "write hello request"
1260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001261run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001262 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001263 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001264 0 \
1265 -c "client hello, adding renegotiation extension" \
1266 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1267 -s "found renegotiation extension" \
1268 -s "server hello, secure renegotiation extension" \
1269 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001270 -c "=> renegotiate" \
1271 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001272 -S "write hello request"
1273
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001274run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001275 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001276 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001277 0 \
1278 -c "client hello, adding renegotiation extension" \
1279 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1280 -s "found renegotiation extension" \
1281 -s "server hello, secure renegotiation extension" \
1282 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001283 -c "=> renegotiate" \
1284 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001285 -s "write hello request"
1286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001287run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001288 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001289 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001290 0 \
1291 -c "client hello, adding renegotiation extension" \
1292 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1293 -s "found renegotiation extension" \
1294 -s "server hello, secure renegotiation extension" \
1295 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001296 -c "=> renegotiate" \
1297 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001298 -s "write hello request"
1299
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001300run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001301 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001302 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001303 1 \
1304 -c "client hello, adding renegotiation extension" \
1305 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1306 -S "found renegotiation extension" \
1307 -s "server hello, secure renegotiation extension" \
1308 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001309 -c "=> renegotiate" \
1310 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001311 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001312 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001313 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001314
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001315run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001316 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001317 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001318 0 \
1319 -C "client hello, adding renegotiation extension" \
1320 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1321 -S "found renegotiation extension" \
1322 -s "server hello, secure renegotiation extension" \
1323 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001324 -C "=> renegotiate" \
1325 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001326 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001327 -S "SSL - An unexpected message was received from our peer" \
1328 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001330run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001331 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001332 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001333 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001334 0 \
1335 -C "client hello, adding renegotiation extension" \
1336 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1337 -S "found renegotiation extension" \
1338 -s "server hello, secure renegotiation extension" \
1339 -c "found renegotiation extension" \
1340 -C "=> renegotiate" \
1341 -S "=> renegotiate" \
1342 -s "write hello request" \
1343 -S "SSL - An unexpected message was received from our peer" \
1344 -S "failed"
1345
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001346# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001347run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001348 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001349 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001350 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001351 0 \
1352 -C "client hello, adding renegotiation extension" \
1353 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1354 -S "found renegotiation extension" \
1355 -s "server hello, secure renegotiation extension" \
1356 -c "found renegotiation extension" \
1357 -C "=> renegotiate" \
1358 -S "=> renegotiate" \
1359 -s "write hello request" \
1360 -S "SSL - An unexpected message was received from our peer" \
1361 -S "failed"
1362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001363run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001364 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001365 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001366 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001367 0 \
1368 -C "client hello, adding renegotiation extension" \
1369 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1370 -S "found renegotiation extension" \
1371 -s "server hello, secure renegotiation extension" \
1372 -c "found renegotiation extension" \
1373 -C "=> renegotiate" \
1374 -S "=> renegotiate" \
1375 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001376 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001377
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001378run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001379 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001380 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001381 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001382 0 \
1383 -c "client hello, adding renegotiation extension" \
1384 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1385 -s "found renegotiation extension" \
1386 -s "server hello, secure renegotiation extension" \
1387 -c "found renegotiation extension" \
1388 -c "=> renegotiate" \
1389 -s "=> renegotiate" \
1390 -s "write hello request" \
1391 -S "SSL - An unexpected message was received from our peer" \
1392 -S "failed"
1393
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001394run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001395 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001396 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1397 0 \
1398 -C "client hello, adding renegotiation extension" \
1399 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1400 -S "found renegotiation extension" \
1401 -s "server hello, secure renegotiation extension" \
1402 -c "found renegotiation extension" \
1403 -S "record counter limit reached: renegotiate" \
1404 -C "=> renegotiate" \
1405 -S "=> renegotiate" \
1406 -S "write hello request" \
1407 -S "SSL - An unexpected message was received from our peer" \
1408 -S "failed"
1409
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001410# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001411run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001412 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001413 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001414 0 \
1415 -c "client hello, adding renegotiation extension" \
1416 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1417 -s "found renegotiation extension" \
1418 -s "server hello, secure renegotiation extension" \
1419 -c "found renegotiation extension" \
1420 -s "record counter limit reached: renegotiate" \
1421 -c "=> renegotiate" \
1422 -s "=> renegotiate" \
1423 -s "write hello request" \
1424 -S "SSL - An unexpected message was received from our peer" \
1425 -S "failed"
1426
1427run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001428 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001429 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001430 0 \
1431 -c "client hello, adding renegotiation extension" \
1432 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1433 -s "found renegotiation extension" \
1434 -s "server hello, secure renegotiation extension" \
1435 -c "found renegotiation extension" \
1436 -s "record counter limit reached: renegotiate" \
1437 -c "=> renegotiate" \
1438 -s "=> renegotiate" \
1439 -s "write hello request" \
1440 -S "SSL - An unexpected message was received from our peer" \
1441 -S "failed"
1442
1443run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001444 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001445 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1446 0 \
1447 -C "client hello, adding renegotiation extension" \
1448 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1449 -S "found renegotiation extension" \
1450 -s "server hello, secure renegotiation extension" \
1451 -c "found renegotiation extension" \
1452 -S "record counter limit reached: renegotiate" \
1453 -C "=> renegotiate" \
1454 -S "=> renegotiate" \
1455 -S "write hello request" \
1456 -S "SSL - An unexpected message was received from our peer" \
1457 -S "failed"
1458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001459run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001460 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001461 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001462 0 \
1463 -c "client hello, adding renegotiation extension" \
1464 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1465 -s "found renegotiation extension" \
1466 -s "server hello, secure renegotiation extension" \
1467 -c "found renegotiation extension" \
1468 -c "=> renegotiate" \
1469 -s "=> renegotiate" \
1470 -S "write hello request"
1471
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001472run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001473 "$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 +02001474 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001475 0 \
1476 -c "client hello, adding renegotiation extension" \
1477 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1478 -s "found renegotiation extension" \
1479 -s "server hello, secure renegotiation extension" \
1480 -c "found renegotiation extension" \
1481 -c "=> renegotiate" \
1482 -s "=> renegotiate" \
1483 -s "write hello request"
1484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001485run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001486 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001487 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001488 0 \
1489 -c "client hello, adding renegotiation extension" \
1490 -c "found renegotiation extension" \
1491 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001492 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001493 -C "error" \
1494 -c "HTTP/1.0 200 [Oo][Kk]"
1495
Paul Bakker539d9722015-02-08 16:18:35 +01001496requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001497run_test "Renegotiation: gnutls server strict, client-initiated" \
1498 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001499 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001500 0 \
1501 -c "client hello, adding renegotiation extension" \
1502 -c "found renegotiation extension" \
1503 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001504 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001505 -C "error" \
1506 -c "HTTP/1.0 200 [Oo][Kk]"
1507
Paul Bakker539d9722015-02-08 16:18:35 +01001508requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001509run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1510 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1511 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1512 1 \
1513 -c "client hello, adding renegotiation extension" \
1514 -C "found renegotiation extension" \
1515 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001516 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001517 -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 "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1522 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1523 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1524 allow_legacy=0" \
1525 1 \
1526 -c "client hello, adding renegotiation extension" \
1527 -C "found renegotiation extension" \
1528 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001529 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001530 -c "error" \
1531 -C "HTTP/1.0 200 [Oo][Kk]"
1532
Paul Bakker539d9722015-02-08 16:18:35 +01001533requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001534run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1535 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1536 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1537 allow_legacy=1" \
1538 0 \
1539 -c "client hello, adding renegotiation extension" \
1540 -C "found renegotiation extension" \
1541 -c "=> renegotiate" \
1542 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001543 -C "error" \
1544 -c "HTTP/1.0 200 [Oo][Kk]"
1545
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001546run_test "Renegotiation: DTLS, client-initiated" \
1547 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1548 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1549 0 \
1550 -c "client hello, adding renegotiation extension" \
1551 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1552 -s "found renegotiation extension" \
1553 -s "server hello, secure renegotiation extension" \
1554 -c "found renegotiation extension" \
1555 -c "=> renegotiate" \
1556 -s "=> renegotiate" \
1557 -S "write hello request"
1558
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001559run_test "Renegotiation: DTLS, server-initiated" \
1560 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001561 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1562 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001563 0 \
1564 -c "client hello, adding renegotiation extension" \
1565 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1566 -s "found renegotiation extension" \
1567 -s "server hello, secure renegotiation extension" \
1568 -c "found renegotiation extension" \
1569 -c "=> renegotiate" \
1570 -s "=> renegotiate" \
1571 -s "write hello request"
1572
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001573requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001574run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1575 "$G_SRV -u --mtu 4096" \
1576 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1577 0 \
1578 -c "client hello, adding renegotiation extension" \
1579 -c "found renegotiation extension" \
1580 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001581 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001582 -C "error" \
1583 -s "Extra-header:"
1584
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001585# Test for the "secure renegotation" extension only (no actual renegotiation)
1586
Paul Bakker539d9722015-02-08 16:18:35 +01001587requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001588run_test "Renego ext: gnutls server strict, client default" \
1589 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1590 "$P_CLI debug_level=3" \
1591 0 \
1592 -c "found renegotiation extension" \
1593 -C "error" \
1594 -c "HTTP/1.0 200 [Oo][Kk]"
1595
Paul Bakker539d9722015-02-08 16:18:35 +01001596requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001597run_test "Renego ext: gnutls server unsafe, client default" \
1598 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1599 "$P_CLI debug_level=3" \
1600 0 \
1601 -C "found renegotiation extension" \
1602 -C "error" \
1603 -c "HTTP/1.0 200 [Oo][Kk]"
1604
Paul Bakker539d9722015-02-08 16:18:35 +01001605requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001606run_test "Renego ext: gnutls server unsafe, client break legacy" \
1607 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1608 "$P_CLI debug_level=3 allow_legacy=-1" \
1609 1 \
1610 -C "found renegotiation extension" \
1611 -c "error" \
1612 -C "HTTP/1.0 200 [Oo][Kk]"
1613
Paul Bakker539d9722015-02-08 16:18:35 +01001614requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001615run_test "Renego ext: gnutls client strict, server default" \
1616 "$P_SRV debug_level=3" \
1617 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1618 0 \
1619 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1620 -s "server hello, secure renegotiation extension"
1621
Paul Bakker539d9722015-02-08 16:18:35 +01001622requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001623run_test "Renego ext: gnutls client unsafe, server default" \
1624 "$P_SRV debug_level=3" \
1625 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1626 0 \
1627 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1628 -S "server hello, secure renegotiation extension"
1629
Paul Bakker539d9722015-02-08 16:18:35 +01001630requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001631run_test "Renego ext: gnutls client unsafe, server break legacy" \
1632 "$P_SRV debug_level=3 allow_legacy=-1" \
1633 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1634 1 \
1635 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1636 -S "server hello, secure renegotiation extension"
1637
Janos Follath0b242342016-02-17 10:11:21 +00001638# Tests for silently dropping trailing extra bytes in .der certificates
1639
1640requires_gnutls
1641run_test "DER format: no trailing bytes" \
1642 "$P_SRV crt_file=data_files/server5-der0.crt \
1643 key_file=data_files/server5.key" \
1644 "$G_CLI " \
1645 0 \
1646 -c "Handshake was completed" \
1647
1648requires_gnutls
1649run_test "DER format: with a trailing zero byte" \
1650 "$P_SRV crt_file=data_files/server5-der1a.crt \
1651 key_file=data_files/server5.key" \
1652 "$G_CLI " \
1653 0 \
1654 -c "Handshake was completed" \
1655
1656requires_gnutls
1657run_test "DER format: with a trailing random byte" \
1658 "$P_SRV crt_file=data_files/server5-der1b.crt \
1659 key_file=data_files/server5.key" \
1660 "$G_CLI " \
1661 0 \
1662 -c "Handshake was completed" \
1663
1664requires_gnutls
1665run_test "DER format: with 2 trailing random bytes" \
1666 "$P_SRV crt_file=data_files/server5-der2.crt \
1667 key_file=data_files/server5.key" \
1668 "$G_CLI " \
1669 0 \
1670 -c "Handshake was completed" \
1671
1672requires_gnutls
1673run_test "DER format: with 4 trailing random bytes" \
1674 "$P_SRV crt_file=data_files/server5-der4.crt \
1675 key_file=data_files/server5.key" \
1676 "$G_CLI " \
1677 0 \
1678 -c "Handshake was completed" \
1679
1680requires_gnutls
1681run_test "DER format: with 8 trailing random bytes" \
1682 "$P_SRV crt_file=data_files/server5-der8.crt \
1683 key_file=data_files/server5.key" \
1684 "$G_CLI " \
1685 0 \
1686 -c "Handshake was completed" \
1687
1688requires_gnutls
1689run_test "DER format: with 9 trailing random bytes" \
1690 "$P_SRV crt_file=data_files/server5-der9.crt \
1691 key_file=data_files/server5.key" \
1692 "$G_CLI " \
1693 0 \
1694 -c "Handshake was completed" \
1695
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001696# Tests for auth_mode
1697
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001698run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001699 "$P_SRV crt_file=data_files/server5-badsign.crt \
1700 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001701 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001702 1 \
1703 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001704 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001705 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001706 -c "X509 - Certificate verification failed"
1707
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001708run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001709 "$P_SRV crt_file=data_files/server5-badsign.crt \
1710 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001711 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001712 0 \
1713 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001714 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001715 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001716 -C "X509 - Certificate verification failed"
1717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001718run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001719 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001720 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001721 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001722 0 \
1723 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001724 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001725 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001726 -C "X509 - Certificate verification failed"
1727
Simon Butcher99000142016-10-13 17:21:01 +01001728run_test "Authentication: client SHA256, server required" \
1729 "$P_SRV auth_mode=required" \
1730 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1731 key_file=data_files/server6.key \
1732 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1733 0 \
1734 -c "Supported Signature Algorithm found: 4," \
1735 -c "Supported Signature Algorithm found: 5,"
1736
1737run_test "Authentication: client SHA384, server required" \
1738 "$P_SRV auth_mode=required" \
1739 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1740 key_file=data_files/server6.key \
1741 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
1742 0 \
1743 -c "Supported Signature Algorithm found: 4," \
1744 -c "Supported Signature Algorithm found: 5,"
1745
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001746run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001747 "$P_SRV debug_level=3 auth_mode=required" \
1748 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001749 key_file=data_files/server5.key" \
1750 1 \
1751 -S "skip write certificate request" \
1752 -C "skip parse certificate request" \
1753 -c "got a certificate request" \
1754 -C "skip write certificate" \
1755 -C "skip write certificate verify" \
1756 -S "skip parse certificate verify" \
1757 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001758 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001759 -s "! mbedtls_ssl_handshake returned" \
1760 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001761 -s "X509 - Certificate verification failed"
1762
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001763run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001764 "$P_SRV debug_level=3 auth_mode=optional" \
1765 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001766 key_file=data_files/server5.key" \
1767 0 \
1768 -S "skip write certificate request" \
1769 -C "skip parse certificate request" \
1770 -c "got a certificate request" \
1771 -C "skip write certificate" \
1772 -C "skip write certificate verify" \
1773 -S "skip parse certificate verify" \
1774 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001775 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001776 -S "! mbedtls_ssl_handshake returned" \
1777 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001778 -S "X509 - Certificate verification failed"
1779
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001780run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001781 "$P_SRV debug_level=3 auth_mode=none" \
1782 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001783 key_file=data_files/server5.key" \
1784 0 \
1785 -s "skip write certificate request" \
1786 -C "skip parse certificate request" \
1787 -c "got no certificate request" \
1788 -c "skip write certificate" \
1789 -c "skip write certificate verify" \
1790 -s "skip parse certificate verify" \
1791 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001792 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001793 -S "! mbedtls_ssl_handshake returned" \
1794 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001795 -S "X509 - Certificate verification failed"
1796
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001797run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001798 "$P_SRV debug_level=3 auth_mode=optional" \
1799 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001800 0 \
1801 -S "skip write certificate request" \
1802 -C "skip parse certificate request" \
1803 -c "got a certificate request" \
1804 -C "skip write certificate$" \
1805 -C "got no certificate to send" \
1806 -S "SSLv3 client has no certificate" \
1807 -c "skip write certificate verify" \
1808 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001809 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001810 -S "! mbedtls_ssl_handshake returned" \
1811 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001812 -S "X509 - Certificate verification failed"
1813
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001814run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001815 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001816 "$O_CLI" \
1817 0 \
1818 -S "skip write certificate request" \
1819 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001820 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001821 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001822 -S "X509 - Certificate verification failed"
1823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001824run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001825 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001826 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001827 0 \
1828 -C "skip parse certificate request" \
1829 -c "got a certificate request" \
1830 -C "skip write certificate$" \
1831 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001832 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001833
Janos Follathe2681a42016-03-07 15:57:05 +00001834requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001835run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001836 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001837 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001838 0 \
1839 -S "skip write certificate request" \
1840 -C "skip parse certificate request" \
1841 -c "got a certificate request" \
1842 -C "skip write certificate$" \
1843 -c "skip write certificate verify" \
1844 -c "got no certificate to send" \
1845 -s "SSLv3 client has no certificate" \
1846 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001847 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001848 -S "! mbedtls_ssl_handshake returned" \
1849 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001850 -S "X509 - Certificate verification failed"
1851
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001852# Tests for certificate selection based on SHA verson
1853
1854run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1855 "$P_SRV crt_file=data_files/server5.crt \
1856 key_file=data_files/server5.key \
1857 crt_file2=data_files/server5-sha1.crt \
1858 key_file2=data_files/server5.key" \
1859 "$P_CLI force_version=tls1_2" \
1860 0 \
1861 -c "signed using.*ECDSA with SHA256" \
1862 -C "signed using.*ECDSA with SHA1"
1863
1864run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1865 "$P_SRV crt_file=data_files/server5.crt \
1866 key_file=data_files/server5.key \
1867 crt_file2=data_files/server5-sha1.crt \
1868 key_file2=data_files/server5.key" \
1869 "$P_CLI force_version=tls1_1" \
1870 0 \
1871 -C "signed using.*ECDSA with SHA256" \
1872 -c "signed using.*ECDSA with SHA1"
1873
1874run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1875 "$P_SRV crt_file=data_files/server5.crt \
1876 key_file=data_files/server5.key \
1877 crt_file2=data_files/server5-sha1.crt \
1878 key_file2=data_files/server5.key" \
1879 "$P_CLI force_version=tls1" \
1880 0 \
1881 -C "signed using.*ECDSA with SHA256" \
1882 -c "signed using.*ECDSA with SHA1"
1883
1884run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1885 "$P_SRV crt_file=data_files/server5.crt \
1886 key_file=data_files/server5.key \
1887 crt_file2=data_files/server6.crt \
1888 key_file2=data_files/server6.key" \
1889 "$P_CLI force_version=tls1_1" \
1890 0 \
1891 -c "serial number.*09" \
1892 -c "signed using.*ECDSA with SHA256" \
1893 -C "signed using.*ECDSA with SHA1"
1894
1895run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1896 "$P_SRV crt_file=data_files/server6.crt \
1897 key_file=data_files/server6.key \
1898 crt_file2=data_files/server5.crt \
1899 key_file2=data_files/server5.key" \
1900 "$P_CLI force_version=tls1_1" \
1901 0 \
1902 -c "serial number.*0A" \
1903 -c "signed using.*ECDSA with SHA256" \
1904 -C "signed using.*ECDSA with SHA1"
1905
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001906# tests for SNI
1907
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001908run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001909 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001910 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001911 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001912 0 \
1913 -S "parse ServerName extension" \
1914 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1915 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001916
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001917run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001918 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001919 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001920 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 +02001921 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001922 0 \
1923 -s "parse ServerName extension" \
1924 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1925 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001926
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001927run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001928 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001929 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001930 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 +02001931 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001932 0 \
1933 -s "parse ServerName extension" \
1934 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1935 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001936
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001937run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001938 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001939 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001940 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 +02001941 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001942 1 \
1943 -s "parse ServerName extension" \
1944 -s "ssl_sni_wrapper() returned" \
1945 -s "mbedtls_ssl_handshake returned" \
1946 -c "mbedtls_ssl_handshake returned" \
1947 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001948
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001949run_test "SNI: client auth no override: optional" \
1950 "$P_SRV debug_level=3 auth_mode=optional \
1951 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1952 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1953 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001954 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001955 -S "skip write certificate request" \
1956 -C "skip parse certificate request" \
1957 -c "got a certificate request" \
1958 -C "skip write certificate" \
1959 -C "skip write certificate verify" \
1960 -S "skip parse certificate verify"
1961
1962run_test "SNI: client auth override: none -> optional" \
1963 "$P_SRV debug_level=3 auth_mode=none \
1964 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1965 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1966 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001967 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001968 -S "skip write certificate request" \
1969 -C "skip parse certificate request" \
1970 -c "got a certificate request" \
1971 -C "skip write certificate" \
1972 -C "skip write certificate verify" \
1973 -S "skip parse certificate verify"
1974
1975run_test "SNI: client auth override: optional -> none" \
1976 "$P_SRV debug_level=3 auth_mode=optional \
1977 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1978 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1979 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001980 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001981 -s "skip write certificate request" \
1982 -C "skip parse certificate request" \
1983 -c "got no certificate request" \
1984 -c "skip write certificate" \
1985 -c "skip write certificate verify" \
1986 -s "skip parse certificate verify"
1987
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001988run_test "SNI: CA no override" \
1989 "$P_SRV debug_level=3 auth_mode=optional \
1990 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1991 ca_file=data_files/test-ca.crt \
1992 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1993 "$P_CLI debug_level=3 server_name=localhost \
1994 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1995 1 \
1996 -S "skip write certificate request" \
1997 -C "skip parse certificate request" \
1998 -c "got a certificate request" \
1999 -C "skip write certificate" \
2000 -C "skip write certificate verify" \
2001 -S "skip parse certificate verify" \
2002 -s "x509_verify_cert() returned" \
2003 -s "! The certificate is not correctly signed by the trusted CA" \
2004 -S "The certificate has been revoked (is on a CRL)"
2005
2006run_test "SNI: CA override" \
2007 "$P_SRV debug_level=3 auth_mode=optional \
2008 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2009 ca_file=data_files/test-ca.crt \
2010 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2011 "$P_CLI debug_level=3 server_name=localhost \
2012 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2013 0 \
2014 -S "skip write certificate request" \
2015 -C "skip parse certificate request" \
2016 -c "got a certificate request" \
2017 -C "skip write certificate" \
2018 -C "skip write certificate verify" \
2019 -S "skip parse certificate verify" \
2020 -S "x509_verify_cert() returned" \
2021 -S "! The certificate is not correctly signed by the trusted CA" \
2022 -S "The certificate has been revoked (is on a CRL)"
2023
2024run_test "SNI: CA override with CRL" \
2025 "$P_SRV debug_level=3 auth_mode=optional \
2026 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2027 ca_file=data_files/test-ca.crt \
2028 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2029 "$P_CLI debug_level=3 server_name=localhost \
2030 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2031 1 \
2032 -S "skip write certificate request" \
2033 -C "skip parse certificate request" \
2034 -c "got a certificate request" \
2035 -C "skip write certificate" \
2036 -C "skip write certificate verify" \
2037 -S "skip parse certificate verify" \
2038 -s "x509_verify_cert() returned" \
2039 -S "! The certificate is not correctly signed by the trusted CA" \
2040 -s "The certificate has been revoked (is on a CRL)"
2041
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002042# Tests for non-blocking I/O: exercise a variety of handshake flows
2043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002044run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002045 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2046 "$P_CLI nbio=2 tickets=0" \
2047 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002048 -S "mbedtls_ssl_handshake returned" \
2049 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002050 -c "Read from server: .* bytes read"
2051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002052run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002053 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2054 "$P_CLI nbio=2 tickets=0" \
2055 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002056 -S "mbedtls_ssl_handshake returned" \
2057 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002058 -c "Read from server: .* bytes read"
2059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002060run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002061 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2062 "$P_CLI nbio=2 tickets=1" \
2063 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002064 -S "mbedtls_ssl_handshake returned" \
2065 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002066 -c "Read from server: .* bytes read"
2067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002068run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002069 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2070 "$P_CLI nbio=2 tickets=1" \
2071 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002072 -S "mbedtls_ssl_handshake returned" \
2073 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002074 -c "Read from server: .* bytes read"
2075
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002076run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002077 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2078 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2079 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002080 -S "mbedtls_ssl_handshake returned" \
2081 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002082 -c "Read from server: .* bytes read"
2083
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002084run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002085 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2086 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2087 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002088 -S "mbedtls_ssl_handshake returned" \
2089 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002090 -c "Read from server: .* bytes read"
2091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002092run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002093 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2094 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2095 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002096 -S "mbedtls_ssl_handshake returned" \
2097 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002098 -c "Read from server: .* bytes read"
2099
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002100# Tests for version negotiation
2101
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002102run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002103 "$P_SRV" \
2104 "$P_CLI" \
2105 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002106 -S "mbedtls_ssl_handshake returned" \
2107 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002108 -s "Protocol is TLSv1.2" \
2109 -c "Protocol is TLSv1.2"
2110
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002111run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002112 "$P_SRV" \
2113 "$P_CLI max_version=tls1_1" \
2114 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002115 -S "mbedtls_ssl_handshake returned" \
2116 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002117 -s "Protocol is TLSv1.1" \
2118 -c "Protocol is TLSv1.1"
2119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002120run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002121 "$P_SRV max_version=tls1_1" \
2122 "$P_CLI" \
2123 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002124 -S "mbedtls_ssl_handshake returned" \
2125 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002126 -s "Protocol is TLSv1.1" \
2127 -c "Protocol is TLSv1.1"
2128
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002129run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002130 "$P_SRV max_version=tls1_1" \
2131 "$P_CLI max_version=tls1_1" \
2132 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002133 -S "mbedtls_ssl_handshake returned" \
2134 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002135 -s "Protocol is TLSv1.1" \
2136 -c "Protocol is TLSv1.1"
2137
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002138run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002139 "$P_SRV min_version=tls1_1" \
2140 "$P_CLI max_version=tls1_1" \
2141 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002142 -S "mbedtls_ssl_handshake returned" \
2143 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002144 -s "Protocol is TLSv1.1" \
2145 -c "Protocol is TLSv1.1"
2146
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002147run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002148 "$P_SRV max_version=tls1_1" \
2149 "$P_CLI min_version=tls1_1" \
2150 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002151 -S "mbedtls_ssl_handshake returned" \
2152 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002153 -s "Protocol is TLSv1.1" \
2154 -c "Protocol is TLSv1.1"
2155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002156run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002157 "$P_SRV max_version=tls1_1" \
2158 "$P_CLI min_version=tls1_2" \
2159 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002160 -s "mbedtls_ssl_handshake returned" \
2161 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002162 -c "SSL - Handshake protocol not within min/max boundaries"
2163
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002164run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002165 "$P_SRV min_version=tls1_2" \
2166 "$P_CLI max_version=tls1_1" \
2167 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002168 -s "mbedtls_ssl_handshake returned" \
2169 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002170 -s "SSL - Handshake protocol not within min/max boundaries"
2171
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002172# Tests for ALPN extension
2173
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002174run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002175 "$P_SRV debug_level=3" \
2176 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002177 0 \
2178 -C "client hello, adding alpn extension" \
2179 -S "found alpn extension" \
2180 -C "got an alert message, type: \\[2:120]" \
2181 -S "server hello, adding alpn extension" \
2182 -C "found alpn extension " \
2183 -C "Application Layer Protocol is" \
2184 -S "Application Layer Protocol is"
2185
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002186run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002187 "$P_SRV debug_level=3" \
2188 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002189 0 \
2190 -c "client hello, adding alpn extension" \
2191 -s "found alpn extension" \
2192 -C "got an alert message, type: \\[2:120]" \
2193 -S "server hello, adding alpn extension" \
2194 -C "found alpn extension " \
2195 -c "Application Layer Protocol is (none)" \
2196 -S "Application Layer Protocol is"
2197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002198run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002199 "$P_SRV debug_level=3 alpn=abc,1234" \
2200 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002201 0 \
2202 -C "client hello, adding alpn extension" \
2203 -S "found alpn extension" \
2204 -C "got an alert message, type: \\[2:120]" \
2205 -S "server hello, adding alpn extension" \
2206 -C "found alpn extension " \
2207 -C "Application Layer Protocol is" \
2208 -s "Application Layer Protocol is (none)"
2209
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002210run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002211 "$P_SRV debug_level=3 alpn=abc,1234" \
2212 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002213 0 \
2214 -c "client hello, adding alpn extension" \
2215 -s "found alpn extension" \
2216 -C "got an alert message, type: \\[2:120]" \
2217 -s "server hello, adding alpn extension" \
2218 -c "found alpn extension" \
2219 -c "Application Layer Protocol is abc" \
2220 -s "Application Layer Protocol is abc"
2221
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002222run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002223 "$P_SRV debug_level=3 alpn=abc,1234" \
2224 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002225 0 \
2226 -c "client hello, adding alpn extension" \
2227 -s "found alpn extension" \
2228 -C "got an alert message, type: \\[2:120]" \
2229 -s "server hello, adding alpn extension" \
2230 -c "found alpn extension" \
2231 -c "Application Layer Protocol is abc" \
2232 -s "Application Layer Protocol is abc"
2233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002234run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002235 "$P_SRV debug_level=3 alpn=abc,1234" \
2236 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002237 0 \
2238 -c "client hello, adding alpn extension" \
2239 -s "found alpn extension" \
2240 -C "got an alert message, type: \\[2:120]" \
2241 -s "server hello, adding alpn extension" \
2242 -c "found alpn extension" \
2243 -c "Application Layer Protocol is 1234" \
2244 -s "Application Layer Protocol is 1234"
2245
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002246run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002247 "$P_SRV debug_level=3 alpn=abc,123" \
2248 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002249 1 \
2250 -c "client hello, adding alpn extension" \
2251 -s "found alpn extension" \
2252 -c "got an alert message, type: \\[2:120]" \
2253 -S "server hello, adding alpn extension" \
2254 -C "found alpn extension" \
2255 -C "Application Layer Protocol is 1234" \
2256 -S "Application Layer Protocol is 1234"
2257
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002258
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002259# Tests for keyUsage in leaf certificates, part 1:
2260# server-side certificate/suite selection
2261
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002262run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002263 "$P_SRV key_file=data_files/server2.key \
2264 crt_file=data_files/server2.ku-ds.crt" \
2265 "$P_CLI" \
2266 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002267 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002268
2269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002270run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002271 "$P_SRV key_file=data_files/server2.key \
2272 crt_file=data_files/server2.ku-ke.crt" \
2273 "$P_CLI" \
2274 0 \
2275 -c "Ciphersuite is TLS-RSA-WITH-"
2276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002277run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002278 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002279 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002280 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002281 1 \
2282 -C "Ciphersuite is "
2283
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002284run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002285 "$P_SRV key_file=data_files/server5.key \
2286 crt_file=data_files/server5.ku-ds.crt" \
2287 "$P_CLI" \
2288 0 \
2289 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2290
2291
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002292run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002293 "$P_SRV key_file=data_files/server5.key \
2294 crt_file=data_files/server5.ku-ka.crt" \
2295 "$P_CLI" \
2296 0 \
2297 -c "Ciphersuite is TLS-ECDH-"
2298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002299run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002300 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002301 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002302 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002303 1 \
2304 -C "Ciphersuite is "
2305
2306# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002307# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002309run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002310 "$O_SRV -key data_files/server2.key \
2311 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002312 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002313 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2314 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002315 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002316 -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 "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002320 "$O_SRV -key data_files/server2.key \
2321 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002322 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002323 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2324 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002325 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002326 -C "Processing of the Certificate handshake message failed" \
2327 -c "Ciphersuite is TLS-"
2328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002329run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002330 "$O_SRV -key data_files/server2.key \
2331 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002332 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002333 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2334 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002335 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002336 -C "Processing of the Certificate handshake message failed" \
2337 -c "Ciphersuite is TLS-"
2338
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002339run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002340 "$O_SRV -key data_files/server2.key \
2341 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002342 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002343 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2344 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002345 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002346 -c "Processing of the Certificate handshake message failed" \
2347 -C "Ciphersuite is TLS-"
2348
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002349run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2350 "$O_SRV -key data_files/server2.key \
2351 -cert data_files/server2.ku-ke.crt" \
2352 "$P_CLI debug_level=1 auth_mode=optional \
2353 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2354 0 \
2355 -c "bad certificate (usage extensions)" \
2356 -C "Processing of the Certificate handshake message failed" \
2357 -c "Ciphersuite is TLS-" \
2358 -c "! Usage does not match the keyUsage extension"
2359
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002360run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002361 "$O_SRV -key data_files/server2.key \
2362 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002363 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002364 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2365 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002366 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002367 -C "Processing of the Certificate handshake message failed" \
2368 -c "Ciphersuite is TLS-"
2369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002370run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002371 "$O_SRV -key data_files/server2.key \
2372 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002373 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002374 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2375 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002376 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002377 -c "Processing of the Certificate handshake message failed" \
2378 -C "Ciphersuite is TLS-"
2379
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002380run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2381 "$O_SRV -key data_files/server2.key \
2382 -cert data_files/server2.ku-ds.crt" \
2383 "$P_CLI debug_level=1 auth_mode=optional \
2384 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2385 0 \
2386 -c "bad certificate (usage extensions)" \
2387 -C "Processing of the Certificate handshake message failed" \
2388 -c "Ciphersuite is TLS-" \
2389 -c "! Usage does not match the keyUsage extension"
2390
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002391# Tests for keyUsage in leaf certificates, part 3:
2392# server-side checking of client cert
2393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002394run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002395 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002396 "$O_CLI -key data_files/server2.key \
2397 -cert data_files/server2.ku-ds.crt" \
2398 0 \
2399 -S "bad certificate (usage extensions)" \
2400 -S "Processing of the Certificate handshake message failed"
2401
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002402run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002403 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002404 "$O_CLI -key data_files/server2.key \
2405 -cert data_files/server2.ku-ke.crt" \
2406 0 \
2407 -s "bad certificate (usage extensions)" \
2408 -S "Processing of the Certificate handshake message failed"
2409
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002410run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002411 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002412 "$O_CLI -key data_files/server2.key \
2413 -cert data_files/server2.ku-ke.crt" \
2414 1 \
2415 -s "bad certificate (usage extensions)" \
2416 -s "Processing of the Certificate handshake message failed"
2417
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002418run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002419 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002420 "$O_CLI -key data_files/server5.key \
2421 -cert data_files/server5.ku-ds.crt" \
2422 0 \
2423 -S "bad certificate (usage extensions)" \
2424 -S "Processing of the Certificate handshake message failed"
2425
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002426run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002427 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002428 "$O_CLI -key data_files/server5.key \
2429 -cert data_files/server5.ku-ka.crt" \
2430 0 \
2431 -s "bad certificate (usage extensions)" \
2432 -S "Processing of the Certificate handshake message failed"
2433
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002434# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2435
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002436run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002437 "$P_SRV key_file=data_files/server5.key \
2438 crt_file=data_files/server5.eku-srv.crt" \
2439 "$P_CLI" \
2440 0
2441
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002442run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002443 "$P_SRV key_file=data_files/server5.key \
2444 crt_file=data_files/server5.eku-srv.crt" \
2445 "$P_CLI" \
2446 0
2447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002448run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002449 "$P_SRV key_file=data_files/server5.key \
2450 crt_file=data_files/server5.eku-cs_any.crt" \
2451 "$P_CLI" \
2452 0
2453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002454run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002455 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002456 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002457 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002458 1
2459
2460# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2461
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002462run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002463 "$O_SRV -key data_files/server5.key \
2464 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002465 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002466 0 \
2467 -C "bad certificate (usage extensions)" \
2468 -C "Processing of the Certificate handshake message failed" \
2469 -c "Ciphersuite is TLS-"
2470
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002471run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002472 "$O_SRV -key data_files/server5.key \
2473 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002474 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002475 0 \
2476 -C "bad certificate (usage extensions)" \
2477 -C "Processing of the Certificate handshake message failed" \
2478 -c "Ciphersuite is TLS-"
2479
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002480run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002481 "$O_SRV -key data_files/server5.key \
2482 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002483 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002484 0 \
2485 -C "bad certificate (usage extensions)" \
2486 -C "Processing of the Certificate handshake message failed" \
2487 -c "Ciphersuite is TLS-"
2488
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002489run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002490 "$O_SRV -key data_files/server5.key \
2491 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002492 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002493 1 \
2494 -c "bad certificate (usage extensions)" \
2495 -c "Processing of the Certificate handshake message failed" \
2496 -C "Ciphersuite is TLS-"
2497
2498# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2499
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002500run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002501 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002502 "$O_CLI -key data_files/server5.key \
2503 -cert data_files/server5.eku-cli.crt" \
2504 0 \
2505 -S "bad certificate (usage extensions)" \
2506 -S "Processing of the Certificate handshake message failed"
2507
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002508run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002509 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002510 "$O_CLI -key data_files/server5.key \
2511 -cert data_files/server5.eku-srv_cli.crt" \
2512 0 \
2513 -S "bad certificate (usage extensions)" \
2514 -S "Processing of the Certificate handshake message failed"
2515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002516run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002517 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002518 "$O_CLI -key data_files/server5.key \
2519 -cert data_files/server5.eku-cs_any.crt" \
2520 0 \
2521 -S "bad certificate (usage extensions)" \
2522 -S "Processing of the Certificate handshake message failed"
2523
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002524run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002525 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002526 "$O_CLI -key data_files/server5.key \
2527 -cert data_files/server5.eku-cs.crt" \
2528 0 \
2529 -s "bad certificate (usage extensions)" \
2530 -S "Processing of the Certificate handshake message failed"
2531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002532run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002533 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002534 "$O_CLI -key data_files/server5.key \
2535 -cert data_files/server5.eku-cs.crt" \
2536 1 \
2537 -s "bad certificate (usage extensions)" \
2538 -s "Processing of the Certificate handshake message failed"
2539
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002540# Tests for DHM parameters loading
2541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002542run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002543 "$P_SRV" \
2544 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2545 debug_level=3" \
2546 0 \
2547 -c "value of 'DHM: P ' (2048 bits)" \
2548 -c "value of 'DHM: G ' (2048 bits)"
2549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002550run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002551 "$P_SRV dhm_file=data_files/dhparams.pem" \
2552 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2553 debug_level=3" \
2554 0 \
2555 -c "value of 'DHM: P ' (1024 bits)" \
2556 -c "value of 'DHM: G ' (2 bits)"
2557
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002558# Tests for DHM client-side size checking
2559
2560run_test "DHM size: server default, client default, OK" \
2561 "$P_SRV" \
2562 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2563 debug_level=1" \
2564 0 \
2565 -C "DHM prime too short:"
2566
2567run_test "DHM size: server default, client 2048, OK" \
2568 "$P_SRV" \
2569 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2570 debug_level=1 dhmlen=2048" \
2571 0 \
2572 -C "DHM prime too short:"
2573
2574run_test "DHM size: server 1024, client default, OK" \
2575 "$P_SRV dhm_file=data_files/dhparams.pem" \
2576 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2577 debug_level=1" \
2578 0 \
2579 -C "DHM prime too short:"
2580
2581run_test "DHM size: server 1000, client default, rejected" \
2582 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2583 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2584 debug_level=1" \
2585 1 \
2586 -c "DHM prime too short:"
2587
2588run_test "DHM size: server default, client 2049, rejected" \
2589 "$P_SRV" \
2590 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2591 debug_level=1 dhmlen=2049" \
2592 1 \
2593 -c "DHM prime too short:"
2594
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002595# Tests for PSK callback
2596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002597run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002598 "$P_SRV psk=abc123 psk_identity=foo" \
2599 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2600 psk_identity=foo psk=abc123" \
2601 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002602 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002603 -S "SSL - Unknown identity received" \
2604 -S "SSL - Verification of the message MAC failed"
2605
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002606run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002607 "$P_SRV" \
2608 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2609 psk_identity=foo psk=abc123" \
2610 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002611 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002612 -S "SSL - Unknown identity received" \
2613 -S "SSL - Verification of the message MAC failed"
2614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002615run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002616 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2617 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2618 psk_identity=foo psk=abc123" \
2619 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002620 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002621 -s "SSL - Unknown identity received" \
2622 -S "SSL - Verification of the message MAC failed"
2623
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002624run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002625 "$P_SRV psk_list=abc,dead,def,beef" \
2626 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2627 psk_identity=abc psk=dead" \
2628 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002629 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002630 -S "SSL - Unknown identity received" \
2631 -S "SSL - Verification of the message MAC failed"
2632
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002633run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002634 "$P_SRV psk_list=abc,dead,def,beef" \
2635 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2636 psk_identity=def psk=beef" \
2637 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002638 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002639 -S "SSL - Unknown identity received" \
2640 -S "SSL - Verification of the message MAC failed"
2641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002642run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002643 "$P_SRV psk_list=abc,dead,def,beef" \
2644 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2645 psk_identity=ghi psk=beef" \
2646 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002647 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002648 -s "SSL - Unknown identity received" \
2649 -S "SSL - Verification of the message MAC failed"
2650
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002651run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002652 "$P_SRV psk_list=abc,dead,def,beef" \
2653 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2654 psk_identity=abc psk=beef" \
2655 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002656 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002657 -S "SSL - Unknown identity received" \
2658 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002659
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002660# Tests for EC J-PAKE
2661
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002662requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002663run_test "ECJPAKE: client not configured" \
2664 "$P_SRV debug_level=3" \
2665 "$P_CLI debug_level=3" \
2666 0 \
2667 -C "add ciphersuite: c0ff" \
2668 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002669 -S "found ecjpake kkpp extension" \
2670 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002671 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002672 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002673 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002674 -S "None of the common ciphersuites is usable"
2675
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002676requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002677run_test "ECJPAKE: server not configured" \
2678 "$P_SRV debug_level=3" \
2679 "$P_CLI debug_level=3 ecjpake_pw=bla \
2680 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2681 1 \
2682 -c "add ciphersuite: c0ff" \
2683 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002684 -s "found ecjpake kkpp extension" \
2685 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002686 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002687 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002688 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002689 -s "None of the common ciphersuites is usable"
2690
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002691requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002692run_test "ECJPAKE: working, TLS" \
2693 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2694 "$P_CLI debug_level=3 ecjpake_pw=bla \
2695 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002696 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002697 -c "add ciphersuite: c0ff" \
2698 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002699 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002700 -s "found ecjpake kkpp extension" \
2701 -S "skip ecjpake kkpp extension" \
2702 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002703 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002704 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002705 -S "None of the common ciphersuites is usable" \
2706 -S "SSL - Verification of the message MAC failed"
2707
Janos Follath74537a62016-09-02 13:45:28 +01002708server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002709requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002710run_test "ECJPAKE: password mismatch, TLS" \
2711 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2712 "$P_CLI debug_level=3 ecjpake_pw=bad \
2713 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2714 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002715 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002716 -s "SSL - Verification of the message MAC failed"
2717
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002718requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002719run_test "ECJPAKE: working, DTLS" \
2720 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2721 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2722 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2723 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002724 -c "re-using cached ecjpake parameters" \
2725 -S "SSL - Verification of the message MAC failed"
2726
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002727requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002728run_test "ECJPAKE: working, DTLS, no cookie" \
2729 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2730 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2731 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2732 0 \
2733 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002734 -S "SSL - Verification of the message MAC failed"
2735
Janos Follath74537a62016-09-02 13:45:28 +01002736server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002737requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002738run_test "ECJPAKE: password mismatch, DTLS" \
2739 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2740 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2741 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2742 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002743 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002744 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002745
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002746# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002747requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002748run_test "ECJPAKE: working, DTLS, nolog" \
2749 "$P_SRV dtls=1 ecjpake_pw=bla" \
2750 "$P_CLI dtls=1 ecjpake_pw=bla \
2751 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2752 0
2753
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002754# Tests for ciphersuites per version
2755
Janos Follathe2681a42016-03-07 15:57:05 +00002756requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002757run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002758 "$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 +02002759 "$P_CLI force_version=ssl3" \
2760 0 \
2761 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2762
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002763run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002764 "$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 +01002765 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002766 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002767 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002769run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002770 "$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 +02002771 "$P_CLI force_version=tls1_1" \
2772 0 \
2773 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002775run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002776 "$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 +02002777 "$P_CLI force_version=tls1_2" \
2778 0 \
2779 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2780
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002781# Test for ClientHello without extensions
2782
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002783requires_gnutls
2784run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002785 "$P_SRV debug_level=3" \
2786 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2787 0 \
2788 -s "dumping 'client hello extensions' (0 bytes)"
2789
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002790# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002791
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002792run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002793 "$P_SRV" \
2794 "$P_CLI request_size=100" \
2795 0 \
2796 -s "Read from client: 100 bytes read$"
2797
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002798run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002799 "$P_SRV" \
2800 "$P_CLI request_size=500" \
2801 0 \
2802 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002803
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002804# Tests for small packets
2805
Janos Follathe2681a42016-03-07 15:57:05 +00002806requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002807run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002808 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002809 "$P_CLI request_size=1 force_version=ssl3 \
2810 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2811 0 \
2812 -s "Read from client: 1 bytes read"
2813
Janos Follathe2681a42016-03-07 15:57:05 +00002814requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002815run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002816 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002817 "$P_CLI request_size=1 force_version=ssl3 \
2818 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2819 0 \
2820 -s "Read from client: 1 bytes read"
2821
2822run_test "Small packet TLS 1.0 BlockCipher" \
2823 "$P_SRV" \
2824 "$P_CLI request_size=1 force_version=tls1 \
2825 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2826 0 \
2827 -s "Read from client: 1 bytes read"
2828
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002829run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2830 "$P_SRV" \
2831 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2832 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2833 0 \
2834 -s "Read from client: 1 bytes read"
2835
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002836run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2837 "$P_SRV" \
2838 "$P_CLI request_size=1 force_version=tls1 \
2839 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2840 trunc_hmac=1" \
2841 0 \
2842 -s "Read from client: 1 bytes read"
2843
2844run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002845 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002846 "$P_CLI request_size=1 force_version=tls1 \
2847 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2848 trunc_hmac=1" \
2849 0 \
2850 -s "Read from client: 1 bytes read"
2851
2852run_test "Small packet TLS 1.1 BlockCipher" \
2853 "$P_SRV" \
2854 "$P_CLI request_size=1 force_version=tls1_1 \
2855 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2856 0 \
2857 -s "Read from client: 1 bytes read"
2858
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002859run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2860 "$P_SRV" \
2861 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2862 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2863 0 \
2864 -s "Read from client: 1 bytes read"
2865
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002866run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002867 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002868 "$P_CLI request_size=1 force_version=tls1_1 \
2869 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2870 0 \
2871 -s "Read from client: 1 bytes read"
2872
2873run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2874 "$P_SRV" \
2875 "$P_CLI request_size=1 force_version=tls1_1 \
2876 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2877 trunc_hmac=1" \
2878 0 \
2879 -s "Read from client: 1 bytes read"
2880
2881run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002882 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002883 "$P_CLI request_size=1 force_version=tls1_1 \
2884 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2885 trunc_hmac=1" \
2886 0 \
2887 -s "Read from client: 1 bytes read"
2888
2889run_test "Small packet TLS 1.2 BlockCipher" \
2890 "$P_SRV" \
2891 "$P_CLI request_size=1 force_version=tls1_2 \
2892 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2893 0 \
2894 -s "Read from client: 1 bytes read"
2895
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002896run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2897 "$P_SRV" \
2898 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2899 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2900 0 \
2901 -s "Read from client: 1 bytes read"
2902
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002903run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2904 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002905 "$P_CLI request_size=1 force_version=tls1_2 \
2906 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002907 0 \
2908 -s "Read from client: 1 bytes read"
2909
2910run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2911 "$P_SRV" \
2912 "$P_CLI request_size=1 force_version=tls1_2 \
2913 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2914 trunc_hmac=1" \
2915 0 \
2916 -s "Read from client: 1 bytes read"
2917
2918run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002919 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002920 "$P_CLI request_size=1 force_version=tls1_2 \
2921 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2922 0 \
2923 -s "Read from client: 1 bytes read"
2924
2925run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002926 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002927 "$P_CLI request_size=1 force_version=tls1_2 \
2928 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2929 trunc_hmac=1" \
2930 0 \
2931 -s "Read from client: 1 bytes read"
2932
2933run_test "Small packet TLS 1.2 AEAD" \
2934 "$P_SRV" \
2935 "$P_CLI request_size=1 force_version=tls1_2 \
2936 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2937 0 \
2938 -s "Read from client: 1 bytes read"
2939
2940run_test "Small packet TLS 1.2 AEAD shorter tag" \
2941 "$P_SRV" \
2942 "$P_CLI request_size=1 force_version=tls1_2 \
2943 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2944 0 \
2945 -s "Read from client: 1 bytes read"
2946
Janos Follath00efff72016-05-06 13:48:23 +01002947# A test for extensions in SSLv3
2948
2949requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2950run_test "SSLv3 with extensions, server side" \
2951 "$P_SRV min_version=ssl3 debug_level=3" \
2952 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2953 0 \
2954 -S "dumping 'client hello extensions'" \
2955 -S "server hello, total extension length:"
2956
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002957# Test for large packets
2958
Janos Follathe2681a42016-03-07 15:57:05 +00002959requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002960run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002961 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002962 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002963 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2964 0 \
2965 -s "Read from client: 16384 bytes read"
2966
Janos Follathe2681a42016-03-07 15:57:05 +00002967requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002968run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002969 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002970 "$P_CLI request_size=16384 force_version=ssl3 \
2971 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2972 0 \
2973 -s "Read from client: 16384 bytes read"
2974
2975run_test "Large packet TLS 1.0 BlockCipher" \
2976 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002977 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002978 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2979 0 \
2980 -s "Read from client: 16384 bytes read"
2981
2982run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2983 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002984 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002985 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2986 trunc_hmac=1" \
2987 0 \
2988 -s "Read from client: 16384 bytes read"
2989
2990run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002991 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002992 "$P_CLI request_size=16384 force_version=tls1 \
2993 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2994 trunc_hmac=1" \
2995 0 \
2996 -s "Read from client: 16384 bytes read"
2997
2998run_test "Large packet TLS 1.1 BlockCipher" \
2999 "$P_SRV" \
3000 "$P_CLI request_size=16384 force_version=tls1_1 \
3001 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3002 0 \
3003 -s "Read from client: 16384 bytes read"
3004
3005run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003006 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003007 "$P_CLI request_size=16384 force_version=tls1_1 \
3008 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3009 0 \
3010 -s "Read from client: 16384 bytes read"
3011
3012run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3013 "$P_SRV" \
3014 "$P_CLI request_size=16384 force_version=tls1_1 \
3015 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3016 trunc_hmac=1" \
3017 0 \
3018 -s "Read from client: 16384 bytes read"
3019
3020run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003021 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003022 "$P_CLI request_size=16384 force_version=tls1_1 \
3023 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3024 trunc_hmac=1" \
3025 0 \
3026 -s "Read from client: 16384 bytes read"
3027
3028run_test "Large packet TLS 1.2 BlockCipher" \
3029 "$P_SRV" \
3030 "$P_CLI request_size=16384 force_version=tls1_2 \
3031 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3032 0 \
3033 -s "Read from client: 16384 bytes read"
3034
3035run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3036 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003037 "$P_CLI request_size=16384 force_version=tls1_2 \
3038 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003039 0 \
3040 -s "Read from client: 16384 bytes read"
3041
3042run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3043 "$P_SRV" \
3044 "$P_CLI request_size=16384 force_version=tls1_2 \
3045 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3046 trunc_hmac=1" \
3047 0 \
3048 -s "Read from client: 16384 bytes read"
3049
3050run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003051 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003052 "$P_CLI request_size=16384 force_version=tls1_2 \
3053 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3054 0 \
3055 -s "Read from client: 16384 bytes read"
3056
3057run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003058 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003059 "$P_CLI request_size=16384 force_version=tls1_2 \
3060 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3061 trunc_hmac=1" \
3062 0 \
3063 -s "Read from client: 16384 bytes read"
3064
3065run_test "Large packet TLS 1.2 AEAD" \
3066 "$P_SRV" \
3067 "$P_CLI request_size=16384 force_version=tls1_2 \
3068 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3069 0 \
3070 -s "Read from client: 16384 bytes read"
3071
3072run_test "Large packet TLS 1.2 AEAD shorter tag" \
3073 "$P_SRV" \
3074 "$P_CLI request_size=16384 force_version=tls1_2 \
3075 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3076 0 \
3077 -s "Read from client: 16384 bytes read"
3078
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003079# Tests for DTLS HelloVerifyRequest
3080
3081run_test "DTLS cookie: enabled" \
3082 "$P_SRV dtls=1 debug_level=2" \
3083 "$P_CLI dtls=1 debug_level=2" \
3084 0 \
3085 -s "cookie verification failed" \
3086 -s "cookie verification passed" \
3087 -S "cookie verification skipped" \
3088 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003089 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003090 -S "SSL - The requested feature is not available"
3091
3092run_test "DTLS cookie: disabled" \
3093 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3094 "$P_CLI dtls=1 debug_level=2" \
3095 0 \
3096 -S "cookie verification failed" \
3097 -S "cookie verification passed" \
3098 -s "cookie verification skipped" \
3099 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003100 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003101 -S "SSL - The requested feature is not available"
3102
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003103run_test "DTLS cookie: default (failing)" \
3104 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3105 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3106 1 \
3107 -s "cookie verification failed" \
3108 -S "cookie verification passed" \
3109 -S "cookie verification skipped" \
3110 -C "received hello verify request" \
3111 -S "hello verification requested" \
3112 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003113
3114requires_ipv6
3115run_test "DTLS cookie: enabled, IPv6" \
3116 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3117 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3118 0 \
3119 -s "cookie verification failed" \
3120 -s "cookie verification passed" \
3121 -S "cookie verification skipped" \
3122 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003123 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003124 -S "SSL - The requested feature is not available"
3125
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003126run_test "DTLS cookie: enabled, nbio" \
3127 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3128 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3129 0 \
3130 -s "cookie verification failed" \
3131 -s "cookie verification passed" \
3132 -S "cookie verification skipped" \
3133 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003134 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003135 -S "SSL - The requested feature is not available"
3136
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003137# Tests for client reconnecting from the same port with DTLS
3138
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003139not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003140run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003141 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3142 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003143 0 \
3144 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003145 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003146 -S "Client initiated reconnection from same port"
3147
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003148not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003149run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003150 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3151 "$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 +02003152 0 \
3153 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003154 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003155 -s "Client initiated reconnection from same port"
3156
Paul Bakker362689d2016-05-13 10:33:25 +01003157not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3158run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003159 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3160 "$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 +02003161 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003162 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003163 -s "Client initiated reconnection from same port"
3164
Paul Bakker362689d2016-05-13 10:33:25 +01003165only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3166run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3167 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3168 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3169 0 \
3170 -S "The operation timed out" \
3171 -s "Client initiated reconnection from same port"
3172
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003173run_test "DTLS client reconnect from same port: no cookies" \
3174 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003175 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3176 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003177 -s "The operation timed out" \
3178 -S "Client initiated reconnection from same port"
3179
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003180# Tests for various cases of client authentication with DTLS
3181# (focused on handshake flows and message parsing)
3182
3183run_test "DTLS client auth: required" \
3184 "$P_SRV dtls=1 auth_mode=required" \
3185 "$P_CLI dtls=1" \
3186 0 \
3187 -s "Verifying peer X.509 certificate... ok"
3188
3189run_test "DTLS client auth: optional, client has no cert" \
3190 "$P_SRV dtls=1 auth_mode=optional" \
3191 "$P_CLI dtls=1 crt_file=none key_file=none" \
3192 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003193 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003194
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003195run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003196 "$P_SRV dtls=1 auth_mode=none" \
3197 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3198 0 \
3199 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003200 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003201
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003202run_test "DTLS wrong PSK: badmac alert" \
3203 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3204 "$P_CLI dtls=1 psk=abc124" \
3205 1 \
3206 -s "SSL - Verification of the message MAC failed" \
3207 -c "SSL - A fatal alert message was received from our peer"
3208
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003209# Tests for receiving fragmented handshake messages with DTLS
3210
3211requires_gnutls
3212run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3213 "$G_SRV -u --mtu 2048 -a" \
3214 "$P_CLI dtls=1 debug_level=2" \
3215 0 \
3216 -C "found fragmented DTLS handshake message" \
3217 -C "error"
3218
3219requires_gnutls
3220run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3221 "$G_SRV -u --mtu 512" \
3222 "$P_CLI dtls=1 debug_level=2" \
3223 0 \
3224 -c "found fragmented DTLS handshake message" \
3225 -C "error"
3226
3227requires_gnutls
3228run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3229 "$G_SRV -u --mtu 128" \
3230 "$P_CLI dtls=1 debug_level=2" \
3231 0 \
3232 -c "found fragmented DTLS handshake message" \
3233 -C "error"
3234
3235requires_gnutls
3236run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3237 "$G_SRV -u --mtu 128" \
3238 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3239 0 \
3240 -c "found fragmented DTLS handshake message" \
3241 -C "error"
3242
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003243requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003244run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3245 "$G_SRV -u --mtu 256" \
3246 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3247 0 \
3248 -c "found fragmented DTLS handshake message" \
3249 -c "client hello, adding renegotiation extension" \
3250 -c "found renegotiation extension" \
3251 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003252 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003253 -C "error" \
3254 -s "Extra-header:"
3255
3256requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003257run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3258 "$G_SRV -u --mtu 256" \
3259 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3260 0 \
3261 -c "found fragmented DTLS handshake message" \
3262 -c "client hello, adding renegotiation extension" \
3263 -c "found renegotiation extension" \
3264 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003265 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003266 -C "error" \
3267 -s "Extra-header:"
3268
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003269run_test "DTLS reassembly: no fragmentation (openssl server)" \
3270 "$O_SRV -dtls1 -mtu 2048" \
3271 "$P_CLI dtls=1 debug_level=2" \
3272 0 \
3273 -C "found fragmented DTLS handshake message" \
3274 -C "error"
3275
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003276run_test "DTLS reassembly: some fragmentation (openssl server)" \
3277 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003278 "$P_CLI dtls=1 debug_level=2" \
3279 0 \
3280 -c "found fragmented DTLS handshake message" \
3281 -C "error"
3282
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003283run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003284 "$O_SRV -dtls1 -mtu 256" \
3285 "$P_CLI dtls=1 debug_level=2" \
3286 0 \
3287 -c "found fragmented DTLS handshake message" \
3288 -C "error"
3289
3290run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3291 "$O_SRV -dtls1 -mtu 256" \
3292 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3293 0 \
3294 -c "found fragmented DTLS handshake message" \
3295 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003296
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003297# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003298
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003299not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003300run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003301 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003302 "$P_SRV dtls=1 debug_level=2" \
3303 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003304 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003305 -C "replayed record" \
3306 -S "replayed record" \
3307 -C "record from another epoch" \
3308 -S "record from another epoch" \
3309 -C "discarding invalid record" \
3310 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003311 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003312 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003313 -c "HTTP/1.0 200 OK"
3314
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003315not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003316run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003317 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003318 "$P_SRV dtls=1 debug_level=2" \
3319 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003320 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003321 -c "replayed record" \
3322 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003323 -c "discarding invalid record" \
3324 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003325 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003326 -s "Extra-header:" \
3327 -c "HTTP/1.0 200 OK"
3328
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003329run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3330 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003331 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3332 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003333 0 \
3334 -c "replayed record" \
3335 -S "replayed record" \
3336 -c "discarding invalid record" \
3337 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003338 -c "resend" \
3339 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003340 -s "Extra-header:" \
3341 -c "HTTP/1.0 200 OK"
3342
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003343run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003344 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003345 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003346 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003347 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003348 -c "discarding invalid record (mac)" \
3349 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003350 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003351 -c "HTTP/1.0 200 OK" \
3352 -S "too many records with bad MAC" \
3353 -S "Verification of the message MAC failed"
3354
3355run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3356 -p "$P_PXY bad_ad=1" \
3357 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3358 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3359 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003360 -C "discarding invalid record (mac)" \
3361 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003362 -S "Extra-header:" \
3363 -C "HTTP/1.0 200 OK" \
3364 -s "too many records with bad MAC" \
3365 -s "Verification of the message MAC failed"
3366
3367run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3368 -p "$P_PXY bad_ad=1" \
3369 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3370 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3371 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003372 -c "discarding invalid record (mac)" \
3373 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003374 -s "Extra-header:" \
3375 -c "HTTP/1.0 200 OK" \
3376 -S "too many records with bad MAC" \
3377 -S "Verification of the message MAC failed"
3378
3379run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3380 -p "$P_PXY bad_ad=1" \
3381 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3382 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3383 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003384 -c "discarding invalid record (mac)" \
3385 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003386 -s "Extra-header:" \
3387 -c "HTTP/1.0 200 OK" \
3388 -s "too many records with bad MAC" \
3389 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003390
3391run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003392 -p "$P_PXY delay_ccs=1" \
3393 "$P_SRV dtls=1 debug_level=1" \
3394 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003395 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003396 -c "record from another epoch" \
3397 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003398 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003399 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003400 -s "Extra-header:" \
3401 -c "HTTP/1.0 200 OK"
3402
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003403# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003404
Janos Follath74537a62016-09-02 13:45:28 +01003405client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003406run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003407 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003408 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3409 psk=abc123" \
3410 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003411 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3412 0 \
3413 -s "Extra-header:" \
3414 -c "HTTP/1.0 200 OK"
3415
Janos Follath74537a62016-09-02 13:45:28 +01003416client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003417run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3418 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003419 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3420 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003421 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3422 0 \
3423 -s "Extra-header:" \
3424 -c "HTTP/1.0 200 OK"
3425
Janos Follath74537a62016-09-02 13:45:28 +01003426client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003427run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3428 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003429 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3430 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003431 0 \
3432 -s "Extra-header:" \
3433 -c "HTTP/1.0 200 OK"
3434
Janos Follath74537a62016-09-02 13:45:28 +01003435client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003436run_test "DTLS proxy: 3d, FS, client auth" \
3437 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003438 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3439 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003440 0 \
3441 -s "Extra-header:" \
3442 -c "HTTP/1.0 200 OK"
3443
Janos Follath74537a62016-09-02 13:45:28 +01003444client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003445run_test "DTLS proxy: 3d, FS, ticket" \
3446 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003447 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3448 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003449 0 \
3450 -s "Extra-header:" \
3451 -c "HTTP/1.0 200 OK"
3452
Janos Follath74537a62016-09-02 13:45:28 +01003453client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003454run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3455 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003456 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3457 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003458 0 \
3459 -s "Extra-header:" \
3460 -c "HTTP/1.0 200 OK"
3461
Janos Follath74537a62016-09-02 13:45:28 +01003462client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003463run_test "DTLS proxy: 3d, max handshake, nbio" \
3464 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003465 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3466 auth_mode=required" \
3467 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003468 0 \
3469 -s "Extra-header:" \
3470 -c "HTTP/1.0 200 OK"
3471
Janos Follath74537a62016-09-02 13:45:28 +01003472client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003473run_test "DTLS proxy: 3d, min handshake, resumption" \
3474 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3475 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3476 psk=abc123 debug_level=3" \
3477 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3478 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3479 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3480 0 \
3481 -s "a session has been resumed" \
3482 -c "a session has been resumed" \
3483 -s "Extra-header:" \
3484 -c "HTTP/1.0 200 OK"
3485
Janos Follath74537a62016-09-02 13:45:28 +01003486client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003487run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3488 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3489 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3490 psk=abc123 debug_level=3 nbio=2" \
3491 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3492 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3493 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3494 0 \
3495 -s "a session has been resumed" \
3496 -c "a session has been resumed" \
3497 -s "Extra-header:" \
3498 -c "HTTP/1.0 200 OK"
3499
Janos Follath74537a62016-09-02 13:45:28 +01003500client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003501run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003502 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003503 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3504 psk=abc123 renegotiation=1 debug_level=2" \
3505 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3506 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003507 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3508 0 \
3509 -c "=> renegotiate" \
3510 -s "=> renegotiate" \
3511 -s "Extra-header:" \
3512 -c "HTTP/1.0 200 OK"
3513
Janos Follath74537a62016-09-02 13:45:28 +01003514client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003515run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3516 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003517 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3518 psk=abc123 renegotiation=1 debug_level=2" \
3519 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3520 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003521 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3522 0 \
3523 -c "=> renegotiate" \
3524 -s "=> renegotiate" \
3525 -s "Extra-header:" \
3526 -c "HTTP/1.0 200 OK"
3527
Janos Follath74537a62016-09-02 13:45:28 +01003528client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003529run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003530 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003531 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003532 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003533 debug_level=2" \
3534 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003535 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003536 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3537 0 \
3538 -c "=> renegotiate" \
3539 -s "=> renegotiate" \
3540 -s "Extra-header:" \
3541 -c "HTTP/1.0 200 OK"
3542
Janos Follath74537a62016-09-02 13:45:28 +01003543client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003544run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003545 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003546 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003547 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003548 debug_level=2 nbio=2" \
3549 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003550 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003551 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3552 0 \
3553 -c "=> renegotiate" \
3554 -s "=> renegotiate" \
3555 -s "Extra-header:" \
3556 -c "HTTP/1.0 200 OK"
3557
Janos Follath74537a62016-09-02 13:45:28 +01003558client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003559not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003560run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003561 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3562 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003563 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003564 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003565 -c "HTTP/1.0 200 OK"
3566
Janos Follath74537a62016-09-02 13:45:28 +01003567client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003568not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003569run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3570 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3571 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003572 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003573 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003574 -c "HTTP/1.0 200 OK"
3575
Janos Follath74537a62016-09-02 13:45:28 +01003576client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003577not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003578run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3579 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3580 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003581 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003582 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003583 -c "HTTP/1.0 200 OK"
3584
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003585requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003586client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003587not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003588run_test "DTLS proxy: 3d, gnutls server" \
3589 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3590 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003591 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003592 0 \
3593 -s "Extra-header:" \
3594 -c "Extra-header:"
3595
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003596requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003597client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003598not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003599run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3600 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3601 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003602 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003603 0 \
3604 -s "Extra-header:" \
3605 -c "Extra-header:"
3606
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003607requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003608client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003609not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003610run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3611 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3612 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003613 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003614 0 \
3615 -s "Extra-header:" \
3616 -c "Extra-header:"
3617
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003618# Final report
3619
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003620echo "------------------------------------------------------------------------"
3621
3622if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003623 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003624else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003625 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003626fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003627PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003628echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003629
3630exit $FAILS