blob: 7f68249c37fa3a316af07b119376718ba46af76f [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
Gilles Peskinef93c7d32017-04-14 17:55:28 +020052# Pick a "unique" server port in the range 10000-19999, and a proxy
53# port which is this plus 10000. Each port number may be independently
54# overridden by a command line option.
55SRV_PORT=$(($$ % 10000 + 10000))
56PXY_PORT=$((SRV_PORT + 10000))
57
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010058print_usage() {
59 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010060 printf " -h|--help\tPrint this help.\n"
61 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020062 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
63 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010064 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010065 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010066 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020067 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
68 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010069 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010070}
71
72get_options() {
73 while [ $# -gt 0 ]; do
74 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010075 -f|--filter)
76 shift; FILTER=$1
77 ;;
78 -e|--exclude)
79 shift; EXCLUDE=$1
80 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010081 -m|--memcheck)
82 MEMCHECK=1
83 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010084 -n|--number)
85 shift; RUN_TEST_NUMBER=$1
86 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010087 -s|--show-numbers)
88 SHOW_TEST_NUMBER=1
89 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010090 -p|--preserve-logs)
91 PRESERVE_LOGS=1
92 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020093 --port)
94 shift; SRV_PORT=$1
95 ;;
96 --proxy-port)
97 shift; PXY_PORT=$1
98 ;;
Andres AGf04f54d2016-10-10 15:46:20 +010099 --seed)
100 shift; SEED="$1"
101 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100102 -h|--help)
103 print_usage
104 exit 0
105 ;;
106 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200107 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100108 print_usage
109 exit 1
110 ;;
111 esac
112 shift
113 done
114}
115
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100116# skip next test if the flag is not enabled in config.h
117requires_config_enabled() {
118 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
119 SKIP_NEXT="YES"
120 fi
121}
122
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200123# skip next test if OpenSSL doesn't support FALLBACK_SCSV
124requires_openssl_with_fallback_scsv() {
125 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
126 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
127 then
128 OPENSSL_HAS_FBSCSV="YES"
129 else
130 OPENSSL_HAS_FBSCSV="NO"
131 fi
132 fi
133 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
134 SKIP_NEXT="YES"
135 fi
136}
137
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200138# skip next test if GnuTLS isn't available
139requires_gnutls() {
140 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200141 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200142 GNUTLS_AVAILABLE="YES"
143 else
144 GNUTLS_AVAILABLE="NO"
145 fi
146 fi
147 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
148 SKIP_NEXT="YES"
149 fi
150}
151
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200152# skip next test if IPv6 isn't available on this host
153requires_ipv6() {
154 if [ -z "${HAS_IPV6:-}" ]; then
155 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
156 SRV_PID=$!
157 sleep 1
158 kill $SRV_PID >/dev/null 2>&1
159 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
160 HAS_IPV6="NO"
161 else
162 HAS_IPV6="YES"
163 fi
164 rm -r $SRV_OUT
165 fi
166
167 if [ "$HAS_IPV6" = "NO" ]; then
168 SKIP_NEXT="YES"
169 fi
170}
171
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200172# skip the next test if valgrind is in use
173not_with_valgrind() {
174 if [ "$MEMCHECK" -gt 0 ]; then
175 SKIP_NEXT="YES"
176 fi
177}
178
Paul Bakker362689d2016-05-13 10:33:25 +0100179# skip the next test if valgrind is NOT in use
180only_with_valgrind() {
181 if [ "$MEMCHECK" -eq 0 ]; then
182 SKIP_NEXT="YES"
183 fi
184}
185
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200186# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100187client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200188 CLI_DELAY_FACTOR=$1
189}
190
Janos Follath74537a62016-09-02 13:45:28 +0100191# wait for the given seconds after the client finished in the next test
192server_needs_more_time() {
193 SRV_DELAY_SECONDS=$1
194}
195
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100196# print_name <name>
197print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100198 TESTS=$(( $TESTS + 1 ))
199 LINE=""
200
201 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
202 LINE="$TESTS "
203 fi
204
205 LINE="$LINE$1"
206 printf "$LINE "
207 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100208 for i in `seq 1 $LEN`; do printf '.'; done
209 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100210
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100211}
212
213# fail <message>
214fail() {
215 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100216 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100217
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200218 mv $SRV_OUT o-srv-${TESTS}.log
219 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200220 if [ -n "$PXY_CMD" ]; then
221 mv $PXY_OUT o-pxy-${TESTS}.log
222 fi
223 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100224
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200225 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
226 echo " ! server output:"
227 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200228 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200229 echo " ! client output:"
230 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200231 if [ -n "$PXY_CMD" ]; then
232 echo " ! ========================================================"
233 echo " ! proxy output:"
234 cat o-pxy-${TESTS}.log
235 fi
236 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200237 fi
238
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200239 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100240}
241
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100242# is_polar <cmd_line>
243is_polar() {
244 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
245}
246
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200247# openssl s_server doesn't have -www with DTLS
248check_osrv_dtls() {
249 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
250 NEEDS_INPUT=1
251 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
252 else
253 NEEDS_INPUT=0
254 fi
255}
256
257# provide input to commands that need it
258provide_input() {
259 if [ $NEEDS_INPUT -eq 0 ]; then
260 return
261 fi
262
263 while true; do
264 echo "HTTP/1.0 200 OK"
265 sleep 1
266 done
267}
268
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100269# has_mem_err <log_file_name>
270has_mem_err() {
271 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
272 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
273 then
274 return 1 # false: does not have errors
275 else
276 return 0 # true: has errors
277 fi
278}
279
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200280# wait for server to start: two versions depending on lsof availability
281wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200282 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200283 START_TIME=$( date +%s )
284 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200285
286 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200287 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200288 while [ $DONE -eq 0 ]; do
289 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
290 then
291 DONE=1
292 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
293 echo "SERVERSTART TIMEOUT"
294 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
295 DONE=1
296 fi
297 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200298 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200299 while [ $DONE -eq 0 ]; do
300 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
301 then
302 DONE=1
303 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
304 echo "SERVERSTART TIMEOUT"
305 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
306 DONE=1
307 fi
308 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200309 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200310 else
311 sleep "$START_DELAY"
312 fi
313}
314
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200315# wait for client to terminate and set CLI_EXIT
316# must be called right after starting the client
317wait_client_done() {
318 CLI_PID=$!
319
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200320 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
321 CLI_DELAY_FACTOR=1
322
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200323 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200324 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200325
326 wait $CLI_PID
327 CLI_EXIT=$?
328
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200329 kill $DOG_PID >/dev/null 2>&1
330 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200331
332 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100333
334 sleep $SRV_DELAY_SECONDS
335 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200336}
337
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200338# check if the given command uses dtls and sets global variable DTLS
339detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200340 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200341 DTLS=1
342 else
343 DTLS=0
344 fi
345}
346
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200347# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100348# Options: -s pattern pattern that must be present in server output
349# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100350# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100351# -S pattern pattern that must be absent in server output
352# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100353# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100354run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100355 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200356 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100357
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100358 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
359 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200360 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100361 return
362 fi
363
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100364 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100365
Paul Bakkerb7584a52016-05-10 10:50:43 +0100366 # Do we only run numbered tests?
367 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
368 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
369 else
370 SKIP_NEXT="YES"
371 fi
372
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200373 # should we skip?
374 if [ "X$SKIP_NEXT" = "XYES" ]; then
375 SKIP_NEXT="NO"
376 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200377 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200378 return
379 fi
380
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200381 # does this test use a proxy?
382 if [ "X$1" = "X-p" ]; then
383 PXY_CMD="$2"
384 shift 2
385 else
386 PXY_CMD=""
387 fi
388
389 # get commands and client output
390 SRV_CMD="$1"
391 CLI_CMD="$2"
392 CLI_EXPECT="$3"
393 shift 3
394
395 # fix client port
396 if [ -n "$PXY_CMD" ]; then
397 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
398 else
399 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
400 fi
401
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200402 # update DTLS variable
403 detect_dtls "$SRV_CMD"
404
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100405 # prepend valgrind to our commands if active
406 if [ "$MEMCHECK" -gt 0 ]; then
407 if is_polar "$SRV_CMD"; then
408 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
409 fi
410 if is_polar "$CLI_CMD"; then
411 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
412 fi
413 fi
414
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200415 TIMES_LEFT=2
416 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200417 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200418
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200419 # run the commands
420 if [ -n "$PXY_CMD" ]; then
421 echo "$PXY_CMD" > $PXY_OUT
422 $PXY_CMD >> $PXY_OUT 2>&1 &
423 PXY_PID=$!
424 # assume proxy starts faster than server
425 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200426
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200427 check_osrv_dtls
428 echo "$SRV_CMD" > $SRV_OUT
429 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
430 SRV_PID=$!
431 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200432
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200433 echo "$CLI_CMD" > $CLI_OUT
434 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
435 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100436
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200437 # terminate the server (and the proxy)
438 kill $SRV_PID
439 wait $SRV_PID
440 if [ -n "$PXY_CMD" ]; then
441 kill $PXY_PID >/dev/null 2>&1
442 wait $PXY_PID
443 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100444
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200445 # retry only on timeouts
446 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
447 printf "RETRY "
448 else
449 TIMES_LEFT=0
450 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200451 done
452
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100453 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200454 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100455 # expected client exit to incorrectly succeed in case of catastrophic
456 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100457 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200458 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100459 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100460 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100461 return
462 fi
463 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100464 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200465 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100466 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100467 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100468 return
469 fi
470 fi
471
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100472 # check server exit code
473 if [ $? != 0 ]; then
474 fail "server fail"
475 return
476 fi
477
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100478 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100479 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
480 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100481 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200482 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100483 return
484 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100485
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100486 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200487 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100488 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100489 while [ $# -gt 0 ]
490 do
491 case $1 in
492 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100493 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100494 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100495 return
496 fi
497 ;;
498
499 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100500 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100501 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100502 return
503 fi
504 ;;
505
506 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100507 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100508 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100509 return
510 fi
511 ;;
512
513 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100514 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100515 fail "pattern '$2' MUST NOT be present in the Client output"
516 return
517 fi
518 ;;
519
520 # The filtering in the following two options (-u and -U) do the following
521 # - ignore valgrind output
522 # - filter out everything but lines right after the pattern occurances
523 # - keep one of each non-unique line
524 # - count how many lines remain
525 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
526 # if there were no duplicates.
527 "-U")
528 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
529 fail "lines following pattern '$2' must be unique in Server output"
530 return
531 fi
532 ;;
533
534 "-u")
535 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
536 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100537 return
538 fi
539 ;;
540
541 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200542 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100543 exit 1
544 esac
545 shift 2
546 done
547
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100548 # check valgrind's results
549 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200550 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100551 fail "Server has memory errors"
552 return
553 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200554 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100555 fail "Client has memory errors"
556 return
557 fi
558 fi
559
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100560 # if we're here, everything is ok
561 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100562 if [ "$PRESERVE_LOGS" -gt 0 ]; then
563 mv $SRV_OUT o-srv-${TESTS}.log
564 mv $CLI_OUT o-cli-${TESTS}.log
565 fi
566
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200567 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100568}
569
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100570cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200571 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200572 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
573 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
574 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
575 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100576 exit 1
577}
578
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100579#
580# MAIN
581#
582
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000583if cd $( dirname $0 ); then :; else
584 echo "cd $( dirname $0 ) failed" >&2
585 exit 1
586fi
587
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100588get_options "$@"
589
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100590# sanity checks, avoid an avalanche of errors
591if [ ! -x "$P_SRV" ]; then
592 echo "Command '$P_SRV' is not an executable file"
593 exit 1
594fi
595if [ ! -x "$P_CLI" ]; then
596 echo "Command '$P_CLI' is not an executable file"
597 exit 1
598fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200599if [ ! -x "$P_PXY" ]; then
600 echo "Command '$P_PXY' is not an executable file"
601 exit 1
602fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100603if [ "$MEMCHECK" -gt 0 ]; then
604 if which valgrind >/dev/null 2>&1; then :; else
605 echo "Memcheck not possible. Valgrind not found"
606 exit 1
607 fi
608fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100609if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
610 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100611 exit 1
612fi
613
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200614# used by watchdog
615MAIN_PID="$$"
616
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200617# be more patient with valgrind
618if [ "$MEMCHECK" -gt 0 ]; then
619 START_DELAY=3
620 DOG_DELAY=30
621else
622 START_DELAY=1
623 DOG_DELAY=10
624fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200625CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100626SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200627
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200628# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000629# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200630P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
631P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100632P_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 +0200633O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200634O_CLI="$O_CLI -connect localhost:+SRV_PORT"
635G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000636G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200637
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200638# Also pick a unique name for intermediate files
639SRV_OUT="srv_out.$$"
640CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200641PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200642SESSION="session.$$"
643
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200644SKIP_NEXT="NO"
645
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100646trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100647
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200648# Basic test
649
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200650# Checks that:
651# - things work with all ciphersuites active (used with config-full in all.sh)
652# - the expected (highest security) parameters are selected
653# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200654run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200655 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200656 "$P_CLI" \
657 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200658 -s "Protocol is TLSv1.2" \
659 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
660 -s "client hello v3, signature_algorithm ext: 6" \
661 -s "ECDHE curve: secp521r1" \
662 -S "error" \
663 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200664
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000665run_test "Default, DTLS" \
666 "$P_SRV dtls=1" \
667 "$P_CLI dtls=1" \
668 0 \
669 -s "Protocol is DTLSv1.2" \
670 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
671
Simon Butcher8e004102016-10-14 00:48:33 +0100672# Test for uniqueness of IVs in AEAD ciphersuites
673run_test "Unique IV in GCM" \
674 "$P_SRV exchanges=20 debug_level=4" \
675 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
676 0 \
677 -u "IV used" \
678 -U "IV used"
679
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100680# Tests for rc4 option
681
Simon Butchera410af52016-05-19 22:12:18 +0100682requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100683run_test "RC4: server disabled, client enabled" \
684 "$P_SRV" \
685 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
686 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100687 -s "SSL - The server has no ciphersuites in common"
688
Simon Butchera410af52016-05-19 22:12:18 +0100689requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100690run_test "RC4: server half, client enabled" \
691 "$P_SRV arc4=1" \
692 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
693 1 \
694 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100695
696run_test "RC4: server enabled, client disabled" \
697 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
698 "$P_CLI" \
699 1 \
700 -s "SSL - The server has no ciphersuites in common"
701
702run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100703 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100704 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
705 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100706 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100707 -S "SSL - The server has no ciphersuites in common"
708
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100709# Tests for Truncated HMAC extension
710
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100711run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200712 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100713 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100714 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100715 -s "dumping 'computed mac' (20 bytes)" \
716 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100717
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100718run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200719 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100720 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
721 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100722 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100723 -s "dumping 'computed mac' (20 bytes)" \
724 -S "dumping 'computed mac' (10 bytes)"
725
726run_test "Truncated HMAC: client enabled, server default" \
727 "$P_SRV debug_level=4" \
728 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
729 trunc_hmac=1" \
730 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100731 -s "dumping 'computed mac' (20 bytes)" \
732 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100733
734run_test "Truncated HMAC: client enabled, server disabled" \
735 "$P_SRV debug_level=4 trunc_hmac=0" \
736 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
737 trunc_hmac=1" \
738 0 \
739 -s "dumping 'computed mac' (20 bytes)" \
740 -S "dumping 'computed mac' (10 bytes)"
741
742run_test "Truncated HMAC: client enabled, server enabled" \
743 "$P_SRV debug_level=4 trunc_hmac=1" \
744 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
745 trunc_hmac=1" \
746 0 \
747 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100748 -s "dumping 'computed mac' (10 bytes)"
749
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100750# Tests for Encrypt-then-MAC extension
751
752run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100753 "$P_SRV debug_level=3 \
754 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100755 "$P_CLI debug_level=3" \
756 0 \
757 -c "client hello, adding encrypt_then_mac extension" \
758 -s "found encrypt then mac extension" \
759 -s "server hello, adding encrypt then mac extension" \
760 -c "found encrypt_then_mac extension" \
761 -c "using encrypt then mac" \
762 -s "using encrypt then mac"
763
764run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100765 "$P_SRV debug_level=3 etm=0 \
766 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100767 "$P_CLI debug_level=3 etm=1" \
768 0 \
769 -c "client hello, adding encrypt_then_mac extension" \
770 -s "found encrypt then mac extension" \
771 -S "server hello, adding encrypt then mac extension" \
772 -C "found encrypt_then_mac extension" \
773 -C "using encrypt then mac" \
774 -S "using encrypt then mac"
775
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100776run_test "Encrypt then MAC: client enabled, aead cipher" \
777 "$P_SRV debug_level=3 etm=1 \
778 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
779 "$P_CLI debug_level=3 etm=1" \
780 0 \
781 -c "client hello, adding encrypt_then_mac extension" \
782 -s "found encrypt then mac extension" \
783 -S "server hello, adding encrypt then mac extension" \
784 -C "found encrypt_then_mac extension" \
785 -C "using encrypt then mac" \
786 -S "using encrypt then mac"
787
788run_test "Encrypt then MAC: client enabled, stream cipher" \
789 "$P_SRV debug_level=3 etm=1 \
790 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100791 "$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 +0100792 0 \
793 -c "client hello, adding encrypt_then_mac extension" \
794 -s "found encrypt then mac extension" \
795 -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é-Gonnard699cafa2014-10-27 13:57:03 +0100800run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100801 "$P_SRV debug_level=3 etm=1 \
802 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100803 "$P_CLI debug_level=3 etm=0" \
804 0 \
805 -C "client hello, adding encrypt_then_mac extension" \
806 -S "found encrypt then mac extension" \
807 -S "server hello, adding encrypt then mac extension" \
808 -C "found encrypt_then_mac extension" \
809 -C "using encrypt then mac" \
810 -S "using encrypt then mac"
811
Janos Follathe2681a42016-03-07 15:57:05 +0000812requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100813run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100814 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100815 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100816 "$P_CLI debug_level=3 force_version=ssl3" \
817 0 \
818 -C "client hello, adding encrypt_then_mac extension" \
819 -S "found encrypt then mac extension" \
820 -S "server hello, adding encrypt then mac extension" \
821 -C "found encrypt_then_mac extension" \
822 -C "using encrypt then mac" \
823 -S "using encrypt then mac"
824
Janos Follathe2681a42016-03-07 15:57:05 +0000825requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100826run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100827 "$P_SRV debug_level=3 force_version=ssl3 \
828 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100829 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100830 0 \
831 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100832 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100833 -S "server hello, adding encrypt then mac extension" \
834 -C "found encrypt_then_mac extension" \
835 -C "using encrypt then mac" \
836 -S "using encrypt then mac"
837
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200838# Tests for Extended Master Secret extension
839
840run_test "Extended Master Secret: default" \
841 "$P_SRV debug_level=3" \
842 "$P_CLI debug_level=3" \
843 0 \
844 -c "client hello, adding extended_master_secret extension" \
845 -s "found extended master secret extension" \
846 -s "server hello, adding extended master secret extension" \
847 -c "found extended_master_secret extension" \
848 -c "using extended master secret" \
849 -s "using extended master secret"
850
851run_test "Extended Master Secret: client enabled, server disabled" \
852 "$P_SRV debug_level=3 extended_ms=0" \
853 "$P_CLI debug_level=3 extended_ms=1" \
854 0 \
855 -c "client hello, adding extended_master_secret extension" \
856 -s "found extended master secret extension" \
857 -S "server hello, adding extended master secret extension" \
858 -C "found extended_master_secret extension" \
859 -C "using extended master secret" \
860 -S "using extended master secret"
861
862run_test "Extended Master Secret: client disabled, server enabled" \
863 "$P_SRV debug_level=3 extended_ms=1" \
864 "$P_CLI debug_level=3 extended_ms=0" \
865 0 \
866 -C "client hello, adding extended_master_secret extension" \
867 -S "found extended master secret extension" \
868 -S "server hello, adding extended master secret extension" \
869 -C "found extended_master_secret extension" \
870 -C "using extended master secret" \
871 -S "using extended master secret"
872
Janos Follathe2681a42016-03-07 15:57:05 +0000873requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200874run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100875 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200876 "$P_CLI debug_level=3 force_version=ssl3" \
877 0 \
878 -C "client hello, adding extended_master_secret extension" \
879 -S "found extended master secret extension" \
880 -S "server hello, adding extended master secret extension" \
881 -C "found extended_master_secret extension" \
882 -C "using extended master secret" \
883 -S "using extended master secret"
884
Janos Follathe2681a42016-03-07 15:57:05 +0000885requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200886run_test "Extended Master Secret: client enabled, server SSLv3" \
887 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100888 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200889 0 \
890 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100891 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200892 -S "server hello, adding extended master secret extension" \
893 -C "found extended_master_secret extension" \
894 -C "using extended master secret" \
895 -S "using extended master secret"
896
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200897# Tests for FALLBACK_SCSV
898
899run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200900 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200901 "$P_CLI debug_level=3 force_version=tls1_1" \
902 0 \
903 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200904 -S "received FALLBACK_SCSV" \
905 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200906 -C "is a fatal alert message (msg 86)"
907
908run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200909 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200910 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
911 0 \
912 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200913 -S "received FALLBACK_SCSV" \
914 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200915 -C "is a fatal alert message (msg 86)"
916
917run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200918 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200919 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200920 1 \
921 -c "adding FALLBACK_SCSV" \
922 -s "received FALLBACK_SCSV" \
923 -s "inapropriate fallback" \
924 -c "is a fatal alert message (msg 86)"
925
926run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200927 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200928 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200929 0 \
930 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200931 -s "received FALLBACK_SCSV" \
932 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200933 -C "is a fatal alert message (msg 86)"
934
935requires_openssl_with_fallback_scsv
936run_test "Fallback SCSV: default, openssl server" \
937 "$O_SRV" \
938 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
939 0 \
940 -C "adding FALLBACK_SCSV" \
941 -C "is a fatal alert message (msg 86)"
942
943requires_openssl_with_fallback_scsv
944run_test "Fallback SCSV: enabled, openssl server" \
945 "$O_SRV" \
946 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
947 1 \
948 -c "adding FALLBACK_SCSV" \
949 -c "is a fatal alert message (msg 86)"
950
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200951requires_openssl_with_fallback_scsv
952run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200953 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200954 "$O_CLI -tls1_1" \
955 0 \
956 -S "received FALLBACK_SCSV" \
957 -S "inapropriate fallback"
958
959requires_openssl_with_fallback_scsv
960run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200961 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200962 "$O_CLI -tls1_1 -fallback_scsv" \
963 1 \
964 -s "received FALLBACK_SCSV" \
965 -s "inapropriate fallback"
966
967requires_openssl_with_fallback_scsv
968run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200969 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200970 "$O_CLI -fallback_scsv" \
971 0 \
972 -s "received FALLBACK_SCSV" \
973 -S "inapropriate fallback"
974
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100975# Tests for CBC 1/n-1 record splitting
976
977run_test "CBC Record splitting: TLS 1.2, no splitting" \
978 "$P_SRV" \
979 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
980 request_size=123 force_version=tls1_2" \
981 0 \
982 -s "Read from client: 123 bytes read" \
983 -S "Read from client: 1 bytes read" \
984 -S "122 bytes read"
985
986run_test "CBC Record splitting: TLS 1.1, no splitting" \
987 "$P_SRV" \
988 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
989 request_size=123 force_version=tls1_1" \
990 0 \
991 -s "Read from client: 123 bytes read" \
992 -S "Read from client: 1 bytes read" \
993 -S "122 bytes read"
994
995run_test "CBC Record splitting: TLS 1.0, splitting" \
996 "$P_SRV" \
997 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
998 request_size=123 force_version=tls1" \
999 0 \
1000 -S "Read from client: 123 bytes read" \
1001 -s "Read from client: 1 bytes read" \
1002 -s "122 bytes read"
1003
Janos Follathe2681a42016-03-07 15:57:05 +00001004requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001005run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001006 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001007 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1008 request_size=123 force_version=ssl3" \
1009 0 \
1010 -S "Read from client: 123 bytes read" \
1011 -s "Read from client: 1 bytes read" \
1012 -s "122 bytes read"
1013
1014run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001015 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001016 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1017 request_size=123 force_version=tls1" \
1018 0 \
1019 -s "Read from client: 123 bytes read" \
1020 -S "Read from client: 1 bytes read" \
1021 -S "122 bytes read"
1022
1023run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1024 "$P_SRV" \
1025 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1026 request_size=123 force_version=tls1 recsplit=0" \
1027 0 \
1028 -s "Read from client: 123 bytes read" \
1029 -S "Read from client: 1 bytes read" \
1030 -S "122 bytes read"
1031
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001032run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1033 "$P_SRV nbio=2" \
1034 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1035 request_size=123 force_version=tls1" \
1036 0 \
1037 -S "Read from client: 123 bytes read" \
1038 -s "Read from client: 1 bytes read" \
1039 -s "122 bytes read"
1040
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001041# Tests for Session Tickets
1042
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001043run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001044 "$P_SRV debug_level=3 tickets=1" \
1045 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001046 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001047 -c "client hello, adding session ticket extension" \
1048 -s "found session ticket extension" \
1049 -s "server hello, adding session ticket extension" \
1050 -c "found session_ticket extension" \
1051 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001052 -S "session successfully restored from cache" \
1053 -s "session successfully restored from ticket" \
1054 -s "a session has been resumed" \
1055 -c "a session has been resumed"
1056
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001057run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001058 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1059 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001060 0 \
1061 -c "client hello, adding session ticket extension" \
1062 -s "found session ticket extension" \
1063 -s "server hello, adding session ticket extension" \
1064 -c "found session_ticket extension" \
1065 -c "parse new session ticket" \
1066 -S "session successfully restored from cache" \
1067 -s "session successfully restored from ticket" \
1068 -s "a session has been resumed" \
1069 -c "a session has been resumed"
1070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001071run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001072 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1073 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001074 0 \
1075 -c "client hello, adding session ticket extension" \
1076 -s "found session ticket extension" \
1077 -s "server hello, adding session ticket extension" \
1078 -c "found session_ticket extension" \
1079 -c "parse new session ticket" \
1080 -S "session successfully restored from cache" \
1081 -S "session successfully restored from ticket" \
1082 -S "a session has been resumed" \
1083 -C "a session has been resumed"
1084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001085run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001086 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001087 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001088 0 \
1089 -c "client hello, adding session ticket extension" \
1090 -c "found session_ticket extension" \
1091 -c "parse new session ticket" \
1092 -c "a session has been resumed"
1093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001094run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001095 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001096 "( $O_CLI -sess_out $SESSION; \
1097 $O_CLI -sess_in $SESSION; \
1098 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001099 0 \
1100 -s "found session ticket extension" \
1101 -s "server hello, adding session ticket extension" \
1102 -S "session successfully restored from cache" \
1103 -s "session successfully restored from ticket" \
1104 -s "a session has been resumed"
1105
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001106# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001108run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001109 "$P_SRV debug_level=3 tickets=0" \
1110 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001111 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001112 -c "client hello, adding session ticket extension" \
1113 -s "found session ticket extension" \
1114 -S "server hello, adding session ticket extension" \
1115 -C "found session_ticket extension" \
1116 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001117 -s "session successfully restored from cache" \
1118 -S "session successfully restored from ticket" \
1119 -s "a session has been resumed" \
1120 -c "a session has been resumed"
1121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001122run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001123 "$P_SRV debug_level=3 tickets=1" \
1124 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001125 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001126 -C "client hello, adding session ticket extension" \
1127 -S "found session ticket extension" \
1128 -S "server hello, adding session ticket extension" \
1129 -C "found session_ticket extension" \
1130 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001131 -s "session successfully restored from cache" \
1132 -S "session successfully restored from ticket" \
1133 -s "a session has been resumed" \
1134 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001135
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001136run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001137 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1138 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001139 0 \
1140 -S "session successfully restored from cache" \
1141 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001142 -S "a session has been resumed" \
1143 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001144
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001145run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001146 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1147 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001148 0 \
1149 -s "session successfully restored from cache" \
1150 -S "session successfully restored from ticket" \
1151 -s "a session has been resumed" \
1152 -c "a session has been resumed"
1153
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001154run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001155 "$P_SRV debug_level=3 tickets=0" \
1156 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001157 0 \
1158 -s "session successfully restored from cache" \
1159 -S "session successfully restored from ticket" \
1160 -s "a session has been resumed" \
1161 -c "a session has been resumed"
1162
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001163run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001164 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1165 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001166 0 \
1167 -S "session successfully restored from cache" \
1168 -S "session successfully restored from ticket" \
1169 -S "a session has been resumed" \
1170 -C "a session has been resumed"
1171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001172run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001173 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1174 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001175 0 \
1176 -s "session successfully restored from cache" \
1177 -S "session successfully restored from ticket" \
1178 -s "a session has been resumed" \
1179 -c "a session has been resumed"
1180
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001181run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001182 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001183 "( $O_CLI -sess_out $SESSION; \
1184 $O_CLI -sess_in $SESSION; \
1185 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001186 0 \
1187 -s "found session ticket extension" \
1188 -S "server hello, adding session ticket extension" \
1189 -s "session successfully restored from cache" \
1190 -S "session successfully restored from ticket" \
1191 -s "a session has been resumed"
1192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001193run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001194 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001195 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001196 0 \
1197 -C "found session_ticket extension" \
1198 -C "parse new session ticket" \
1199 -c "a session has been resumed"
1200
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001201# Tests for Max Fragment Length extension
1202
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001203run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001204 "$P_SRV debug_level=3" \
1205 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001206 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001207 -c "Maximum fragment length is 16384" \
1208 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001209 -C "client hello, adding max_fragment_length extension" \
1210 -S "found max fragment length extension" \
1211 -S "server hello, max_fragment_length extension" \
1212 -C "found max_fragment_length extension"
1213
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001214run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001215 "$P_SRV debug_level=3" \
1216 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001217 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001218 -c "Maximum fragment length is 4096" \
1219 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001220 -c "client hello, adding max_fragment_length extension" \
1221 -s "found max fragment length extension" \
1222 -s "server hello, max_fragment_length extension" \
1223 -c "found max_fragment_length extension"
1224
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001225run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001226 "$P_SRV debug_level=3 max_frag_len=4096" \
1227 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001228 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001229 -c "Maximum fragment length is 16384" \
1230 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001231 -C "client hello, adding max_fragment_length extension" \
1232 -S "found max fragment length extension" \
1233 -S "server hello, max_fragment_length extension" \
1234 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001235
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001236requires_gnutls
1237run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001238 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001239 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001240 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001241 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001242 -c "client hello, adding max_fragment_length extension" \
1243 -c "found max_fragment_length extension"
1244
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001245run_test "Max fragment length: client, message just fits" \
1246 "$P_SRV debug_level=3" \
1247 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1248 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001249 -c "Maximum fragment length is 2048" \
1250 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001251 -c "client hello, adding max_fragment_length extension" \
1252 -s "found max fragment length extension" \
1253 -s "server hello, max_fragment_length extension" \
1254 -c "found max_fragment_length extension" \
1255 -c "2048 bytes written in 1 fragments" \
1256 -s "2048 bytes read"
1257
1258run_test "Max fragment length: client, larger message" \
1259 "$P_SRV debug_level=3" \
1260 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1261 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001262 -c "Maximum fragment length is 2048" \
1263 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001264 -c "client hello, adding max_fragment_length extension" \
1265 -s "found max fragment length extension" \
1266 -s "server hello, max_fragment_length extension" \
1267 -c "found max_fragment_length extension" \
1268 -c "2345 bytes written in 2 fragments" \
1269 -s "2048 bytes read" \
1270 -s "297 bytes read"
1271
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001272run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001273 "$P_SRV debug_level=3 dtls=1" \
1274 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1275 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001276 -c "Maximum fragment length is 2048" \
1277 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001278 -c "client hello, adding max_fragment_length extension" \
1279 -s "found max fragment length extension" \
1280 -s "server hello, max_fragment_length extension" \
1281 -c "found max_fragment_length extension" \
1282 -c "fragment larger than.*maximum"
1283
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001284# Tests for renegotiation
1285
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001286run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001287 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001288 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001289 0 \
1290 -C "client hello, adding renegotiation extension" \
1291 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1292 -S "found renegotiation extension" \
1293 -s "server hello, secure renegotiation extension" \
1294 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001295 -C "=> renegotiate" \
1296 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001297 -S "write hello request"
1298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001299run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001300 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001301 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001302 0 \
1303 -c "client hello, adding renegotiation extension" \
1304 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1305 -s "found renegotiation extension" \
1306 -s "server hello, secure renegotiation extension" \
1307 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001308 -c "=> renegotiate" \
1309 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001310 -S "write hello request"
1311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001312run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001313 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001314 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001315 0 \
1316 -c "client hello, adding renegotiation extension" \
1317 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1318 -s "found renegotiation extension" \
1319 -s "server hello, secure renegotiation extension" \
1320 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001321 -c "=> renegotiate" \
1322 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001323 -s "write hello request"
1324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001325run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001326 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001327 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001328 0 \
1329 -c "client hello, adding renegotiation extension" \
1330 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1331 -s "found renegotiation extension" \
1332 -s "server hello, secure renegotiation extension" \
1333 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001334 -c "=> renegotiate" \
1335 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001336 -s "write hello request"
1337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001338run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001339 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001340 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001341 1 \
1342 -c "client hello, adding renegotiation extension" \
1343 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1344 -S "found renegotiation extension" \
1345 -s "server hello, secure renegotiation extension" \
1346 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001347 -c "=> renegotiate" \
1348 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001349 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001350 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001351 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001352
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001353run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001354 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001355 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001356 0 \
1357 -C "client hello, adding renegotiation extension" \
1358 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1359 -S "found renegotiation extension" \
1360 -s "server hello, secure renegotiation extension" \
1361 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001362 -C "=> renegotiate" \
1363 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001364 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001365 -S "SSL - An unexpected message was received from our peer" \
1366 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001367
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001368run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001369 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001370 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001371 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001372 0 \
1373 -C "client hello, adding renegotiation extension" \
1374 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1375 -S "found renegotiation extension" \
1376 -s "server hello, secure renegotiation extension" \
1377 -c "found renegotiation extension" \
1378 -C "=> renegotiate" \
1379 -S "=> renegotiate" \
1380 -s "write hello request" \
1381 -S "SSL - An unexpected message was received from our peer" \
1382 -S "failed"
1383
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001384# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001385run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001386 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001387 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001388 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001389 0 \
1390 -C "client hello, adding renegotiation extension" \
1391 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1392 -S "found renegotiation extension" \
1393 -s "server hello, secure renegotiation extension" \
1394 -c "found renegotiation extension" \
1395 -C "=> renegotiate" \
1396 -S "=> renegotiate" \
1397 -s "write hello request" \
1398 -S "SSL - An unexpected message was received from our peer" \
1399 -S "failed"
1400
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001401run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001402 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001403 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001404 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001405 0 \
1406 -C "client hello, adding renegotiation extension" \
1407 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1408 -S "found renegotiation extension" \
1409 -s "server hello, secure renegotiation extension" \
1410 -c "found renegotiation extension" \
1411 -C "=> renegotiate" \
1412 -S "=> renegotiate" \
1413 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001414 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001416run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001417 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001418 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001419 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001420 0 \
1421 -c "client hello, adding renegotiation extension" \
1422 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1423 -s "found renegotiation extension" \
1424 -s "server hello, secure renegotiation extension" \
1425 -c "found renegotiation extension" \
1426 -c "=> renegotiate" \
1427 -s "=> renegotiate" \
1428 -s "write hello request" \
1429 -S "SSL - An unexpected message was received from our peer" \
1430 -S "failed"
1431
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001432run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001433 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001434 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1435 0 \
1436 -C "client hello, adding renegotiation extension" \
1437 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1438 -S "found renegotiation extension" \
1439 -s "server hello, secure renegotiation extension" \
1440 -c "found renegotiation extension" \
1441 -S "record counter limit reached: renegotiate" \
1442 -C "=> renegotiate" \
1443 -S "=> renegotiate" \
1444 -S "write hello request" \
1445 -S "SSL - An unexpected message was received from our peer" \
1446 -S "failed"
1447
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001448# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001449run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001450 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001451 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001452 0 \
1453 -c "client hello, adding renegotiation extension" \
1454 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1455 -s "found renegotiation extension" \
1456 -s "server hello, secure renegotiation extension" \
1457 -c "found renegotiation extension" \
1458 -s "record counter limit reached: renegotiate" \
1459 -c "=> renegotiate" \
1460 -s "=> renegotiate" \
1461 -s "write hello request" \
1462 -S "SSL - An unexpected message was received from our peer" \
1463 -S "failed"
1464
1465run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001466 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001467 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001468 0 \
1469 -c "client hello, adding renegotiation extension" \
1470 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1471 -s "found renegotiation extension" \
1472 -s "server hello, secure renegotiation extension" \
1473 -c "found renegotiation extension" \
1474 -s "record counter limit reached: renegotiate" \
1475 -c "=> renegotiate" \
1476 -s "=> renegotiate" \
1477 -s "write hello request" \
1478 -S "SSL - An unexpected message was received from our peer" \
1479 -S "failed"
1480
1481run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001482 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001483 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1484 0 \
1485 -C "client hello, adding renegotiation extension" \
1486 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1487 -S "found renegotiation extension" \
1488 -s "server hello, secure renegotiation extension" \
1489 -c "found renegotiation extension" \
1490 -S "record counter limit reached: renegotiate" \
1491 -C "=> renegotiate" \
1492 -S "=> renegotiate" \
1493 -S "write hello request" \
1494 -S "SSL - An unexpected message was received from our peer" \
1495 -S "failed"
1496
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001497run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001498 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001499 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001500 0 \
1501 -c "client hello, adding renegotiation extension" \
1502 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1503 -s "found renegotiation extension" \
1504 -s "server hello, secure renegotiation extension" \
1505 -c "found renegotiation extension" \
1506 -c "=> renegotiate" \
1507 -s "=> renegotiate" \
1508 -S "write hello request"
1509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001510run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001511 "$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 +02001512 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001513 0 \
1514 -c "client hello, adding renegotiation extension" \
1515 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1516 -s "found renegotiation extension" \
1517 -s "server hello, secure renegotiation extension" \
1518 -c "found renegotiation extension" \
1519 -c "=> renegotiate" \
1520 -s "=> renegotiate" \
1521 -s "write hello request"
1522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001523run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001524 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001525 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001526 0 \
1527 -c "client hello, adding renegotiation extension" \
1528 -c "found renegotiation extension" \
1529 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001530 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001531 -C "error" \
1532 -c "HTTP/1.0 200 [Oo][Kk]"
1533
Paul Bakker539d9722015-02-08 16:18:35 +01001534requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001535run_test "Renegotiation: gnutls server strict, client-initiated" \
1536 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001537 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001538 0 \
1539 -c "client hello, adding renegotiation extension" \
1540 -c "found renegotiation extension" \
1541 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001542 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001543 -C "error" \
1544 -c "HTTP/1.0 200 [Oo][Kk]"
1545
Paul Bakker539d9722015-02-08 16:18:35 +01001546requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001547run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1548 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1549 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1550 1 \
1551 -c "client hello, adding renegotiation extension" \
1552 -C "found renegotiation extension" \
1553 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001554 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001555 -c "error" \
1556 -C "HTTP/1.0 200 [Oo][Kk]"
1557
Paul Bakker539d9722015-02-08 16:18:35 +01001558requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001559run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1560 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1561 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1562 allow_legacy=0" \
1563 1 \
1564 -c "client hello, adding renegotiation extension" \
1565 -C "found renegotiation extension" \
1566 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001567 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001568 -c "error" \
1569 -C "HTTP/1.0 200 [Oo][Kk]"
1570
Paul Bakker539d9722015-02-08 16:18:35 +01001571requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001572run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1573 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1574 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1575 allow_legacy=1" \
1576 0 \
1577 -c "client hello, adding renegotiation extension" \
1578 -C "found renegotiation extension" \
1579 -c "=> renegotiate" \
1580 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001581 -C "error" \
1582 -c "HTTP/1.0 200 [Oo][Kk]"
1583
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001584run_test "Renegotiation: DTLS, client-initiated" \
1585 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1586 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1587 0 \
1588 -c "client hello, adding renegotiation extension" \
1589 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1590 -s "found renegotiation extension" \
1591 -s "server hello, secure renegotiation extension" \
1592 -c "found renegotiation extension" \
1593 -c "=> renegotiate" \
1594 -s "=> renegotiate" \
1595 -S "write hello request"
1596
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001597run_test "Renegotiation: DTLS, server-initiated" \
1598 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001599 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1600 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001601 0 \
1602 -c "client hello, adding renegotiation extension" \
1603 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1604 -s "found renegotiation extension" \
1605 -s "server hello, secure renegotiation extension" \
1606 -c "found renegotiation extension" \
1607 -c "=> renegotiate" \
1608 -s "=> renegotiate" \
1609 -s "write hello request"
1610
Andres AG692ad842017-01-19 16:30:57 +00001611run_test "Renegotiation: DTLS, renego_period overflow" \
1612 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1613 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1614 0 \
1615 -c "client hello, adding renegotiation extension" \
1616 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1617 -s "found renegotiation extension" \
1618 -s "server hello, secure renegotiation extension" \
1619 -s "record counter limit reached: renegotiate" \
1620 -c "=> renegotiate" \
1621 -s "=> renegotiate" \
1622 -s "write hello request" \
1623
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001624requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001625run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1626 "$G_SRV -u --mtu 4096" \
1627 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1628 0 \
1629 -c "client hello, adding renegotiation extension" \
1630 -c "found renegotiation extension" \
1631 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001632 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001633 -C "error" \
1634 -s "Extra-header:"
1635
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001636# Test for the "secure renegotation" extension only (no actual renegotiation)
1637
Paul Bakker539d9722015-02-08 16:18:35 +01001638requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001639run_test "Renego ext: gnutls server strict, client default" \
1640 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1641 "$P_CLI debug_level=3" \
1642 0 \
1643 -c "found renegotiation extension" \
1644 -C "error" \
1645 -c "HTTP/1.0 200 [Oo][Kk]"
1646
Paul Bakker539d9722015-02-08 16:18:35 +01001647requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001648run_test "Renego ext: gnutls server unsafe, client default" \
1649 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1650 "$P_CLI debug_level=3" \
1651 0 \
1652 -C "found renegotiation extension" \
1653 -C "error" \
1654 -c "HTTP/1.0 200 [Oo][Kk]"
1655
Paul Bakker539d9722015-02-08 16:18:35 +01001656requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001657run_test "Renego ext: gnutls server unsafe, client break legacy" \
1658 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1659 "$P_CLI debug_level=3 allow_legacy=-1" \
1660 1 \
1661 -C "found renegotiation extension" \
1662 -c "error" \
1663 -C "HTTP/1.0 200 [Oo][Kk]"
1664
Paul Bakker539d9722015-02-08 16:18:35 +01001665requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001666run_test "Renego ext: gnutls client strict, server default" \
1667 "$P_SRV debug_level=3" \
1668 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1669 0 \
1670 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1671 -s "server hello, secure renegotiation extension"
1672
Paul Bakker539d9722015-02-08 16:18:35 +01001673requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001674run_test "Renego ext: gnutls client unsafe, server default" \
1675 "$P_SRV debug_level=3" \
1676 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1677 0 \
1678 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1679 -S "server hello, secure renegotiation extension"
1680
Paul Bakker539d9722015-02-08 16:18:35 +01001681requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001682run_test "Renego ext: gnutls client unsafe, server break legacy" \
1683 "$P_SRV debug_level=3 allow_legacy=-1" \
1684 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1685 1 \
1686 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1687 -S "server hello, secure renegotiation extension"
1688
Janos Follath0b242342016-02-17 10:11:21 +00001689# Tests for silently dropping trailing extra bytes in .der certificates
1690
1691requires_gnutls
1692run_test "DER format: no trailing bytes" \
1693 "$P_SRV crt_file=data_files/server5-der0.crt \
1694 key_file=data_files/server5.key" \
1695 "$G_CLI " \
1696 0 \
1697 -c "Handshake was completed" \
1698
1699requires_gnutls
1700run_test "DER format: with a trailing zero byte" \
1701 "$P_SRV crt_file=data_files/server5-der1a.crt \
1702 key_file=data_files/server5.key" \
1703 "$G_CLI " \
1704 0 \
1705 -c "Handshake was completed" \
1706
1707requires_gnutls
1708run_test "DER format: with a trailing random byte" \
1709 "$P_SRV crt_file=data_files/server5-der1b.crt \
1710 key_file=data_files/server5.key" \
1711 "$G_CLI " \
1712 0 \
1713 -c "Handshake was completed" \
1714
1715requires_gnutls
1716run_test "DER format: with 2 trailing random bytes" \
1717 "$P_SRV crt_file=data_files/server5-der2.crt \
1718 key_file=data_files/server5.key" \
1719 "$G_CLI " \
1720 0 \
1721 -c "Handshake was completed" \
1722
1723requires_gnutls
1724run_test "DER format: with 4 trailing random bytes" \
1725 "$P_SRV crt_file=data_files/server5-der4.crt \
1726 key_file=data_files/server5.key" \
1727 "$G_CLI " \
1728 0 \
1729 -c "Handshake was completed" \
1730
1731requires_gnutls
1732run_test "DER format: with 8 trailing random bytes" \
1733 "$P_SRV crt_file=data_files/server5-der8.crt \
1734 key_file=data_files/server5.key" \
1735 "$G_CLI " \
1736 0 \
1737 -c "Handshake was completed" \
1738
1739requires_gnutls
1740run_test "DER format: with 9 trailing random bytes" \
1741 "$P_SRV crt_file=data_files/server5-der9.crt \
1742 key_file=data_files/server5.key" \
1743 "$G_CLI " \
1744 0 \
1745 -c "Handshake was completed" \
1746
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001747# Tests for auth_mode
1748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001749run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001750 "$P_SRV crt_file=data_files/server5-badsign.crt \
1751 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001752 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001753 1 \
1754 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001755 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001756 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001757 -c "X509 - Certificate verification failed"
1758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001759run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001760 "$P_SRV crt_file=data_files/server5-badsign.crt \
1761 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001762 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001763 0 \
1764 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001765 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001766 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001767 -C "X509 - Certificate verification failed"
1768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001769run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001770 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001771 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001772 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001773 0 \
1774 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001775 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001776 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001777 -C "X509 - Certificate verification failed"
1778
Simon Butcher99000142016-10-13 17:21:01 +01001779run_test "Authentication: client SHA256, server required" \
1780 "$P_SRV auth_mode=required" \
1781 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1782 key_file=data_files/server6.key \
1783 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1784 0 \
1785 -c "Supported Signature Algorithm found: 4," \
1786 -c "Supported Signature Algorithm found: 5,"
1787
1788run_test "Authentication: client SHA384, server required" \
1789 "$P_SRV auth_mode=required" \
1790 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1791 key_file=data_files/server6.key \
1792 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
1793 0 \
1794 -c "Supported Signature Algorithm found: 4," \
1795 -c "Supported Signature Algorithm found: 5,"
1796
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001797run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001798 "$P_SRV debug_level=3 auth_mode=required" \
1799 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001800 key_file=data_files/server5.key" \
1801 1 \
1802 -S "skip write certificate request" \
1803 -C "skip parse certificate request" \
1804 -c "got a certificate request" \
1805 -C "skip write certificate" \
1806 -C "skip write certificate verify" \
1807 -S "skip parse certificate verify" \
1808 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001809 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001810 -s "! mbedtls_ssl_handshake returned" \
1811 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001812 -s "X509 - Certificate verification failed"
1813
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001814run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001815 "$P_SRV debug_level=3 auth_mode=optional" \
1816 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001817 key_file=data_files/server5.key" \
1818 0 \
1819 -S "skip write certificate request" \
1820 -C "skip parse certificate request" \
1821 -c "got a certificate request" \
1822 -C "skip write certificate" \
1823 -C "skip write certificate verify" \
1824 -S "skip parse certificate verify" \
1825 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001826 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001827 -S "! mbedtls_ssl_handshake returned" \
1828 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001829 -S "X509 - Certificate verification failed"
1830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001831run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001832 "$P_SRV debug_level=3 auth_mode=none" \
1833 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001834 key_file=data_files/server5.key" \
1835 0 \
1836 -s "skip write certificate request" \
1837 -C "skip parse certificate request" \
1838 -c "got no certificate request" \
1839 -c "skip write certificate" \
1840 -c "skip write certificate verify" \
1841 -s "skip parse certificate verify" \
1842 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001843 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001844 -S "! mbedtls_ssl_handshake returned" \
1845 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001846 -S "X509 - Certificate verification failed"
1847
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001848run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001849 "$P_SRV debug_level=3 auth_mode=optional" \
1850 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001851 0 \
1852 -S "skip write certificate request" \
1853 -C "skip parse certificate request" \
1854 -c "got a certificate request" \
1855 -C "skip write certificate$" \
1856 -C "got no certificate to send" \
1857 -S "SSLv3 client has no certificate" \
1858 -c "skip write certificate verify" \
1859 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001860 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001861 -S "! mbedtls_ssl_handshake returned" \
1862 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001863 -S "X509 - Certificate verification failed"
1864
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001865run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001866 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001867 "$O_CLI" \
1868 0 \
1869 -S "skip write certificate request" \
1870 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001871 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001872 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001873 -S "X509 - Certificate verification failed"
1874
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001875run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001876 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001877 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001878 0 \
1879 -C "skip parse certificate request" \
1880 -c "got a certificate request" \
1881 -C "skip write certificate$" \
1882 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001883 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001884
Janos Follathe2681a42016-03-07 15:57:05 +00001885requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001886run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001887 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001888 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001889 0 \
1890 -S "skip write certificate request" \
1891 -C "skip parse certificate request" \
1892 -c "got a certificate request" \
1893 -C "skip write certificate$" \
1894 -c "skip write certificate verify" \
1895 -c "got no certificate to send" \
1896 -s "SSLv3 client has no certificate" \
1897 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001898 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001899 -S "! mbedtls_ssl_handshake returned" \
1900 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001901 -S "X509 - Certificate verification failed"
1902
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001903# Tests for certificate selection based on SHA verson
1904
1905run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1906 "$P_SRV crt_file=data_files/server5.crt \
1907 key_file=data_files/server5.key \
1908 crt_file2=data_files/server5-sha1.crt \
1909 key_file2=data_files/server5.key" \
1910 "$P_CLI force_version=tls1_2" \
1911 0 \
1912 -c "signed using.*ECDSA with SHA256" \
1913 -C "signed using.*ECDSA with SHA1"
1914
1915run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1916 "$P_SRV crt_file=data_files/server5.crt \
1917 key_file=data_files/server5.key \
1918 crt_file2=data_files/server5-sha1.crt \
1919 key_file2=data_files/server5.key" \
1920 "$P_CLI force_version=tls1_1" \
1921 0 \
1922 -C "signed using.*ECDSA with SHA256" \
1923 -c "signed using.*ECDSA with SHA1"
1924
1925run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1926 "$P_SRV crt_file=data_files/server5.crt \
1927 key_file=data_files/server5.key \
1928 crt_file2=data_files/server5-sha1.crt \
1929 key_file2=data_files/server5.key" \
1930 "$P_CLI force_version=tls1" \
1931 0 \
1932 -C "signed using.*ECDSA with SHA256" \
1933 -c "signed using.*ECDSA with SHA1"
1934
1935run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1936 "$P_SRV crt_file=data_files/server5.crt \
1937 key_file=data_files/server5.key \
1938 crt_file2=data_files/server6.crt \
1939 key_file2=data_files/server6.key" \
1940 "$P_CLI force_version=tls1_1" \
1941 0 \
1942 -c "serial number.*09" \
1943 -c "signed using.*ECDSA with SHA256" \
1944 -C "signed using.*ECDSA with SHA1"
1945
1946run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1947 "$P_SRV crt_file=data_files/server6.crt \
1948 key_file=data_files/server6.key \
1949 crt_file2=data_files/server5.crt \
1950 key_file2=data_files/server5.key" \
1951 "$P_CLI force_version=tls1_1" \
1952 0 \
1953 -c "serial number.*0A" \
1954 -c "signed using.*ECDSA with SHA256" \
1955 -C "signed using.*ECDSA with SHA1"
1956
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001957# tests for SNI
1958
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001959run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001960 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001961 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001962 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001963 0 \
1964 -S "parse ServerName extension" \
1965 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1966 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001967
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001968run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001969 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001970 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001971 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 +02001972 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001973 0 \
1974 -s "parse ServerName extension" \
1975 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1976 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001977
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001978run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001979 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001980 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001981 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 +02001982 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001983 0 \
1984 -s "parse ServerName extension" \
1985 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1986 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001987
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001988run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001989 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001990 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001991 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 +02001992 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001993 1 \
1994 -s "parse ServerName extension" \
1995 -s "ssl_sni_wrapper() returned" \
1996 -s "mbedtls_ssl_handshake returned" \
1997 -c "mbedtls_ssl_handshake returned" \
1998 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001999
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002000run_test "SNI: client auth no override: optional" \
2001 "$P_SRV debug_level=3 auth_mode=optional \
2002 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2003 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2004 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002005 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002006 -S "skip write certificate request" \
2007 -C "skip parse certificate request" \
2008 -c "got a certificate request" \
2009 -C "skip write certificate" \
2010 -C "skip write certificate verify" \
2011 -S "skip parse certificate verify"
2012
2013run_test "SNI: client auth override: none -> optional" \
2014 "$P_SRV debug_level=3 auth_mode=none \
2015 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2016 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2017 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002018 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002019 -S "skip write certificate request" \
2020 -C "skip parse certificate request" \
2021 -c "got a certificate request" \
2022 -C "skip write certificate" \
2023 -C "skip write certificate verify" \
2024 -S "skip parse certificate verify"
2025
2026run_test "SNI: client auth override: optional -> none" \
2027 "$P_SRV debug_level=3 auth_mode=optional \
2028 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2029 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2030 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002031 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002032 -s "skip write certificate request" \
2033 -C "skip parse certificate request" \
2034 -c "got no certificate request" \
2035 -c "skip write certificate" \
2036 -c "skip write certificate verify" \
2037 -s "skip parse certificate verify"
2038
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002039run_test "SNI: CA no override" \
2040 "$P_SRV debug_level=3 auth_mode=optional \
2041 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2042 ca_file=data_files/test-ca.crt \
2043 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2044 "$P_CLI debug_level=3 server_name=localhost \
2045 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2046 1 \
2047 -S "skip write certificate request" \
2048 -C "skip parse certificate request" \
2049 -c "got a certificate request" \
2050 -C "skip write certificate" \
2051 -C "skip write certificate verify" \
2052 -S "skip parse certificate verify" \
2053 -s "x509_verify_cert() returned" \
2054 -s "! The certificate is not correctly signed by the trusted CA" \
2055 -S "The certificate has been revoked (is on a CRL)"
2056
2057run_test "SNI: CA override" \
2058 "$P_SRV debug_level=3 auth_mode=optional \
2059 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2060 ca_file=data_files/test-ca.crt \
2061 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2062 "$P_CLI debug_level=3 server_name=localhost \
2063 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2064 0 \
2065 -S "skip write certificate request" \
2066 -C "skip parse certificate request" \
2067 -c "got a certificate request" \
2068 -C "skip write certificate" \
2069 -C "skip write certificate verify" \
2070 -S "skip parse certificate verify" \
2071 -S "x509_verify_cert() returned" \
2072 -S "! The certificate is not correctly signed by the trusted CA" \
2073 -S "The certificate has been revoked (is on a CRL)"
2074
2075run_test "SNI: CA override with CRL" \
2076 "$P_SRV debug_level=3 auth_mode=optional \
2077 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2078 ca_file=data_files/test-ca.crt \
2079 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2080 "$P_CLI debug_level=3 server_name=localhost \
2081 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2082 1 \
2083 -S "skip write certificate request" \
2084 -C "skip parse certificate request" \
2085 -c "got a certificate request" \
2086 -C "skip write certificate" \
2087 -C "skip write certificate verify" \
2088 -S "skip parse certificate verify" \
2089 -s "x509_verify_cert() returned" \
2090 -S "! The certificate is not correctly signed by the trusted CA" \
2091 -s "The certificate has been revoked (is on a CRL)"
2092
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002093# Tests for non-blocking I/O: exercise a variety of handshake flows
2094
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002095run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002096 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2097 "$P_CLI nbio=2 tickets=0" \
2098 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002099 -S "mbedtls_ssl_handshake returned" \
2100 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002101 -c "Read from server: .* bytes read"
2102
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002103run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002104 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2105 "$P_CLI nbio=2 tickets=0" \
2106 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002107 -S "mbedtls_ssl_handshake returned" \
2108 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002109 -c "Read from server: .* bytes read"
2110
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002111run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002112 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2113 "$P_CLI nbio=2 tickets=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é-Gonnard0b6609b2014-02-26 14:45:12 +01002117 -c "Read from server: .* bytes read"
2118
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002119run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002120 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2121 "$P_CLI nbio=2 tickets=1" \
2122 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002123 -S "mbedtls_ssl_handshake returned" \
2124 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002125 -c "Read from server: .* bytes read"
2126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002127run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002128 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2129 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2130 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002131 -S "mbedtls_ssl_handshake returned" \
2132 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002133 -c "Read from server: .* bytes read"
2134
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002135run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002136 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2137 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2138 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002139 -S "mbedtls_ssl_handshake returned" \
2140 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002141 -c "Read from server: .* bytes read"
2142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002143run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002144 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2145 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2146 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002147 -S "mbedtls_ssl_handshake returned" \
2148 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002149 -c "Read from server: .* bytes read"
2150
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002151# Tests for version negotiation
2152
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002153run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002154 "$P_SRV" \
2155 "$P_CLI" \
2156 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002157 -S "mbedtls_ssl_handshake returned" \
2158 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002159 -s "Protocol is TLSv1.2" \
2160 -c "Protocol is TLSv1.2"
2161
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002162run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002163 "$P_SRV" \
2164 "$P_CLI max_version=tls1_1" \
2165 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002166 -S "mbedtls_ssl_handshake returned" \
2167 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002168 -s "Protocol is TLSv1.1" \
2169 -c "Protocol is TLSv1.1"
2170
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002171run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002172 "$P_SRV max_version=tls1_1" \
2173 "$P_CLI" \
2174 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002175 -S "mbedtls_ssl_handshake returned" \
2176 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002177 -s "Protocol is TLSv1.1" \
2178 -c "Protocol is TLSv1.1"
2179
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002180run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002181 "$P_SRV max_version=tls1_1" \
2182 "$P_CLI max_version=tls1_1" \
2183 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002184 -S "mbedtls_ssl_handshake returned" \
2185 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002186 -s "Protocol is TLSv1.1" \
2187 -c "Protocol is TLSv1.1"
2188
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002189run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002190 "$P_SRV min_version=tls1_1" \
2191 "$P_CLI max_version=tls1_1" \
2192 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002193 -S "mbedtls_ssl_handshake returned" \
2194 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002195 -s "Protocol is TLSv1.1" \
2196 -c "Protocol is TLSv1.1"
2197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002198run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002199 "$P_SRV max_version=tls1_1" \
2200 "$P_CLI min_version=tls1_1" \
2201 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002202 -S "mbedtls_ssl_handshake returned" \
2203 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002204 -s "Protocol is TLSv1.1" \
2205 -c "Protocol is TLSv1.1"
2206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002207run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002208 "$P_SRV max_version=tls1_1" \
2209 "$P_CLI min_version=tls1_2" \
2210 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002211 -s "mbedtls_ssl_handshake returned" \
2212 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002213 -c "SSL - Handshake protocol not within min/max boundaries"
2214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002215run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002216 "$P_SRV min_version=tls1_2" \
2217 "$P_CLI max_version=tls1_1" \
2218 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002219 -s "mbedtls_ssl_handshake returned" \
2220 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002221 -s "SSL - Handshake protocol not within min/max boundaries"
2222
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002223# Tests for ALPN extension
2224
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002225run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002226 "$P_SRV debug_level=3" \
2227 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002228 0 \
2229 -C "client hello, adding alpn extension" \
2230 -S "found alpn extension" \
2231 -C "got an alert message, type: \\[2:120]" \
2232 -S "server hello, adding alpn extension" \
2233 -C "found alpn extension " \
2234 -C "Application Layer Protocol is" \
2235 -S "Application Layer Protocol is"
2236
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002237run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002238 "$P_SRV debug_level=3" \
2239 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002240 0 \
2241 -c "client hello, adding alpn extension" \
2242 -s "found alpn extension" \
2243 -C "got an alert message, type: \\[2:120]" \
2244 -S "server hello, adding alpn extension" \
2245 -C "found alpn extension " \
2246 -c "Application Layer Protocol is (none)" \
2247 -S "Application Layer Protocol is"
2248
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002249run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002250 "$P_SRV debug_level=3 alpn=abc,1234" \
2251 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002252 0 \
2253 -C "client hello, adding alpn extension" \
2254 -S "found alpn extension" \
2255 -C "got an alert message, type: \\[2:120]" \
2256 -S "server hello, adding alpn extension" \
2257 -C "found alpn extension " \
2258 -C "Application Layer Protocol is" \
2259 -s "Application Layer Protocol is (none)"
2260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002261run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002262 "$P_SRV debug_level=3 alpn=abc,1234" \
2263 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002264 0 \
2265 -c "client hello, adding alpn extension" \
2266 -s "found alpn extension" \
2267 -C "got an alert message, type: \\[2:120]" \
2268 -s "server hello, adding alpn extension" \
2269 -c "found alpn extension" \
2270 -c "Application Layer Protocol is abc" \
2271 -s "Application Layer Protocol is abc"
2272
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002273run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002274 "$P_SRV debug_level=3 alpn=abc,1234" \
2275 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002276 0 \
2277 -c "client hello, adding alpn extension" \
2278 -s "found alpn extension" \
2279 -C "got an alert message, type: \\[2:120]" \
2280 -s "server hello, adding alpn extension" \
2281 -c "found alpn extension" \
2282 -c "Application Layer Protocol is abc" \
2283 -s "Application Layer Protocol is abc"
2284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002285run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002286 "$P_SRV debug_level=3 alpn=abc,1234" \
2287 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002288 0 \
2289 -c "client hello, adding alpn extension" \
2290 -s "found alpn extension" \
2291 -C "got an alert message, type: \\[2:120]" \
2292 -s "server hello, adding alpn extension" \
2293 -c "found alpn extension" \
2294 -c "Application Layer Protocol is 1234" \
2295 -s "Application Layer Protocol is 1234"
2296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002297run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002298 "$P_SRV debug_level=3 alpn=abc,123" \
2299 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002300 1 \
2301 -c "client hello, adding alpn extension" \
2302 -s "found alpn extension" \
2303 -c "got an alert message, type: \\[2:120]" \
2304 -S "server hello, adding alpn extension" \
2305 -C "found alpn extension" \
2306 -C "Application Layer Protocol is 1234" \
2307 -S "Application Layer Protocol is 1234"
2308
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002309
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002310# Tests for keyUsage in leaf certificates, part 1:
2311# server-side certificate/suite selection
2312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002313run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002314 "$P_SRV key_file=data_files/server2.key \
2315 crt_file=data_files/server2.ku-ds.crt" \
2316 "$P_CLI" \
2317 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002318 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002319
2320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002321run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002322 "$P_SRV key_file=data_files/server2.key \
2323 crt_file=data_files/server2.ku-ke.crt" \
2324 "$P_CLI" \
2325 0 \
2326 -c "Ciphersuite is TLS-RSA-WITH-"
2327
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002328run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002329 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002330 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002331 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002332 1 \
2333 -C "Ciphersuite is "
2334
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002335run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002336 "$P_SRV key_file=data_files/server5.key \
2337 crt_file=data_files/server5.ku-ds.crt" \
2338 "$P_CLI" \
2339 0 \
2340 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2341
2342
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002343run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002344 "$P_SRV key_file=data_files/server5.key \
2345 crt_file=data_files/server5.ku-ka.crt" \
2346 "$P_CLI" \
2347 0 \
2348 -c "Ciphersuite is TLS-ECDH-"
2349
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002350run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002351 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002352 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002353 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002354 1 \
2355 -C "Ciphersuite is "
2356
2357# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002358# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002359
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002360run_test "keyUsage cli: DigitalSignature+KeyEncipherment, 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_ke.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-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+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002371 "$O_SRV -key data_files/server2.key \
2372 -cert data_files/server2.ku-ds_ke.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-DHE-RSA-WITH-AES-128-CBC-SHA" \
2375 0 \
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é-Gonnard8e03c712014-08-30 21:42:40 +02002380run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002381 "$O_SRV -key data_files/server2.key \
2382 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002383 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002384 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2385 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002386 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002387 -C "Processing of the Certificate handshake message failed" \
2388 -c "Ciphersuite is TLS-"
2389
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002390run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002391 "$O_SRV -key data_files/server2.key \
2392 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002393 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002394 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2395 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002396 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002397 -c "Processing of the Certificate handshake message failed" \
2398 -C "Ciphersuite is TLS-"
2399
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002400run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2401 "$O_SRV -key data_files/server2.key \
2402 -cert data_files/server2.ku-ke.crt" \
2403 "$P_CLI debug_level=1 auth_mode=optional \
2404 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2405 0 \
2406 -c "bad certificate (usage extensions)" \
2407 -C "Processing of the Certificate handshake message failed" \
2408 -c "Ciphersuite is TLS-" \
2409 -c "! Usage does not match the keyUsage extension"
2410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002411run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002412 "$O_SRV -key data_files/server2.key \
2413 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002414 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002415 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2416 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002417 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002418 -C "Processing of the Certificate handshake message failed" \
2419 -c "Ciphersuite is TLS-"
2420
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002421run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002422 "$O_SRV -key data_files/server2.key \
2423 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002424 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002425 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2426 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002427 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002428 -c "Processing of the Certificate handshake message failed" \
2429 -C "Ciphersuite is TLS-"
2430
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002431run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2432 "$O_SRV -key data_files/server2.key \
2433 -cert data_files/server2.ku-ds.crt" \
2434 "$P_CLI debug_level=1 auth_mode=optional \
2435 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2436 0 \
2437 -c "bad certificate (usage extensions)" \
2438 -C "Processing of the Certificate handshake message failed" \
2439 -c "Ciphersuite is TLS-" \
2440 -c "! Usage does not match the keyUsage extension"
2441
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002442# Tests for keyUsage in leaf certificates, part 3:
2443# server-side checking of client cert
2444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002445run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002446 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002447 "$O_CLI -key data_files/server2.key \
2448 -cert data_files/server2.ku-ds.crt" \
2449 0 \
2450 -S "bad certificate (usage extensions)" \
2451 -S "Processing of the Certificate handshake message failed"
2452
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002453run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002454 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002455 "$O_CLI -key data_files/server2.key \
2456 -cert data_files/server2.ku-ke.crt" \
2457 0 \
2458 -s "bad certificate (usage extensions)" \
2459 -S "Processing of the Certificate handshake message failed"
2460
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002461run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002462 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002463 "$O_CLI -key data_files/server2.key \
2464 -cert data_files/server2.ku-ke.crt" \
2465 1 \
2466 -s "bad certificate (usage extensions)" \
2467 -s "Processing of the Certificate handshake message failed"
2468
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002469run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002470 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002471 "$O_CLI -key data_files/server5.key \
2472 -cert data_files/server5.ku-ds.crt" \
2473 0 \
2474 -S "bad certificate (usage extensions)" \
2475 -S "Processing of the Certificate handshake message failed"
2476
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002477run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002478 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002479 "$O_CLI -key data_files/server5.key \
2480 -cert data_files/server5.ku-ka.crt" \
2481 0 \
2482 -s "bad certificate (usage extensions)" \
2483 -S "Processing of the Certificate handshake message failed"
2484
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002485# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002487run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002488 "$P_SRV key_file=data_files/server5.key \
2489 crt_file=data_files/server5.eku-srv.crt" \
2490 "$P_CLI" \
2491 0
2492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002493run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002494 "$P_SRV key_file=data_files/server5.key \
2495 crt_file=data_files/server5.eku-srv.crt" \
2496 "$P_CLI" \
2497 0
2498
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002499run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002500 "$P_SRV key_file=data_files/server5.key \
2501 crt_file=data_files/server5.eku-cs_any.crt" \
2502 "$P_CLI" \
2503 0
2504
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002505run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002506 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002507 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002508 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002509 1
2510
2511# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2512
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002513run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002514 "$O_SRV -key data_files/server5.key \
2515 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002516 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002517 0 \
2518 -C "bad certificate (usage extensions)" \
2519 -C "Processing of the Certificate handshake message failed" \
2520 -c "Ciphersuite is TLS-"
2521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002522run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002523 "$O_SRV -key data_files/server5.key \
2524 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002525 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002526 0 \
2527 -C "bad certificate (usage extensions)" \
2528 -C "Processing of the Certificate handshake message failed" \
2529 -c "Ciphersuite is TLS-"
2530
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002531run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002532 "$O_SRV -key data_files/server5.key \
2533 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002534 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002535 0 \
2536 -C "bad certificate (usage extensions)" \
2537 -C "Processing of the Certificate handshake message failed" \
2538 -c "Ciphersuite is TLS-"
2539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002540run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002541 "$O_SRV -key data_files/server5.key \
2542 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002543 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002544 1 \
2545 -c "bad certificate (usage extensions)" \
2546 -c "Processing of the Certificate handshake message failed" \
2547 -C "Ciphersuite is TLS-"
2548
2549# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002551run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002552 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002553 "$O_CLI -key data_files/server5.key \
2554 -cert data_files/server5.eku-cli.crt" \
2555 0 \
2556 -S "bad certificate (usage extensions)" \
2557 -S "Processing of the Certificate handshake message failed"
2558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002559run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002560 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002561 "$O_CLI -key data_files/server5.key \
2562 -cert data_files/server5.eku-srv_cli.crt" \
2563 0 \
2564 -S "bad certificate (usage extensions)" \
2565 -S "Processing of the Certificate handshake message failed"
2566
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002567run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002568 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002569 "$O_CLI -key data_files/server5.key \
2570 -cert data_files/server5.eku-cs_any.crt" \
2571 0 \
2572 -S "bad certificate (usage extensions)" \
2573 -S "Processing of the Certificate handshake message failed"
2574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002575run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002576 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002577 "$O_CLI -key data_files/server5.key \
2578 -cert data_files/server5.eku-cs.crt" \
2579 0 \
2580 -s "bad certificate (usage extensions)" \
2581 -S "Processing of the Certificate handshake message failed"
2582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002583run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002584 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002585 "$O_CLI -key data_files/server5.key \
2586 -cert data_files/server5.eku-cs.crt" \
2587 1 \
2588 -s "bad certificate (usage extensions)" \
2589 -s "Processing of the Certificate handshake message failed"
2590
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002591# Tests for DHM parameters loading
2592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002593run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002594 "$P_SRV" \
2595 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2596 debug_level=3" \
2597 0 \
2598 -c "value of 'DHM: P ' (2048 bits)" \
2599 -c "value of 'DHM: G ' (2048 bits)"
2600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002601run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002602 "$P_SRV dhm_file=data_files/dhparams.pem" \
2603 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2604 debug_level=3" \
2605 0 \
2606 -c "value of 'DHM: P ' (1024 bits)" \
2607 -c "value of 'DHM: G ' (2 bits)"
2608
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002609# Tests for DHM client-side size checking
2610
2611run_test "DHM size: server default, client default, OK" \
2612 "$P_SRV" \
2613 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2614 debug_level=1" \
2615 0 \
2616 -C "DHM prime too short:"
2617
2618run_test "DHM size: server default, client 2048, OK" \
2619 "$P_SRV" \
2620 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2621 debug_level=1 dhmlen=2048" \
2622 0 \
2623 -C "DHM prime too short:"
2624
2625run_test "DHM size: server 1024, client default, OK" \
2626 "$P_SRV dhm_file=data_files/dhparams.pem" \
2627 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2628 debug_level=1" \
2629 0 \
2630 -C "DHM prime too short:"
2631
2632run_test "DHM size: server 1000, client default, rejected" \
2633 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2634 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2635 debug_level=1" \
2636 1 \
2637 -c "DHM prime too short:"
2638
2639run_test "DHM size: server default, client 2049, rejected" \
2640 "$P_SRV" \
2641 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2642 debug_level=1 dhmlen=2049" \
2643 1 \
2644 -c "DHM prime too short:"
2645
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002646# Tests for PSK callback
2647
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002648run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002649 "$P_SRV psk=abc123 psk_identity=foo" \
2650 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2651 psk_identity=foo psk=abc123" \
2652 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002653 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002654 -S "SSL - Unknown identity received" \
2655 -S "SSL - Verification of the message MAC failed"
2656
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002657run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002658 "$P_SRV" \
2659 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2660 psk_identity=foo psk=abc123" \
2661 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002662 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002663 -S "SSL - Unknown identity received" \
2664 -S "SSL - Verification of the message MAC failed"
2665
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002666run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002667 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2668 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2669 psk_identity=foo psk=abc123" \
2670 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002671 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002672 -s "SSL - Unknown identity received" \
2673 -S "SSL - Verification of the message MAC failed"
2674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002675run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002676 "$P_SRV psk_list=abc,dead,def,beef" \
2677 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2678 psk_identity=abc psk=dead" \
2679 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002680 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002681 -S "SSL - Unknown identity received" \
2682 -S "SSL - Verification of the message MAC failed"
2683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002684run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002685 "$P_SRV psk_list=abc,dead,def,beef" \
2686 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2687 psk_identity=def psk=beef" \
2688 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002689 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002690 -S "SSL - Unknown identity received" \
2691 -S "SSL - Verification of the message MAC failed"
2692
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002693run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002694 "$P_SRV psk_list=abc,dead,def,beef" \
2695 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2696 psk_identity=ghi psk=beef" \
2697 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002698 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002699 -s "SSL - Unknown identity received" \
2700 -S "SSL - Verification of the message MAC failed"
2701
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002702run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002703 "$P_SRV psk_list=abc,dead,def,beef" \
2704 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2705 psk_identity=abc psk=beef" \
2706 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002707 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002708 -S "SSL - Unknown identity received" \
2709 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002710
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002711# Tests for EC J-PAKE
2712
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002713requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002714run_test "ECJPAKE: client not configured" \
2715 "$P_SRV debug_level=3" \
2716 "$P_CLI debug_level=3" \
2717 0 \
2718 -C "add ciphersuite: c0ff" \
2719 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002720 -S "found ecjpake kkpp extension" \
2721 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002722 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002723 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002724 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002725 -S "None of the common ciphersuites is usable"
2726
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002727requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002728run_test "ECJPAKE: server not configured" \
2729 "$P_SRV debug_level=3" \
2730 "$P_CLI debug_level=3 ecjpake_pw=bla \
2731 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2732 1 \
2733 -c "add ciphersuite: c0ff" \
2734 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002735 -s "found ecjpake kkpp extension" \
2736 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002737 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002738 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002739 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002740 -s "None of the common ciphersuites is usable"
2741
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002742requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002743run_test "ECJPAKE: working, TLS" \
2744 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2745 "$P_CLI debug_level=3 ecjpake_pw=bla \
2746 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002747 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002748 -c "add ciphersuite: c0ff" \
2749 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002750 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002751 -s "found ecjpake kkpp extension" \
2752 -S "skip ecjpake kkpp extension" \
2753 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002754 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002755 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002756 -S "None of the common ciphersuites is usable" \
2757 -S "SSL - Verification of the message MAC failed"
2758
Janos Follath74537a62016-09-02 13:45:28 +01002759server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002760requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002761run_test "ECJPAKE: password mismatch, TLS" \
2762 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2763 "$P_CLI debug_level=3 ecjpake_pw=bad \
2764 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2765 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002766 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002767 -s "SSL - Verification of the message MAC failed"
2768
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002769requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002770run_test "ECJPAKE: working, DTLS" \
2771 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2772 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2773 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2774 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002775 -c "re-using cached ecjpake parameters" \
2776 -S "SSL - Verification of the message MAC failed"
2777
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002778requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002779run_test "ECJPAKE: working, DTLS, no cookie" \
2780 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2781 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2782 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2783 0 \
2784 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002785 -S "SSL - Verification of the message MAC failed"
2786
Janos Follath74537a62016-09-02 13:45:28 +01002787server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002788requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002789run_test "ECJPAKE: password mismatch, DTLS" \
2790 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2791 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2792 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2793 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002794 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002795 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002796
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002797# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002798requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002799run_test "ECJPAKE: working, DTLS, nolog" \
2800 "$P_SRV dtls=1 ecjpake_pw=bla" \
2801 "$P_CLI dtls=1 ecjpake_pw=bla \
2802 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2803 0
2804
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002805# Tests for ciphersuites per version
2806
Janos Follathe2681a42016-03-07 15:57:05 +00002807requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002808run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002809 "$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 +02002810 "$P_CLI force_version=ssl3" \
2811 0 \
2812 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2813
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002814run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002815 "$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 +01002816 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002817 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002818 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002819
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002820run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002821 "$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 +02002822 "$P_CLI force_version=tls1_1" \
2823 0 \
2824 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2825
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002826run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002827 "$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 +02002828 "$P_CLI force_version=tls1_2" \
2829 0 \
2830 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2831
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002832# Test for ClientHello without extensions
2833
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002834requires_gnutls
2835run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002836 "$P_SRV debug_level=3" \
2837 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2838 0 \
2839 -s "dumping 'client hello extensions' (0 bytes)"
2840
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002841# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002842
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002843run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002844 "$P_SRV" \
2845 "$P_CLI request_size=100" \
2846 0 \
2847 -s "Read from client: 100 bytes read$"
2848
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002849run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002850 "$P_SRV" \
2851 "$P_CLI request_size=500" \
2852 0 \
2853 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002854
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002855# Tests for small packets
2856
Janos Follathe2681a42016-03-07 15:57:05 +00002857requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002858run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002859 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002860 "$P_CLI request_size=1 force_version=ssl3 \
2861 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2862 0 \
2863 -s "Read from client: 1 bytes read"
2864
Janos Follathe2681a42016-03-07 15:57:05 +00002865requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002866run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002867 "$P_SRV min_version=ssl3 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=ssl3 \
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.0 BlockCipher" \
2874 "$P_SRV" \
2875 "$P_CLI request_size=1 force_version=tls1 \
2876 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2877 0 \
2878 -s "Read from client: 1 bytes read"
2879
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002880run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2881 "$P_SRV" \
2882 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2883 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2884 0 \
2885 -s "Read from client: 1 bytes read"
2886
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002887run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2888 "$P_SRV" \
2889 "$P_CLI request_size=1 force_version=tls1 \
2890 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2891 trunc_hmac=1" \
2892 0 \
2893 -s "Read from client: 1 bytes read"
2894
2895run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002896 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002897 "$P_CLI request_size=1 force_version=tls1 \
2898 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2899 trunc_hmac=1" \
2900 0 \
2901 -s "Read from client: 1 bytes read"
2902
2903run_test "Small packet TLS 1.1 BlockCipher" \
2904 "$P_SRV" \
2905 "$P_CLI request_size=1 force_version=tls1_1 \
2906 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2907 0 \
2908 -s "Read from client: 1 bytes read"
2909
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002910run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2911 "$P_SRV" \
2912 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2913 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2914 0 \
2915 -s "Read from client: 1 bytes read"
2916
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002917run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002918 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002919 "$P_CLI request_size=1 force_version=tls1_1 \
2920 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2921 0 \
2922 -s "Read from client: 1 bytes read"
2923
2924run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2925 "$P_SRV" \
2926 "$P_CLI request_size=1 force_version=tls1_1 \
2927 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2928 trunc_hmac=1" \
2929 0 \
2930 -s "Read from client: 1 bytes read"
2931
2932run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002933 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002934 "$P_CLI request_size=1 force_version=tls1_1 \
2935 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2936 trunc_hmac=1" \
2937 0 \
2938 -s "Read from client: 1 bytes read"
2939
2940run_test "Small packet TLS 1.2 BlockCipher" \
2941 "$P_SRV" \
2942 "$P_CLI request_size=1 force_version=tls1_2 \
2943 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2944 0 \
2945 -s "Read from client: 1 bytes read"
2946
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002947run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2948 "$P_SRV" \
2949 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2950 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2951 0 \
2952 -s "Read from client: 1 bytes read"
2953
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002954run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2955 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002956 "$P_CLI request_size=1 force_version=tls1_2 \
2957 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002958 0 \
2959 -s "Read from client: 1 bytes read"
2960
2961run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2962 "$P_SRV" \
2963 "$P_CLI request_size=1 force_version=tls1_2 \
2964 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2965 trunc_hmac=1" \
2966 0 \
2967 -s "Read from client: 1 bytes read"
2968
2969run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002970 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002971 "$P_CLI request_size=1 force_version=tls1_2 \
2972 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2973 0 \
2974 -s "Read from client: 1 bytes read"
2975
2976run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002977 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002978 "$P_CLI request_size=1 force_version=tls1_2 \
2979 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2980 trunc_hmac=1" \
2981 0 \
2982 -s "Read from client: 1 bytes read"
2983
2984run_test "Small packet TLS 1.2 AEAD" \
2985 "$P_SRV" \
2986 "$P_CLI request_size=1 force_version=tls1_2 \
2987 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2988 0 \
2989 -s "Read from client: 1 bytes read"
2990
2991run_test "Small packet TLS 1.2 AEAD shorter tag" \
2992 "$P_SRV" \
2993 "$P_CLI request_size=1 force_version=tls1_2 \
2994 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2995 0 \
2996 -s "Read from client: 1 bytes read"
2997
Janos Follath00efff72016-05-06 13:48:23 +01002998# A test for extensions in SSLv3
2999
3000requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3001run_test "SSLv3 with extensions, server side" \
3002 "$P_SRV min_version=ssl3 debug_level=3" \
3003 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3004 0 \
3005 -S "dumping 'client hello extensions'" \
3006 -S "server hello, total extension length:"
3007
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003008# Test for large packets
3009
Janos Follathe2681a42016-03-07 15:57:05 +00003010requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003011run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003012 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003013 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003014 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3015 0 \
3016 -s "Read from client: 16384 bytes read"
3017
Janos Follathe2681a42016-03-07 15:57:05 +00003018requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003019run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003020 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003021 "$P_CLI request_size=16384 force_version=ssl3 \
3022 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3023 0 \
3024 -s "Read from client: 16384 bytes read"
3025
3026run_test "Large packet TLS 1.0 BlockCipher" \
3027 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003028 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003029 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3030 0 \
3031 -s "Read from client: 16384 bytes read"
3032
3033run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3034 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003035 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003036 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3037 trunc_hmac=1" \
3038 0 \
3039 -s "Read from client: 16384 bytes read"
3040
3041run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003042 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003043 "$P_CLI request_size=16384 force_version=tls1 \
3044 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3045 trunc_hmac=1" \
3046 0 \
3047 -s "Read from client: 16384 bytes read"
3048
3049run_test "Large packet TLS 1.1 BlockCipher" \
3050 "$P_SRV" \
3051 "$P_CLI request_size=16384 force_version=tls1_1 \
3052 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3053 0 \
3054 -s "Read from client: 16384 bytes read"
3055
3056run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003057 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003058 "$P_CLI request_size=16384 force_version=tls1_1 \
3059 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3060 0 \
3061 -s "Read from client: 16384 bytes read"
3062
3063run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3064 "$P_SRV" \
3065 "$P_CLI request_size=16384 force_version=tls1_1 \
3066 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3067 trunc_hmac=1" \
3068 0 \
3069 -s "Read from client: 16384 bytes read"
3070
3071run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003072 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003073 "$P_CLI request_size=16384 force_version=tls1_1 \
3074 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3075 trunc_hmac=1" \
3076 0 \
3077 -s "Read from client: 16384 bytes read"
3078
3079run_test "Large packet TLS 1.2 BlockCipher" \
3080 "$P_SRV" \
3081 "$P_CLI request_size=16384 force_version=tls1_2 \
3082 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3083 0 \
3084 -s "Read from client: 16384 bytes read"
3085
3086run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3087 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003088 "$P_CLI request_size=16384 force_version=tls1_2 \
3089 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003090 0 \
3091 -s "Read from client: 16384 bytes read"
3092
3093run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3094 "$P_SRV" \
3095 "$P_CLI request_size=16384 force_version=tls1_2 \
3096 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3097 trunc_hmac=1" \
3098 0 \
3099 -s "Read from client: 16384 bytes read"
3100
3101run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003102 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003103 "$P_CLI request_size=16384 force_version=tls1_2 \
3104 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3105 0 \
3106 -s "Read from client: 16384 bytes read"
3107
3108run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003109 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003110 "$P_CLI request_size=16384 force_version=tls1_2 \
3111 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3112 trunc_hmac=1" \
3113 0 \
3114 -s "Read from client: 16384 bytes read"
3115
3116run_test "Large packet TLS 1.2 AEAD" \
3117 "$P_SRV" \
3118 "$P_CLI request_size=16384 force_version=tls1_2 \
3119 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3120 0 \
3121 -s "Read from client: 16384 bytes read"
3122
3123run_test "Large packet TLS 1.2 AEAD shorter tag" \
3124 "$P_SRV" \
3125 "$P_CLI request_size=16384 force_version=tls1_2 \
3126 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3127 0 \
3128 -s "Read from client: 16384 bytes read"
3129
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003130# Tests for DTLS HelloVerifyRequest
3131
3132run_test "DTLS cookie: enabled" \
3133 "$P_SRV dtls=1 debug_level=2" \
3134 "$P_CLI dtls=1 debug_level=2" \
3135 0 \
3136 -s "cookie verification failed" \
3137 -s "cookie verification passed" \
3138 -S "cookie verification skipped" \
3139 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003140 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003141 -S "SSL - The requested feature is not available"
3142
3143run_test "DTLS cookie: disabled" \
3144 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3145 "$P_CLI dtls=1 debug_level=2" \
3146 0 \
3147 -S "cookie verification failed" \
3148 -S "cookie verification passed" \
3149 -s "cookie verification skipped" \
3150 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003151 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003152 -S "SSL - The requested feature is not available"
3153
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003154run_test "DTLS cookie: default (failing)" \
3155 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3156 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3157 1 \
3158 -s "cookie verification failed" \
3159 -S "cookie verification passed" \
3160 -S "cookie verification skipped" \
3161 -C "received hello verify request" \
3162 -S "hello verification requested" \
3163 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003164
3165requires_ipv6
3166run_test "DTLS cookie: enabled, IPv6" \
3167 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3168 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3169 0 \
3170 -s "cookie verification failed" \
3171 -s "cookie verification passed" \
3172 -S "cookie verification skipped" \
3173 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003174 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003175 -S "SSL - The requested feature is not available"
3176
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003177run_test "DTLS cookie: enabled, nbio" \
3178 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3179 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3180 0 \
3181 -s "cookie verification failed" \
3182 -s "cookie verification passed" \
3183 -S "cookie verification skipped" \
3184 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003185 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003186 -S "SSL - The requested feature is not available"
3187
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003188# Tests for client reconnecting from the same port with DTLS
3189
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003190not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003191run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003192 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3193 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003194 0 \
3195 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003196 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003197 -S "Client initiated reconnection from same port"
3198
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003199not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003200run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003201 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3202 "$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 +02003203 0 \
3204 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003205 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003206 -s "Client initiated reconnection from same port"
3207
Paul Bakker362689d2016-05-13 10:33:25 +01003208not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3209run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003210 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3211 "$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 +02003212 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003213 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003214 -s "Client initiated reconnection from same port"
3215
Paul Bakker362689d2016-05-13 10:33:25 +01003216only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3217run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3218 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3219 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3220 0 \
3221 -S "The operation timed out" \
3222 -s "Client initiated reconnection from same port"
3223
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003224run_test "DTLS client reconnect from same port: no cookies" \
3225 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003226 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3227 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003228 -s "The operation timed out" \
3229 -S "Client initiated reconnection from same port"
3230
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003231# Tests for various cases of client authentication with DTLS
3232# (focused on handshake flows and message parsing)
3233
3234run_test "DTLS client auth: required" \
3235 "$P_SRV dtls=1 auth_mode=required" \
3236 "$P_CLI dtls=1" \
3237 0 \
3238 -s "Verifying peer X.509 certificate... ok"
3239
3240run_test "DTLS client auth: optional, client has no cert" \
3241 "$P_SRV dtls=1 auth_mode=optional" \
3242 "$P_CLI dtls=1 crt_file=none key_file=none" \
3243 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003244 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003245
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003246run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003247 "$P_SRV dtls=1 auth_mode=none" \
3248 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3249 0 \
3250 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003251 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003252
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003253run_test "DTLS wrong PSK: badmac alert" \
3254 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3255 "$P_CLI dtls=1 psk=abc124" \
3256 1 \
3257 -s "SSL - Verification of the message MAC failed" \
3258 -c "SSL - A fatal alert message was received from our peer"
3259
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003260# Tests for receiving fragmented handshake messages with DTLS
3261
3262requires_gnutls
3263run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3264 "$G_SRV -u --mtu 2048 -a" \
3265 "$P_CLI dtls=1 debug_level=2" \
3266 0 \
3267 -C "found fragmented DTLS handshake message" \
3268 -C "error"
3269
3270requires_gnutls
3271run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3272 "$G_SRV -u --mtu 512" \
3273 "$P_CLI dtls=1 debug_level=2" \
3274 0 \
3275 -c "found fragmented DTLS handshake message" \
3276 -C "error"
3277
3278requires_gnutls
3279run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3280 "$G_SRV -u --mtu 128" \
3281 "$P_CLI dtls=1 debug_level=2" \
3282 0 \
3283 -c "found fragmented DTLS handshake message" \
3284 -C "error"
3285
3286requires_gnutls
3287run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3288 "$G_SRV -u --mtu 128" \
3289 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3290 0 \
3291 -c "found fragmented DTLS handshake message" \
3292 -C "error"
3293
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003294requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003295run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3296 "$G_SRV -u --mtu 256" \
3297 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3298 0 \
3299 -c "found fragmented DTLS handshake message" \
3300 -c "client hello, adding renegotiation extension" \
3301 -c "found renegotiation extension" \
3302 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003303 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003304 -C "error" \
3305 -s "Extra-header:"
3306
3307requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003308run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3309 "$G_SRV -u --mtu 256" \
3310 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3311 0 \
3312 -c "found fragmented DTLS handshake message" \
3313 -c "client hello, adding renegotiation extension" \
3314 -c "found renegotiation extension" \
3315 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003316 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003317 -C "error" \
3318 -s "Extra-header:"
3319
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003320run_test "DTLS reassembly: no fragmentation (openssl server)" \
3321 "$O_SRV -dtls1 -mtu 2048" \
3322 "$P_CLI dtls=1 debug_level=2" \
3323 0 \
3324 -C "found fragmented DTLS handshake message" \
3325 -C "error"
3326
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003327run_test "DTLS reassembly: some fragmentation (openssl server)" \
3328 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003329 "$P_CLI dtls=1 debug_level=2" \
3330 0 \
3331 -c "found fragmented DTLS handshake message" \
3332 -C "error"
3333
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003334run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003335 "$O_SRV -dtls1 -mtu 256" \
3336 "$P_CLI dtls=1 debug_level=2" \
3337 0 \
3338 -c "found fragmented DTLS handshake message" \
3339 -C "error"
3340
3341run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3342 "$O_SRV -dtls1 -mtu 256" \
3343 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3344 0 \
3345 -c "found fragmented DTLS handshake message" \
3346 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003347
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003348# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003349
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003350not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003351run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003352 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003353 "$P_SRV dtls=1 debug_level=2" \
3354 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003355 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003356 -C "replayed record" \
3357 -S "replayed record" \
3358 -C "record from another epoch" \
3359 -S "record from another epoch" \
3360 -C "discarding invalid record" \
3361 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003362 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003363 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003364 -c "HTTP/1.0 200 OK"
3365
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003366not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003367run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003368 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003369 "$P_SRV dtls=1 debug_level=2" \
3370 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003371 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003372 -c "replayed record" \
3373 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003374 -c "discarding invalid record" \
3375 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003376 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003377 -s "Extra-header:" \
3378 -c "HTTP/1.0 200 OK"
3379
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003380run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3381 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003382 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3383 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003384 0 \
3385 -c "replayed record" \
3386 -S "replayed record" \
3387 -c "discarding invalid record" \
3388 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003389 -c "resend" \
3390 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003391 -s "Extra-header:" \
3392 -c "HTTP/1.0 200 OK"
3393
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003394run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003395 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003396 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003397 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003398 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003399 -c "discarding invalid record (mac)" \
3400 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003401 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003402 -c "HTTP/1.0 200 OK" \
3403 -S "too many records with bad MAC" \
3404 -S "Verification of the message MAC failed"
3405
3406run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3407 -p "$P_PXY bad_ad=1" \
3408 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3409 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3410 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003411 -C "discarding invalid record (mac)" \
3412 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003413 -S "Extra-header:" \
3414 -C "HTTP/1.0 200 OK" \
3415 -s "too many records with bad MAC" \
3416 -s "Verification of the message MAC failed"
3417
3418run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3419 -p "$P_PXY bad_ad=1" \
3420 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3421 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3422 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003423 -c "discarding invalid record (mac)" \
3424 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003425 -s "Extra-header:" \
3426 -c "HTTP/1.0 200 OK" \
3427 -S "too many records with bad MAC" \
3428 -S "Verification of the message MAC failed"
3429
3430run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3431 -p "$P_PXY bad_ad=1" \
3432 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3433 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3434 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003435 -c "discarding invalid record (mac)" \
3436 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003437 -s "Extra-header:" \
3438 -c "HTTP/1.0 200 OK" \
3439 -s "too many records with bad MAC" \
3440 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003441
3442run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003443 -p "$P_PXY delay_ccs=1" \
3444 "$P_SRV dtls=1 debug_level=1" \
3445 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003446 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003447 -c "record from another epoch" \
3448 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003449 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003450 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003451 -s "Extra-header:" \
3452 -c "HTTP/1.0 200 OK"
3453
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003454# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003455
Janos Follath74537a62016-09-02 13:45:28 +01003456client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003457run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003458 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003459 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3460 psk=abc123" \
3461 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003462 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3463 0 \
3464 -s "Extra-header:" \
3465 -c "HTTP/1.0 200 OK"
3466
Janos Follath74537a62016-09-02 13:45:28 +01003467client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003468run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3469 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003470 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3471 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003472 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3473 0 \
3474 -s "Extra-header:" \
3475 -c "HTTP/1.0 200 OK"
3476
Janos Follath74537a62016-09-02 13:45:28 +01003477client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003478run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3479 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003480 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3481 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003482 0 \
3483 -s "Extra-header:" \
3484 -c "HTTP/1.0 200 OK"
3485
Janos Follath74537a62016-09-02 13:45:28 +01003486client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003487run_test "DTLS proxy: 3d, FS, client auth" \
3488 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003489 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3490 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003491 0 \
3492 -s "Extra-header:" \
3493 -c "HTTP/1.0 200 OK"
3494
Janos Follath74537a62016-09-02 13:45:28 +01003495client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003496run_test "DTLS proxy: 3d, FS, ticket" \
3497 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003498 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3499 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003500 0 \
3501 -s "Extra-header:" \
3502 -c "HTTP/1.0 200 OK"
3503
Janos Follath74537a62016-09-02 13:45:28 +01003504client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003505run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3506 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003507 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3508 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003509 0 \
3510 -s "Extra-header:" \
3511 -c "HTTP/1.0 200 OK"
3512
Janos Follath74537a62016-09-02 13:45:28 +01003513client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003514run_test "DTLS proxy: 3d, max handshake, nbio" \
3515 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003516 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3517 auth_mode=required" \
3518 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003519 0 \
3520 -s "Extra-header:" \
3521 -c "HTTP/1.0 200 OK"
3522
Janos Follath74537a62016-09-02 13:45:28 +01003523client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003524run_test "DTLS proxy: 3d, min handshake, resumption" \
3525 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3526 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3527 psk=abc123 debug_level=3" \
3528 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3529 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3530 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3531 0 \
3532 -s "a session has been resumed" \
3533 -c "a session has been resumed" \
3534 -s "Extra-header:" \
3535 -c "HTTP/1.0 200 OK"
3536
Janos Follath74537a62016-09-02 13:45:28 +01003537client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003538run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3539 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3540 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3541 psk=abc123 debug_level=3 nbio=2" \
3542 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3543 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3544 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3545 0 \
3546 -s "a session has been resumed" \
3547 -c "a session has been resumed" \
3548 -s "Extra-header:" \
3549 -c "HTTP/1.0 200 OK"
3550
Janos Follath74537a62016-09-02 13:45:28 +01003551client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003552run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003553 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003554 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3555 psk=abc123 renegotiation=1 debug_level=2" \
3556 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3557 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003558 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3559 0 \
3560 -c "=> renegotiate" \
3561 -s "=> renegotiate" \
3562 -s "Extra-header:" \
3563 -c "HTTP/1.0 200 OK"
3564
Janos Follath74537a62016-09-02 13:45:28 +01003565client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003566run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3567 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003568 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3569 psk=abc123 renegotiation=1 debug_level=2" \
3570 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3571 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003572 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3573 0 \
3574 -c "=> renegotiate" \
3575 -s "=> renegotiate" \
3576 -s "Extra-header:" \
3577 -c "HTTP/1.0 200 OK"
3578
Janos Follath74537a62016-09-02 13:45:28 +01003579client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003580run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003581 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003582 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003583 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003584 debug_level=2" \
3585 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003586 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003587 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3588 0 \
3589 -c "=> renegotiate" \
3590 -s "=> renegotiate" \
3591 -s "Extra-header:" \
3592 -c "HTTP/1.0 200 OK"
3593
Janos Follath74537a62016-09-02 13:45:28 +01003594client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003595run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003596 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003597 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003598 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003599 debug_level=2 nbio=2" \
3600 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003601 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003602 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3603 0 \
3604 -c "=> renegotiate" \
3605 -s "=> renegotiate" \
3606 -s "Extra-header:" \
3607 -c "HTTP/1.0 200 OK"
3608
Janos Follath74537a62016-09-02 13:45:28 +01003609client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003610not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003611run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003612 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3613 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003614 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003615 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003616 -c "HTTP/1.0 200 OK"
3617
Janos Follath74537a62016-09-02 13:45:28 +01003618client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003619not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003620run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3621 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3622 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003623 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003624 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003625 -c "HTTP/1.0 200 OK"
3626
Janos Follath74537a62016-09-02 13:45:28 +01003627client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003628not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003629run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3630 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3631 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003632 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003633 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003634 -c "HTTP/1.0 200 OK"
3635
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003636requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003637client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003638not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003639run_test "DTLS proxy: 3d, gnutls server" \
3640 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3641 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003642 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003643 0 \
3644 -s "Extra-header:" \
3645 -c "Extra-header:"
3646
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003647requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003648client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003649not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003650run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3651 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3652 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003653 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003654 0 \
3655 -s "Extra-header:" \
3656 -c "Extra-header:"
3657
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003658requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003659client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003660not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003661run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3662 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3663 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003664 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003665 0 \
3666 -s "Extra-header:" \
3667 -c "Extra-header:"
3668
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003669# Final report
3670
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003671echo "------------------------------------------------------------------------"
3672
3673if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003674 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003675else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003676 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003677fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003678PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003679echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003680
3681exit $FAILS